Self created check - wrong info

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
Anton @ CPB
Posts: 15
Joined: Tue Sep 01, 2015 11:10 pm

Self created check - wrong info

Post by Anton @ CPB »

Hi

I created to check a MySQL instance. The check runs fine within libexec.

Code: Select all

root@nagios:/usr/local/nagios/libexec# ./check_nprobe_mysql 
OK - The times are 59 sec apart
root@nagios:/usr/local/nagios/libexec# 
But not with the check running - See attached png

Herewith the check_nprobe_mysql code

Code: Select all

#!/bin/bash

#Get the date & times from the system and mysql nprobe mysql db
mdatetime=$(date +"%Y-%m-%d %H:%M:%S")
nprobeDateTime=$(mysql --login-path=remote -e "select from_unixtime(FIRST_SWITCHED) from nprobe.flowsflows order by from_unixtime(FIRST_SWITCHED) desc limit 1;" | cut -d')' -f2)

#Convert the dates & time to seconds
systemt=$(date -d "$mdatetime" +%s)
nprobetime=$(date -d "$nprobeDateTime" +%s)

#Get the diffirence between the systtem time and nprobe FIRST_SWITCHED
diff=$((systemt - nprobetime))

#Get the results - Results are measured in seconds
if (("$diff" <= 120))     #Change the OK time to your threshold
        then
                echo "OK - The times are $diff sec apart"
                exit 0
elif (("$diff" > 121)) && (("$diff" <=159)) #Change the WARNING time to your threshold - Between a period ie. currently between 121 sec & 159 sec
                then
                        echo "WARNING - Times are $diff sec apart"
                        exit 1
else
        if (("$diff" > 160))  #Change the CRITICAL time to your threshold - 1 above the last sec from WARNING
                then
                        echo "CRITICAL - Times are $diff sec apart"
                        exit 2
        fi
fi
Don't know if I'm missing anything
Attachments
incorrect info
incorrect info
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Self created check - wrong info

Post by rkennedy »

For debugging purposes, can you have the result echo also systemt and nprobetime in the result so we can try to see where these numbers are coming from?

Then, run it over CLI and Nagios and post the results back.
Former Nagios Employee
Locked