[help] Where to discuss SysStats tech. details?

After a (cursory - admittedly) search of forums & threads I could find nowhere to ask more detailed questions about SysStats such as how to get the most out of certain overlays and meters and their interaction with scripts.

[in case this thread will be OK to start!]

My specific request is about the HistogramOverlay class. I want ot be able to adjust the 'Max' value on the fly to make an autoscaling histogram - particularly for monitoring network traffic. My NIC sometimes talks to other PCs at up to 100MB/s or to the ADSL (internet) connection which is 512kB/s. So if I configure it for internet, then the LAN traffic maxes it out constantly, or vice versa and the internet traffic is so low it doesn't show.

So can I adjust the histogram->'max' property via a script based on the current meter value, & if so how? Alternatively, where can I find this info?

TIA.

#267855

Knowing where to look helps a lot!

Thanks for the details - hopefully I can make my own way from here...

#267967

OK, a further question, please...

I'm using the PDHMeter class to monitor network activity. I have both ethernet and WLAN adapters installed which both appear in the list of available interfaces/instances when configuring the meter.

Now, I can get byte/sec values out of the meter if it is set to either of the NIC instances indivudually, but there is also an option to select all instances which does not appear to work. It would be good if the meter just got values for whatever NIC was currently active (or both simultaneously if it occurrs!). Basically, I have a 3rd party app called NetMeter (http://readerror.gmxhome.de/) that I'm trying to emulate with SysStats.

Is this a limitation with the PDHMeter class?, or a bug in SysStats?, or a bug in the Windows WMI interface?

I can think of a workaround but it's not elegant and I'm hoping for a simpler, more 'correct' method.

#269796

So one way to do what you want is to add a PDH meter for each interface you want to monitor and then add a ScriptMeter that aggregates their values.

That was basically the route I was going to take if it wasn't possible any other way.

Thanks for your help!

#269860

Ok, I've almost got it together, and it seemed to be running nicely on one of the NICs (the wireless one as it happens).

Today, I connected the ethernet port (was disconnected - not disabled - when using the WLAN) and now the docklet is using 45% CPU time for some reason.

I opened the script console and it's filling with the message below:

Object doesn't support this property or method: 'SysStatsModel.Meters' at line 8, char 2: (null)

I don't recall seeing the above message when I was only using the WLAN.

Whats the best way to troubleshoot this? I've attached the config and scripts etc in case anyone feels like looking at them and offerng advice.

TIA.

sysstats_netmeter.zip

Attachment: sysstats_netmeter.zip

#270982

I'll try that out - many thanks!

I hadn't implemented the scaling yet, and yes the process of dropping the scale back again is going to be tricky (I predict).

#271197

Basically you can't set the value of the histogram meter - you should just return the value from the GetValue function.

That made a *big* difference [grin]. The CPU load is now under control - thanks!

I took the liberty of fixing your resizing code too, though you should probably implement something that reduces Max over time...

I see what you've done and it makes sense.

Thinking it through further, since it's a histogram the scale should drop to whatever the next highest value is already being diplayed by the histogram. Is it possible to enumerate all the values in the historymeter class to determine the 'next highest' value? I cannot see it in the configs. If not, then I'll have to maintain an internal array that duplicates the history values.

Further again, it would be better if both Rx & Tx meters were scaled identically so that relative loads could be seen at-a-glance. If I declare a public 'max scale' variable will it be visible within the scope of both scripts?

BTW your Tx History history meter is monitoring the wrong meter - it should be monitoring Tx Script.

Fixed - thanks again!

#271208

If you call GetValue() on the history meter it will return you an array. Iterate through the array and record the highest value - ignore the last value in the array as that is the index of the oldest value.

Great, that makes things easier! Is there more comprehensive documents anywhere so I don't have to keep bothering you with these basic questions?

Use one script to record both values. In ScriptMeter_GetValue(selector) use the selector to specify which value you want - choose anything you like, it will be a string - and set the overlays that call it to pass in the correct selector.

This is where I need some further clarification...

Currently the (2) HistoryMeter class meters I use rely on individual script(s) for their values. If I use a combined script, I can't find a way to specify a selector in the HistoryMeter config to get the appropriate value from the ScriptMeter_GetValue() function - or does it automagically know which value to take?

Also, on a different note, regarding the calculation of the scale factor, is it better to put this in the ScriptMeter_GetValue() or should it stay in the ScriptMeter_Update function? What determines, generally, which of these functions should handle the bulk of the functionality?

Thanks for all your advice so far :D

#271267

Darned, your right. So a different way would be to: Add two fixed meters.

Ok, Did that.

Change the history meters to read from them instead of the scripts.

Yep, this works. If I enter a value manually into the fixed meter it's reflected in the overlay's value...

Implement one script that sets the value of both fixed meters (use the PutValue() method on the fixed meters)

Here's where it falls apart :( I can't find any reference to a PutValue method for meters exept the ScriptMeter class. I also tried various syntaxes in case it's undocumented ;) such as:

SysStatsModel.Meters("Tx Fixed").PutValue(AsString(TxVal)) but that generates console errors.

What is the correct syntax for the PutValue method?

Or do I need to use a valuesetter control to set the value of a fixed meter? If so how?

Thanks in advance.

#272163

Sorry to say, my ignorance of scripting is showing... I'm still having trouble getting several parts of the script to work. It'll probably only make sense if I show you the whole thing and insert comments....

' Called every 'interval' seconds as defined in the 'Configure meters...' dialog

Dim RxVal,TxVal

Function ScriptMeter_Update

Dim RxOv, TxOv, NetMax, HistCount, i

'add the 2 NIC traffic values - add more meters here if required

RxVal = SysStatsModel.Meters("NIC1 Rx") + SysStatsModel.Meters("NIC2 Rx")

TxVal = SysStatsModel.Meters("NIC1 Tx") + SysStatsModel.Meters("NIC2 Tx")

'Update the fixed meters from where the histories get their final value

SysStatsModel.Meters("Tx Fixed") = CStr(TxVal)

SysStatsModel.Meters("Rx Fixed") = RxVal

The avove two attempts to set the fixed meter value result in the console error:

"Object doesn't support this property or method: 'SysStatsModel.Meters' at line 13, char 2: (null)"

'save the overlay names (for simplicity)

Set RxOv = SysStatsModel.Overlays("Net Meter")("Net Rx Histogram")

Set TxOv = SysStatsModel.Overlays("Net Meter")("Net Tx Histogram")

'!!! Ensure Rx & Tx history meter lengths are equal !!! - last value is not used

HistCount = SysStatsModel.Meters("Rx History").Count-1

Dim RxHist(90), TxHist(90) 'history meter # of samples = 90

RxHist = Array(SysStatsModel.Meters("Rx History").GetValue()) 'load the arrays

TxHist = SysStatsModel.Meters("Tx History").GetValue()

Both the above attempts at getting the array of history values give "type mismatch" errors

This is as far as I've got at the moment...

NetMax = 0 'reset the maximum

For i=0 to HistCount 'loop through the arrays

if RxHist(i) > NetMax then

NetMax = RxHist(i) 'save the highest value

end if

if TxHist(i) > NetMax then

NetMax = TxHist(i) 'same for Rx - want one max for both meters

end if

Next

RxOv.Max = NetMax 'set the max. in the overlays

TxOv.Max = NetMax

ScriptMeter_Update = true 'The meter always updates.

End Function

Function ScriptMeter_GetValue(selector)

if selector = "Rx" then

ScriptMeter_GetValue = RxVal

else

ScriptMeter_GetValue = TxVal

end if

End Function

Any advice you feel like offering would be greatly appreciated... :)

