Jump to content
Software FX Community

How to set value for multiple scales/indicators on a gauge?


wwar1ace

Recommended Posts

Here's a couple of examples:

http://community.softwarefx.com/forums/t/9167.aspxhttp://community.softwarefx.com/forums/t/9132.aspx

Something I also found on my computer:

$val=Get-WmiObject win32_Processor|%{$_.loadpercentage}$val1=(get-wmiobject Win32_Process).countout-gauge -type digital -value $val -float -innergauges_add digital `-innergauges_0_digitalpanel_value $val1

I was almost sure I had either seen something with more details written up, but my memory is failing me.  Let me know if the above gets you going...

 

Marco 

 

Link to comment
Share on other sites

@marco

Thanks.  I did come across those examples as well before I posted my question... but when I tried them, the Refresh of the gauge did not work.  I had tried basically the same thing with creating an object in the following script and then piping it to the Out-Gauge, but it would just display the initial values:

$RAM = [INT]((1-(gwmi win32_PerfRawData_perfOS_memory).availablebytes/1gb)*100)$CPU =(gwmi -class "Win32_PerfFormattedData_PerfOS_Processor"|where{$_.name -eq $_Total"}).percentprocessortime$obj = new-object System.Objectadd-member -inputobject $obj -membertype NoteProperty -Name RAM -value $RAMadd-member -inputobject $obj -membertype NoteProperty -Name CPU -value $CPU$obj

= [INT]((1-(gwmi win32_PerfRawData_perfOS_memory).availablebytes/1gb)*100)$CPU =(gwmi -class "Win32_PerfFormattedData_PerfOS_Processor"|where{$_.name -eq $_Total"}).percentprocessortime$obj = new-object System.Objectadd-member -inputobject $obj -membertype NoteProperty -Name RAM -value $RAMadd-member -inputobject $obj -membertype NoteProperty -Name CPU -value $CPU$obj

But I did come up with another way to get it working... just by placing the calculated values as their own little scriptblocks in the one-liner... $template just points to a radialgauge template with two scales and two DigitalPanel innergauges.

 gwmi "Win32_PerfFormattedData_PerfOS_Processor"|where{$_.name -eq "_Total"}|out-gauge -template $template -refresh 0:0:1 -value percentprocessortime -scales_1_indicators_0_value {([INT]((1-(gwmi win32_PerfRawData_perfOS_memory).availablebytes/1gb)*100))} -innergauges_1_DigitalPanel_Value {(gps|sort WS -desc|select -first 1).name} -innergauges_0_DigitalPanel_Value {(gps|sort CPU -desc|select -first 1).name}

I think the object method definitely looks nicer, but I think this more-raw way may reduce the overhead.  Also, I'm still confused as to why using the object method you pointed to wouldn't refresh.  Any ideas? 

Thanks for your help though. I'm sure I'll be needing it again... ;-)

-wwar1ace

Link to comment
Share on other sites

The approach using a variable is not supposed to refresh (read more about this)

>> I think the object method definitely looks nicer, but I think this more-raw way may reduce the overhead.

We tend to favor the object approach. This also allows you to use the same in other scripts to package information even if you are not using PowerGadgets. I think the overhead is minimal although I have not run any comparisons.

>> I'm still confused as to why using the object method you pointed to wouldn't refresh.

Can you please try using the object approach with gps instead of gwmi. I have seen some cases where WMI requests are not refreshed.

Regards,

JuanC

Link to comment
Share on other sites

icon-quote.gifJuanC:

>The approach using a variable is not supposed to refresh (read more about this)

Interesting.  Makes sense.

>> I think the object method definitely looks nicer, but I think this more-raw way may reduce the overhead.

>We tend to favor the object approach. This also allows you to use the same in other scripts to package >information even if you are not using PowerGadgets. I think the overhead is minimal although I have not >run any comparisons.

You're right, reusability is a good thing.  But I think I'm more apt to stick with inserting the scriptblock directly, since it seems to work for all instances.  I can see berating myself for several days over something that SHOULD work because I didn't remember that the object method doesn't work with GWMI calls... ;-)

>> I'm still confused as to why using the object method you pointed to wouldn't refresh.

>Can you please try using the object approach with gps instead of gwmi. I have seen some cases where WMI >requests are not refreshed.

Verified.  I piped this script through Out-Chart with refresh and it worked fine:

$Processes
=((gps|Measure-Object).count)
$obj = new-object System.Object
add-member -inputobject $obj -membertype NoteProperty -Name Processes -value $Processes
$obj

 

Off topic, but from reading one of your examples, can you tell me what the second "$" in this statement is doing (just before Read-Host) ?  I haven't seen that before:

[string]$serverName = $(read-host "Please enter the web server name")

 

Thanks,

-wwar1ace

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...