[Nagiosplug-devel] Issue with custom nagios plugin
William Dinyes
wdinyes at ourvacationstore.com
Mon Jul 28 14:47:08 CEST 2003
In toying around with writing my own nagios plugin, I've run into a rather
strange error, which I am hoping someone here has seen before. The script I
am running sets a date as part of a URL to check freshness of stats pages on
my sites. Here's the script (simple? oh yes, and a kludge to boot):
#!/bin/bash
#
# This is a simple script to check our stats servers to make sure that
# new stats were uploaded properly today.
PATH=/bin:/usr/bin
URL=$1
if [ "$1" == "--help" -o "$1" == "-h" ]
then
//simple help output
fi
URLDATE=`date -d yesterday +"%Y\/%m"`
SEARCHDATE=`date +"%d %b %Y"`
URLOUT=`/bin/sed -e "s/DATE/$URLDATE/g" << EOF
$URL
EOF`
/usr/bin/lynx -dump http://$URLOUT | /bin/egrep "Last Update
:[[:space:]]+$SEARC
HDATE" > /dev/null
OUTCODE=$?
if [ "$OUTCODE" -eq "1" ]
then
echo "CRITICAL: Update failed, check hex logs."
exit 2
elif [ "$OUTCODE" -eq "0" ]
then
echo "OK: Update for $SEARCHDATE has occurred."
exit 0
else
echo "WARNING: Unable to parse file, website down?"
exit 1
fi
If I run this from the command line as nagios, I get:
nagios at tuxedo:~/libexec
125$ ./check_stats 10.1.1.50/DATE/awstats.market.html
OK: Update for 28 Jul 2003 has occurred.
But when I set it up and run it from nagios itself against the same server,
I get the CRITICAL: Update failed... line every time.
Things I've tried to no avail:
- putting the full path on every command (from sed to date)
- outputting additional information indicates that the URL is being
constructed fine, the
dates are all set properly.
- checked services.cfg, checkcommands.cfg, etc. All seem fine.
Frankly, all I can think of is that my return code is somehow always getting
set to 1
for no reason.
Is there something I am missing (like pathing, or some sort of nagios config
I've missed)?
I did try this with check_http, but getting the date set properly wasn't
working at all,
no matter how many $USERx$ lines I had.
William Dinyes
Website Administrator
OurVacationStore.com
10030 N. 25th Ave.
Phoenix, AZ 85021
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 7/24/2003
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3488 bytes
Desc: not available
URL: <http://nagios-plugins.org/archive/devel/attachments/20030728/90d06711/attachment.bin>
More information about the Devel
mailing list