[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to get performance data out of a single check command (a script)  that returns only 1 value in nagios?

Posted on 2010-03-31
3
Medium Priority
?
1,109 Views
Last Modified: 2013-12-26
I have this probe.sh script, which checks for temperature of a probe, the result is a simple number, which is the temperature in Celsius. My goal is to make centreon draw graphs from this number, but it returns nothing but that number.  To draw graphs, nagios needs performance data, which involves a lot of other values to be returned from the script (command). So basically I'm asking for someone to write the rest of the script (which is a huge part really), a person who understands bash scripting and nagios. I'm not in a hurry, I just can't seem to do it.

Bellow is the command example, plus another command that returns pefdata (check_centreon_ping). If you need the contents of tp_read.pl, I'll add them, but they're irrelevant in my opinion, awk only filters the number after probe.sh, which is the probe identifier and which is the useless part of the output from that check. I can in desperation send the IP address and both scripts so someone could check if it's working as he tests it.

I know it's a serious task so I'm really grateful to anyone that decides to try this. Thank you!
ngs:/usr/local/nagios/libexec# ./probe.sh 0.10132c65010800ec
21.0
ngs:/usr/local/nagios/libexec# cat probe.sh
#!/bin/bash
/usr/local/nagios/libexec/tp_read.pl d -f=10 -p=**.***.***.*** -a=$1|awk -F = '{print $2}'

ngs:/usr/local/nagios/libexec# ./check_centreon_ping **.***.***.***
GPING OK - rtt min/avg/max/mdev = 6.095/6.095/6.095/0.000 ms|time=6.095ms;20;40;; ok=1

Open in new window

0
Comment
Question by:zelia5
  • 2
3 Comments
 
LVL 81

Expert Comment

by:arnold
ID: 29236384
You actually have two values, the time the check was done and the temperature.  What other value are you looking for?
0
 

Author Comment

by:zelia5
ID: 29363197

Thank You for Your interest, I'm sorry for the late reply, maybe this link can help you:
http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201
0
 

Accepted Solution

by:
zelia5 earned 0 total points
ID: 30745331
I got it, it was just a matter of editing the output so nagios can understand it as performance data

#!/bin/bash

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4

declare -rx SCRIPT=${0##*/}
declare -rx CMD_AWK="/bin/awk"
declare  -rx CMD_CAT="/bin/cat"
declare  -rx CMD_FREE="/usr/bin/free"
declare  -rx CMD_GREP="/bin/grep"


TEMP=$(/usr/local/nagios/libexec/tp_read.pl d -f=10 -p=**.***.***.*** -a=$1|awk -F = '{print $2}')

CRITICAL=35
WARN=33
if [ $TEMP -lt $CRITICAL ]; then
        echo "Temperature OK,Temperature Level: $TEMP|Temperature_level=$TEMP"
        exit $STATE_OK
else
        echo "High Temperature detected on Rack xx|$TEMP degrees"
        echo $STATE_CRITICAL

fi

Open in new window

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question