Archive for the 'bash' Category
Creating a Nagios Plug-in … making it easy.

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.
nagios_-screenshots

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.

opensuse 10.3 bash prompt

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.