Jump to content
Software FX Community
Sign in to follow this  
cosmin.onea

monitoring financial data, conditional attributes and dynamic execution of powershell statements

Recommended Posts

Hi,I have a simple requirement to implement but I dont know where to start from and what are the best practices using PowerGadgets which, by the way, is the greatest monitoring tool I've seen so far.So here we go:Inside the company there is a need for an on-going monitoring of some financial figures.I created a webservice that prepares a dataset the gadgets will connect to.Few problems here. I'm not a charting expert so I need some advice on it.I have a list of companies(partners) and the account balance figures coresponding to each of them. For each company there is a specific credit limit also. I need to display a chart with the balance and also have some conditions for each company according to the credit limit. If the compapny is less than 90% of the credit limit the color of the bars should be green, 90%-100% yellow, more than 100% Red.If I get the data directly from the webservice and display it on the chart I have only one series and conditional attributes will apply to all the companies accordingly.The dataset is like:Company, CreditLimit, BalanceC1, 10000, 9500C2,10000,8900C3,12000,15000I hope you got the point. Somehow I need 1 serie for each company so I can set the conditional attributes. Tried to use the transpose opption but I lose the horizontal labels with company names and I get different colors for each.

Another problem would be that because the CreditLimit is in the dataset I have to contruct the out-chart command dynamically to add all the conditional attributes.When I try the following PowerShell complains that out-chart is not recognized as a cmdlet, function, operable program, or script file.$command = "out-chart "foreach company in $WSResponseDS    add conditional attrs to $command$WSResponseDS | & $commandWhat is goning on here? Is the PowerShell starting a new shell when using "&" operator and the gadgets are not loaded or something? Do I have any other option not to build the string at run-time?

Later on I'll have to add drill-down to the chart but my current issue is the above so any input is greatly appreciated.

I'm using PG v1.0.2588.21909

Thanks,Cosmin.

 

Share this post


Link to post
Share on other sites

$command = "out-chart "

foreach company in $WSResponseDS 

  add conditional attrs to $command

$WSResponseDS | & $command

I'm short on time to comment on the remainder of your questions, but I'll address the one above.  How are you loading PowerGadgets?  In your profile or via add-pssnapin?

Instead of using "& command", try "invoke-expression $command".  Make sure to do a 'write-host $command' to make sure the string looks OK.

If anyone else doesn't come along, I'll give your other questions some more thought in the next few days.

post-4822-13922403363622_thumb.jpg

Share this post


Link to post
Share on other sites

Hi Marco,

Thanks for the quick reply.Not sure yet how to load the powergadgets on clients. Maybe you can advice from your experience. I have to distribute the gadgets somehow to the business people who need it so what I'm thinking, instead of modifying everybody's profiles, is to load them in the script itself.

The scripts will be used from a shared network folder. Initially I thought that I can distribute the pgf files themselves as self-contained monitoring gadgets but I need to do the drill-down part at some point and as I read in the documentation it can be done only by using scripts when the data set is different. Am I wrong? I need to show more figures(most probably a different web method on the webservice part) about a company when clicking on the total column in the main chart.I'm just playing around now and testing if the gadgets meet the requirements I have to implement. In the particular case I wrote about the gadgets are loaded on my machine from the powershell profile.

I have it working now, no errors no warnings and everything works fine. I used invoke-expression as you adviced.One thing I noticed is that even though I specify a -template option the chart is always loaded with the defaults(line chart, instead of bar chart as the template was designed). Could this be because I data-bound it at design time and at runtime the datasource might be different? Should I put all the params in the command line just to be sure?

Thanks again,Cosmin

 

 

Share this post


Link to post
Share on other sites

Ok, the graph looks pretty much ok now.How do I make the grid(below the chart) to show the values vertically instead of horizontally. now it looks like:   C1 C2 C3   C4   C5  ............... this might get longerTotal  1000 2000  -1000 3000 34000Transpose the data basically but not affecting the chart.Something like:   TotalC1 1000C2 2000C3   -1000C4   3000C5   34000Any way to achieve this?

Thanks,Cosmin

Share this post


Link to post
Share on other sites

I don't know of a way to change the grid layout.

So, what else are we left with outstanding?  Just how to install the application on some other machines?  I checked the install .exe (with just a simple /? flag), and it doesn't seem to accept any options which leads me to believe something "silent" is not possible.

Do you have any kind of tool to remotely access the other machines?  I'd like to think there's a remote way to automate PowerGadgets installs, but I can't think of any way right now.

Share this post


Link to post
Share on other sites

Sorry, I didnt make that clear.

I dont need an automated installation as the number of machines is very limited.(around 10-15, how many managers we could have :)). The problem is how to distribute the gadgets I create, not the powergadgets installer, in a way easy to understand and use by the users.So I was thinking of running the scripts from a shared folder.

Cosmin.

Share this post


Link to post
Share on other sites

More problems.

I'm testing the chart with random data I generate from a mockup web-service. In fact the chart looks green,yellow and red but there is only one serie in it. So all my conditional attributes are ignored except the first one.

