Re: [Nagios-devel] Nagios sometimes shows wrong status

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Nagios sometimes shows wrong status

Post by Guest »

Hi!
> Whilst I'm not sure it has anything to do with your issue, nagios
> executes scripts without an environment defined (usually), which means
> just calling "grep" will not find the path. You should define full
> path to executables whenever possible. Of course, you said "relevant
> part of the script" which could imply you've defined the path earlier
> on.
>
...
> Definetly an odd outcome. What about dumping the content of the
> metastat calls, and the variables you've assigned? That way you can
> see what nagios is actually seeing. ie:
>
> echo "====" >> /tmp/svm.debug
> datum=`date`
> META=`/usr/sbin/metastat`
> echo ${datum} ${META} >> /tmp/svm.debug
> MAINTCNT="`/usr/sbin/metastat |grep -i maint |wc -l`"
> RESYNCNT="`/usr/sbin/metastat |grep -i resync |wc -l`"
> echo ${datum} ${MAINTCNT} >> /tmp/svm.debug
> echo ${datum} ${RESYNCNT} >> /tmp/svm.debug
>
> [.. rest of script ..]
>

ok, i've changed the script:

echo "====" >> /tmp/svm.debug
datum=`/usr/bin/date`
#META=`/usr/sbin/metastat`
META=`/usr/bin/cat /export/home/nagios/metastat.out`
echo ${datum} ${META} >> /tmp/svm.debug
MAINTCNT="`/usr/bin/cat /export/home/nagios/metastat.out | /usr/bin/grep
-i maint | /usr/bin/wc -l`"
RESYNCNT="`/usr/sbin/metastat | /usr/bin/grep -i resync | /usr/bin/wc -l`"
echo ${datum} ${MAINTCNT} >> /tmp/svm.debug
echo ${datum} ${RESYNCNT} >> /tmp/svm.debug


NOTOK=0
status=$STATE_UNKNOWN

if [ $RESYNCNT -gt 0 ]; then
NOTOK=1
TEXT="WARNING - One or more disks are in resync state."
status=$STATE_WARNING
fi

if [ $MAINTCNT -gt 0 ]; then
NOTOK=1
TEXT="CRITICAL - One or more disks are in maintenance state."
status=$STATE_CRITICAL
fi


if [ $NOTOK -eq 1 ]; then
echo $TEXT
datum=`date`
echo $datum $status >> /tmp/svm.debug
exit $status
fi

echo "OK - There is no maintenance necessary!"
exit $STATE_OK

##############################################################

i've dumped the metastat output to a file before the disk has been
replaced...

/export/home/nagios/metastat.out:
d31: Mirror
Submirror 0: d41
State: Okay
Submirror 1: d51
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 58542696 blocks (27 GB)

d41: Submirror of d31
State: Okay
Size: 58542696 blocks (27 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t1d0s1 0 No Okay Yes


d51: Submirror of d31
State: Okay
Size: 58542696 blocks (27 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t3d0s1 0 No Okay Yes


d30: Mirror
Submirror 0: d40
State: Okay
Submirror 1: d50
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 12584484 blocks (6.0 GB)

d40: Submirror of d30
State: Okay
Size: 12584484 blocks (6.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t1d0s0 0 No Okay Yes


d50: Submirror of d30
State: Okay
Size: 12584484 blocks (6.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t3d0s0 0 No Okay Yes


d7: Mirror
Submirror 0: d17
State: Needs maintenance
Submirror 1: d27
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 41679603 blocks (19 GB)

d17: Submirror of d7
State: Unavailable
Size: 41679603 blocks (19 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t0d0s7 0 No - Yes


d27: Submirror of d7
State: Okay
Size: 41679603 blocks (19 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t2d0s7 0 No Okay Yes


d3: Mirror
Submirror 0: d13
State: Needs maintenance
Submirror 1: d23
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 12584484 blocks (6.0 GB)

d13: Submirror of d3
State: Unavailable
Size: 12584484 blocks (6.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1t0d0s3 0 No - Yes


d23: Submirror of d3
State: Okay
Size: 12584484 blocks (6.0 GB)
St

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked