-
Source: pimylifeup
-
install several packages
sudo apt install -y autoconf build-essential wget unzip apache2 apache2-utils php libgd-dev snmp libnet-snmp-perl gettext libssl-dev wget bc gawk dc libmcrypt-dev
-
get Nagios
mkdir temp
cd temp
download Nagios
wget -O nagios.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
extract
tar xzf nagios.tar.gz
-
change to nagioscore-nagios-4.4.6
cd nagioscore-nagios-4.4.6
configure
./configure --with-httpd-conf=/etc/apache2/sites-enabled
and make all
make all
-
user and group
sudo make install-groups-users
sudo usermod -a -G nagios www-data
and install
sudo make install and start on boot
sudo make install-daemoninit
install commandmode
sudo make install-commandmode
create config files
sudo make install-config
-
sudo make install-config
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi
create nagiosadmin user
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
systemctl restart apache2
-
start Nagios
sudo systemctl enable nagios
sudo systemctl start nagios
check status with
sudo systemctl status nagios
-
Nagios plugins
wget -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.3.3/nagios-plugins-2.3.3.tar.gz
extract and configure
tar zxf nagios-plugins.tar.gz
cd nagios-plugins-2.3.3
./configure
make and install
make
sudo make install
restart
sudo systemctl restart nagios
-
To access the Nagios web interface, you will need to know the Raspberry Pi’s IP address.
http://[IPADDRESS]/nagios
enter user nagiosadmin and password
-
Adding devices
cd /usr/local/nagios/etc/objects
sudo nano pimylifeuphost.cfg
add
define host {
use linux-server ; Host group to use
host_name Pi My Life Up Host ; Name of this host
alias pimylifeuphost ; Alias
address [YOURHOSTIPADDRESS] ; IP Address
}
modyfy Nagios configuration
sudo nano /usr/local/nagios/etc/nagios.cfg
find
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
add below
cfg_file=/usr/local/nagios/etc/objects/pimylifeuphost.cfg
and restart
sudo systemctl restart nagios
-
adding SSH and HTTP services
sudo nano /usr/local/nagios/etc/objects/pimylifeuphost.cfg
define service {
use local-service
host_name Pi My Life Up Host
service_description SSH
check_command check_ssh
}
define service {
use local-service
host_name Pi My Life Up Host
service_description HTTP
check_command check_http
}
check file with and restart if no errors
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo systemctl restart nagios
-
Monitoring Remote Host-Resources with Nagios