Basically a part from my command line looks like this:
-ConditionalAttributes_0_Series 0 -ConditionalAttributes_0_Condition_From "-1088.75874713471" -ConditionalAttributes_0_Color Green
-ConditionalAttributes_1_Series 0 -ConditionalAttributes_1_Condition_From "-2177.51749426942" -ConditionalAttributes_1_Condition_To "-1088.75874713471" -ConditionalAttributes_1_Color Gold
-ConditionalAttributes_2_Series 0 -ConditionalAttributes_2_Condition_To "-2177.51749426942" -ConditionalAttributes_2_Color Red

-ConditionalAttributes_3_Series 1 -ConditionalAttributes_3_Condition_From "-2559.86984472716" -ConditionalAttributes_3_Color Green
-ConditionalAttributes_4_Series 1 -ConditionalAttributes_4_Condition_From "-5119.73968945431" -ConditionalAttributes_4_Condition_To "-2559.86984472716" -ConditionalAttributes_4_Color Gold
-ConditionalAttributes_5_Series 1 -ConditionalAttributes_5_Condition_To "-5119.73968945431" -ConditionalAttributes_5_Color Red

The chart looks like the following:
http://byfiles.storage.msn.com/y1pk5FAYs_Y-GX287i9yXC1FC2oxQLU9xDsyzM_K5w4RPEIeMb8g-xyora9SBtTmO2sr_JTzGwV-3g 

There is only one serie and only the first 3 conditional formats apply, those that have the Serie set to 0.

If I add -datasourcesettings_style +Transpose to the command line it works but I come back to the original post: there is only one horizontal label "Total" and the "legend" contains the name of the companies.

In this case the chart looks like:
http://byfiles.storage.msn.com/y1pk5FAYs_Y-GUi7GwlF7hx4Yagwzwf49A_filpWSLOFUaz9k_VeidVcfopqb6mXiCRI4XyT7FmJeA

Is there a way to have multiple series so I can apply the conditional attributes and preserve the company names as horizontal Labels?

Cosmin.

Share this post


Link to post
Share on other sites

Sorry, I didnt make that clear.

I dont need an automated installation as the number of machines is very limited.(around 10-15, how many managers we could have :)).

The problem is how to distribute the gadgets I create, not the powergadgets installer, in a way easy to understand and use by the users.

So I was thinking of running the scripts from a shared folder.

Cosmin.

Running the script from a shared folder sounds like a good idea.  For ease of use for end-users, perhaps you could pass around a VBscript script to all the users, which could kick off the PowerShell script.  Using VBscript will allow you to easily create a script that can easily be defined with an icon, so it can easily be identified.

By default, Windows has no idea what to do with a .ps1 script and will just likely open it in notepad if it is double-clicked.

It is pretty simple to create a VBscript to kick off a PowerShell script.

Here's an article that shows how to use VBscript (even if you're not planning to use this as a scheduled task, the concept is the same):

http://blog.sapien.com/current/2006/12/25/more-fun-with-scheduled-powershell.html

(It also links to a previous article.)

This way, you have an .vbs script with the somewhat familiar script icon associated with it already.

(I've not had the time to play with your issue of how you can setup your bar colors dynamically, but I'm thinking about it.  I haven't played much with the transpose option, if that's what will give you the solution you need.)

Share this post


Link to post
Share on other sites

I also investigated the distribution thing.
It seems that I can create shortcuts and put as the command: "c:\......\powershell.exe -command \\server\share\script.ps1
Basically the same thing as in the article you provided but instead of vbs files I'll have .lnk's.

I will create a shared folder with all the shortcuts to all the monitoring scripts.

Cosmin

Share this post


Link to post
Share on other sites

Please check the following blog post, I think the combined approach will give you the exact chart you need. If you need an updated build please send an email to support at powergadgets dot com.

JuanC

Share this post


Link to post
Share on other sites

Wow! That is exactly what I'm looking for.

Thanks Juan, excellent work. One correction to the blog post, last command has a typo "-legendbox_itemattributes_-series_visible false". Most probably you wanted to hide the totals in the "FreeSpace" in the Legend. I couldnt figure the syntax out

Cosmin. 

Share this post


Link to post
Share on other sites

I have a ps1 script that I run from powershell command prompt.

in the script I have: get-wmiobject Win32_Processor | out-gauge -value LoadPercentage -refresh 0:0:1

The gauge or chart(same thing with the chart) doesn't refresh when using PG last version. I rolled back to version 1.0.2588 and it works fine. Somewhere in the middle the refresh feature was lost. I hope it will be fixed quickly; it is something I really need.

 Cosmin. 

Share this post


Link to post
Share on other sites

We have finally found and fixed the refresh issue.

In an interim build we tried to fix an issue with a localized PowerShell version and we introduced a bug that affects refreshing on scripts. You can download an updated build from the same place you downloaded it before (check that the file date should be July 23rd or later before downloading).

>> One correction to the blog post, last command has a typo "-legendbox_itemattributes_-series_visible false". Most probably you wanted to hide >> the totals in the "FreeSpace" in the Legend. I couldnt figure the syntax out

It is not a typo. Although it is a weird syntax, it was the easiest way for us to expose a way to hide the series collection (regardles of how many series are plotted) from the legend box. Because this is definitely not a common scenario we thought the weirdness would not be too bad.

JuanC

Share this post


Link to post
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.

Loading...
Sign in to follow this  

×
×
  • Create New...