no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:cpu2 [2009/11/23 05:42] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== My Monitor (CHANGEME) ====== | ||
+ | |||
+ | ^ Author | [[ butchdeal@yahoo.com | Butch Deal ]] | | ||
+ | ^ Compatibility | Xymon 4.2 | | ||
+ | ^ Requirements | unix, dmidecode for linux | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2009-06-02 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | Monitors lots of extra CPU and system related bits. Works on Linux (RH & SuSe), Solaris, and now MacOS X (Darwin). Removed the need to install prtdiag on Linux, and added more complete relese version info. | ||
+ | Added some support for Solaris 10 zones and for dual core Ultra sparc IV. | ||
+ | ===== Installation ===== | ||
+ | === Client side === | ||
+ | add these lines to hobbitclient.cfg: | ||
+ | < | ||
+ | UNAME="/ | ||
+ | SWAP="/ | ||
+ | PSRINFO="/ | ||
+ | MPSTAT="/ | ||
+ | </ | ||
+ | |||
+ | Modify your clientlaunch.cfg, | ||
+ | < | ||
+ | [cpu2] | ||
+ | ENVFILE $HOBBITCLIENTHOME/ | ||
+ | CMD $HOBBITCLIENTHOME/ | ||
+ | LOGFILE $HOBBITCLIENTHOME/ | ||
+ | INTERVAL 5m | ||
+ | </ | ||
+ | edit cpu2.sh for proper path to sudo and dmidecode. | ||
+ | === Server side === | ||
+ | |||
+ | ===== Source ===== | ||
+ | ==== cpu2.sh ==== | ||
+ | <hidden onHidden=" | ||
+ | < | ||
+ | #!/bin/sh | ||
+ | # | ||
+ | # bb-cpu2.sh: Sun Enterprise Server check - BB external script test | ||
+ | # ^ and now Linux | ||
+ | # | ||
+ | ##### Purpose is to report back to a central server, all " | ||
+ | ##### detailed information about network, disk, volume, cpu, memory | ||
+ | ##### which is not reported thru regular " | ||
+ | ##### | ||
+ | # | ||
+ | # version 1.0 | ||
+ | # version 2.0 - includes uname and prtdiag checks too | ||
+ | # version 2.1 - properly uses $CAT instead of cat | ||
+ | # version 2.2 - properly uses $MACHINE instead of `uname -n` in bb-hosts check | ||
+ | # version 2.4 - properly uses $THIS_HOST instead of $MACHINE due to fqdn using | ||
+ | # comma in name - thanks Craig Cook | ||
+ | # version 3.0 - updates to work properly with BB 1.6 | ||
+ | # | ||
+ | # version 3.1 - changed /tmp to $BBTMP | ||
+ | # cpu2 to $TEST | ||
+ | # | ||
+ | # | ||
+ | # after the server name in bb-hosts | ||
+ | # moved comment explaining purpose of script to start of code | ||
+ | # | ||
+ | # version 3.2 - made swap check optional | ||
+ | # | ||
+ | # added check for bbsys.local vars being set | ||
+ | # | ||
+ | # | ||
+ | # after the server name in bb-hosts, but now optional | ||
+ | # | ||
+ | # version 3.3 - Added changes suggested by Andrew Clarke | ||
+ | # - skip tests that involve uname -x on solaris 2.5.1, since it | ||
+ | # does not support this switch. | ||
+ | # - [ " | ||
+ | # - new comment line for testing | ||
+ | # - swap -s on solaris 2.51 returns " | ||
+ | # version 3.5 - Added support for Linux | ||
+ | # - physical cpu count for both Solaris and Linux | ||
+ | # - OS release information for both Solaris and Linux | ||
+ | # - have not tested SWAP_INFO for Linux | ||
+ | # version 3.6 - Added some support for Mac OS X (Darwin) | ||
+ | # - modularised some of the procedures | ||
+ | # - removed need for prtdiag on Linux | ||
+ | # version 3.9 - Added some support for Solaris zones | ||
+ | # - added support for dual core Ultra sparc IV | ||
+ | # version 3.9.1 - started support for Sun4v Niagara chips | ||
+ | # version 3.10 - Added more dmidecode entries | ||
+ | # | ||
+ | # BIG BROTHER / XXXXXXXXXXXXXXXX status | ||
+ | # | ||
+ | # Written by Paul A. Luzzi | ||
+ | # on March 22, 2000 | ||
+ | # | ||
+ | # 3.0 Updates by David Levin | ||
+ | # on January 3, 2001 | ||
+ | # | ||
+ | # 3.1 Updates by Craig Cook 26 Apr 2001 | ||
+ | # 3.2 Updates by Craig Cook 31 Oct 2001 | ||
+ | # 3.3 Updates by Craig Cook 21 Nov 2001 | ||
+ | # 3.5 Updates by Richard Deal & Dan Gomez 1 Oct 2004 | ||
+ | # 3.6 Updates by Richard Deal 6 Oct 2004 | ||
+ | # 3.7 Updates by Daniel Gomez 6 Dec 2004 - update paths | ||
+ | # 3.8 Updates by Daniel Gomez 8/2/05- added / | ||
+ | # 3.9 Updates by Richard Deal 9/1/05 | ||
+ | # 3.10 Updates by Daniel Gomez 8/18/07 | ||
+ | |||
+ | ######################################## | ||
+ | # NOTE | ||
+ | # This has been tested with BB 1.8c and 1.9e | ||
+ | # | ||
+ | # Tested on : | ||
+ | # Sun Solaris, Linux, Darwin | ||
+ | ######################################## | ||
+ | |||
+ | ########################################################################### | ||
+ | # INSTALLATION | ||
+ | # step 1 - update bb-bbexttab to include this bb-cpu2.sh | ||
+ | # (older BB versions update EXT section of the bbdef.sh script) | ||
+ | # | ||
+ | # step 2 - if you want this script to show swap info uncomment | ||
+ | # | ||
+ | # NOTE: it does not do any error checking on swap space though | ||
+ | # | ||
+ | # step 3 - copy lines mentioned to bbsys.local (without the #'s) | ||
+ | # | ||
+ | # step 4 - if you are using an older version of BB without bb-bbexttab | ||
+ | # and you don't want this run on every client uncomment | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # step 5 - restart Big Brother | ||
+ | # | ||
+ | # *Linux* | ||
+ | # | ||
+ | # | ||
+ | # NOTE - the TEST variable in the configuration section, this is the name | ||
+ | # used as the column header and in the BB-HOSTS file. | ||
+ | ########################################################################### | ||
+ | |||
+ | ########################################################################### | ||
+ | # For testing, ensure BBHOME is set and uncomment the following line | ||
+ | # BB=""; | ||
+ | ########################################################################### | ||
+ | |||
+ | ################################## | ||
+ | # CONFIGURE IT HERE | ||
+ | ################################## | ||
+ | TEST=" | ||
+ | BBPROG=" | ||
+ | |||
+ | VERSION="< | ||
+ | |||
+ | # | ||
+ | # Start of lines to put in bbsys.local for Solaris | ||
+ | # | ||
+ | # SWAP="/ | ||
+ | # PSRINFO="/ | ||
+ | # MPSTAT="/ | ||
+ | # UNAME="/ | ||
+ | # PLATFORM_SPEC=`$UNAME -i` | ||
+ | # PRTDIAG_COMMAND="/ | ||
+ | # PRTDIAG_OPT=" | ||
+ | # export SWAP PSRINFO MPSTAT UNAME | ||
+ | |||
+ | # | ||
+ | # Start of lines to put in bbsys.local for Linux | ||
+ | # | ||
+ | # SWAP="/ | ||
+ | # PSRINFO=" | ||
+ | # MPSTAT="/ | ||
+ | # UNAME="/ | ||
+ | # export SWAP PSRINFO MPSTAT UNAME | ||
+ | # | ||
+ | # For Linux this determins actual cpu count | ||
+ | # you can use sudo to run dmidecode if need be | ||
+ | # | ||
+ | if [ -x "/ | ||
+ | DMIDECODE="/ | ||
+ | else | ||
+ | DMIDECODE="/ | ||
+ | fi | ||
+ | |||
+ | # | ||
+ | |||
+ | # | ||
+ | # Start of lines to put in bbsys.local for Mac OS X Darwin | ||
+ | # | ||
+ | # UNAME="/ | ||
+ | # export UNAME | ||
+ | |||
+ | # | ||
+ | # End of lines to put in bbsys.local | ||
+ | # | ||
+ | |||
+ | # define colours for graphics | ||
+ | RED_PIC="& | ||
+ | YELLOW_PIC="& | ||
+ | |||
+ | # don't scan through bb-hosts every time | ||
+ | # this is here for older BB versions without bb-bbexttab | ||
+ | # uncomment to activate | ||
+ | # | ||
+ | |||
+ | # Uncomment to display swap info | ||
+ | # | ||
+ | |||
+ | ################################## | ||
+ | # Start of script | ||
+ | ################################## | ||
+ | |||
+ | if test ! " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if test ! -d " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if test ! " | ||
+ | then | ||
+ | # echo "*** LOADING BBDEF ***" | ||
+ | . $BBHOME/ | ||
+ | fi | ||
+ | |||
+ | # | ||
+ | # Define header | ||
+ | # | ||
+ | get_header() | ||
+ | { | ||
+ | echo "" | ||
+ | echo "< | ||
+ | echo "" | ||
+ | #If you do not want the header in a bigger font use line below instead | ||
+ | # echo "< | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # Define footer | ||
+ | # | ||
+ | get_footer() | ||
+ | { | ||
+ | #echo "< | ||
+ | echo "" | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # Mac OS X Darwin prtdiag cpu info | ||
+ | # | ||
+ | darwin_prtdiag() { | ||
+ | |||
+ | printf " | ||
+ | printf " | ||
+ | |||
+ | CPUSPEED=`system_profiler SPHardwareDataType | $GREP "CPU Speed" | cut -d ":" | ||
+ | L2CACHE=`system_profiler SPHardwareDataType | $GREP "L2 Cache" | cut -d ":" | ||
+ | L3CACHE=`system_profiler SPHardwareDataType | $GREP "L3 Cache" | cut -d ":" | ||
+ | CPU_MODEL=`system_profiler SPHardwareDataType | $GREP "CPU Type" | $AWK {' | ||
+ | CPU_TYPE=`hostinfo | $GREP " | ||
+ | for i in `hostinfo | grep active | cut -d : -f 2-` ; do | ||
+ | printf " $i\t$CPUSPEED\t | ||
+ | done | ||
+ | } # end darwin_prtdiag | ||
+ | |||
+ | # | ||
+ | # Linux prtdiag cpu info | ||
+ | # | ||
+ | linux_prtdiag() { | ||
+ | |||
+ | printf " | ||
+ | printf " | ||
+ | |||
+ | for i in `grep " | ||
+ | CPULINE=`grep processor / | ||
+ | CPUSPEED=`grep -A20 -w " | ||
+ | CPUCACHE=`grep -A20 -w " | ||
+ | BOGOMIPS=`grep -A20 -w " | ||
+ | CPUARCH=`grep -A20 -w " | ||
+ | printf " $i\t $CPUSPEED\t | ||
+ | done | ||
+ | } # end linux_prtdiag | ||
+ | |||
+ | # Get Setup - check environment | ||
+ | get_setup () { | ||
+ | ##### | ||
+ | ##### Setup any and all variables before beginning. | ||
+ | ##### | ||
+ | # Check defaults have been set | ||
+ | if [ " | ||
+ | if [ $BBOSTYPE = " | ||
+ | UNAME="/ | ||
+ | else | ||
+ | UNAME="/ | ||
+ | fi | ||
+ | echo "" | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | if [ $BBOSTYPE != " | ||
+ | if [ " | ||
+ | SWAP="/ | ||
+ | echo "" | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | PSRINFO="/ | ||
+ | echo "" | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | if [ `$UNAME -s` = " | ||
+ | MPSTAT="/ | ||
+ | else | ||
+ | MPSTAT="/ | ||
+ | fi | ||
+ | echo "" | ||
+ | echo " | ||
+ | fi | ||
+ | if [ `$UNAME -s` != " | ||
+ | if [ " | ||
+ | PLATFORM_SPEC=`$UNAME -i` | ||
+ | fi | ||
+ | | ||
+ | if [ " | ||
+ | PRTDIAG_COMMAND="/ | ||
+ | fi | ||
+ | | ||
+ | if [ " | ||
+ | PRTDIAG_OPT=" | ||
+ | echo "" | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | fi | ||
+ | |||
+ | fi # end if darwin | ||
+ | export COLOR | ||
+ | |||
+ | } # end get_setup | ||
+ | |||
+ | get_procinfo () { | ||
+ | ##### | ||
+ | ##### List CPU Info. | ||
+ | ##### | ||
+ | |||
+ | case $BBOSTYPE in | ||
+ | | ||
+ | get_header " | ||
+ | NUM_PROCS=`hostinfo | grep " | ||
+ | | ||
+ | hostinfo | $GREP -A3 " | ||
+ | |||
+ | get_footer | ||
+ | ;; | ||
+ | | ||
+ | CATCH_COMMAND=` $PSRINFO ` | ||
+ | |||
+ | get_header " | ||
+ | | ||
+ | NUM_PROCS=` $PSRINFO | $WC -l ` | ||
+ | if [ " | ||
+ | ON_LINES=`$PSRINFO | $EGREP " | ||
+ | if [ " | ||
+ | echo " | ||
+ | else | ||
+ | COLOR=" | ||
+ | echo " | ||
+ | echo " | ||
+ | fi | ||
+ | else | ||
+ | COLOR=" | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | get_footer | ||
+ | ;; | ||
+ | linux | redhat | debian | \ | ||
+ | * ) ;; | ||
+ | esac | ||
+ | | ||
+ | |||
+ | } # end get_procinfo | ||
+ | |||
+ | get_mpstat () { | ||
+ | ##### | ||
+ | ##### List more CPU Info. | ||
+ | ##### | ||
+ | |||
+ | if [ $BBOSTYPE != " | ||
+ | CATCH_COMMAND=` $MPSTAT ` | ||
+ | |||
+ | get_header " | ||
+ | |||
+ | if [ " | ||
+ | echo " | ||
+ | else | ||
+ | COLOR=" | ||
+ | echo " | ||
+ | fi | ||
+ | get_footer | ||
+ | fi | ||
+ | export COLOR | ||
+ | |||
+ | } # end get_mpstat | ||
+ | |||
+ | get_prtdiag () { | ||
+ | ##### | ||
+ | ##### List still more CPU Info. | ||
+ | ##### | ||
+ | |||
+ | if [ " | ||
+ | # Solaris 2.5.1 does not support -X on uname, so skip this test | ||
+ | |||
+ | case $BBOSTYPE in | ||
+ | darwin ) | ||
+ | get_header " | ||
+ | ECHO_COMMAND=`darwin_prtdiag` | ||
+ | ;; | ||
+ | solaris ) | ||
+ | ZONENAME=/ | ||
+ | if [ -s " | ||
+ | ZONE=`$ZONENAME` | ||
+ | else | ||
+ | ZONE=" | ||
+ | fi | ||
+ | if [ " | ||
+ | get_header " | ||
+ | else | ||
+ | get_header " | ||
+ | |||
+ | if [ -s " | ||
+ | ECHO_COMMAND=` $PRTDIAG_COMMAND $PRTDIAG_OPT | | ||
+ | $AWK '/ | ||
+ | $GREP -v " | ||
+ | CATCH_COMMAND=` $PRTDIAG_COMMAND $PRTDIAG_OPT | | ||
+ | $AWK '/ | ||
+ | $GREP -v " | ||
+ | CONFIGURED_PROCS=` $PRTDIAG_COMMAND $PRTDIAG_OPT | | ||
+ | $AWK '/ | ||
+ | $GREP -v " | ||
+ | $TAIL +4 | | ||
+ | $WC | | ||
+ | $AWK ' | ||
+ | if [ " | ||
+ | # Solaris 10 supports psrinfo -p and Sparc IV chips | ||
+ | INSTALLED_CHIPS=` $PSRINFO -p` | ||
+ | INSTALLED_PROCS=` $PSRINFO -p` | ||
+ | else | ||
+ | INSTALLED_PROCS=` $UNAME -X | | ||
+ | $GREP NumCPU | | ||
+ | $AWK ' | ||
+ | fi | ||
+ | else | ||
+ | echo "No prtdiag installed on this platform - $PLATFORM_SPEC" | ||
+ | fi | ||
+ | fi | ||
+ | ;; | ||
+ | linux | redhat | debian | \ | ||
+ | * ) | ||
+ | get_header " | ||
+ | ECHO_COMMAND=`linux_prtdiag` | ||
+ | ;; | ||
+ | esac | ||
+ | | ||
+ | if [ `$UNAME -m` != " | ||
+ | if [ " | ||
+ | COLOR=" | ||
+ | echo " | ||
+ | echo "Some processors seem to be offline or problematic !!!" | ||
+ | # else | ||
+ | # echo " | ||
+ | fi | ||
+ | fi | ||
+ | echo " | ||
+ | |||
+ | get_footer | ||
+ | |||
+ | fi | ||
+ | export COLOR | ||
+ | } # end get_prtdiag | ||
+ | |||
+ | get_sysinfo () { | ||
+ | case $BBOSTYPE in | ||
+ | | ||
+ | get_header "uname info" " | ||
+ | echo "Node = `$UNAME -n`" | ||
+ | NUM_PROCS=`hostinfo | grep " | ||
+ | echo " | ||
+ | system_profiler SPSoftwareDataType | $GREP " | ||
+ | $UNAME -v | ||
+ | | ||
+ | get_footer | ||
+ | ;; | ||
+ | | ||
+ | get_header "uname info" " | ||
+ | |||
+ | if [ " | ||
+ | # Solaris 2.5.1 does not support -X on uname, so skip this test | ||
+ | | ||
+ | if [ " | ||
+ | echo " | ||
+ | else | ||
+ | | ||
+ | echo " | ||
+ | fi | ||
+ | if [ " | ||
+ | echo "Chips = $INSTALLED_CHIPS" | ||
+ | fi | ||
+ | fi | ||
+ | $GREP Solaris / | ||
+ | get_footer | ||
+ | ;; | ||
+ | linux | redhat | debian | \ | ||
+ | * ) | ||
+ | get_header "uname info" " | ||
+ | echo "Node = `$UNAME -n`" | ||
+ | echo " | ||
+ | if [ " | ||
+ | echo " | ||
+ | MANUFACTURER=` $DMIDECODE -s system-manufacturer` | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo "BIOS Version = `$DMIDECODE -s bios-version`" | ||
+ | fi | ||
+ | echo "Boot Command = `$CAT / | ||
+ | echo " | ||
+ | echo " | ||
+ | $CAT / | ||
+ | ;; | ||
+ | esac | ||
+ | | ||
+ | } # end get_sysinfo | ||
+ | |||
+ | ##### | ||
+ | ##### Get Status proc - used to get all responses | ||
+ | ##### | ||
+ | get_swap() | ||
+ | { | ||
+ | |||
+ | ##### | ||
+ | ##### System Swap and Memory Monitoring | ||
+ | ##### | ||
+ | if [ " | ||
+ | |||
+ | get_header "Swap Info" "$SWAP -l and $SWAP -s" | ||
+ | |||
+ | CATCH_COMMAND1=` $SWAP -l ` | ||
+ | |||
+ | if [ " | ||
+ | echo " | ||
+ | else | ||
+ | COLOR=" | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | # This is the " | ||
+ | RETURN_VAL=0 | ||
+ | |||
+ | if [ " | ||
+ | # Solaris 2.51 returns " | ||
+ | RETURN_VAL=1 | ||
+ | fi | ||
+ | |||
+ | CATCH_COMMAND2=` $SWAP -s ` | ||
+ | |||
+ | if [ " | ||
+ | echo " | ||
+ | else | ||
+ | COLOR=" | ||
+ | echo " | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | export COLOR | ||
+ | |||
+ | } # end get_swap | ||
+ | |||
+ | ##### | ||
+ | ##### Setup some variables for use later | ||
+ | ##### | ||
+ | COLOR=" | ||
+ | OS_REL=` $UNAME -r ` | ||
+ | |||
+ | ##### | ||
+ | ##### Main body | ||
+ | ##### | ||
+ | |||
+ | if [ " | ||
+ | # convert "," | ||
+ | MACHINE_WITH_DOTS=`echo $MACHINE | $SED ' | ||
+ | |||
+ | $GREP $MACHINE_WITH_DOTS $BBHOSTS | $GREP " | ||
+ | while read line | ||
+ | do | ||
+ | if [ ! -z " | ||
+ | get_status > $BBTMP/ | ||
+ | |||
+ | # NOW USE THE BB COMMAND TO SEND THE DATA ACROSS | ||
+ | $BB $BBDISP " | ||
+ | fi | ||
+ | done | ||
+ | else | ||
+ | get_setup > $BBTMP/ | ||
+ | get_procinfo >> $BBTMP/ | ||
+ | get_mpstat >> $BBTMP/ | ||
+ | get_prtdiag >> $BBTMP/ | ||
+ | get_sysinfo >> $BBTMP/ | ||
+ | if [ " | ||
+ | get_swap >> $BBTMP/ | ||
+ | fi | ||
+ | |||
+ | # NOW USE THE BB COMMAND TO SEND THE DATA ACROSS | ||
+ | |||
+ | # | ||
+ | $BB $BBDISP " | ||
+ | |||
+ | $VERSION" | ||
+ | fi | ||
+ | |||
+ | # Clean up our mess | ||
+ | # Checking for existence of files since the whole test may be optional | ||
+ | # and may not actually run on every client | ||
+ | # | ||
+ | if [ -f $BBTMP/ | ||
+ | $RM $BBTMP/ | ||
+ | fi | ||
+ | |||
+ | ############################################## | ||
+ | # end of script | ||
+ | ############################################## | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | |||
+ | ===== To Do ===== | ||
+ | |||
+ | ===== Credits ===== | ||
+ | * Paul A. Luzzi | ||
+ | * David Levin | ||
+ | * Craig Cook | ||
+ | * Butch Deal | ||
+ | * Daniel Gomez | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2000-03-22** | ||
+ | * Initial release ....... | ||
+ | |||
+ | * version 3.5 - Added support for Linux | ||
+ | - physical cpu count for both Solaris and Linux | ||
+ | - OS release information for both Solaris and Linux | ||
+ | - have not tested SWAP_INFO for Linux | ||
+ | * version 3.6 - Added some support for Mac OS X (Darwin) | ||
+ | - modularised some of the procedures | ||
+ | - removed need for prtdiag on Linux | ||
+ | * version 3.9 - Added some support for Solaris zones | ||
+ | - added support for dual core Ultra sparc IV | ||
+ | * version 3.9.1 - started support for Sun4v Niagara chips | ||
+ | * version 3.10 - Added more dmidecode entries | ||
+ | |||