Page 1 of 1

Comparing and showing in Reports service outputs

Posted: Fri Oct 14, 2016 4:25 pm
by peplopez
Hello,

first of all, thanks in advance for your time reading this questions.

Question 1

I have some services that count some files in some server folders. As far as the count result can be different every day and even 0, the check is always OK and I show the count result as the output of the check. This is working fine.
I need to compare the output of 2 of this services and raise a Critical or a OK if outputs are different or not. I readed that with check_multi I can execute some child checks and get a global result but as I said, as far as the checks will always be OK, How can I use check_multi (or other different way) to get the final result comparing the output of the child services instead the service status?

Question 2

Very related with the previous question, is there a way to show in a Dashboard and in a Report the output of the service check instead of the service status?
I mean.. create a report in Nagios for this service in which I get someting like :
Server_Name1 --> 50 files
Server_Name2 --> 60 files
Server_Name3 --> 45 files

I saw that in a Dashboard I can use the text_label=[output] to show the output near to the service Icon but I don“t know if this is the best way to do it.
Of course the purpouse of all of this is to use nagios to automate the process for counting files and presenting the result in a Dashboard or scheduled Report, which I know that is not the main purpouse for this monitoring tool but nagios will never stop surprising me.

Many thanks for your help and comments.

Best Regards

Re: Comparing and showing in Reports service outputs

Posted: Mon Oct 17, 2016 4:44 pm
by rkennedy
1. I would create a wrapper script to compare the two variables observed by the different checks. Then, have your actual check just be the comparison of the two numbers.

2. This was posted in the Core board, but when you mention Dashboard and Report I think of XI. Which one are you using?

Re: Comparing and showing in Reports service outputs

Posted: Mon Oct 17, 2016 8:47 pm
by peplopez
rkennedy wrote:1. I would create a wrapper script to compare the two variables observed by the different checks. Then, have your actual check just be the comparison of the two numbers.

2. This was posted in the Core board, but when you mention Dashboard and Report I think of XI. Which one are you using?
Hello, thanks in advance for your help.

1. Can you show me an example or code portion of a script that captures the output/status_information column of a nagios service check? If I know how to reference this value I will manage to make a script for comparing the values.

2. Its "still" Nagios 3 , sorry if this is not the right forum. Can it be posible to show the service output in a report?

Regards

Re: Comparing and showing in Reports service outputs

Posted: Tue Oct 18, 2016 10:19 am
by rkennedy
Sure, here's a rough example of something I hacked together just the other day. I am pulling the amount of memory usage by using the awk part of the commands when setting $memory and $memory2.

Code: Select all

#!/bin/bash
#set vars
memory=$(/usr/local/nagios/libexec/check_nrpe -H 192.168.5.47 -c check_process -a process=firefox.exe "crit=working_set > 32M" "detail-syntax=%(working_set) %(exe)" | awk '{print $2}')
memory2=$(/usr/local/nagios/libexec/check_nrpe -H 192.168.5.47 -c check_process -a process=explorer.exe "crit=working_set > 32M" "detail-syntax=%(working_set) %(exe)" | awk '{print $2}')
memmb=$(($memory/1024/1024))
memmb2=$(($memory2/1024/1024))

#logic for checking values
if [ "$memmb" -ne "$memmb2" ]
then
        state="CRITICAL"
                ecode=2
elif [ "$memmb" -eq "$memmb2"  ]
then
        state="OK"
                ecode=0
else
        state="UNKNOWN"
                ecode=3
fi
echo "$state: firefox=$memmb explorer=$memmb2 | firefox=$memmb;;; explorer=$memmb2"
exit $ecode
Basically, both checks are running when defining $memory and $memory2, then $memmb / $memmb2 are doing math based on those variables. I've then added in logic similar to what you're after. Modify as needed.

2. I don't think this is going to be possible out of the box. You could raise an issue on our GitHub for the request here - https://github.com/NagiosEnterprises/nagioscore

Re: Comparing and showing in Reports service outputs

Posted: Sun Oct 23, 2016 2:21 am
by peplopez
Many thanks for your help an examples, I think I Will manage to get It working.

The thread can be closed.

Regards

Re: Comparing and showing in Reports service outputs

Posted: Mon Oct 24, 2016 9:42 am
by dwhitfield
We can leave it open until you have confirmed you have things working.