I know this is going to be like "somebody who's played racquetball 3 times teaching someone else to play for the first time", but here goes:
HT RiffTrax Ator the Fighting Eagle
Installing Nagios was pretty easy - they have a really good instruction page here. It boils down to:
apt-get updateThat installs Nagios and the basic plug-ins. Please NOTE that I slipped in chmod u+s /bin/ping. Debian allows only root to ping, but nagios needs it too.
apt-get upgrade
apt-get install -y autoconf gcc libc6 make wget unzip apache2 apache2-utils php5 libgd2-xpm-dev
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.3.2.tar.gz
tar xzf nagioscore.tar.gz
cd nagioscore-nagios-4.3.2/
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
useradd nagios
usermod -a -G nagios www-data
make install
make install-init
systemctl enable nagios.service
make install-commandmode
make install-config
make install-webconf
a2enmod rewrite
a2enmod cgi
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
systemctl restart apache2.service
systemctl start nagios.service
apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
chmod u+s /bin/ping
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz
cd /tmp/nagios-plugins-release-2.2.1/
./tools/setup
./configure
make
make install
systemctl restart nagios.service
When you do the htpasswd bit - you'll be required to enter the password for your Nagios administrator. You might want to write that down somewhere.
You'll also need an MTA if you want to receive emails from Nagios - I used postfix. I don't know this guy, but I did check out his blog post about installing postfix. That will save me from having to describe it here.
The commands for sending mail won't work out-of-the-box with postfix, but they won't work with sendmail either. I'm not sure what package provides /bin/mail, but I didn't spend much time looking for it. If dpkg doesn't know, I'm going to use something else.
So, visit this guys blog to see how he altered his commands.cfg file to use postfix. It works. Dang it, I forgot to copy the link for that blog post - so I won't be able to give credit to him.
# 'notify-host-by-email' command definitionNagios support has another way, and I'll try that one on an AWS server. It should be noted that the contacts.cfg file needs to be altered - putting your email address in there. Also - check out templates.cfg to make sure you're using the right host template - unless you want 24x7 notification.
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$\n\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTdOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/sbin/sendmail -vt $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\n\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/sbin/sendmail -vt $CONTACTEMAIL$
}
So - right now you should be able to log-in, and Nagios is monitoring itself. In part two, I'll talk about adding servers and monitoring them. I'll also cover a little bit about how Nagios works.
And - to start Nagios - `sudo /usr/local/bin/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg`
No comments:
Post a Comment