Top Core Usage
 
Notifications
Clear all

Top Core Usage

10 Posts
2 Users
0 Reactions
276 Views
(@sts-mike)
Active Member Registered
Joined: 4 months ago
Posts: 10
Topic starter  

Long time user- first time posting.  Here's one I finally got working today that shows the percentage of use of just the top core.  We have a standard INI for all our client servers that showed each cores' usage, but with the number of cores on some servers it was starting to overflow the screen!

The PS1 file needs to be in the same dir as your executable.  The only thing I couldn't figure out was displaying single digits with a leading zero (so 5 would be 05).  It must be something to do with PowerShell as i'm able to do it on other lines with [2.0d]% being in the display options.

Anyway- here's the line.  If someone has a better option, I'd be glad to hear it.

CMD=text:Top Core Usage,interval:3,file:powershell.exe -NoProfile -ExecutionPolicy Bypass -File GetTopCore.ps1,multirow:0,display:%4[2.0d]%,regex:\|


   
Quote
Glenn
(@glenn)
Member Admin
Joined: 6 years ago
Posts: 1318
 

i guess because %4 is treated as text.   The string format may be useful although it pads with spaces.   %4[w.ps]


   
ReplyQuote
(@sts-mike)
Active Member Registered
Joined: 4 months ago
Posts: 10
Topic starter  

Wow, my first reply and it's from the Man himself!  Nice to finally meet you!  I'll give that a try later and let you know.


   
ReplyQuote
(@sts-mike)
Active Member Registered
Joined: 4 months ago
Posts: 10
Topic starter  

Sadly, no love on %4[w.ps]

Appears to act the same as the previous %4[2.0d] and doesn't add the leading zero.  Not a show stopper though- I'll continue to mess with it.

-File GetTopCore.ps1,multirow:0,display:%4[2.0s]%,regex:\|


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 6 years ago
Posts: 1318
 

I'm thinking it might be useful to add an option to the 's' format so we can specify what character it pads with.


   
ReplyQuote
(@sts-mike)
Active Member Registered
Joined: 4 months ago
Posts: 10
Topic starter  

Well, I'm a network/server guy so you don't want to take any programming advice from me, but I'd assume the default would be a 0.  I'm just assume it was something to do with the weird way I had to get the number out of PowerShell.


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 6 years ago
Posts: 1318
 

The default is a space because it's working with text. The purpose is for building aligned columns of text.

 

However, it would make sense to modify the 'd' format to try to force the returned text to a number so it can format it.


   
ReplyQuote
(@sts-mike)
Active Member Registered
Joined: 4 months ago
Posts: 10
Topic starter  

Ah.  Makes sense.  I'll be looking for it in 3.13.1. 🙂


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 6 years ago
Posts: 1318
 

so does the script return just the usage of whichever core is most in use. does it show the core number as well?


   
ReplyQuote
(@sts-mike)
Active Member Registered
Joined: 4 months ago
Posts: 10
Topic starter  

It can show which core it is- I think the value is %2 for core number.  %4 is the usage, but I'm only worried which is maxing.  I had a few instances where a memory leak caused one core to spike while overall usage was still low.  This is our standard for servers.  We have a different one for workstations that's a little more trimmed down.  I also have a fancy one for my workstation:

 

###########################################################
#                                                         #
# Name:    DesktopInfo Configuration - Mike's Version     #
# Created: 04-22-24                                       #
# Updated: 04-30-24                                       #
# Author:  Mike Anderson - manderson@stsmsp.com           #
#                                                         #
# Credits:                                                #
#                                                         #
###########################################################
 
[options]
 
# SIZE AND POSTITION
top=0
right=0
width=400
 
# FONT
font-face=Arial
font-size=10
 
# MISC
desktopinfo64=1
formcolor=000000
transparency=40
contextmenu=1
 
[TEXT]
noresults=<N/A>
error=[Error]
null-result=<null>
unknown=Unknown
executing=<Executing>
menu-ini=Select Config
 
[PAGES]
1=Main
2=
3=
4=
5=
6=
7=
8=
9=
 
[items]
 
# colors
set=key:White,value:#ffffff
set=key:Grey,value:#909090
set=key:Cyan,value:#00ffff
set=key:Magenta,value:#ff00ff
set=key:Green,value:#00ff00
set=key:Orange,value:#ffd000
set=key:Yellow,value:#ffff00
set=key:Silver,value:#d0d0d0
set=key:Blue,value:#0000f0
set=key:Red,value:#ff0000
set=key:M-Blue,value:#2299ff
#33aaff
 
