Showing posts with label PowerGadgets. Show all posts
Showing posts with label PowerGadgets. Show all posts

Wednesday, September 3, 2008

Print Queue Analysis - Revisited

A few weeks ago, I mentioned that I was asked to assist with the monitoring of a print queue. I have now included that PowerGadget chart. Enjoy!

function Get-PrintQueue {
$Printers
= Get-WmiObject `
-Class Win32_PerfFormattedData_Spooler_PrintQueue `
-ComputerName 'PrintServer'`
-Filter 'Name <> "_Total"'

foreach ($Printer in $Printers) {
if($Printer.Jobs -gt 1) {
$obj
= New-Object psObject
$obj
| Add-Member NoteProperty Printer $Printer.Name
$obj
| Add-Member NoteProperty JobCount $Printer.Jobs
Write
-Output $obj}
}
}
$dt
= Get-Date -Format g
Get
-PrintQueue | Out-Chart `
-Title "PrintServer printer queues as of $dt" `
-Size 800,400 `
-gallery bar `
-LegendBox_Visible false `
-View3D_Enabled true `
-AllSeries_BarShape Cylinder `
-AllSeries_PointLabels_Visible true `
-AllSeries_Color Yellow `
-Output "\\WebServer\e$\Inetpub\Extranet\Departments\InfoSys\ClinApps\HIS-Print.png"

Resulting chart:

HISPrint

Monday, July 21, 2008

A generic error occurred in GDI+.

OK - sometimes I am a little slow.
One of the reasons I decided to maintain a blog was to help myself remember those peculiar idiosyncrasies when scripting. Well shame on me....

My script was working fine until I added the most important piece (from a customer perspective) - the pretty chart. I am a big fan of PowerGadgets and try to utilize them wherever possible. Well, when I added Out-Chart with an output parameter, I received the ambiguous error, "A generic error occurred in GDI+".

So naturally, I pulled up Google and started searching. I vaguely recalled seeing this before but couldn't quite put my finger on it. Then I saw it. ....Permissions....

Yes! Now I remember. If the UNC path I am trying to save my chart to is wrong or permissions are not configure properly, I get the error.

Lesson Learned:

  1. Verify your UNC path before throwing it into your script.
  2. Use your blog!

Thursday, June 26, 2008

ASPNet_WP.exe analysis on multiple servers via PowerGadgets


Was recently asked if I could help our development team analyze the ASPNet_WP process on 3 web servers. These 3 servers are load balanced and deliver the same content (FRS). There has been some spikes in the process and they wanted to be able to see this graphically. PowerGadgets to the rescue!

Steps are:
- Grabs an encrypted password (see previous post) as I am going across domains.
- Get WorkingSizeSet of the ASPNet_WP on the servers via WMI
- Store the WorkingSizeSet in a csv file (DB soon!)
- Grab the CSV file an pipe it to Out-Chart (PowerGadgets)
- Create a bat file that calls PowerShell with the appropriate ps1 file
(powershell.exe -nologo -command "& {c:\productionscripts\get-aspnet_wp1.ps1})
- Schedule the bat file
Please forgive the lack of pipes in this post. I am struggling to find a blog that handles code nicely.

###################################################
# Script Name: Get-ASPNet_WP.ps1
# Description: PowerShell Script for ASPNet_WP
# analysis on intapp-p2, webster-vp01
# and webster-vp02
#
# Created By: Wes Stahler
# Date Created: 6/25/2008
# Change Log:
# 6/26/2008 Added PowerGadget chart for
# inclusion on admin web page
###################################################

# Get password from encrypted file
# Once these servers are moved into the correct domain
# we won't have to worry about the creds....
$password = Get-Content c:\cred.txt ConvertTo-SecureString

# Create credentials
$creds = New-Object -typename System.Management.Automation.PSCredential `
-argumentlist "nt3osumc\stah06",$password

# Get WorkingSetSize for the 3 NT3OSUMC servers
$intapp_p2 = Get-WmiObject -Class Win32_Process `
-ComputerName intapp-p2 -Credential $creds `
Where-Object {$_.ProcessName -eq "aspnet_wp.exe"} `
Sort-Object WorkingSetSize -Descending `
Select-Object -First 1

$webster_vp01= Get-WmiObject -Class Win32_Process `
-ComputerName webster-vp01 -Credential $creds `
Where-Object {$_.ProcessName -eq "aspnet_wp.exe"} `
Sort-Object WorkingSetSize -Descending `
Select-Object -First 1

$webster_vp02= Get-WmiObject -Class Win32_Process `
-ComputerName webster-vp02 -Credential $creds `
Where-Object {$_.ProcessName -eq "aspnet_wp.exe"} `
Sort-Object WorkingSetSize -Descending `
Select-Object -First 1

# Being lazy....
$intappp2 = [math]::Round($intapp_p2.workingsetsize/1024/1024,0)
$webstervp01 = [math]::Round($webster_vp01.workingsetsize/1024/1024,0)
$webstervp02 = [math]::Round($webster_vp02.workingsetsize/1024/1024,0)
$dt = Get-Date -Format T

# Format string for to append to the historical file
# Will add to a DB later
$str = "{0},{1},{2},{3}" -f $dt,$intappp2,$webstervp01,$webstervp02

# Append to file
Add-Content -Path "c:\ProductionScripts\ASPNet_WP.csv" -Value $str

# Grab the data (last 7 hours worth) and chart!
$b = Import-Csv "c:\ProductionScripts\ASPNet_WP.csv" select -last 28
$b Out-Chart -Values Intapp-p2, webster-vp01, Webster-vp02 `
-Label Time `
-Title "ASPNet_WP.exe as of $dt" `
-gallery Lines `
-AxisY_Max 1000 `
-Size 800,533 `
-Series_1_AxisY AxesY_0 `
-Series_2_AxisY AxesY_0 `
-Output "file://intapp-p2/e$/Inetpub/Extranet/ProjectManager/Exception/ASPNet_WP.png"
###################################################