librenms-librenms/doc/Extensions/Applications.md
Tony Murray 66a500cd28 Rename Agent Setup to Applications
This is to make the document easier to find.  No one sets out with a goal to set up an agent (unless they are told to).  They want to monitor an application.  Coming to this doc will give them a list of applications they can monitor and ways they can collect the data from the application.  (Direct, SNMP Extend, or Agent)

There needs to be a lot of expansion here, but this is a start.  I'd like to see most applications support 2-3 ways of collecting data.
2016-07-26 21:27:12 -05:00

5.8 KiB

Applications

You can use Application support to graph performance statistics from many applications.

Different applications support a variety of ways collect data: by direct connection to the application, snmpd extend, or the agent.

  1. BIND9/named - Agent
  2. MySQL - Agent
  3. NGINX - Agent
  4. PowerDNS - Agent
  5. PowerDNS Recursor - Agent
  6. TinyDNS/djbdns - Agent

BIND9 aka named

Agent

Install the agent on this device if it isn't already and copy the bind script to /usr/lib/check_mk_agent/local/

Create stats file with appropriate permissions:

~$ touch /etc/bind/named.stats
~$ chown bind:bind /etc/bind/named.stats

Change user:group to the user and group that's running bind/named.

Bind/named configuration:

options {
	...
	statistics-file "/etc/bind/named.stats";
	zone-statistics yes;
	...
};

Restart your bind9/named after changing the configuration.

Verify that everything works by executing rndc stats && cat /etc/bind/named.stats. In case you get a Permission Denied error, make sure you chown'ed correctly.

Note: if you change the path you will need to change the path in scripts/agent-local/bind.

MySQL

Agent

Install the agent on this device if it isn't already and copy the mysql script to /usr/lib/check_mk_agent/local/

Unlike most other scripts, the MySQL script requires a configuration file /usr/lib/check_mk_agent/local/mysql.cnf with following content:

<?php
$mysql_user = 'root';
$mysql_pass = 'toor';
$mysql_host = 'localhost';
$mysql_port = 3306;

NGINX

NGINX is a free, open-source, high-performance HTTP server: https://www.nginx.org/

Agent

Install the agent on this device if it isn't already and copy the nginx script to /usr/lib/check_mk_agent/local/

It's required to have the following directive in your nginx configuration responsible for the localhost server:

location /nginx-status {
    stub_status on;
    access_log   off;
    allow 127.0.0.1;
    deny all;
}

PowerDNS

An authoritative DNS server: https://www.powerdns.com/auth.html

Agent

Install the agent on this device if it isn't already and copy the powerdns script to /usr/lib/check_mk_agent/local/

PowerDNS Recursor

A recursive DNS server: https://www.powerdns.com/recursor.html

Direct

The LibreNMS polling host must be able to connect to port 8082 on the monitored device. The web-server must be enabled, see the Recursor docs: https://doc.powerdns.com/md/recursor/settings/#webserver There is currently no way to specify a custom port or password.

Agent

Install the agent on this device if it isn't already and copy the powerdns-recursor script to /usr/lib/check_mk_agent/local/

This script uses rec_control get-all to collect stats.

TinyDNS aka djbdns

Agent

Install the agent on this device if it isn't already and copy the tinydns script to /usr/lib/check_mk_agent/local/

Note: We assume that you use DJB's Daemontools to start/stop tinydns. And that your tinydns instance is located in /service/dns, adjust this path if necessary.

  1. Replace your log's run file, typically located in /service/dns/log/run with:
#!/bin/sh
exec setuidgid dnslog tinystats ./main/tinystats/ multilog t n3 s250000 ./main/
  1. Create tinystats directory and chown:
mkdir /service/dns/log/main/tinystats
chown dnslog:nofiles /service/dns/log/main/tinystats
  1. Restart TinyDNS and Daemontools: /etc/init.d/svscan restart Note: Some say svc -t /service/dns is enough, on my install (Gentoo) it doesn't rehook the logging and I'm forced to restart it entirely.

Agent Setup

To gather data from remote systems you can use LibreNMS in combination with check_mk (found here).

Make sure that systemd or xinetd is installed on the host you want to run the agent on.

The agent uses TCP-Port 6556, please allow access from the LibreNMS host and poller nodes if you're using the Distributed Polling setup.

On each of the hosts you would like to use the agent on then you need to do the following:

  1. Clone the librenms-agent repository:
cd /opt/
git clone https://github.com/librenms/librenms-agent.git
cd librenms-agent
  1. Copy the relevant check_mk_agent to /usr/bin:
linux freebsd
cp check_mk_agent /usr/bin/check_mk_agent cp check_mk_agent_freebsd /usr/bin/check_mk_agent
chmod +x /usr/bin/check_mk_agent
  1. Copy the service file(s) into place.
xinetd systemd
cp check_mk_xinetd /etc/xinetd.d/check_mk cp check_mk@.service check_mk.socket /etc/systemd/system
  1. Create the relevant directories.
mkdir -p /usr/lib/check_mk_agent/plugins /usr/lib/check_mk_agent/local
  1. Copy each of the scripts from agent-local/ into /usr/lib/check_mk_agent/local that you require to be graphed. You can find detail setup instructions for specific applications above.
  2. Make each one executable that you want to use with chmod +x /usr/lib/check_mk_agent/local/$script
  3. Enable the check_mk service
xinetd systemd
/etc/init.d/xinetd restart systemctl enable --now check_mk.socket
  1. Login to the LibreNMS web interface and edit the device you want to monitor. Under the modules section, ensure that unix-agent is enabled.
  2. Then under Applications, enable the apps that you plan to monitor.
  3. Wait for around 10 minutes and you should start seeing data in your graphs under Apps for the device.