{"id":10204,"date":"2021-08-27T21:38:03","date_gmt":"2021-08-27T18:38:03","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10204"},"modified":"2024-03-18T18:37:32","modified_gmt":"2024-03-18T15:37:32","slug":"install-nagios-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-nagios-on-debian-11\/","title":{"rendered":"Install Nagios on Debian 11"},"content":{"rendered":"\n
In this guide, we are going to learn how to install Nagios on Debian 11. Nagios<\/a> is an opensource tool that provides an enterprise-class central monitoring engine for IT monitoring, network monitoring, server and applications monitoring.<\/p>\n\n\n\n Some of the Nagios’ features include:.<\/p>\n\n\n\n You can install Nagios either from the source code or directly from the default Debian main repositories.<\/p>\n\n\n\n The good thing here is that, the default Debian 11 repositories provides Nagios core packages.<\/p>\n\n\n\n You can verify this by running the command below;<\/p>\n\n\n\n As of this writing, the default repos provides the current stable release version of Nagios Core, which is version 4.4.6. You can check on the releases page<\/a>.<\/p>\n\n\n\n You can then simply execute the command below to install Nagios.<\/p>\n\n\n\n The installation command creates dedicated Nagios user and group;<\/p>\n\n\n\n The install command creates Nagios service configuration files;<\/p>\n\n\n\n Enable the service to run on system boot.<\/p>\n\n\n\n The Nagios configuration files are installed under, Apache configuration files for Nagios web interface, is also setup on the The sample configuration file without comment lines<\/strong> is shown below;<\/p>\n\n\n\n You can adjust the configuration file as you so wish.<\/p>\n\n\n\n For example, run the commands below to update the default configuration file.<\/p>\n\n\n\n You need to enable Apache rewrite and CGI modules.<\/p>\n\n\n\n If you can check the configuration above, Nagios by default uses MD5 digest authentication. As such you need to enable the required module. Run the command below to check if the modules are already enabled;<\/p>\n\n\n\n If not enabled, run the command below to enable;<\/p>\n\n\n\n To setup Nagios Web authentication, you need to create an Apache user for authentication.<\/p>\n\n\n\n Since it is using MD5 digest, then this can be done using the htfigest<\/strong> command.<\/p>\n\n\n\n The syntax for the command is;<\/p>\n\n\n\n The auth passwdfile is defined in the configuration above as Add the users and passwords into this file.<\/p>\n\n\n\n The user, nagiosadmin<\/strong>, is used by default and is defined in the \/etc\/nagios4\/cgi.cfg<\/strong> config file.<\/p>\n\n\n\n If you need to use a different user, you need to replace all the occurrences of nagiosadmin<\/strong> on the \/etc\/nagios4\/cgi.cfg<\/strong> file with the user you created.<\/p>\n\n\n\n For example, if you use like admin<\/strong>, replace nagiosadmin<\/strong> as shown below.<\/p>\n\n\n\n If you also want to use a different authentication user file instead of, And of course, you can then generate the password for that user.<\/p>\n\n\n\n Once you are done with configuration, restart Apache.<\/p>\n\n\n\n To check the status;<\/p>\n\n\n\n If any firewall is running on your system, be sure to enable Apache through it.<\/p>\n\n\n\n Restart Nagios service by running the command below;<\/p>\n\n\n\n To check the status<\/p>\n\n\n\n If you need to go through the Nagios logs, the log file is;<\/p>\n\n\n\n Once you are done with the configuration, navigate to the browser and access your Nagios with the address http:\/\/<server-IP>\/nagios4<\/strong>.<\/p>\n\n\n\n You will be prompted to enter username and password created above to login.<\/p>\n\n\n\n Nagios uses various plugins located under Host Status<\/p>\n\n\n\n Host Services Status<\/p>\n\n\n\n There you go. You have successfully install and configured Nagios on Debian 11.<\/p>\n\n\n\n If you need to monitor you Linux\/Windows Hosts or any other device, see out links below;<\/p>\n\n\n\n Monitor Linux Hosts using Nagios check_by_ssh Plugin<\/a><\/p>\n\n\n\n How to Install Nagios Plugins and NRPE agents on CentOS 7\/RHEL 7\/Fedora 29<\/a><\/p>\n\n\n\n How to Install Nagios Plugins From Source RHEL\/CentOS\/Oracle Linux<\/a><\/p>\n\n\n\n\n
Installing Nagios on Debian 11<\/h2>\n\n\n\n
<\/meta>Install Nagios from APT Repositories<\/h3>\n\n\n\n
apt-cache policy nagios4<\/code><\/pre>\n\n\n\n
nagios4:\n Installed: (none)\n Candidate: 4.4.6-4\n Version table:\n 4.4.6-4 500\n 500 http:\/\/deb.debian.org\/debian bullseye\/main amd64 Packages<\/code><\/pre>\n\n\n\n
Install Nagios<\/h3>\n\n\n\n
apt install nagios4<\/code><\/pre>\n\n\n\n
Reading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nThe following additional packages will be installed:\n apache2 apache2-bin apache2-data apache2-utils javascript-common libapache2-mod-php libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap\n libarchive13 libcurl4 libdbi1 libgd3 libgpgme11 libjs-jquery libldb2 liblua5.3-0 libmariadb3 libnet-snmp-perl libpq5 libpython3.9 libradcli4 libsensors-config\n libsensors5 libsmbclient libsnmp-base libsnmp40 libsodium23 libtalloc2 libtdb1 libtevent0 liburiparser1 libwbclient0 libxpm4 mariadb-common monitoring-plugins\n monitoring-plugins-basic monitoring-plugins-common monitoring-plugins-standard mysql-common nagios-images nagios4-cgi nagios4-common nagios4-core php-common php7.4-cli\n php7.4-common php7.4-json php7.4-opcache php7.4-readline python3-gpg python3-ldb python3-samba python3-talloc python3-tdb rpcbind samba-common samba-common-bin\n samba-dsdb-modules samba-libs smbclient snmp ssl-cert sudo\nSuggested packages:\n apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear lrzip libgd-tools libcrypt-des-perl libdigest-hmac-perl libio-socket-inet6-perl\n lm-sensors snmp-mibs-downloader icinga2 nagios-plugins-contrib fping qstat nagios-nrpe-plugin heimdal-clients python3-markdown python3-dnspython cifs-utils\nThe following NEW packages will be installed:\n apache2 apache2-bin apache2-data apache2-utils javascript-common libapache2-mod-php libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap\n libarchive13 libcurl4 libdbi1 libgd3 libgpgme11 libjs-jquery libldb2 liblua5.3-0 libmariadb3 libnet-snmp-perl libpq5 libpython3.9 libradcli4 libsensors-config\n libsensors5 libsmbclient libsnmp-base libsnmp40 libsodium23 libtalloc2 libtdb1 libtevent0 liburiparser1 libwbclient0 libxpm4 mariadb-common monitoring-plugins\n monitoring-plugins-basic monitoring-plugins-common monitoring-plugins-standard mysql-common nagios-images nagios4 nagios4-cgi nagios4-common nagios4-core php-common\n php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline python3-gpg python3-ldb python3-samba python3-talloc python3-tdb rpcbind samba-common\n samba-common-bin samba-dsdb-modules samba-libs smbclient snmp ssl-cert sudo\n0 upgraded, 67 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 33.7 MB of archives.\nAfter this operation, 131 MB of additional disk space will be used.\nDo you want to continue? [Y\/n] y\n<\/code><\/pre>\n\n\n\n
Nagios User and Group<\/h3>\n\n\n\n
getent passwd nagios<\/code><\/pre>\n\n\n\n
nagios:x:109:115::\/var\/lib\/nagios:\/usr\/sbin\/nologin<\/code><\/pre>\n\n\n\n
getent group nagios<\/code><\/pre>\n\n\n\n
nagios:x:115:<\/code><\/pre>\n\n\n\n
Nagios Service<\/h3>\n\n\n\n
systemctl status nagios4<\/code><\/pre>\n\n\n\n
\u25cf nagios4.service - nagios4\n Loaded: loaded (\/lib\/systemd\/system\/nagios4.service; disabled; vendor preset: enabled)\n Active: active (running) since Fri 2021-08-27 07:47:28 EAT; 8min ago\n Docs: man:nagios4\n Main PID: 17993 (nagios4)\n Tasks: 6 (limit: 2341)\n Memory: 20.2M\n CPU: 296ms\n CGroup: \/system.slice\/nagios4.service\n \u251c\u250017993 \/usr\/sbin\/nagios4 \/etc\/nagios4\/nagios.cfg\n \u251c\u250017994 \/usr\/sbin\/nagios4 --worker \/var\/lib\/nagios4\/rw\/nagios.qh\n \u251c\u250017995 \/usr\/sbin\/nagios4 --worker \/var\/lib\/nagios4\/rw\/nagios.qh\n \u251c\u250017996 \/usr\/sbin\/nagios4 --worker \/var\/lib\/nagios4\/rw\/nagios.qh\n \u251c\u250017997 \/usr\/sbin\/nagios4 --worker \/var\/lib\/nagios4\/rw\/nagios.qh\n \u2514\u250017998 \/usr\/sbin\/nagios4 \/etc\/nagios4\/nagios.cfg\n\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17994;pid=17994\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17994;pid=17994\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17997;pid=17997\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17997;pid=17997\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17996;pid=17996\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17996;pid=17996\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17995;pid=17995\nAug 27 07:47:28 debian11 nagios4[17993]: wproc: Registry request: name=Core Worker 17995;pid=17995\nAug 27 07:47:29 debian11 nagios4[17993]: Successfully launched command file worker with pid 17998\nAug 27 07:47:29 debian11 nagios4[17993]: Successfully launched command file worker with pid 17998\n<\/code><\/pre>\n\n\n\n
systemctl enable nagios4<\/code><\/pre>\n\n\n\n
Nagios Configuration Files<\/h3>\n\n\n\n
\/etc\/nagios4\/<\/code>.<\/p>\n\n\n\n
ls -1d \/etc\/nagios4\/*<\/code><\/pre>\n\n\n\n
\/etc\/nagios4\/apache2.conf\n\/etc\/nagios4\/cgi.cfg\n\/etc\/nagios4\/conf.d\n\/etc\/nagios4\/htdigest.users\n\/etc\/nagios4\/nagios.cfg\n\/etc\/nagios4\/objects\n\/etc\/nagios4\/resource.cfg\n\/etc\/nagios4\/stylesheets<\/code><\/pre>\n\n\n\n
Nagios Apache Config files<\/h3>\n\n\n\n
\/etc\/apache2\/conf-available\/nagios4-cgi.conf<\/strong><\/code> configuration file.<\/p>\n\n\n\n
ScriptAlias \/cgi-bin\/nagios4 \/usr\/lib\/cgi-bin\/nagios4\nScriptAlias \/nagios4\/cgi-bin \/usr\/lib\/cgi-bin\/nagios4\n\nAlias \/nagios4\/stylesheets \/etc\/nagios4\/stylesheets\n\nAlias \/nagios4 \/usr\/share\/nagios4\/htdocs\n\n<DirectoryMatch (\/usr\/share\/nagios4\/htdocs|\/usr\/lib\/cgi-bin\/nagios4|\/etc\/nagios4\/stylesheets)>\n Options FollowSymLinks\n DirectoryIndex index.php index.html\n AllowOverride AuthConfig\n Require ip\t::1\/128 fc00::\/7 fe80::\/10 10.0.0.0\/8 127.0.0.0\/8 169.254.0.0\/16 172.16.0.0\/12 192.168.0.0\/16\n <Files \"cmd.cgi\">\n\tAuthDigestDomain \"Nagios4\"\n\tAuthDigestProvider file\n\tAuthUserFile\t\"\/etc\/nagios4\/htdigest.users\"\n\tAuthGroupFile\t\"\/etc\/group\"\n\tAuthName\t\"Nagios4\"\n\tAuthType\tDigest\n\tRequire all\tgranted\n <\/Files>\n<\/DirectoryMatch>\n\n<Directory \/usr\/share\/nagios4\/htdocs>\n Options\t+ExecCGI\t\n<\/Directory>\n<\/code><\/pre>\n\n\n\n
Update Default Configuration<\/h3>\n\n\n\n
cp \/etc\/apache2\/conf-enabled\/nagios4-cgi.conf{,.original}<\/code><\/pre>\n\n\n\n
\ncat > \/etc\/apache2\/conf-enabled\/nagios4-cgi.conf << EOL\nScriptAlias \/cgi-bin\/nagios4 \/usr\/lib\/cgi-bin\/nagios4\nScriptAlias \/nagios4\/cgi-bin \/usr\/lib\/cgi-bin\/nagios4\n\nAlias \/nagios4\/stylesheets \/etc\/nagios4\/stylesheets\n\nAlias \/nagios4 \/usr\/share\/nagios4\/htdocs\n\n<DirectoryMatch (\/usr\/share\/nagios4\/htdocs|\/usr\/lib\/cgi-bin\/nagios4|\/etc\/nagios4\/stylesheets)>\n Options FollowSymLinks\n DirectoryIndex index.php index.html\n AllowOverride AuthConfig\n\tAuthDigestDomain \"nagios4\"\n\tAuthDigestProvider file\n\tAuthUserFile\t\"\/etc\/nagios4\/htdigest.users\"\n\tAuthGroupFile\t\"\/etc\/group\"\n\tAuthName\t\"Restricted Nagios4 Access\"\n\tAuthType\tDigest\n\tRequire\tvalid-user\n<\/DirectoryMatch>\n\n<Directory \/usr\/share\/nagios4\/htdocs>\n Options\t+ExecCGI\t\n<\/Directory>\nEOL\n<\/code><\/pre>\n\n\n\n
Enable Apache rewrite and CGI modules<\/h3>\n\n\n\n
a2enmod rewrite cgi<\/code><\/pre>\n\n\n\n
Setup Nagios Apache Authentication<\/h3>\n\n\n\n
Enable Required Modules<\/h4>\n\n\n\n
apachectl -M | grep -iE 'digest|group'<\/code><\/pre>\n\n\n\n
auth_digest_module (shared)\n authz_groupfile_module (shared)<\/code><\/pre>\n\n\n\n
a2enmod auth_digest authz_groupfile<\/code><\/pre>\n\n\n\n
Create Nagios Authentication Users<\/h3>\n\n\n\n
htdigest [ -c ] passwdfile realm username<\/code><\/pre>\n\n\n\n
\/etc\/nagios4\/htdigest.users<\/code>.<\/p>\n\n\n\n
htdigest -c \/etc\/nagios4\/htdigest.users \"Restricted Nagios4 Access\" nagiosadmin<\/code><\/pre>\n\n\n\n
sed -i 's\/nagiosadmin\/admin\/g' \/etc\/nagios4\/cgi.cfg<\/code><\/pre>\n\n\n\n
\/etc\/nagios4\/htdigest.users<\/code><\/strong>, ensure you edit the Nagios Apache configuration file,
\/etc\/apache2\/conf-available\/nagios4-cgi.conf<\/strong><\/code> <\/strong>and change the value of AuthUserFile<\/strong>.<\/p>\n\n\n\n
Start Apache Web server<\/h3>\n\n\n\n
systemctl restart apache2<\/code><\/pre>\n\n\n\n
systemctl status apache2<\/code><\/pre>\n\n\n\n
ufw allow 80\/tcp<\/code><\/pre>\n\n\n\n
Restart Nagios service<\/h3>\n\n\n\n
systemctl restart nagios4<\/code><\/pre>\n\n\n\n
systemctl status nagios4<\/code><\/pre>\n\n\n\n
\/var\/log\/nagios4\/nagios.log<\/code><\/pre>\n\n\n\n
Accessing Nagios Web UI on Debian 11<\/h2>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
\/usr\/lib\/nagios\/plugins\/<\/strong><\/code> to monitor various services.<\/p>\n\n\n\n
ls -1 \/usr\/lib\/nagios\/plugins\/*<\/code><\/pre>\n\n\n\n
\n\/usr\/lib\/nagios\/plugins\/check_apt\n\/usr\/lib\/nagios\/plugins\/check_breeze\n\/usr\/lib\/nagios\/plugins\/check_by_ssh\n\/usr\/lib\/nagios\/plugins\/check_clamd\n\/usr\/lib\/nagios\/plugins\/check_cluster\n\/usr\/lib\/nagios\/plugins\/check_curl\n\/usr\/lib\/nagios\/plugins\/check_dbi\n\/usr\/lib\/nagios\/plugins\/check_dhcp\n\/usr\/lib\/nagios\/plugins\/check_dig\n\/usr\/lib\/nagios\/plugins\/check_disk\n\/usr\/lib\/nagios\/plugins\/check_disk_smb\n\/usr\/lib\/nagios\/plugins\/check_dns\n\/usr\/lib\/nagios\/plugins\/check_dummy\n\/usr\/lib\/nagios\/plugins\/check_file_age\n\/usr\/lib\/nagios\/plugins\/check_flexlm\n\/usr\/lib\/nagios\/plugins\/check_fping\n\/usr\/lib\/nagios\/plugins\/check_ftp\n\/usr\/lib\/nagios\/plugins\/check_game\n\/usr\/lib\/nagios\/plugins\/check_host\n\/usr\/lib\/nagios\/plugins\/check_hpjd\n\/usr\/lib\/nagios\/plugins\/check_http\n\/usr\/lib\/nagios\/plugins\/check_icmp\n\/usr\/lib\/nagios\/plugins\/check_ide_smart\n\/usr\/lib\/nagios\/plugins\/check_ifoperstatus\n\/usr\/lib\/nagios\/plugins\/check_ifstatus\n\/usr\/lib\/nagios\/plugins\/check_imap\n\/usr\/lib\/nagios\/plugins\/check_ircd\n\/usr\/lib\/nagios\/plugins\/check_jabber\n\/usr\/lib\/nagios\/plugins\/check_ldap\n\/usr\/lib\/nagios\/plugins\/check_ldaps\n\/usr\/lib\/nagios\/plugins\/check_load\n\/usr\/lib\/nagios\/plugins\/check_log\n\/usr\/lib\/nagios\/plugins\/check_mailq\n\/usr\/lib\/nagios\/plugins\/check_mrtg\n\/usr\/lib\/nagios\/plugins\/check_mrtgtraf\n\/usr\/lib\/nagios\/plugins\/check_mysql\n\/usr\/lib\/nagios\/plugins\/check_mysql_query\n\/usr\/lib\/nagios\/plugins\/check_nagios\n\/usr\/lib\/nagios\/plugins\/check_nntp\n\/usr\/lib\/nagios\/plugins\/check_nntps\n\/usr\/lib\/nagios\/plugins\/check_nt\n\/usr\/lib\/nagios\/plugins\/check_ntp\n\/usr\/lib\/nagios\/plugins\/check_ntp_peer\n\/usr\/lib\/nagios\/plugins\/check_ntp_time\n\/usr\/lib\/nagios\/plugins\/check_nwstat\n\/usr\/lib\/nagios\/plugins\/check_oracle\n\/usr\/lib\/nagios\/plugins\/check_overcr\n\/usr\/lib\/nagios\/plugins\/check_pgsql\n\/usr\/lib\/nagios\/plugins\/check_ping\n\/usr\/lib\/nagios\/plugins\/check_pop\n\/usr\/lib\/nagios\/plugins\/check_procs\n\/usr\/lib\/nagios\/plugins\/check_radius\n\/usr\/lib\/nagios\/plugins\/check_real\n\/usr\/lib\/nagios\/plugins\/check_rpc\n\/usr\/lib\/nagios\/plugins\/check_rta_multi\n\/usr\/lib\/nagios\/plugins\/check_sensors\n\/usr\/lib\/nagios\/plugins\/check_simap\n\/usr\/lib\/nagios\/plugins\/check_smtp\n\/usr\/lib\/nagios\/plugins\/check_snmp\n\/usr\/lib\/nagios\/plugins\/check_spop\n\/usr\/lib\/nagios\/plugins\/check_ssh\n\/usr\/lib\/nagios\/plugins\/check_ssmtp\n\/usr\/lib\/nagios\/plugins\/check_swap\n\/usr\/lib\/nagios\/plugins\/check_tcp\n\/usr\/lib\/nagios\/plugins\/check_time\n\/usr\/lib\/nagios\/plugins\/check_udp\n\/usr\/lib\/nagios\/plugins\/check_ups\n\/usr\/lib\/nagios\/plugins\/check_users\n\/usr\/lib\/nagios\/plugins\/check_wave\n\/usr\/lib\/nagios\/plugins\/negate\n\/usr\/lib\/nagios\/plugins\/urlize\n\/usr\/lib\/nagios\/plugins\/utils.pm\n\/usr\/lib\/nagios\/plugins\/utils.sh\n<\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n