Nagios script output issue

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Infrastructure Monitoring Nagios script output issue
# 1  
Old 08-27-2010
Nagios script output issue

Hi Folks,

Nagios is acting a little weird for me, I have this external script which I hooked into Nagios, it merely does a curl/wget on a URL and returns the status based on string in the content/output. Initially for 2-3 hrs the script returns the right status and Nagios reports correctly i.e. OK, WARN, ERROR based on the exit from the script. After 2-3 hrs output which was (and should be) OK or WARN starts returning CRITICAL and the output line says "Application is" and not even "Application is ERROR" or "Application is FATAL".

There is nothing in the logs to suggest what could be the problem. Have you experienced this before and let me know the corrective action. I am running Nagios on Mac OSX.

Here is the script for the curious -
Code:
#!/bin/bash

read URL < "$1"

STATUS=`curl -s $URL |grep summary|awk -F\" '{print $2}'`
echo "Application is $STATUS"
echo "curl $URL"

case $STATUS in
OK)
   exit 0
   ;;
WARN)
  exit 1
  ;;
ERROR)
  exit 2
  ;;
FATAL)
  exit 2
  ;;
*)
  exit 2
  ;;
esac

Thanks,
Jack

---------- Post updated at 11:23 AM ---------- Previous update was at 12:27 AM ----------

When I run the script on the commandline it returns the correct status.

But on nagios it shows different error.

Any clues?

Thanks,
Jack

Last edited by Franklin52; 08-27-2010 at 02:24 PM.. Reason: Please use code tags
# 2  
Old 08-27-2010
Maybe you are missing something!

I am not sure about how Nagios works, but try to create another script that calls this one and redirect its output to a file, like:
Code:
#!/bin/bash
# lets name the script above: nagiosTest.sh
nagiosTest.sh 1>> /<path to>/nagiosTest.log 2>> /<path to>/nagiosTest.log
retCode=$?
echo "nagiosTest.sh return code: [${retCode}]" 1>> /<path to>/nagiosTest.log 2>> /<path to>/nagiosTest.log
exit ${retCode}

# 3  
Old 08-27-2010
How often are you checking the service in question. i.e. the interval of execution?

Maybe the curl part is timing out and commands are getting queued up.

Also, your script is assumig that all possible output values of "curl -s $URL" contain the pattern "summary" (else $STATUS would become ""). Are you sure that's correct?
# 4  
Old 08-27-2010
try change
Code:
read URL < "$1"

to
Code:
URL="$1"

# 5  
Old 08-29-2010
Folks,

I switched to "check_http" plugin (official nagios plugin) but that also has same problem.

Initially when I start nagios then the status on the Nagios Web interface is same as the one returned from commandline.

After some time the status becomes critical but is not as same as the commandline. Command line returns the correct status of OK instead of what the Nagios web interface shows as "CRITICAL"

Result from commandline(& browser) -
./check_http -H xyz.com -p 2222 -u /abc -t 3
OK

Result from Nagios Interface -
nodename nor servname provided, or not known
HTTP CRITICAL - Unable to open TCP socket

I am thinking that this has something to do with Nagios as the box is behaving just fine based on the commandline result(and verified on the URL through the browser).

Please help!

Thanks,
Jack.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk Script Output in Outlook Formatting Issue

When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Discussion started by: Ariean
1 Replies

2. Shell Programming and Scripting

Nagios script to get total and free memory

Hi Experts, need some help. I`m trying to write a shell script to get free, used and total memory on our linux servers. It's working great, but i need follow some standards to make it a real nagios plugin. It's pretty simple, you just type two parameters to the script, check_ram -w 80 -c 90... (4 Replies)
Discussion started by: berveglieri
4 Replies

3. Shell Programming and Scripting

Expect script works on CLI, but not under Nagios

I'm having a problem scripting Expect to work as a Nagios check. The script runs fine from the cli, but not when run as a Nagios check. I turn on the debug output, and it looks like it's not seeing the whole buffer's worth of info, like it's paged interactively somehow. I'm new to Expect, but this... (1 Reply)
Discussion started by: dhargens
1 Replies

4. Infrastructure Monitoring

Nagios check dependent on second nagios server

We have a dual Nagios server setup. One is setup for internal server monitoring on our LAN, while the second Nagios server is hosted externally and is used for external checks only such as URL and ping checks form the WAN side. I was wondering if there is any way to setup cross dependencies... (1 Reply)
Discussion started by: eugenes18t
1 Replies

5. Shell Programming and Scripting

df script output issue

hi all,i m using this script for disk space : #################################### #!/bin/ksh # HOSTS='/usr/bin/cat /host_list' DATE=$(date) DISK=$(df -gt) afile=/tmp/diskspace.log >$afile # for i in $HOSTS do echo ip: $i passed echo ip: $i passed >>$afile ... (1 Reply)
Discussion started by: viveksangwan
1 Replies

6. Infrastructure Monitoring

Facing Issue in Nagios 3.3

Hi, I have installed Nagios on Redhat Linux, I have installed Nagios+Plugins+NRPE on Server A (Host Server) and Nagios Plugins + nrpe on remote linux server (red hat linux) run the command on remote linux host, it returns nrpe version usr/local/nagios/libexec/check_nrpe -H localhost ... (1 Reply)
Discussion started by: manoj.solaris
1 Replies

7. Infrastructure Monitoring

Hooking script into Nagios

Hi! I have a perl script which returns data in the following format - AppName : BillingApp "status" = "OK"; AppName : PaymentApp "status" = "WARN"; AppName : OrderApp "status" = "ERROR"; AppName : OrderApp "status" = "FATAL"; the output consists of... (4 Replies)
Discussion started by: jacki
4 Replies

8. Infrastructure Monitoring

Nagios on Solaris 10 Sparc issue

I've got it installed but when I logging to the interface to http://localhost/nagios I get the following: Forbidden You don't have permission to access /nagios/ on this server. Apache/2.0.63 (Unix) DAV/2 Server at localhost Port 80 im running Solaris Version: SunOS dotstoas442 5.10... (0 Replies)
Discussion started by: frenchykd
0 Replies

9. Solaris

Duplex Script - output format issue.

Hi Gurus, I had downloaded the below script from the net and used it to get the Link and duplex settings in my Sun servers. In all except one(Sol-5.10 on X86) i am getting output format like below: root: /var/ADMIN/bin/speed_duplex.sh Interface Speed Duplex --------- ... (2 Replies)
Discussion started by: Hari_Ganesh
2 Replies

10. UNIX for Dummies Questions & Answers

Nagios Alerts Issue

Hi, I had installed Nagios on RHEL5.0 for Server Monitoring and configured the email alerts. Presently i am able to get the alerts of the c drive space,ftp,http services, But when the host goes down I dont get any alert saying that the Host is down or Host is Up. Request you to please help me... (4 Replies)
Discussion started by: Arun.Kakarla
4 Replies
Login or Register to Ask a Question