# shared resources type lookup table
#set=key:share_type_0,value:Disk Drive
#set=key:share_type_1,value:Print Queue
#set=key:share_type_2,value:Device
#set=key:share_type_3,value:IPC
#set=key:share_type_-2147483645,value:IPC Admin
#set=key:share_type_-2147483648,value:Disk Drive Admin
#set=key:share_type_-2147483649,value:Print Queue Admin
#set=key:share_type_-2147483650,value:Device Admin
#set=key:share_type_-2147483651,value:IPC Admin
 
COLOR=%m-blue%
 
# CPU INFORMATION
WMI=interval:3,id:cputotal,text:CPU Total,chart:bar scale:linear max:100 series1:%PercentProcessorUtility% color1:00ff00,threshold:80 0000ff, namespace:root\cimv2,query:Win32_PerfFormattedData_Counters_ProcessorInformation where Name like "_Total"
CPUUSAGE=interval:3,row-text:CPU %1,chart:bar max:100 series1:%2
 
COMMENT=font-size:25%
 
TOPPROCESSCPU=interval:10,maxrows:2,text:Top Processes (CPU),display:%1 (pid:%2) %3%
 
COMMENT=______________________________________________________________________________________________
 
# MEMORY INFORMATION
PHYSICALRAM=text:Physical RAM,interval:3,chart:bar scale:linear max:100 series1:3 color1:%green%,alarms:(%3 ge 80 0000f0),display:%1[2.0b]B / %2[2.0b]B (%3% used)
# VIRTUALMEMORY=interval:1,chart:line scale:100 series1,display:%1[2.0b]B / %2[2.0b]B (%3% used)|
PAGEFILE=interval:1,chart:bar scale:linear max:100 series1:3 color1:%green%,alarms:(%3 ge 80 0000f0),display:%1[2.0b]B / %2[2.0b]B (%3% used)
# PAGEFAULTS=interval:5,threshold1:5 -80 2222cc,text:Page Faults/sec
 
COMMENT=font-size:25%
 
TOPPROCESSMEM=interval:10,counter:pu,maxrows:2,text:Top Process (Mem),display:%1 (pid:%2) %3[1.1b]B
 
COMMENT=______________________________________________________________________________________________
 
# STORAGE INFORMATION
LOGICALDRIVES=interval:3,\
  alarms:(%11 ge 10000000 0000f0)(%13 ge 10000000 0000f0)(%7 ge 90 0070f0),row-text:Drive %1: (%2)| %3,display:%6[1.0B]B/%5[1.0B]B (%7[1.1f]% used)| R: %11[1.1B]B/s\, W: %13[1.1B]B/s|
LOGICALDRIVES=text:Read Bps,interval:3,chart:bar scale:linear max:10000000 series1:11 color1:%green%,alarms:(%11 ge 10000000 0000f0)
LOGICALDRIVES=text:Write Bps,interval:3,chart:bar scale:linear max:10000000 series1:13 color1:%green%,alarms:(%11 ge 10000000 0000f0)
 
COMMENT=______________________________________________________________________________________________
 
# NETWORK INFORMATION
NETPACKETSRATE=interval:1,active:0,text:Net Rate,mtu:1500,display:D: %1[1.1b]Bps  U: %2[1.1b]Bps
NETWORKINTERFACES=interval:30,operstatus:1,iftype:6 71,row-text:%2 IP,display:%8
WMI=interval:5,background-interval:60,hide-no-result:1,chart:line log 22 1 00ff00 2 bb00bb,threshold1:1 3500000 0000ff,threshold2:2 1000000 ff0000,text:   Ethernet Traffic,namespace:root\cimv2,query:Win32_PerfFormattedData_Tcpip_NetworkInterface where Name like "%Ethernet%" and CurrentBandwidth>0 ,display:D: %BytesReceivedPersec%[3.1b]Bps\, U: %BytesSentPersec%[3.1b]Bps\
WMI=interval:5,active:0,background-interval:60,hide-no-result:1,chart:line log 22 1 00ff00 2 bb00bb,threshold1:1 3500000 0000ff,threshold2:2 1000000 ff0000,text:   Wifi Traffic,namespace:root\cimv2,query:Win32_PerfFormattedData_Tcpip_NetworkInterface where Name like "%Wireless%" and CurrentBandwidth>0,display:D: %BytesReceivedPersec%[3.1b]Bps\, U: %BytesSentPersec%[3.1b]Bps\
 
 
Apologies for the wonky formatting on the header- it looks fine in notepad.  There is a little unused code from testing as well, but it is usable as-is.

   
ReplyQuote
Glenn's Page