nmon and External Data Collectors
nagger 100000MRSJ Comment (1) Visits (7680)
As Mr nmon I was recently asked about a nmon feature for which the answer was: "You should use the nmon External Data Collectors feature." Only to be told "Eh!" When I went looking there is a mention of the feature in the nmon
A common requirement is for some new stats to be added. This falls in to two classes:
So you want some extra data collected. We a assume:
When nmon starts it check if you have set some shell variables set and acts on them.
Simple Worked Example - the Number of Processes Count
echo "PROCCOUNT,Process Count, Procs" >/home/nag/ps.csv
/bin/echo -e "PROCCOUNT,$1,\c" >>/home/nag/ps.csv ps -ef | wc -l >>/home/nag/ps.csv
Setup the environment variables
Notes: I like the full path names - it avoids complications if you happen to be in a different directory. nmon will search your path for the command or script but lets not waste CPU cycles.
Collecting the data
Now run nmon as you would normally for saving the data to a file. This does NOT work if you are using nmon online to screen - which is good and you don't want to muck up you background data collection.
The new data collected
$ cat ps .csv PROCCOUNT,Process Count, Procs PROCCOUNT,T0001,243 PROCCOUNT,T0002,243 PROCCOUNT,T0003,242 PROCCOUNT,T0004,242 PROCCOUNT,T0005,241 PROCCOUNT,T0006,241 PROCCOUNT,T0007,240 PROCCOUNT,T0008,240 PROCCOUNT,T0009,239 PROCCOUNT,T0010,241 PROCCOUNT,T0011,241 PROCCOUNT,T0012,242 PROCCOUNT,T0013,243 PROCCOUNT,T0014,242 PROCCOUNT,T0015,243 PROCCOUNT,T0016,244 PROCCOUNT,T0017,245 PROCCOUNT,T0018,246 PROCCOUNT,T0019,247 . . .
and we have a nmon output file: vm26
Merge the data
It is not hard just append it to the end of the nmon file either:
cat ps.csv >>vm
Graphing it with nmon Analyser - its automatic
If we use the nmon Analyser it fines the new data lines PROCCOUNT and automatically graphs the numbers.
If you are collecting many similar numbers like say percentages then the graphs will work well. If however, you have on/off values like 0 and 1 plus percentages plus counts in the thousand or millions then the graphs are scaled for the larger numbers and you will never see on/off or percentage on the graph. So collect the type of number separately in different Data Names (here PROCCOUNT).
Here is the graph from the Analyser;
IMHO quite system admin hostile and only 10 processes so far and any CPU time in the ps -e output.
The analyser also created a min, max, average and weighted average graph.
Graphing it with nmonchart
This involved adding 6 lines of script plus adding buttons and checking if the data is in the file - all by cut'n'pasting the lines for another sort of data in fixed columns. This took me about 2 minutes of Korn shell scripting time.
Well done Google Chart is adjusted the left data offset to make the graph more interesting and useful.
Oracle Transaction Counters External Data Collectors Example
Here is another example collecting transaction commits and rollback statistics from the Oracle database using two scripts called oraclestart and oraclesnap that run an SQL statement and save the data in a file called dbstats.csv:
Setting up the shell variables
export TIMESTAMP=0 export NMON
Now run nmon
You need to ensure the ORACLE_SID and usernames and password work in your environment. Do this by running the command manually with: * oraclesnap T9999
This should put one line in the file dbstats.csv. This script has to log on to the Oracle database each time it runs, so you should not be doing this every second as it will take elapsed time and CPU resources. But if you are collecting nmon data once a minute or more this overhead should be small.
Thanks to Ralf Schmidt-Dannert of the IBM SAP and Oracle Solutions team in Minneapolis, USA for this example.
- - - T h e E n d - - -