Since your question is performance related, you really don't need to know how much physical memory is in use. vmstat will give you the performance information you're looking for (I cleaned up the output a little, format wise).
Distilled from Sun Performance and Tuning by Adrian Cockcroft:
The sr column (Scan Rate) is probably the most important when determining whether you're short on memory or not. When this number gets to a high rate (200 pages per second averaged over 30 seconds), then you're short on memory and need to add more.
Swap space and available swap isn't a real help since the system will balance things out and the free column will stablize out.
For CPU's, four times the number of CPUs in the run queue (the procs/r column) means you should add another cpu.
For disk slowness, the blocked queue gives you the info (procs/b column). If b => r then you should look at balancing your data or perhaps getting a RAID in place.
I think that's fine if you're troubleshooting a memory issue, but it sounds like from his initial request, that he wanted something to keep an eye on. "Healthchecking" he said. I think the vmstat info would give good health checking information.
I am very appreciative that you are all helping me with this. Let me first explain what I am trying to accomplish, and then let me ask for clarification about vmstat and top.
I am a middleware sys admin (not a Unix admin). I do a daily healthcheck of the Solaris servers where my software (MQSeries) runs. In addition to looking at specific MQ logs and queues, I also look at some system-level stats, including CPU and memory usage. This is not a "scientific" look; rather, it's a point-in-time peek that has allowed me to develop a "baseline" of normal operations. I look at the system-level stuff because 1) these are dedicated middleware servers & nothing else runs on them and 2) MQ & related software spawns many processes (that's why I don't just look at one process).
This approach has helped me catch problems several times.
My specific question about vmstat and top is about interpreting the data. (Remember, I'm not a unix admin!)
Here is vmstat output:
r b w swap free re mf pi po fr de sr m1 m1 m1 m2 in sy cs us sy id
0 0 0 5622568 1636016 38 137 5 0 0 0 0 0 0 0 0 258 1235 307 1 1 99
I *think* this means that I have 5.6 Gb of total memory available, of which 1.6 Gb is free.
Here is the top output:
Memory: 2048M real, 1555M free, 4099M swap free
I *think* this means that I have 2.0 GB of physical memory, of which 1.5 Gb is free AND I have 4.1 GB of swap that is also free.
I must not understand how to read these outputs, eh?
I have a Fedora Core 8 box I ran these on, it should work for Unix and Linux systems:
This command pipes the cleansed output of 'top' to command line and cleans the escape codes.
Quote:
top -cSb n 1
My results: Use this to pipe the cleansed output of 'top' to command line and cut off the unnecessary header lines.
Quote:
top -cSb n 1 | tail -n+8
My Results: How to get the top output for only one pid (process id).
Quote:
top -cSb n 1 -p 3812 | tail -n+8
My results: How to track the cpu usage for a single process in Linux/Unix:
*Important: change the process id '3812' to one of your PID's.
Quote:
top -cSb -p 3812 n 1 | tail -n+8 | sort -rn -k5 | awk 'NR > 0 { s +=$9 }; END {print "cpu %",s}'
My Results:
For some reason the 'ps' command does not come out with the same results as top does (based on my observation). Top yields the most accurate summary of how much CPU your process is using.
You could also use ps to figure out how much total CPU load in Linux/Unix.
Quote:
ps aux|awk 'NR > 0 { s +=$3 }; END {print "cpu %",s}'
I make no guarantees for this command, it seems to match up with top's version, however if you have a dual core, or more than one core, this number returned will go to 200%. It's a hack.
My Results:
This was the command that satisfied my problem:
replace 12345 with your PID:
Last edited by sentientmachine; 05-21-2009 at 06:16 PM..
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am required to create a bash shell script with either emacs or vi. It must include the year 2014 calendar on... (9 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi,
I am trying to get the system RAM size from "top" command's output by the following but it is not working.
top | sed "s/^Mem.**\(*\), *//" (10 Replies)
Hi All,
I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations:
1. I am restrained to 2 input files only.
2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Hi All,
I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel).
For my application:
<sar -U ALL>
CPU %user %nice %system %idle
...
10:58:04 0 153.10 0.00 38.76 0.00
10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Hi,
I have a process that can be seen after "ps aux" command.
However when I do "top" command. This process
cannot be seen.
How can this happen? Is there anything wrong
with my code? (3 Replies)
Hi,
We have a DEC Alpha 4100 Server with OSF1 Digital Unix 4.0.
Can any one tell me, if there are any commands on this Unix which are equivalent to "top" and "sar" on HP-UX or Sun Solaris ?
I am particularly interested in knowing the CPU Load, what process is running on which CPU, etc.
... (1 Reply)