Nagios – Notify via Prowl

If your not familiar with Prowl, then check it out. It allows your growl notifications to be sent to your iPhone via push. I use this in several different ways on my home computer to notifications when I’m out at about. You can also access the prowl service directly with its API, so no need to even have it go to growl first.

I like using Prowl (in addition to Growl) with nagios. This allows me to get my notifications anywhere as long as I have my iphone. Just like with the growl notifications, the prowl notifications are just as easy to setup. It is very well documented here at the Reluctant Hacker.

Nagios – Notify via Growl

There are several different ways to get notified by nagios when there is a problem. The most common way is via email. This is usally just fine, except when the service that goes down is the mailserver. There are ways to mitigate this of course.

One simple was is to get your notifications via growl. I really like this, it lets me know almost instantly when some is going on and I don’t have to worry about keeping my eyes on my email program while I’m busy on something else.

The way I implemented it was from a great script and good write up on the Nagios-users mailing list, you can see it all right here: Notify via Growl

Checking the snort process from nagios

I’m checking the snort basically like i’m checking most processes, if you’ve been following allong then you’ll already have a check_procs setup.

So I simply edit my localhost.cfg and add:
define service{
use generic-service
host_name localhost
service_description Snort
check_command check_snort_procs!1:1!snort
}

Edit the commands.cfg and add:
define command{
command_name check_snort_procs
command_line $USER1$/check_procs -c $ARG1$ -C $ARG2$
}

reload nagios and thats it.

My BASE (for Snort) Install Notes for OSX

To get base up and going with snort already installed I did the following.
1. Downlaod ADOdb (database abstraction library for PHP) : http://sourceforge.net/projects/adodb/files/
The version I got was adodb510.tgz

2. Unzip and untar the file
tar -xvzf adodb510.tgz

3. Move the folder
I did:
cp -R adodb5/ /Library/WebServer/Documents/adodb5/

4. Download base: http://sourceforge.net/projects/secureideas/ The version I got was: base-1.4.4.tar.gz

5. Unzip and tar the file
tar -xvzf base-1.4.4.tar.gz

6. You should now have a folder: base-1.4.4/
cd base-1.4.4/

7. Copy the base folder to your webserver folder
cp base-1.4.4/ /Library/WebServer/Documents/base/
change the owner on the folder
sudo chown -R _www:_www /Library/WebServer/Documents/base/
*NOTE*
With this version there was a known problem with the file: base_state_citems.inc.php on some setups, mine included.
So I had to download the fixed version from CVS
You can also download it from the website, follow the link from here:
http://secureideas.cvs.sourceforge.net/viewvc/secureideas/base-php4/includes/base_state_citems.inc.php?view=log
it goes in your /base/templates/

8. Now install the needed pear extensions for graphs to work in base
On my system it was as follows:
First I had to update pear to the rest of the packages would work:
sudo /usr/local/php5/bin/pear install PEAR-1.9.0

Then the following packages:
sudo /usr/local/php5/bin/pear install Image_Color
sudo /usr/local/php5/bin/pear install Image_Canvas-0.3.2
sudo /usr/local/php5/bin/pear install Image_Graph-0.7.2

9. Open up base in your browser:
http://localhost/base/setup/index.php
You should get the page up with the settings, if you have any errors you need to fix them first with their suggestions.
Once you answer all the setup questions you should have a working base install.

My Snort on OSX Install Notes

1 Download Snort2 Download pcre
3 Untar pcre
4 Cd to pcre
5 ./configure
make
make install
(NOTE: Install prefix ……………… : /usr/local)
6 Untar Snort
7 CD to snort
8 ./configure -enable-dynamicplugin –with-mysql –with-mysql-includes=/opt/local/include/mysql5/ –with-mysql-libraries=/opt/local/lib/mysql5/mysql/
9 make
10 sudo make install
/usr/bin/install -c -m 644 ‘./snort.8’ ‘/usr/local/man/man8/snort.8’
test -z “/usr/local/lib/pkgconfig” || /bin/sh ./mkinstalldirs “/usr/local/lib/pkgconfig”
/usr/bin/install -c -m 644 ‘snort.pc’ ‘/usr/local/lib/pkgconfig/snort.pc’

