Glance Tool usage to get CPU utilization on Server
Glance:
Glance is the best tool for checking memmory usage, as it provides the complete information.
The various tools report different numbers because they disagree about which regions to report as part of the size and how to count shared memory regions.
We can also obtain CPU Utilization and Disk Utilization as shown in the output.
Glance is the best tool for checking memmory usage, as it provides the complete information.
The various tools report different numbers because they disagree about which regions to report as part of the size and how to count shared memory regions.
We can also obtain CPU Utilization and Disk Utilization as shown in the output.
$ glance --h
Usage: glance [-?|-h|-g|-A|-c|-m|-d|-i|-u|-w|-l|-t|-a|-N|-T|-H]
[-j interval] [-nice nice_value] [-nosort] [-lock]
[-p [dest_device]] [-f dest_file] [-maxpages num_pages]
[-no_fkeys]
[-advis[eo]r_off | -advis[eo]r_only] [-iterations count]
[-bootup] [-syntax filename]
[-aos filename]
[-all_trans] [-all_instances]
Command: glance –j 60 –iterations 100 –maxpages 100
Press s and Enter PID.
Press p to Print the Result
Press c for continuous printing.
Press f to store to a file
Enter file name:
The results start printing.
Output Sample:
B3694A GlancePlus C.04.50.00 06:06:48 <Server> sun4u Current Avg High
-------------------------------------------------------------------------------
CPU Util | 1% 1% 1%
Disk Util | 0% 0% 0%
Mem Util SUUUUUUUUUUUU | 27% 27% 27%
Swap Util UUUURRRRRRR | 21% 21% 21%
-------------------------------------------------------------------------------
Resources PID: 1703, java PPID: 1 User: noaccess
--------------------------------------------------------------------------------
CPU Usage (util): 0.1 Block Reads : 0
User CPU : 0.0 Block Writes : 0
System CPU : 0.0 Total IO Bytes : 0kb
Priority : 59 Data VSS : 23.8mb
Nice Value : 20 Stack VSS : 80kb
Forced CSwitch : 5 Total VSS : 293.7mb
Volunt CSwitch : 1082 Total RSS : 91.5mb
Blocked On : SLEEP System Calls : 627
Signals Recd : 0 Threads Total : 31
Major Faults : 0 Proc Start Time Mon Aug 17 22:27:05 2009
Minor Faults : 0
C - cum/interval toggle % - pct/absolute toggle
Argv1: org.apache.catalina.startup.Bootstrap
Cmd : /usr/jdk/instances/jdk1.5.0/bin/java -server -XX: ……
Page 1 of 1
How to extract the CPU Util from Glance output.
CPU Monitoring sample perl program
#open and parse file to get current CPU usage
open (INPUTFILE, "filename.gl") or die "can not open Input File:$!";
open (OUTFILE, ">cpu_app.txt") or die "can not open Output File:$!";
while ($line = <INPUTFILE>)
{
# CPU Util | 1% 1% 1%
if ($line =~ /CPU Util .*?(\d+.*?)%\s+/)
{
$value = "$1";
print OUTFILE "$value";
print OUTFILE "\n";
}
}
close(INPUTFILE);
close(OUTFILE);
print "\n DONE";
The same perl program can be modified to get Disk Util, Mem Util by changing the Regular Expression.
Memory Report can be obtained by pressing m after entering PID.
B3694A GlancePlus C.04.50.00 02:14:06 <Server> sun4u Current Avg High
----------------------------------------------------------------------------------------------------------------------------------------------
CPU Util U | 1% 1% 1%
Disk Util | 0% 0% 0%
Mem Util S SU U | 54% 54% 54%
Swap Util U UR R | 45% 45% 45%
----------------------------------------------------------------------------------------------------------------------------------------------
MEMORY REPORT Users= 22
Event Current Cumulative Current Rate Cum Rate High Rate
--------------------------------------------------------------------------------
Page Scans 0 0 0.0 0.0 0.0
Page Faults 375 375 312.5 312.5 312.5
Paging Requests 0 0 0.0 0.0 0.0
Paged In 0kb 0kb 0.0 0.0 0.0
Paged Out 0kb 0kb 0.0 0.0 0.0
Swap In 0 0 0.0 0.0 0.0
Swap Out 0 0 0.0 0.0 0.0
Swap Bytes In 0kb 0kb 0.0 0.0 0.0
Swap Bytes Out 0kb 0kb 0.0 0.0 0.0
Phys Mem : 16.0gb User Mem : 8.2gb Sys Mem : 407mb
Avail Mem : 15.6gb Free Mem : 7.4gb Buf Cache: 9mb
The same perl program can be modified to get Disk Util, Mem Util by changing the Regular Expression.
Memory Report can be obtained by pressing m after entering PID.
B3694A GlancePlus C.04.50.00 02:14:06 <Server> sun4u Current Avg High
----------------------------------------------------------------------------------------------------------------------------------------------
CPU Util U | 1% 1% 1%
Disk Util | 0% 0% 0%
Mem Util S SU U | 54% 54% 54%
Swap Util U UR R | 45% 45% 45%
----------------------------------------------------------------------------------------------------------------------------------------------
MEMORY REPORT Users= 22
Event Current Cumulative Current Rate Cum Rate High Rate
--------------------------------------------------------------------------------
Page Scans 0 0 0.0 0.0 0.0
Page Faults 375 375 312.5 312.5 312.5
Paging Requests 0 0 0.0 0.0 0.0
Paged In 0kb 0kb 0.0 0.0 0.0
Paged Out 0kb 0kb 0.0 0.0 0.0
Swap In 0 0 0.0 0.0 0.0
Swap Out 0 0 0.0 0.0 0.0
Swap Bytes In 0kb 0kb 0.0 0.0 0.0
Swap Bytes Out 0kb 0kb 0.0 0.0 0.0
Phys Mem : 16.0gb User Mem : 8.2gb Sys Mem : 407mb
Avail Mem : 15.6gb Free Mem : 7.4gb Buf Cache: 9mb
Comments
Post a Comment