Author Topic: Report of System Stats: CPU/RAM/ETC.  (Read 4104 times)

TheLastGunslinger

  • Guest
Report of System Stats: CPU/RAM/ETC.
« on: August 23, 2016, 07:20:53 AM »
I got the CPU reporting to work with this:


However, I'm not sure w/ the math of having it report memory usage. The tokens allow for math but I'm not sure about the dividing and rounding and getting it to actually say something close to "5.5 Gigs in use of 16 Gigs total" or "10.5 Gigs of free ram".

So far I just get really long numerical read outs with:
Code: [Select]
Currenly there is {EXP: ({STATE_RAMAVAILABLE} / 1073741824)} of {EXP: ({STATE_RAMTOTAL} / 1073741824)} total RAM.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: Report of System Stats: CPU/RAM/ETC.
« Reply #1 on: August 23, 2016, 09:10:36 AM »
Really long numeric readout you say?

Try this:
Code: [Select]
Set decimal [STATE_RAMAVAILABLE] value to the converted value of {EXP:{STATE_RAMAVAILABLE} / 1073741824} (round to 2 decimal places)
Set decimal [STATE_RAMTOTAL] value to the converted value of {EXP:{STATE_RAMTOTAL} / 1073741824} (round to 2 decimal places)
Write '[Blue] Currenly there is {DEC:STATE_RAMAVAILABLE} of {DEC:STATE_RAMTOTAL} total RAM.' to log

Does your locale use a decimal point or a comma? There's a bug with decimals where locales using a comma will treat any number as an integer.

TheLastGunslinger

  • Guest
Re: Report of System Stats: CPU/RAM/ETC.
« Reply #2 on: August 23, 2016, 07:12:29 PM »
I get what you are saying with rounding to 2 decimal places, but I haven't a clue how to make this happen.

Primarily I want the text-to-speech output to be a report of RAM usage. If my expression is correct (math wise) how would I get it to round to only 2 decimal places?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: Report of System Stats: CPU/RAM/ETC.
« Reply #3 on: August 23, 2016, 08:07:24 PM »
In that code block are the exact actions you'd use in your command, however I'll attach a premade command as well.

There is another method(also included), which will work around the decimal bug:
Code: [Select]
Set decimal [STATE_RAMTOTAL] value to the converted value of {STATE_RAMTOTAL}
Set decimal [STATE_RAMTOTAL] to [STATE_RAMTOTAL] divided by 1073741824 (round to 2 decimal places)
Set decimal [STATE_RAMAVAILABLE] value to the converted value of {STATE_RAMAVAILABLE}
Set decimal [STATE_RAMAVAILABLE] to [STATE_RAMAVAILABLE] divided by 1073741824 (round to 2 decimal places)
Write '[Blue] Currenly there is {DEC:STATE_RAMAVAILABLE} of {DEC:STATE_RAMTOTAL} total RAM.' to log

TheLastGunslinger

  • Guest
Re: Report of System Stats: CPU/RAM/ETC.
« Reply #4 on: August 24, 2016, 06:18:06 AM »
I get it now! I was trying to do all of the expressions just in the text-to-voice dialog, not using the actual "Set a Decimal Value" function.

Thanks a million brother!