In this article, we will figure out how to introduce Nagios in openSUSE 15 .Nagios It is a free source application that screens framework, systems and foundation. It gives checking and alarming administrations to switches, applications, servers, and administrations.
To install pre-request packages
Server Information = Opensuse 15
linux-osradar:~ # uname -a Linux linux-osradar 4.12.14-lp150.12.28-default #1 SMP Mon Dec 3 16:46:15 UTC 2018 (b91289f) x86_64 x86_64 x86_64 GNU/Linux
First install the pre-request packages by utilizing the following command.
linux-osradar:~ # zypper install apache2 php7 gcc glibc gd wget perl make apache2-mod_php7 Retrieving repository 'openSUSE-Leap-15.0-Update' metadata ............................................................................................................................................[done] Building repository 'openSUSE-Leap-15.0-Update' cache .................................................................................................................................................[done] Loading repository data... Reading installed packages... Resolving package dependencies... The following 35 NEW packages are going to be installed: apache2 apache2-mod_php7 apache2-prefork apache2-utils gcc gcc7 gd git-web glibc-devel libapr-util1 libapr1 libasan4 libatomic1 libbrotlicommon1 libbrotlienc1 libcilkrts5 libgomp1 libitm1 liblsan0 libmpx2 libmpxwrappers2 libtsan0 libubsan0 linux-glibc-devel php7 php7-ctype php7-dom php7-iconv php7-json php7-pdo php7-sqlite php7-tokenizer php7-xmlreader php7-xmlwriter system-user-wwwrun The following 8 recommended packages were automatically selected: php7-ctype php7-dom php7-iconv php7-json php7-sqlite php7-tokenizer php7-xmlreader php7-xmlwriter The following 5 packages are suggested, but will not be installed: php7-gd php7-gettext php7-mbstring php7-mysql php7-pear
Enable php7
linux-osradar:/etc/apache2 # a2enmod php7
To check and restart the deleted files, you can use ‘ zypper ps’ to list these programs.
Then create user and group for nagios.
# useradd nagios # groupadd ngadmin nagios nagcmd
Once you have created the user, add those user into the nagios group.
# usermod -a -G ngadmin nagios # usermod -a -G ngadmin wwwrun
I- download and install Nagios Core
Download the nagios package by running the following command.
linux-osradar:~ # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.4.3.tar.gz --2019-01-16 07:56:02-- http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.4.3.tar.gz Resolving prdownloads.sourceforge.net (prdownloads.sourceforge.net)... 216.105.38.13 .. 2019-01-16 07:56:04 (11.0 MB/s) - ‘nagios-4.4.3.tar.gz’ saved [11302228/11302228]
Once the download is completed, extract the downloaded tar package.
linux-osradar:~ # tar -xvf nagios-4.4.3.tar.gz nagios-4.4.3/ nagios-4.4.3/.gitignore nagios-4.4.3/.travis.yml nagios-4.4.3/CONTRIBUTING.md nagios-4.4.3/Changelog nagios-4.4.3/INSTALLING nagios-4.4.3/LEGAL nagios-4.4.3/LICENSE nagios-4.4.3/Makefile.in nagios-4.4.3/README.md nagios-4.4.3/THANKS nagios-4.4.3/UPGRADING ..
Now compile to install the Nagios.
linux-osradar:~ # cd nagios-4.4.3/ linux-osradar:~/nagios-4.4.3 # ./configure --with-nagios-group=nagios --with-command-group=nagcmd ........ ....
Web Interface Options:
————————
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/sbin/traceroute
Review the options above for accuracy. If they look okay,
type ‘make all’ to compile the main program and CGIs.
Run the following command to install the Nagios package.
# make all .......
.. make test - This runs the test suite make install - This installs the main program, CGIs, and HTML files make install-init - This installs the init script in /usr/lib/systemd/system make install-daemoninit - This will initialize the init script in /usr/lib/systemd/system make install-groups-users - This adds the users and groups if they do not exist make install-commandmode - This installs and configures permissions on the directory for holding the external command file make install-config - This installs *SAMPLE* config files in /usr/local/nagios/etc You'll have to modify these sample files before you can use Nagios. Read the HTML documentation for more info on doing this. Pay particular attention to the docs on object configuration files, as they determine what/how things get monitored! make install-webconf - This installs the Apache config file for the Nagios web interface make install-exfoliation - This installs the Exfoliation theme for the Nagios web interface make install-classicui - This installs the classic theme for the Nagios web interface
# make install
*** Main program, CGIs and HTML files installed *** You can continue with installing Nagios as follows (type 'make' without any arguments for a list of all possible options): make install-init - This installs the init script in /usr/lib/systemd/system make install-commandmode - This installs and configures permissions on the directory for holding the external command file make install-config - This installs sample config files in /usr/local/nagios/etc
..
After installing Nagios, run the make install-init command to add nagios ervice to systemd.
linux-osradar:~/nagios-4.4.3 # make install-init /usr/bin/install -c -m 755 -d -o root -g root /usr/lib/systemd/system /usr/bin/install -c -m 755 -o root -g root startup/default-service /usr/lib/systemd/system/nagios.service
After installing Nagios, run the make install-config command.
linux-osradar:~/nagios-4.4.3 # make install-config /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg /usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg .
Then run the make install-commandmode command.
linux-osradar:~/nagios-4.4.3 # make install-commandmode /usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw chmod g+s /usr/local/nagios/var/rw *** External command directory configured ***
Finally use the below command for the webconf installation.
linux-osradar:~/nagios-4.4.3 # make install-webconf /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf if [ 0 -eq 1 ]; then \ ln -s /etc/apache2/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \ fi *** Nagios/Apache conf file installed ***
Verify the nagios access details as shown below.
# vi /usr/local/nagios/etc/objects/contacts.cfg
After verifying the Nagios access details, create password for nagios login and restart the apache services.
linux-osradar:~/nagios-4.4.3 # htpasswd2 -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin linux-osradar:~/nagios-4.4.3 #
Adding password for user nagiosadmin
~ # systemctl restart apache2
Invalid command ‘<IfVersion’, perhaps misspelled or defined by a module not included in the server configuration
to solve this. please add this command bellow to your apache or nagios web config
LoadModule version_module /usr/lib64/apache2/mod_version.so
check your apache Now
linux-osradar:~/nagios-4.4.3 # systemctl restart apache2 linux-osradar:~/nagios-4.4.3 # systemctl status apache2 ● apache2.service - The Apache Webserver Loaded: loaded (/usr/lib/systemd/system/apache2.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-01-16 08:31:53 EST; 14s ago Process: 12177 ExecStop=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful-stop (code=exited, status=0/SUCCESS) Main PID: 12185 (httpd-prefork) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" Tasks: 6 Memory: 4.2M CPU: 56ms CGroup: /system.slice/apache2.service ├─12185 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache> ├─12191 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache> Jan 16 08:31:53 linux-osradar systemd[1]: Stopped The Apache Webserver. Jan 16 08:31:53 linux-osradar systemd[1]: Starting The Apache Webserver... Jan 16 08:31:53 linux-osradar systemd[1]: Started The Apache Webserver.
II-Download and Install the Nagios plugin.
linuxhelp:/tmp # wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz --2016-09-16 19:42:48-- http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz Resolving nagios-plugins.org (nagios-plugins.org)... 72.14.186.43 Connecting to nagios-plugins.org (nagios-plugins.org)|72.14.186.43|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2659772 (2.5M) [application/x-gzip] Saving to: ‘ nagios-plugins-2.0.3.tar.gz’ nagios-plugins-2.0.3.tar.gz 100%[=================================================> ] 2.54M 581KB/s in 5.1s 2016-09-16 19:42:53 (512 KB/s) - ‘ nagios-plugins-2.0.3.tar.gz’ saved [2659772/2659772]
Run the following command to extract the nagios plugin.
linux-osradar:~ # wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz --2019-01-16 08:34:23-- https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz Resolving nagios-plugins.org (nagios-plugins.org)... 72.14.186.43 Connecting to nagios-plugins.org (nagios-plugins.org)|72.14.186.43|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 2728818 (2.6M) [application/x-gzip] Saving to: ‘nagios-plugins-2.2.1.tar.gz’ nagios-plugins-2.2.1.tar.gz 12%[================>
After extraction, compile and install the nagios plugin.
linux-osradar:~ # tar -xvf nagios-plugins-2.2.1.tar.gz linux-osradar:~ # cd nagios-plugins-2.2.1/ linux-osradar:~/nagios-plugins-2.2.1 # ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin --enable-libtap: no
Use the following command to start installing the Nagios plugin.
' linux-osradar:~/nagios-plugins-2.2.1 # make checking for symlink... yes checking for mbsinit... yes checking for mbrtowc... yes checking for mprotect... yes checking for _set_invalid_parameter_handler... no checking for nl_langinfo... yes checking for isblank... yes .
After the plugins are installed, check the nagios configuration file.
linux-osradar:~/nagios-plugins-2.2.1 # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.4.3 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2019-01-15 License: GPL Website: https://www.nagios.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 8 services. Checked 1 hosts. Checked 1 host groups. Checked 0 service groups. Checked 1 contacts. Checked 1 contact groups. Checked 24 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 1 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings...Total Warnings: 0 Total Errors: 0
Things look okay – No serious problems were detected during the pre-flight check
Lets Start the nagios service
linux-osradar:~/nagios-plugins-2.2.1 # systemctl restart nagios linux-osradar:~/nagios-plugins-2.2.1 # systemctl status nagios ● nagios.service - Nagios Core 4.4.3 Loaded: loaded (/usr/lib/systemd/system/nagios.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-01-16 08:42:51 EST; 4s ago Docs: https://www.nagios.org/documentation Process: 32229 ExecStopPost=/usr/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd (code=exited, status=0/SUCCESS) Process: 32228 ExecStop=/usr/bin/kill -s TERM ${MAINPID} (code=exited, status=0/SUCCESS) Process: 32231 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS) Process: 32230 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS) Main PID: 32232 (nagios) Tasks: 6 (limit: 4915) Memory: 2.3M CPU: 17ms
You can also use the following command to start the nagios and apache on boot itself.
linux-osradar:~/nagios-plugins-2.2.1 # systemctl enable nagios Created symlink /etc/systemd/system/multi-user.target.wants/nagios.service → /usr/lib/systemd/system/nagios.service. linux-osradar:~/nagios-plugins-2.2.1 # systemctl enable apache2 Created symlink /etc/systemd/system/httpd.service → /usr/lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/apache.service → /usr/lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /usr/lib/systemd/system/apache2.service. linux-osradar:~/nagios-plugins-2.2.1 #
Trigger the browser with the following URL http://< IP_address> /nagios and enter the user credentials to login into the Nagios. please login with nagiosadmin user
if you have issues to detect the plugins directory, please copy them all to /usr/local/nagios/lib/
This Tutorial is tested under my Opensuse 15 VM , and its working 100%
Now you can start checking the status of your server.
if you have issues with PHP please consult install lamp on opensuse15
How to Install Apache, MariaDB, PHP7 (LAMP) on openSUSE Leap 15
#./configure –with-nagios-user=nagios –with-nagios-group=nagios
configure: error: cannot guess build type; you must specify one