Hi Greg,
I needed to do this originally with BB to track a memory leak with HP OpenView's pmd process, when we used to use it.
#!/bin/sh
SCRIPTS IN THE BBHOME/ext DIRECTORY ARE ONLY RUN IF
THEY ARE DEFINED IN THE ENTRY FOR THE CURRENT HOST
LISTED IN THE ext/bb-bbexttab FILE.
BBPROG SHOULD JUST CONTAIN THE NAME OF THIS FILE
USEFUL WHEN YOU GET ENVIRONMENT DUMPS TO LOCATE
THE OFFENDING SCRIPT...
BBPROG=bb-pmd.sh; export BBPROG
TEST NAME: THIS WILL BECOME A COLUMN ON THE DISPLAY
IT SHOULD BE AS SHORT AS POSSIBLE TO SAVE SPACE...
NOTE YOU CAN ALSO CREATE A HELP FILE FOR YOUR TEST
WHICH SHOULD BE PUT IN www/help/$TEST.html. IT WILL
BE LINKED INTO THE DISPLAY AUTOMATICALLY.
TEST="pmd"
BBHOME CAN BE SET MANUALLY WHEN TESTING.
OTHERWISE IT SHOULD BE SET FROM THE BB ENVIRONMENT
#BBHOME=/opt/BB/bb19c ; export BBHOME # FOR TESTING
if test "$BBHOME" = "" then echo "BBHOME is not set... exiting" exit 1 fi
if test ! "$BBTMP" # GET DEFINITIONS IF NEEDED then # echo "*** LOADING BBDEF ***" . $BBHOME/etc/bbdef.sh # INCLUDE STANDARD DEFINITIONS fi
PMDMEM=/bin/ps -e -o vsz -o comm | grep " pmd" | awk '{printf "%d", $1/1024}'
if test "$PMDMEM" = ""
then
COLOR="clear"
else
COLOR="green"
fi
AT THIS POINT WE HAVE OUR RESULTS. NOW WE HAVE TO SEND IT TO
THE BBDISPLAY TO BE DISPLAYED...
MACHINE NAME MUST EITHER BE A REAL MACHINE NAME, OR
LOOK LIKE A REAL MACHINE (in the case of arbitrary measurements
like temperature). IF THE NAME YOU ARE USING DOESN'T EXIST
IN THE DNS THEN IT SHOULD BE LISTED IN THE bb-hosts FILE WITH noping,
PREFERABLY IN IT'S OWN GROUP...
NOTE THE COMMAS HERE - YOU NEED THEM!
MACHINE=echo $MACHINE | $SED 's/\./,/g' # HAS TO BE IN A,B,C FORM
THE FIRST LINE IS STATUS INFORMATION... STRUCTURE IMPORANT!
THE REST IS FREE-FORM - WHATEVER YOU'D LIKE TO SEND...
LINE="PMD Statistics. " SUMMARY=" PMD memory usage is $PMDMEM"
NOW USE THE BB COMMAND TO SEND THE DATA ACROSS
SEND IT TO BBDISPLAY
$BB $BBDISP "status $MACHINE.$TEST $COLOR date $LINE $SUMMARY MB"
-----Original Message----- From: Hubbard, Greg L [mailto:greg.hubbard at eds.com] Sent: Tuesday, July 24, 2007 4:44 PM To: hobbit at hswn.dk Subject: RE: [hobbit] Highlights of the 4.3.0 version
Well, we watch for the presence of processes today. It would be nice to be able to track cpu and size of "important" processes over time.
Another problem is detecting CPU hogs (sometimes things run away), another problem is detecting processes with memory leaks -- they just grow and grow and grow. How can Hobbit help?
GLH
-----Original Message----- From: Henrik Stoerner [mailto:henrik at hswn.dk] Sent: Tuesday, July 24, 2007 3:31 PM To: hobbit at hswn.dk Subject: Re: [hobbit] Highlights of the 4.3.0 version
On Sat, Jul 21, 2007 at 07:16:12PM -0400, Asif Iqbal wrote:
- Display column only when it is red (http://www.*hobbit*mon.com/*hobbit*on/2006/08/msg00920.html)
I'll leave that for later. There will probably be an entire new version with just display things.
- SNMP trap by default
- SNMP probe option builtin
Too much for now. I need to dig into the Net-SNMP library API to do that.
- Process specific alert (http://www.hswn.dk/hobbiton/2005/11/msg00159.html)
Already in 4.2.0 via the GROUP definition in hobbit-clients.cfg and the corresponding rule in hobbit-alerts.cfg
- Comment TAG for DOWNTIME (http://www.hobbitmon.com/hobbiton/2007/04/msg00141.html)
Has been implemented for 4.3.0
- Add functionalities in `delay' (http://www.hswn.dk/hobbiton/2005/06/msg00272.html)
Haven't looked at that.
- CPU/Memory Usage per process (http://osdir.com/ml/monitoring.hobbit/2007-01/msg00429.html)
Probably impossible. Most "ps" implementations can report the current amount of cpu/memory a process uses, but that's a snapshot (ever noticed how "top" always has itself in the top list of cpu-using processes?). What's interesting is not how much cpu/memory a process uses exactly when the Hobbit client runs the "ps" command, but how much it has used on average since the last client run - similar to what "vmstat" reports for the system as a whole. I don't know of any way to get this data.
Another problem with this is identifying what a process is. A long-running daemon often forks child-processes that are short-lived; should we add their cpu-utilisation to that of the long-running process? If yes, then we have to monitor all processes that are started (so running once every N seconds is not sufficient); if no, then you won't spot the cpu hog because it was spawned as a child process.
- Text based alert for `msgs'. Currently it shows as html in my email (http://osdir.com/ml/monitoring.hobbit/2007-01/msg00203.html)
Easily done with an alert script.
Regards, Henrik
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk