Posted by: sutrisno | September 4, 2014

Nagios 4.0.6 on ubuntu 12.04

Nagios 4 on ubuntu 12.04

nagios

Di tempat baru di suruh membuat monitoring nagios 4.0.6 di ubuntu 4 dengan refensi sebagai berikut
https://raymii.org/s/tutorials/Nagios_Core_4_Installation_on_Ubuntu_12.04.html
Langkahnya install paket
#sudo apt-get install apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev sendmail-bin sendmail heirloom-mailx wget apache2-utils curl daemon apt-file libnet-snmp-perl libperl5.14 libpq5 libradius1 libsensors4 libsnmp-base libtalloc2 libtdb1 libwbclient0 samba-common samba-common-bin smbclient snmp whois mrtg libmysqlclient15-dev libcgi-pm-perl librrds-perl libgd-gd2-perl
#groupadd -g 3000 nagios
#groupadd -g 3001 nagcmd
#useradd -u 3000 -g nagios -G nagcmd -d /usr/local/nagios -c ‘Nagios Admin’ nagios
#adduser www-data nagcmd

#mkdir -p /usr/local/src/nagios4
#cd /usr/local/src/nagios4
#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gztar xf nagios-4.0.8.tar.gz
#cd nagios-4.0.8
#mkdir -p /usr/local/nagios/share/{stylesheets,images}
#./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios –with-command-user=nagios –with-command-group=nagcmd
—–
*** Configuration summary for nagios 4.0.8 08-12-2014 ***:

General Options:
————————-
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/conf.d
Mail program: /usr/bin/mail
Host OS: linux-gnu
IOBroker Method: epoll

Web Interface Options:
————————
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
——–
#make all
#make install
#make install-init
#make install-config
#make install-commandmode
#make install-webconf
#cp -rvf contrib/eventhandlers/ /usr/local/nagios/libexec/
#chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin nagio**mo
#a2enmod rewrite
#/etc/init.d/apache2 restart
#mkdir -p /usr/local/src/nagios-plugins
#cd /usr/local/src/nagios-plugins/
#wget https://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Then the use checkinstall, for all the parts:

#mkdir -p /usr/local/src/nagios-plugins
#cd /usr/local/src/nagios-plugins
#wget https://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
#tar -xf nagios-plugins-2.0.3.tar.gz
#cd nagios-plugins-2.0.3
#./configure –with-nagios-user=nagios –with-nagios-group=nagios –with-openssl=/usr/bin/openssl –enable-perl-modules –enable-libtap
#make

#mkdir -p /usr/local/src/nrpe
#cd /usr/local/src/nrpe
#wget http://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
#tar -xf nrpe-2.15.tar.gz
#cd nrpe-2.15
#./configure –with-ssl=/usr/bin/openssl –with-ssl-lib=/usr/lib/x86_64-linux-gnu
#make all
#checkinstall
#The fixes in that topic and on the Nagios forum did not work for me, so I wrote a very simple upstart script.
#Place it in /etc/init/nagios.conf:
————-
# nagios – monitoriong system
# by https://raymii.org

description “nagios monitoring system”

start on virtual-filesystems
stop on runlevel [06]

respawn
respawn limit 5 30
limit nofile 65550 65550

chdir /usr/local/nagios/
setuid nagios
setgid nagios
console log

script
exec bin/nagios etc/nagios.cfg
end script
———————–

#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#chown nagios:nagcmd /usr/local/nagios/etc/htpasswd.users
#mkdir /etc/apache2/ssl
#cd /etc/apache2/ssl
#a2enmod ssl
#openssl req -x509 -nodes -days 365 -newkey rsa:4096 -out nagios.pem -keyout nagios.key
#mkdir -p /var/www/nagios4/
#chown www-data:www-data /var/www/nagios4
#ln -s /usr/local/src/nagios4/nagios-4.0.8/contrib/exfoliation/images/favicon.ico /var/www/favicon.ico
Set up a vhost for Nagios. The below file can be used on Ubuntu 12.04. Place it in /etc/apache2/sites-available/nagios.conf:
———————-

ServerAdmin webmaster@example.org
ServerName nagios.example.org
DocumentRoot /var/www/nagios

Options FollowSymLinks
AllowOverride None

Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/nagios.pem
SSLCertificateKeyFile /etc/apache2/ssl/nagios.key

————————-
#a2enmod cgi
#a2dissite default
#a2ensite nagios # or nagios.conf
#/etc/init.d/apache2 restart
#ln -s /usr/local/nagios/etc/ /etc/nagios4
#mkdir /etc/nagios4/conf.d
Then add this to /etc/nagios4/nagios.cfg
cfg_dir=/etc/nagios4/conf.d/

#mkdir -p /etc/nagios4/conf.d/{hosts,services,timeperiods,templates,hostgroups,servicegroups,contacts}
#service nagios restart
#mkdir -p /usr/local/src/nagiosgraph/
#cd /usr/local/src/nagiosgraph/
#wget http://downloads.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.1/nagiosgraph-1.5.1.tar.gz
#cd nagiosgraph-1.5.1
#./install.pl –check-prereq
#./install.pl –layout standalone –prefix /usr/local/nagiosgraph
Modify the Nagios configuration? [n] y
Path of Nagios commands file? /usr/local/nagios/etc/objects/commands.cfg
Modify the Apache configuration? [n] y
#service nagios restart
#service apache2 restart
For example, the Load of the system:
————————
define service {
use local-service
host_name localhost
service_description Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&geom=1000×200′ onMouseOver=’showGraphPopup(this)’ onMouseOut=’hideGraphPopup()’ rel=’/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
}
————————
For the ping check you can show both RTA and packet loss:
———————–
define service {
use local-service
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=pl,data&db=pl,warn&db=pl,crit&geom=1000×200′ onMouseOver=’showGraphPopup(this)’ onMouseOut=’hideGraphPopup()’ rel=’/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=pl,data&db=pl,warn&db=pl,crit
notes_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=rta,data&db=rta,warn&db=rta,crit&geom=1000×200′ onMouseOver=’showGraphPopup(this)’ onMouseOut=’hideGraphPopup()’ rel=’/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=rta,data&db=rta,warn&db=rta,crit
}
———————–
#vim /usr/local/nagios/share/ssi/common-header.ssi

————-
service nagios restart

MRTG
#cp /usr/local/src/nagios4/nagios-4.0.8/sample-config/mrtg.cfg /usr/local/nagios/etc/
#mkdir -p /usr/local/nagios/share/stats
Configure MRTG to use this folder:

vim /usr/local/nagios/etc/mrtg.cfg
Add the following at the top of the file:
————————-
WorkDir: /usr/local/nagios/share/stats
#env LANG=C /usr/bin/mrtg /usr/local/nagios/etc/mrtg.cfg
Create the HTML pages:

#/usr/bin/indexmaker /usr/local/nagios/etc/mrtg.cfg –output=/usr/local/nagios/share/stats/index.html
Finally create a cron job to run MRTG every 5 minutes:

#vim /etc/cron.d/mrtg-nagios
Add the following:

*/5 * * * * root env LANG=C /usr/bin/mrtg /usr/local/nagios/etc/mrtg.cfg
#vim /usr/local/nagios/share/side.php
And add the following somewhere in the menu:
———————–

———————–


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: