header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Creating multicolor HTML?
Last Post 22 Jan 2008 04:05 PM by marco.shaw. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
DannyUser is Offline
New Member
New Member
Posts:10
Avatar

--
", ""} elseif ($_.CPU -ge $limitCPU70 -and  $_.CPU -lt $limitCPU90) {$_ -replace "", ""} elseif ( $_.CPU -ge $limitCPU90) {$_ -replace "", ""} } | Out-File -filepath SKRIPTS:\CPU-Usage.html

 

 

How can i calculate percentages for example the empty space on a HDD or the 70% and 90% of the whole RAM and CPU?  (limitCPU = $_.CPU *0.7??)

 

 

Thanks in advance

Greetz

22 Jan 2008 09:37 AM  

HEy,

i am trying to create  script that produces an overview about the CPU-, RAM-, HDD- and Networkusage of a Server. At the end the results shall be converted to HTML. Furthermore the backgroundcolor has to change for different values for example 70% CPU yellow, 90% red and the rest green.

My problem is that the whole table is displayed in green at the moment.

 

Here's the snippet for the CPU-Usage

 

Set-Variable -name limitCPU70 -value 5,00 -option constant
Set-Variable -name limitCPU90 -value 15,0 -option constant

get-process | Sort-Object CPU | ConvertTo-Html -title "CPU Table" -property CPU, Name, Description | Foreach-Object { if ( $_.CPU -lt $limitCPU70) {$_ -replace "



marco.shawUser is Offline
Co-Community Director
Basic Member
Basic Member
Posts:195
Avatar

--
22 Jan 2008 02:07 PM  
You'll have to fix up your post. Maybe attach what's you're running as a .txt file so we can see your script, otherwise the post is getting all messed up possibly because you have a lot of HTML tags in your original post.


Marco

*Microsoft MVP - Windows PowerShell: http://www.microsoft.com/mvp
*PowerGadgets MVP: http://www.powergadgets.com/mvp
*Blog: http://marcoshaw.blogspot.com
DannyUser is Offline
New Member
New Member
Posts:10
Avatar

--
22 Jan 2008 02:46 PM  

Hey,

i am trying to create  script that produces an overview about the CPU-, RAM-, HDD- and Networkusage of a Server. At the end the results shall be converted to HTML. Furthermore the backgroundcolor has to change for different values for example 70% CPU yellow, 90% red and the rest green.

My problem is that the whole table is displayed in green at the moment.

How can i calculate percentages for example the empty space on a HDD or the 70% and 90% of the whole RAM and CPU?  (limitCPU = $_.CPU *0.7??)

 Thanks in advance

Greetz
 

Here's the snippet for the CPU-Usage


Attachment: 1122502426571.txt

marco.shawUser is Offline
Co-Community Director
Basic Member
Basic Member
Posts:195
Avatar

--
22 Jan 2008 04:05 PM  
OK, you should be aware that this CPU value is the # of seconds that the process has actually used the CPU. This is not a calculation of the current % of CPU utilization. Not impossible to do the calculations, but it will take some calculations.

You could go maybe with WMI to get most of this inforamation, but I've seen what appear to be inconsistencies with how WMI seems to handle CPU % in use with processes.

I'll see if others might have a better idea on how to approach this. For some of the values, I'd be tempted to just have you run perfmon to get a count of all the utilization of all processes, then bring that into PowerShell with import-csv maybe.


Marco

*Microsoft MVP - Windows PowerShell: http://www.microsoft.com/mvp
*PowerGadgets MVP: http://www.powergadgets.com/mvp
*Blog: http://marcoshaw.blogspot.com
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer