Creating a Nagios plug-in looks daunting and hard at first. It’s really not as hard as you think.
Here is a couple things you should know:
Know what you want to monitor.
I create most of my plug-ins in bash scripts and perl scripts. (other languages supported, those are just what I use)
Know your exit codes.
Your plug-in output should be helpful and informative.
Exit codes are simple, and key to your plug-in success.
0 – OK
1 – WARN
2 – CRITICAL
3 – UKNOWN
Now those look family don’t they, they are the states or status of a service. i.e. my disk space is in OK state because I have 120GB free space.

here is a sample code snippet:
if [ $space -ge $CRITCAL ] ; then
echo "DISK SPACE CRITICAL - 90% disk space used [10GB free on /]"
exit 2;
fi
Need Nagios/Monitoring consulting? Maybe I can help, I am currently working on, as project lead, one of the biggest Nagios installs, for a Wal-Mart and Novell.
For a while now I have been working on a desk with at least 2 computers (most of the time more). Each computer runs a different OS. (Linux / OSX / Windows) While over the past few years I have upgraded my desk a few times, going from the door on saw horses to the long tables you get at Samsclub really cheap to a really nice desk, still a table top, but a bit nicer looking. I’ve always preferred these type of desks because of what they can hold – monitors! I learned a while back that having a keyboard on my desktop for each machine was a lot of clutter. Enter an app I’ve grown to love over the past few years. Synergy. It’s over due worthy for a post. Synergy allows me to take a number of computers and use 1 keyboard/mouse combo for them.
Basically the setup is easy:
Say I have 2 computers at my desk. My work Mac Book Pro and my beloved linux box (in this case it’s running Ubuntu) I really like my Apple hardware, the famous flat keyboard and the mighty mouse and I use my Mac Book Pro a majority of the time. So I pick my MPB to be my “server” for synergy. My linux box will be the client machine. I setup the server with a quick configuration:
mbprover-2:synergy-1.3.1 jhigley$ cat synergy.conf
section: screens
mbprover-2.local:
jamesh-desktop:
end
section: links
mbprover-2.local:
right = jamesh-desktop
jamesh-desktop:
left = mbprover-2.local
end
Now I run synergys (the server) on the MPB and on the linux box I run the client, you guessed it, I run synergyc and tell it to connect to the server. There are a few tricks, be sure to use the “hostnames” of each box in the config. You can customize the config all you want, I just wanted to show you how to get it up quick.
Visit the synergy website for more info: http://synergy2.sourceforge.net/
Price: Free!! (this is why opensource software is so cool.)

I updated the bash prompt on my opensuse 10.3 servers. In my .bashrc file I added:
# Set the prompt for root: (taken from suse 10.3 /etc/bash.bashrc (I added the title bar)
PS1=”\[$_bred\]$PS1\[$_sgr0\] \e]2;\h\a”
the \e]2;\h\a adds the hostname to the titlebar on my term, allowing me to quickly know which server I’m on.
I also have a set of define aliases, aliases are very nice for the cli. An alias is basically a shortcut.
#Define aliases
alias www=”cd /srv/www/htdocs”
#alias commands
alias tm=”tail -f /var/log/mail”
alias restart=”shutdown -r -f -t 5 now”
So now, when I want to tail the mail log, I just type tm at the prompt.
Today I installed KDE4 on to my desktop. As many of you know who read this, I’m more of a Gnome fan. (it’s just me) But I do like to dabble in the latest stuff out, so KDE4 needed to be run. After installing, I switched over to it and played with it for about 5 minutes. My best way to explain it, it was “blank”, with tons of potential. I’m looking forward to it moving out of beta and into prime time.
Linux is awesome that it gives you choices like this. That’s what it’s about. I’ll post some SS later one.