Howto Write Your Own Icinga Nagios Check

Introduction

You searched the whole day for just this one damn monitoring check, but you can’t find one that is matching your needs?
You could even do it by hand on the command line, but you don’t know how to tell your monitoring system about it?

Read on, it ain’t that hard, it is all about return codes.

A check is basically a executable script that ‘checks’ something and returns a exit code, that icinga/nagios is able to work with.
So there a 4 return codes that both accept, you can see them here in the table:

ReturncodeService-StatusDescription
0OKEverything works as expected
1WARNINGThe System is running, but something isn't working properly
2CRITICALThe system isn't working at all or it is above a threshold
3UNKNOWNThe check isn't running properly, for example when the login data for a service are wrong

Hands on

Great, but how do I use them? Calm down, it is really easy.

I will explain it to you with a little bash script, that does nothing more than checking if /dev/null is avaible.
(Even that is important ;))

As you save this script and make it executable:

you can easily add it to your nrpe_local.cfg as a npre-command or run it from the icinga host, this is up to you.

I hope I could help you a bit 😉

Don’t forget to follow on twitter or subscribe to our newsletter!

Leave a Reply

Your email address will not be published. Required fields are marked *