nagios tomcat open files check

here is a quick and dirty little script to see how many open files tomcat is using up. #!/bin/bash USER=tomcat LSOF=`lsof -u $USER | wc -l` OPEN_F=`ulimit -a | egrep “open files” | awk ‘{print $4}’` #PERCDONE=$(( $LSOF / $OPENF * 100 )) PERCDONE_PRE=$(echo “scale=2;(($LSOF/$OPEN_F) * 100)” |bc) PERCDONE=`echo $PERCDONE_PRE | cut -d. -f1` if … Read More

nagios qmail current log alert check

here is a real dirty way for counting and monitoring how many “alerts” are in qmails current log using bash: #!/bin/bash # this script requires Date::Parse module in CPAN TMP_TIME=/tmp/tmp_time TMP_FILE=/tmp/tmp_file TMP_FILE2=/tmp/tmp_file2 if [ -f ${TMP_FILE2} ]; then rm -f ${TMP_FILE2} && touch ${TMP_FILE2} fi # CURTIME is present time in epoch perl -MDate::Parse -le’print … Read More

another stupid nagios process checker

here is another in the long line of stupid scripts for nagios. this script finds specific process, then counts them and spits out an error level according to setting enjoy!! #!/bin/bash ## replace “ORA_” with some other unique identifier ## from vi :1,$s/ORA_/”unique”/g ORA_TEMP=/tmp/ora_procs.tmp ## replace “ora_” with what you need grep’ed ps -ef | … Read More

simple nagios port check

here is a simple little nagios script to check the status of a port with ouput – sounds stupid but i needed it to check 2 specific ports for ouput and it works. #!/bin/bash if [ -z $2 ]; then if [ -z $1 ]; then printf “needs \$1 & \$2 (address & port number)\n” … Read More

slight spin on nagios file system check

here is a slight spin on the nagios disk check function – this is for when it is not critical for you to check free/used space on the fs but you still want to be alerted when something is wrong works both in linux and solaris #!/bin/bash TMP_FILE=/tmp/disk_usage.tmp.$$ df -h | tr -d ‘%’ | … Read More

nagios ram check for solaris and linux

these scripts work when checking nagios services over ssh (check_by_ssh) linux: #!/bin/bash TMP_FILE1=/tmp/ram.free.tmp1.$$ top -b -n1 |head -4 |tail -1 | awk ‘{free = $4 / $2 * 100; if (free >= 90.0) print $0 }’ >$TMP_FILE1 if [ -s $TMP_FILE1 ]; then cat $TMP_FILE1 rm -f $TMP_FILE1 exit 1 fi solaris: #!/bin/bash TMP_FILE1=/tmp/ram_free.tmp1.$$ TMP_FILE2=/tmp/ram_free.tmp2.$$ … Read More

ramdisk script for nagios

to prevent the hard drive on the nagios server from thrashing around like a drunken idiot while running nagios, i set the status.dat file to reside in a ramdisk since that file gets read and written everytime that either a service,passive or host check goes through. i put this little script in start up so … Read More

simple nagios script to check disk usage in solaris

i know that there already is a command in nagios to check file system usage, but it gives you the percentage in the wrong format (it says there is 21% free when i am used to it saying that 79% is being used) this will give you the format in basic df per device usage … Read More

simple nagios script for exp match in solaris

we just needed something on the fly to monitor /var/adm/messages for certain output in nagios. this does the trick rather nicely and its not that big of a script either. tested with nagios versions 2.3 – 2.5 #!/bin/bash TMPFILE=/tmp/tmpfile.$$ #GREP=/usr/bin/egrep egrep “(ALERT|EMERG|ERR|WARN|NOTICE|panic|halt)” /var/adm/messages > $TMPFILE egrep “\\(sd[0-9]+\\):” /var/adm/messages >> $TMPFILE egrep “su:.*su\ root.*failed” /var/adm/messages >> … Read More