11. Get the rules from the snort site and untar them
I used snorttemp as the folder
12. Make a folder for the rules
mkdir /opt/local/etc/snort/
mkdir /opt/local/etc/snort/rules/
13. Copy the rules over
cd ~/snorttemp/rules/
cp * /opt/local/etc/snort/rules/
I also copied over the etc folder
cd ~/snorttemp/etc/
cp * /opt/local/etc/snort/
14. Edit the Snort configuration
vi /opt/local/etc/snort/snort.cfg
change “var HOME_NET any” to “var HOME_NET 192.168.0.0/24” or whatever your home network is
change “var EXTERNAL_NET any” to “var EXTERNAL_NET !$HOME_NET” This is everything except your home network
change “var RULE_PATH ../rules” to “var RULE_PATH /opt/local/etc/snort/rules”
goto the line that starts with “# output database: log, mysql, user=” and remove the # from the begining of the line
enter your user password and db name
15. mysql setup
log in to mysql as root
mysql -u root -p

create a snort database
mysql> create database snort;

create a user and password to match your mysql setup in the snort config:
mysql> CREATE USER ‘snort’@’localhost’ IDENTIFIED BY ‘somepassword’;

give that user access to the database
mysql> GRANT ALL PRIVILEGES ON snort.* TO ‘snort’@’localhost’;
mysql> exit

Import the snort schema into the database.
mysql -D snort -u root -p < /schemas/create_mysql

16. Start it up
snort -c /opt/local/etc/snort/snort.conf

If it works it should look something like:
–== Initialization Complete ==–

,,_ -*> Snort! <*-
o” )~ Version 2.8.5.1 (Build 114)
”” By Martin Roesch & The Snort Team: http://www.snort.org/snort/snort-team

You can use ctrl+c to stop it.

Debian Boot Thumb drive from OSX

Last week I had a need to create a debian boot disk. The computer I needed to use it on doesn’t have a CD and I didn’t feel like purchasing a USB CD reader just for the purpose of loading debian, and I didn’t feel like waiting until I could go to down or have it shipped.

So I had to make a boot disk. I’ve done it in Linux several times before but never from OSX. So the commands aren’t exactly the same, here are my notes taken from a couple places on the web, which should serve as a reminder for the next time I have do to it.

First I downloaded the debian image I wanted to use from there site.
Next I stuck the thumb drive in the box.
from the termial (I use iTerm)
#diskutil list
mine was listed as /dev/disk1
#diskutil unmountDisk /dev/disk1
#bzcat debian.img | dd of=/dev/disk1
#diskutil eject /dev/disk1

It was a simple as that. To test i stuck it in my handy netbook and reboot and I was at the lovely command prompt. Then of course other things happened that required my attention so I haven’t gotten back to that project of getting the box installed yet.

Checking the Splunk Process from Nagios

Now its time to have Nagios check to make sure that splunk is running. For version 3 of Splunk there was a app / plugin you could get for Splunk that would work with Nagios. It appears to be gone. But I did find a snippet that some one posted here. Several things have changed so that script doesn’t work 100% out by cut and paste, but it was an excellent jumping off point and it took very few modifications to get going. Due to the fact that there is a copy right on this script, then I can’t put it here with out permission. But I will note that you can do the same thing almost by using the default nagios check_procs command.

So copy that script as check_splunk and stick it in your libexec folder. If your playing along with my setup thats: /opt/local/libexec/nagios

Once you have it downloaded you can ./check_splunk ports or procs
I didn’t worry about checking or trying to edit the search portion as for what I’m doing I don’t really need it right now, but I will revisit it if the need arises.

Now you have the script, its time todo the normal nagios setup stuff.
1. Add it to your commands
vi /opt/local/etc/nagios/objects/commands.cfg

define command {
command_name check_splunk
command_line $USER1$/check_splunk $ARG1$
}

2. Add it to your localhost
vi /opt/local/etc/nagios/objects/localhost.cfg

define service{
use generic-service
host_name localhost
service_description Splunk Port
check_command check_splunk!ports
}

define service{
use generic-service
host_name localhost
service_description Splunk Procs
check_command check_splunk!procs
}

Now restart nagios and you should be good to go