========================================================== SMONITOR, Simple snmp based script for monitoring systems ========================================================== :Author: Frédéric de Zorzi :Contact: fredz@_nospam_pimentech.net :Revision: $Revision: 1.31 $ :Date: $Date: 2008-11-13 15:48:16 $ :Copyright: This document has been placed in the public domain. :Tags: shell system snmp english smonitor ----------- Description ----------- SMONITOR is a simple shell script designed to generate e-mail alerts when processes/disk/memory problems occur on a set of hosts running snmpd. ------ Source ------ The source is located in pimentech script package: http://www.pimentech.fr/en/technologies/outils , you can also download it here: ftp://ftp.pimentech.net/src/scripts/src/shell/smonitor .. include:: smonitor :literal: ----- Setup ----- SNMP Setup ========== On each host you want to monitor : 1. Install snmpd 2. Edit /etc/snmp/snmpd.conf : - Add the line :: com2sec readonly listener.host public where "listener.host" is the host where the listener script will run. - For each process you want to monitor, add :: proc NAME [MAX=0] [MIN=0] where NAME is the name of the process to check for. It must match exactly (ie, http will not find httpd processes). 3. Restart snmpd SMONITOR Setup ============== You must have the snmp client package installed on listener host. Configuration file ------------------ For processes monitoring, simply add the line :: HOST proc for each destination host. For disk/swap monitoring, you have to find the node number in the snmp tree. On listener host, type the command:: snmpwalk -v2c -c public HOST .iso.org.dod.internet.mgmt.mib-2.host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr You should have an output like that:: HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: / HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: /dev/pts HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: /mnt/sdb1 HOST-RESOURCES-MIB::hrStorageDescr.101 = STRING: Real Memory HOST-RESOURCES-MIB::hrStorageDescr.102 = STRING: Swap Space HOST-RESOURCES-MIB::hrStorageDescr.103 = STRING: Memory Buffers If not, ensure that UDP port 161 is opened on HOST. For instance, if you want to be warned when disk usage exceeds 80% on the root partition, 10% on the swap partition, add :: HOST 1 80 HOST 102 10 Repeat this operation for each host. Usage ----- Now try to launch smonitor:: smonitor smonitor.conf Problems on your hosts will be reported on stdout, like this :: hal : Too many apache2 running (# = 219) mdm2 : Too many postmaster running (# = 265) No output means no problems :) That's it ! Additionally, you can put smonitor in your crontab to get e-mail alerts.