#272422

I hope you're not sick of this yet! ;)

Maybe I should just hand the lot over to you... but, then, I'm enjoying the challenge :)

Put some WScript.Echo statements in there. e.g.:

Ok, I rearranged the code a little and simplified it to look at one meter at a time (since it's the same for Tx and Rx)

So for this snippet:

  Dim RxOv, TxOv, RxHist, TxHist

RxHist = SysStatsModel.Meters("Rx History").GetValue() 'load the arrays
TxHist = SysStatsModel.Meters("Tx History").GetValue()

'add the 2 NIC traffic values - add more meters here if required
RxVal = SysStatsModel.Meters("NIC1 Rx") + SysStatsModel.Meters("NIC2 Rx")
TxVal = SysStatsModel.Meters("NIC1 Tx") + SysStatsModel.Meters("NIC2 Tx")

WScript.Echo "TxVal=" & TxVal
WScript.Echo "TxVal(str) =" & CStr(TxVal)

'Update the fixed meters from where the histories get their final value
WScript.Echo "Type of TxFixed=" & TypeName(SysStatsModel.Meters("Tx Fixed"))

SysStatsModel.Meters("Tx Fixed") = CStr(TxVal)

I get the following in the console:

TxVal=1.37770149718805

TxVal(str) =1.37770149718805

Type of TxFixed=IFixedMeter

Object doesn't support this property or method: 'SysStatsModel.Meters' at line 23, char 2: (null)

Changing the syntax of the fixed meter assignment to:

SysStatsModel.Meters("Tx Fixed") = TxVal

Sill gives the error:

Object doesn't support this property or method: 'SysStatsModel.Meters' at line 23, char 2: (null)

My conclusions are that 'TxVal' is already a string value, and that there is no method implemented to change a fixedmeter's value using a script! If you can give me a known working example (or point to one for download) I'd be happy to try and disassemble it myself.

I suspect that you can't just add the meter values together or that you aren't setting the value of the RX Fixed meter to a string.

I don't think there's problem about adding the the two meter values - I have text overlays that use RxVal, TxVal supplied by the ScriptMeter_GetValue with no problems.

Try this:

   Dim RxHist, TxHist		   'history meter # of samples = 90

set RxHist = SysStatsModel.Meters("Rx History").GetValue()
set TxHist = SysStatsModel.Meters("Tx History").GetValue()

This gives me:

Object required at line 10, char 2: (null)

Same if I declare RxHist as RxHist() (i.e an array).

If I write:

  Dim RxHist()

RxHist = SysStatsModel.Meters("Rx History").GetValue() 'load the arrays

Then I get a 'type mismatch' error. The only thing that works is:

  Dim RxHist

RxHist = SysStatsModel.Meters("Rx History").GetValue() 'load the arrays

But then I get a' type mismatch' when I try to use RxHist as an array at the lines:

	if RxHist(i) > NetMax then

I think I need a serious VBScript tutorial. I do have the Windows Script 5.6 documentation, but it's not that helpful in these little details (and not many good examples!).

As ever, your advice is appreciated.

#272656

Hi Judge... I know you're busy tracking down all my scripting 'quirks' ;) ... (of course you are!)

I just thought I'd summarise where I'm blocked at the moment - if it's something crashingly stupid on my part, please say so! :D

Anyway, highlighted in red are the console errors I'm stuck on currently.

I hope you (or anyone!) can offer some advice.

  Dim RxOv, TxOv, RxHist, TxHist, NetMax, HistCount

NetMax = 0 'reset the maximum

RxHist = SysStatsModel.Meters("Rx History").GetValue 'load the arrays
TxHist = SysStatsModel.Meters("Tx History").GetValue

'add the 2 NIC traffic values - add more meters here if required
RxVal = SysStatsModel.Meters("NIC1 Rx") + SysStatsModel.Meters("NIC2 Rx")
TxVal = SysStatsModel.Meters("NIC1 Tx") + SysStatsModel.Meters("NIC2 Tx")

'Update the fixed meters from where the histories get their final value

WScript.Echo "RxVal=" & TypeName(CStr(RxVal))
[color=Red]RxVal=String[/color]
SysStatsModel.Meters("Rx Fixed") = CStr(RxVal)
[color=Red] Object doesn't support this property or method: 'SysStatsModel.Meters' at line 20, char 2: (null)[/color]
' SysStatsModel.Meters("Tx Fixed") = CStr(TxVal)

'save the overlay names (for simplicity)
Set RxOv = SysStatsModel.Overlays("Net Meter")("Net Rx Histogram")
Set TxOv = SysStatsModel.Overlays("Net Meter")("Net Tx Histogram")

'!!! Ensure Rx & Tx history meter lengths are equal !!! - last value is not used
HistCount = CInt(SysStatsModel.Meters("Rx History").Count-1)

WScript.Echo "RxHist=" & TypeName(RxHist)
[color=Red] RxHist=Double()[/color]
For i = 0 to HistCount 'loop through the arrays
if RxHist(i) > NetMax then
[color=Red]Type mismatch: 'RxHist' at line 33, char 4: (null)[/color]
NetMax = RxHist(i) 'save the highest value
end if

#273904

Thanks for the suggestions :), but... :(

Regarding your suggestion assigning the fixed meter value, it eliminated the error from the script console (:D) but it seems to have no effect on the associated history meter. I tested it further by linking a text overlay to the fixed meter and the overlay is not updated - it appears that the meter is somehow not delivering it's value to the items I was attaching to it. What am I doing wrong?

Regarding getting the array of values out of the history meter...

Here are the combinations I tried:

Set RxHist = SysStatsModel.Meters("Rx History")

WScript.Echo "RxHist=" & TypeName(RxHist)

which gives the console message:

RxHist=IHistoryMeter

but then if I try to use the variable eg:

if RxHist(i) > NetMax then

I get:

Object not a collection: 'RxHist' at line 32, char 4: (null)

Next combination:

Set RxHist = SysStatsModel.Meters("Rx History").GetValue()

Simply gives the error:

Object required at line 10, char 2: (null)

The next two combinations :

RxHist = SysStatsModel.Meters("Rx History").GetValue()

RxHist = SysStatsModel.Meters("Rx History")

which the console tells me (in both cases)

RxHist=Double()

which I would assume is OK but then I try to use it eg:

if RxHist(i) > NetMax then

and i get:

Type mismatch: 'RxHist' at line 32, char 4: (null)

Note that if I call TypeName() against my own array variable eg TxHist() it returns a type: 'variant' - I don't know if this is important or not.

#276416

Am I allowed to.... Bump? :(:o;)

#281168

Yes, it was a long shot... :(

Still gives type mismatch error, I even tried:

if RxHist(i) > Cdbl(NetMax) which also gives type mismatch.

In any case, even if I got this part working, the line:

SysStatsModel.Meters("Rx Fixed").Value = CStr(RxVal)

where I try to assign the value to the fixed meter, also doesn't work - it doesn't update the fixed meter value (no errors are generated at least).

I'm ready to give up now. :SNIFF:

Thanks, anyway for your efforts.

#281501

In any case, even if I got this part working, the line:

SysStatsModel.Meters("Rx Fixed").Value = CStr(RxVal)

where I try to assign the value to the fixed meter, also doesn't work - it doesn't update the fixed meter value (no errors are generated at least).

Ok, for completeness, I tried to investigate what's going on with this. It looks like the fixed meter is accepting the value but the history meter can't understand it.

By playing around with overlays to display the fixed meter value, it seems that it contains a string (duh, this was mentioned earlier - it's even the correct value) and obviously the history meter can't interpret it.

Maybe SysStats 2.5.5 will fix it? ;) If I knew how to rewrite history.spl I'd even consider that!

#281507

Hmmm... using echo statements and observing in the script console it sure looked like the fixed meters contained numbers - floating point and identical to the value it was assigned by the script.

However when I used a text overlay to display the fixed meter value in the docklet, the value was only displayed when the format was specified as %s.

My usual default format to display the instantaneous value is %0.1f which works fine when getting the value from the script, but it just stays at 0.0 when getting the value from the fixed meter.

So the following code:

'Update the fixed meters from where the histories get their final value

SysStatsModel.Meters("Rx Fixed").Value = RxVal

SysStatsModel.Meters("Tx Fixed").Value = CStr(TxVal)

WScript.Echo "RxVal =" & RxVal

WScript.Echo "Rx Fixed.Val =" & SysStatsModel.Meters("Rx Fixed").Value

WScript.Echo "Rx Fixed Type =" & TypeName(SysStatsModel.Meters("Rx Fixed").Value)

Shows in the console as follows:

RxVal =0.149452360415111

Rx Fixed.Val =0.149452360415111

Rx Fixed Type =String

or:

RxVal =0

Rx Fixed.Val =0

Rx Fixed Type =String

It looks like it should work!

#281738

I'm bumping the thread because I edited-in some console output so you can see what results I'm getting ;)

#283209

Hi Judge, any doubts I had about SysSyats are now eliminated!

I took some time out on the problems and approached from a different angle and have had considerably more success. The whole business with the history meters not taking the fixed meter values was a false alarm - somehow I had the max value in the history overlay set to zero! DOH!

The only thing I had to work around was the array of history values which I still can't get out of the meter itself, so I recreated the array within the script and maintain it manually.

I hope to tidy it up a little more and release it soon.

Thanks for all your help along the way!

#283870