Pages

Showing posts with label check_mk. Show all posts
Showing posts with label check_mk. Show all posts

Thursday, September 11, 2014

Check_MK MRPE

Check_mk provides a nice way to migrate your old NRPE based checks into Check_mk using MRPE

Although the documentation of MRPE is very comprehensive but today I messed the whole day with small issue.

I had written small script which  can connect to another host by ssh and collect some facts. The problem started when I was using the same command two times with different parameters.

e.g. check my mrpe.cfg

[root@appmon2 tmp]# cat  mrpe.cfg
### Just a Test
TEST1 ./test.sh ALL
TEST2 ./test.sh COLO

so despite I have defined two services , check_mk_agent is recongnizing only one,

[root@tiber tmp]# check_mk_agent
<<>>
(test.sh) TEST1 0 OK: ALL is Green

The whole issue was in the script test.sh I have used ssh to connect to remote host and which is causing the issue.

To fix this need to append the

[root@tiber tmp]# diff test.sh test1.sh
52,53c52
<       ssh root@$HA $command >> /tmp/juned.txt
---
>      
> /tmp/juned.txt
And now check_mk_agent is happy

<<>>
(test.sh) TEST1 0 OK: ALL is Green
(test.sh) TEST2 0 OK: app is Green


Edit : 2 July 2015
Once again messed with the same issue, and found that if you are using ssh inside mrpe its always advisable to Close stdin. to avoid the issue.

So in the function where you using the ssh command on remote host add <&- after the closing }.

e.g.

function execute_command {
        ssh root@$SRV $command >> /tmp/out.txt
        if [ $? -eq 0  ]; then
                msg="Green"
                sstatus=0
        else
                msg="Critical: Red"
                sstatus=2
        fi
}<&-

Friday, September 5, 2014

Monitor Failed Jenkins Job

We use Jenkins quite differently :) ( I will write it the use case later ) , And although the Jenkins provides the Email alerting if the Job is unstable. But  in our scenario we wanted an aggregate Job monitoring for the jenkins job so that as soon as any of the Jenkins Job failed our level team got hold of it.

Below is the simple Python plugin I have written  to achieve this. This python script gets all jobs stats using the Jenkins API and then parses for the stability of the Job.