Nagios server

Setup Nagios Core server (free license).

 

apt-get install build-essential wget libgd-dev unzip


groupadd -g 5666 nagios
useradd -u 5666 -g nagios -c "Nagios user for monitoring" -d /usr/local/nagios nagios
groupadd -g 5667 nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd www-data

# Next is for the Ramdrive. Original location read-only..
#usermod -d /usr/local/nagios/var nagios

tar zxvf nagios-4.#.#.tar.gz
tar zxvf nagios-plugins-2.#.#.tar.gz

cd nagios-4.#.#

./configure --with-command-group=nagcmd --with-mail=/usr/sbin/sendmail --with-httpd-conf=/etc/apache2/conf-available


make all


make install
make install-init
make install-daemoninit
(/lib/systemd/system/nagios.service)
make install-commandmode
make install-config
make install-webconf

a2enconf nagios
systemctl reload apache2


cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


mkdir /usr/local/nagios/etc/objects/ak72
chown nagios:nagios /usr/local/nagios/etc/objects/ak72
mkdir /usr/local/nagios/var/tmp
chown nagios:nagios /usr/local/nagios/var/tmp
mkdir /usr/local/nagios/archives
chown nagios:nagios /usr/local/nagios/archives
cp -p /usr/local/nagios/libexec/check_http /usr/local/nagios/libexec/check_https

 

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin (<your password>)
chmod 640 /usr/local/nagios/etc/htpasswd.users


cd ../nagios-plugins-2.#.#
./configure --with-nagios-user=nagios --with-nagios-group=nagios

make
make install

cp -p /usr/local/nagios/libexec/check_http /usr/local/nagios/libexec/check_https

systemctl enable nagios

a2enconf nagios
a2enmod rewrite cgi

service apache2 restart

systemctl start nagios

vi /lib/systemd/system/nagios.service
[Unit]
Description=Nagios Core 4.4.5
Documentation=https://www.nagios.org/documentation
After=network.target local-fs.target
[Service]
Type=forking
ExecStartPre=/root/nagios_start_stop_server.ksh start
ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
ExecStartPost=/usr/local/nagios/libexec/ak72/set_passive_servicechecks_ok_at_start
ExecStop=/bin/kill -s TERM ${MAINPID}
ExecStopPost=/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd
ExecStopPost=/root/nagios_start_stop_server.ksh stop
ExecReload=/bin/kill -s HUP ${MAINPID}
[Install]
WantedBy=multi-user.target

 

 

systemctl daemon-reload
systemctl enable nagios

  If you appreciate my website feel free to donate via the Paypal button...Small amount for a coffee is enough;-) Thanks!