Jump to content
Software FX Community

DrillDown_script and -refresh


cmorrall

Recommended Posts

I'm experementing with having a master overview of a number of similar systems. If I see one system peaking in load, I want to be able to drill down and look at details on that particular system.

So far, I've been able to create the overview script, and this is working well with -refresh. I have also been able to create a detail script called by DrillDown_script and DrillDown_parameter. Multiple charts are launched, and it contains the information I want.

However, I want to keep refreshing the detail charts as well, as I monitor the system I have drilled down to. But it seems like on each refresh, $_.Name which I passed on the drilldown is lost. Since I use the $systemname=$args[0] construct, and then use $systemname to get a detailed look at the system in question, on the next refresh all systems are now shown in the detail charts.

Am I going about this the wrong way, or is this something that simply won't work?

Link to comment
Share on other sites

Is there an issue with you posting your entire script?  When you use refresh, there's something that happens in the background where your "gadget" basically detaches itself from the original gadget, so some things are just lost.  There is definitely a work around where we might be able to "transfer" information via a temp file, but there might also be a way to use variables to help out...

post-5059-13922406202848_thumb.jpg

Link to comment
Share on other sites

Primary script is just one line, altered a few specifics to protect the innocent.

get-WmiObject Win32_PerfFormattedData_PerfCounter 1 -computerName MANAGER | select Name,TotalhostKBPers,TotalhostReqPers | sort Name | out-chart -DrillDown_Script U:\Reports\PowerShell\details.ps1 -DrillDown_Parameter {$_.Name} -Title "Overview" -Refresh 0:0:15

Drilldown script. It's actually several lines to get all the details, but one line is enough to explain what I want to do.

$systemname=$args[0]

get-wmiobject Win32_PerfFormattedData_PerfCounter 2-computerName MANAGER | where {$_.Name -like "$systemname*"} | select Name,ReadKBPers,ReadLatencyus,ReadReqPers,WriteKBPers,WriteLatencyus,WriteReqPers | out-chart -Title "$Detail" -Refresh 0:0:10

 

After the refresh time ticks, it looks like $systemname is now blank, which means $_.Name -like "$systemname" now matches all names returned by Win32_PerfFormattedData_PerfCounter2

Link to comment
Share on other sites

As I kind of suspected...  Your $args is lost on refresh.  I'll have to think about this a bit to see if there's another way.  There is something else that I'd think wouldn't work with what you're doing.

I don't think I can work on this today, so hopefully you aren't in a big hurry...

Link to comment
Share on other sites

This is will be one way this should work...

In your first script, you will need a way to write out $_.name to a .tmp file.  Then your drilldown will have to be able to pull in the contents of the .tmp file so it can "reconstruct" $_.name basically.

Now...  It is possible that you'll be having more than one copy of the "first script" running at once?  If so, the .tmp files could conflict when you try to drill down to more than once.

I'm hope I'm making sense...

I just realized though, that the .tmp file could be cleaned up as soon as it is read.  So in other words, unless you do 2 drill downs at exactly the same time, the chances of having a tmp file conflict are very minimal.

I'll try to come up with some working code... 

 

Link to comment
Share on other sites

You might be able to workaround this issue if you can separate the script that gets the drilldown data from the one where out-chart is executed, please note the following sample

ps | out-chart -values Handles -label ProcessName -drilldown_script ShowProcess.ps1 -drilldown_parameter {$_.ProcessName}

Version of ShowProcess.ps1 that does NOT work

$selected = $args[0]

ps | where {$_.ProcessName -eq $selected} | out-chart -values Handles,CPU -Label ProcessName -refresh 0:0:5

Version of ShowProcess.ps1 that works

$selected = $args[0]

ps $selected | out-chart -values Handles,CPU -Label ProcessName -refresh 0:0:5

We will research if we can make both scenarios work but in the meantime separating your scripts might be the way to go. 

Regards,

JuanC

Link to comment
Share on other sites

I'm sure this works, however the above example relies on the possibility of using "ps $selected" instead of a where construct. I can't use that, I must use where $_.Name -like, the get-wmiobject will not accept a $selected on the end of the Win32 object.

I've been experimenting with using a temp file with the system name. I can write and read the variable, but so far I've been unsuccessful in getting -Refresh to work.

$systemname=$args[0]write $systemname > u:\reports\PowerShell\1.tmp$systemname = get-content u:\reports\PowerShell\1.tmp

get-wmiobject Win32_PerfFormattedData1 -computerName MANAGER| where {$_.Name -like "$systemname*"} | select Name,ReadKBPers,ReadLatencyus,ReadReqPers,WriteKBPers,WriteLatencyus,WriteReqPers | out-chart -Title "$systemname Disk Groups" -Refresh 0:0:10

The above does not work

Link to comment
Share on other sites

My suggestion was that you would write a script like the following

MyDrillDetailsData.ps

$systemname=$args[0]

get-wmiobject Win32_PerfFormattedData1 -computerName MANAGER| where {$_.Name -like "$systemname*"} | select Name,ReadKBPers,ReadLatencyus,ReadReqPers,WriteKBPers,WriteLatencyus,WriteReqPers

Note that you can use a where construct and use $systemname in any way supported by PS. This would simplify your Details.ps1 as follows

$systemname=$args[0]

MyDrillScript $systemname | out-chart ...

Regards,

JuanC

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...