This is going to explain how to add Nagios plugins to your existing LibreNMS setup. We are going to use the check_http plugin to monitor a website and SSL certificate. The server we are setting this up on is running the following:
Server Version: 16.04.2 LTS (Xenial Xerus)
Apache Version: Apache/2.4.18 (Ubuntu)
MariaDB Version: 15.1 Distrib 10.0.29-MariaDB
PHP Version: 7.0.18
Install Nagios plugins:
root@stupiderror:~# apt install nagios-plugins
Edit config.php and add the following lines to integrate the Nagios plugins with LibreNMS:
root@stupiderror:~# vi /opt/librenms/config.php $config['show_services'] = 1; $config['nagios_plugins'] = '/usr/lib/nagios/plugins';
Now in LibreNMS you should see Services on the Navigation bar between Devices and Ports. Under Services if you choose Add Service you should have a list of all of the plugins under the Type drop down menu.
Edit the LibreNMS cron job and make sure it is running check-services.php every 5 minutes. This was already present for me, if it is missing add it.
root@stupiderror:~# vi /etc/cron.d/librenms */5 * * * * librenms /opt/librenms/check-services.php >> /dev/null 2>&1
You can add a service from the Services menu or you can go to devices and choose a device. We are going to add the HTTP service to monitor the status code, response time, and SSL certificate expiration. Choose your device and then click on Services which should be in between Inventory and Logs. Click Add Service and choose http for the type. Fill in the description you want. For IP address fill in the website address such as stupiderror.com. If your site redirects to www then fill in something like www.stupiderror.com. For the Parameters we are going to use -S -w 3 -c 5. The -S tells it to connect with ssl so it uses HTTPS instead of HTTP. The -w says to put the service in a Warning state if it takes 3 seconds or longer to respond. The -c option tells it to put the service in a Critical state if it takes 5 seconds or longer to respond.
To monitor the expiration of the certificate click on Add Service again. Choose HTTP for type. For IP address fill in your domain name, something like www.stupiderror.com. For Parameters we can do -C 30,14. This says the service is good when the certificate is valid for more than 30 days. If the certificate is valid for 15 to 30 then days then change the state to Warning and if it is valid for 14 or less days then change the state to Critical. If you click on Details you can see graphs for these metrics.
For more information on check_http check out the man page: https://www.monitoring-plugins.org/doc/man/check_http.html