2008
07.01

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 | awk '/ora_/ && !/awk/ {print $8}' >${ORA_TEMP}
ORA_COUNT=`cat ${ORA_TEMP} | wc -l`

if [ ${ORA_COUNT} -gt 0 ]; then
        ## change ge & le to what is needed
        if [ ${ORA_COUNT} -ge 6 ] && [ ${ORA_COUNT} -le 15 ]; then
                printf "${ORA_COUNT} proc(s) counted\n"
                echo exit 1
                        ## change ge & le to what is needed
                        if [ ${ORA_COUNT} -ge 1 ] && [ ${ORA_COUNT} -le 5 ]; then
                                printf "${ORA_COUNT} proc(s) counted\n"
                ## exit 0 - ok for nagios
                                echo exit 2
                                fi
        else
                printf "${ORA_COUNT} proc(s) counted\n"
                ## exit 0 - ok for nagios
                echo exit 0
        fi
else
    ## replace the word "ORACLE" with whatever it is you are monitoring
    printf "${ORA_COUNT} proc(s) counted\n - ORACLE is not running!!!"
    ## exit 2 - critical for nagios
    echo exit 2
fi
The following two tabs change content below.

charlie root

VP of keeping it real / HNIC at pissedoffadmins.com
I bring the cold coffee.

Latest posts by charlie root (see all)

No Comment.

Add Your Comment