source: Extensions/Applications.md ## Introduction You can use Application support to graph performance statistics from many applications. Different applications support a variety of ways to collect data: by direct connection to the application, snmpd extend, or [the agent](Agent-Setup.md). 1. [Apache](#apache) - SNMP extend, Agent 1. [BIND9/named](#bind9-aka-named) - SNMP extend, Agent 1. [C.H.I.P.](#chip) - SNMP extend 1. [DHCP Stats](#dhcp-stats) - SNMP extend 1. [Entropy](#entropy) - SNMP extend 1. [EXIM Stats](#exim-stats) - SNMP extend 1. [Fail2ban](#fail2ban) - SNMP extend 1. [FreeBSD NFS Client](#freebsd-nfs-client) - SNMP extend 1. [FreeBSD NFS Server](#freebsd-nfs-server) - SNMP extend 1. [FreeRADIUS](#freeradius) - SNMP extend, Agent 1. [Freeswitch](#freeswitch) - SNMP extend, Agent 1. [GPSD](#gpsd) - Agent 1. [Mailscanner](#mailscanner) - SNMP extend 1. [Memcached](#memcached) - SNMP extend 1. [Munin](#munin) - Agent 1. [MySQL](#mysql) - SNMP extend, Agent 1. [NGINX](#nginx) - SNMP extend, Agent 1. [NFS Server](#nfs-server) - SNMP extend 1. [NTP Client](#ntp-client) - SNMP extend 1. [NTP Server/NTPD](#ntp-server-aka-ntpd) - SNMP extend 1. [Nvidia GPU](#nvidia-gpu) - SNMP extend 1. [Open Grid Scheduler](#opengridscheduler) - SNMP extend 1. [OS Updates](#os-updates) - SNMP extend 1. [PHP-FPM](#php-fpm) - SNMP extend 1. [Pi-hole](#pi-hole) - SNMP extend 1. [Postfix](#postfix) - SNMP extend 1. [Postgres](#postgres) - SNMP extend 1. [PowerDNS](#powerdns) - Agent 1. [PowerDNS Recursor](#powerdns-recursor) - Direct, Agent 1. [PowerDNS dnsdist](#powerdns-dnsdist) - SNMP extend 1. [Proxmox](#proxmox) - SNMP extend 1. [Raspberry PI](#raspberry-pi) - SNMP extend 1. [SDFS info](#sdfs-info) - SNMP extend 1. [SMART](#smart) - SNMP extend 1. [Squid](#squid) - SNMP proxy 1. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent 1. [Unbound](#unbound) - SNMP extend, Agent 1. [UPS-nut](#ups-nut) - SNMP extend 1. [UPS-apcups](#ups-apcups) - SNMP extend 1. [ZFS](#zfs) - SNMP extend ### Apache Either use SNMP extend or use the agent. Note that you need to install and configure the Apache [mod_status](https://httpd.apache.org/docs/2.4/en/mod/mod_status.html) module before trying the script. ##### SNMP Extend 1. Download the script onto the desired host (the host must be added to LibreNMS devices) ``` wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/apache-stats.py -O /etc/snmp/apache-stats.py ``` 2. Make the script executable (chmod +x /etc/snmp/apache-stats.py) 3. Verify it is working by running /etc/snmp/apache-stats.py In some cases urlgrabber and pycurl needs to be installed, in Debian this can be achieved by: apt-get install python-urlgrabber python-pycurl . Make sure to remove /tmp/apache-snmp afterwards. 4. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: ``` extend apache /etc/snmp/apache-stats.py ``` 5. Restart snmpd on your host 6. Test by running ``` snmpwalk localhost NET-SNMP-EXTEND-MIB::nsExtendOutput2Table ``` ##### Agent [Install the agent](Agent-Setup.md) on this device if it isn't already and copy the `apache` script to `/usr/lib/check_mk_agent/local/` 1. Verify it is working by running /usr/lib/check_mk_agent/local/apache (If you get error like "Can't locate LWP/Simple.pm". libwww-perl needs to be installed: apt-get install libwww-perl) 2. On the device page in Librenms, edit your host and check the `Apache` under the Applications tab. ### BIND9 aka named 1: Create stats file with appropriate permissions: ```shell ~$ touch /var/run/named/stats ~$ chown bind:bind /var/run/named/stats ``` Change `user:group` to the user and group that's running bind/named. 2: Bind/named configuration: ```text options { ... statistics-file "/var/run/named/stats"; zone-statistics yes; ... }; ``` 3: Restart your bind9/named after changing the configuration. 4: Verify that everything works by executing `rndc stats && cat /var/run/named/stats`. In case you get a `Permission Denied` error, make sure you chown'ed correctly. 5: Also be aware that this file is appended to each time `rndc stats` is called. Given this it is suggested you setup file rotation for it. Alternatively you can also set zero_stats to 1 in the config. 6: The script for this also requires the Perl module File::ReadBackwards. On FreeBSD this is available as p5-File-ReadBackwards and on linux as perl-File-ReadBackwards in CentOS/Redhat and libfile-readbackwards-perl Debian/Ubuntu. If it is not available, it can be installed by `cpan -i File::ReadBackwards`. 7: You may possibly need to configure the agent/extend script as well. The config file's path defaults to the same path as the script, but with .config appended. So if the script is located at `/etc/snmp/bind`, the config file will be `/etc/snmp/bind.config`. Alternatively you can also specify a config via `-c $file`. Anything starting with a # is comment. The format for variables is $variable=$value. Empty lines are ignored. Spaces and tabes at either the start or end of a line are ignored. The variables are as below. ``` rndc = The path to rndc. Default: /usr/bin/env rndc call_rndc = A 0/1 boolean on weather to call rndc stats. Suggest to set to 0 if using netdata. Default: 1 stats_file = The path to the named stats file. Default: /var/run/named/stats agent = A 0/1 boolean for if this is being used as a LibreNMS agent or not. Default: 0 zero_stats = A 0/1 boolean for if the stats file should be zeroed first. Default: 0 (1 if guessed) ``` If you want to guess at the configuration, call it with -g and it will print out what it thinks it should be. 8: On the device page in Librenms, edit your host and check `BIND` under the Applications tab. ##### SNMP Extend 1: Copy the bind shell script, to the desired host (the host must be added to LibreNMS devices) ``` wget https://github.com/librenms/librenms-agent/raw/master/snmp/bind -O /etc/snmp/bind ``` 2: Make the script executable (chmod +x /etc/snmp/bind) 3: Edit your snmpd.conf file and add: ``` extend bind /etc/snmp/bind ``` 4: Restart snmpd on the host in question. ##### Agent 1: [Install the agent](Agent-Setup.md) on this device if it isn't already and copy the script to `/usr/lib/check_mk_agent/local/bind` via `wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/bind -O /usr/lib/check_mk_agent/local/bind` 2: Run `chmod +x /usr/lib/check_mk_agent/local/bind` 3: Set the variable 'agent' to '1' in the config. ### C.H.I.P C.H.I.P. is a $9 R8 based tiny computer ideal for small projects. Further details: https://getchip.com/pages/chip #### SNMP Extend 1. Copy the shell script to the desired host (the host must be added to LibreNMS devices) ``` wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/chip.sh -O /etc/snmp/power-stat.sh ``` 2. Make the script executable (chmod +x /etc/snmp/power-stat.sh) 3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: ``` extend power-stat /etc/snmp/power-stat.sh ``` 4. Restart snmpd on your host ### DHCP Stats A small shell script that reports current DHCP leases stats. ##### SNMP Extend 1. Copy the shell script to the desired host (the host must be added to LibreNMS devices) ``` wget https://github.com/librenms/librenms-agent/raw/master/snmp/dhcp-status.sh -O /etc/snmp/dhcp-status.sh ``` 2. Make the script executable (chmod +x /etc/snmp/dhcp-status.sh) 3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: ``` extend dhcpstats /etc/snmp/dhcp-status.sh ``` 4. Restart snmpd on your host ### Entropy A small shell script that checks your system's available random entropy. ##### SNMP Extend 1. Download the script onto the desired host (the host must be added to LibreNMS devices) ``` wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/entropy.sh -O /etc/snmp/entropy.sh ``` 2. Make the script executable (chmod +x /etc/snmp/entropy.sh) 3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: ``` extend entropy /etc/snmp/entropy.sh ``` 4. Restart snmpd on your host ### EXIM Stats SNMP extend script to get your exim stats data into your host. ##### SNMP Extend 1. Copy the [exim stats](https://github.com/librenms/librenms-agent/blob/master/snmp/exim-stats.sh) to `/etc/snmp/` (or any other suitable location) on your host. 2. Make the script executable: `chmod +x /etc/snmp/exim-stats.sh` 3. Edit your snmpd.conf file (usually `/etc/snmp/snmpd.conf`) and add: ``` extend exim-stats /etc/snmp/exim-stats.sh ``` 4. If you are using sudo edit your sudo users (usually `visudo`) and add at the bottom: ``` snmp ALL=(ALL) NOPASSWD: /etc/snmp/exim-stats.sh, /usr/bin/exim* ``` 5. Restart snmpd on your host ### Fail2ban #### SNMP Extend 1: Copy the shell script, fail2ban, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/fail2ban -O /etc/snmp/fail2ban) 2: Make the script executable (chmod +x /etc/snmp/fail2ban) 3: Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: ``` extend fail2ban /etc/snmp/fail2ban ``` If you want to use the cache, it is as below, by using the -c switch. ``` extend fail2ban /etc/snmp/fail2ban -c ``` If you want to use the cache and update it if needed, this can by using the -c and -U switches. ``` extend fail2ban /etc/snmp/fail2ban -c -U ``` If you need to specify a custom location for the fail2ban-client, that can be done via the -f switch. If not specified, "/usr/bin/env fail2ban-client" is used. ``` extend fail2ban /etc/snmp/fail2ban -f /foo/bin/fail2ban-client ``` 5: Restart snmpd on your host 6: If you wish to use caching, add the following to /etc/crontab and restart cron. ``` */3 * * * * root /etc/snmp/fail2ban -u ``` 7: Restart or reload cron on your system. If you have more than a few jails configured, you may need to use caching as each jail needs to be polled and fail2ban-client can't do so in a timely manner for than a few. This can result in failure of other SNMP information being polled. For additional details of the switches, please see the POD in the script it self at the top. ### FreeBSD NFS Client #### SNMP Extend 1: Copy the shell script, fbsdnfsserver, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/fbsdnfsclient -O /etc/snmp/fbsdnfsclient) 2: Make the script executable (chmod +x /etc/snmp/fbsdnfsclient) 3: Edit your snmpd.conf file and add: ``` extend fbsdnfsclient /etc/snmp/fbsdnfsclient ``` 4: Restart snmpd on your host ### FreeBSD NFS Server #### SNMP Extend 1: Copy the shell script, fbsdnfsserver, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/fbsdnfsserver -O /etc/snmp/fbsdnfsserver) 2: Make the script executable (chmod +x /etc/snmp/fbsdnfsserver) 3: Edit your snmpd.conf file and add: ``` extend fbsdnfsserver /etc/snmp/fbsdnfsserver ``` 4: Restart snmpd on your host ### FreeRADIUS The FreeRADIUS application extension requires that status_server be enabled in your FreeRADIUS config. For more information see: https://wiki.freeradius.org/config/Status You should note that status requests increment the FreeRADIUS request stats. So LibreNMS polls will ultimately be reflected in your stats/charts. 1: Go to your FreeRADIUS configuration directory (usually /etc/raddb or /etc/freeradius). 2: `cd sites-enabled` 3: `ln -s ../sites-available/status status` 4: Restart FreeRADIUS. 5: You should be able to test with the radclient as follows... ``` echo "Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 31, Response-Packet-Type = Access-Accept" | \ radclient -x localhost:18121 status adminsecret ``` Note that adminsecret is the default secret key in status_server. Change if you've modified this. ##### SNMP Extend 1: Copy the freeradius shell script, to the desired host (the host must be added to LibreNMS devices) ``` wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/freeradius.sh -O /etc/snmp/freeradius.sh ``` 2: Make the script executable (chmod +x /etc/snmp/freeradius.sh) 3: If you've made any changes to the FreeRADIUS status_server config (secret key, port, etc.) edit freeradius.sh and adjust the config variable accordingly. 4: Edit your snmpd.conf file and add: ``` extend freeradius /etc/snmp/freeradius.sh ``` 5: Restart snmpd on the host in question. ##### Agent 1: [Install the agent](Agent-Setup.md) on this device if it isn't already and copy the script to `/usr/lib/check_mk_agent/local/freeradius.sh` via `wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/freeradius.sh -O /usr/lib/check_mk_agent/local/freeradius.sh` 2: Run `chmod +x /usr/lib/check_mk_agent/local/freeradius.sh` 3: If you've made any changes to the FreeRADIUS status_server config (secret key, port, etc.) edit freeradius.sh and adjust the config variable accordingly. 4: Edit the freeradius.sh script and set the variable 'AGENT' to '1' in the config. ### Freeswitch A small shell script that reports various Freeswitch call status. ##### Agent 1. [Install the agent](Agent-Setup.md) on your Freeswitch server if it isn't already 2. Copy the [freeswitch script](https://github.com/librenms/librenms-agent/blob/master/agent-local/freeswitch) to `/usr/lib/check_mk_agent/local/` 3. Configure `FSCLI` in the script. You may also have to create an `/etc/fs_cli.conf` file if your `fs_cli` command requires authentication. 4. Verify it is working by running `/usr/lib/check_mk_agent/local/freeswitch` ##### SNMP Extend 1. Copy the [freeswitch script](https://github.com/librenms/librenms-agent/blob/master/agent-local/freeswitch) to `/etc/snmp/` on your Freeswitch server. 2. Make the script executable: `chmod +x /etc/snmp/freeswitch` 3. Configure `FSCLI` in the script. You may also have to create an `/etc/fs_cli.conf` file if your `fs_cli` command requires authentication. 4. Verify it is working by running `/etc/snmp/freeswitch` 5. Edit your snmpd.conf file (usually `/etc/snmp/snmpd.conf`) and add: ``` extend freeswitch /etc/snmp/freeswitch ``` 6. Restart snmpd on your host ### GPSD A small shell script that reports GPSD status. ##### Agent [Install the agent](Agent-Setup.md) on this device if it isn't already and copy the `gpsd` script to `/usr/lib/check_mk_agent/local/` You may need to configure `$server` or `$port`. Verify it is working by running `/usr/lib/check_mk_agent/local/gpsd` ### Mailscanner ##### SNMP Extend 1. Download the script onto the desired host (the host must be added to LibreNMS devices) ``` wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/mailscanner.php -O /etc/snmp/mailscanner.php ``` 2. Make the script executable (chmod +x /etc/snmp/mailscanner.php) 3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: ``` extend mailscanner /etc/snmp/mailscanner.php ``` 4. Restart snmpd on your host ### Memcached ##### SNMP Extend 1. Copy the [memcached script](https://github.com/librenms/librenms-agent/blob/master/agent-local/memcached) to `/etc/snmp/` on your remote server. 2. Make the script executable: `chmod +x /etc/snmp/memcached` 3. Edit your snmpd.conf file (usually `/etc/snmp/snmpd.conf`) and add: ``` extend memcached /etc/snmp/memcached ``` 4. Restart snmpd on your host ### Munin #### Agent 1. Install the script to your agent: `wget https://raw.githubusercontent.com/librenms/librenms-agent/master/agent-local/munin -O /usr/lib/check_mk_agent/local/munin` 2. Make the script executable (`chmod +x /usr/lib/check_mk_agent/local/munin`) 3. Create the munin scripts dir: `mkdir -p /usr/share/munin/munin-scripts` 4. Install your munin scripts into the above directory. To create your own custom munin scripts, please see this example: ``` #!/bin/bash if [ "$1" = "config" ]; then echo 'graph_title Some title' echo 'graph_args --base 1000 -l 0' #not required echo 'graph_vlabel Some label' echo 'graph_scale no' #not required, can be yes/no echo 'graph_category system' #Choose something meaningful, can be anything echo 'graph_info This graph shows something awesome.' #Short desc echo 'foobar.label Label for your unit' # Repeat these two lines as much as you like echo 'foobar.info Desc for your unit.' exit 0 fi echo -n "foobar.value " $(date +%s) #Populate a value, here unix-timestamp ``` ### MySQL ##### Agent [Install the agent](Agent-Setup.md) on this device if it isn't already and copy the `mysql` script to `/usr/lib/check_mk_agent/local/` The MySQL script requires PHP-CLI and the PHP MySQL extension, so please verify those are installed. CentOS (May vary based on PHP version) ``` yum install php-cli php-mysql ``` Debian (May vary based on PHP version) ``` apt-get install php5-cli php5-mysql ``` Unlike most other scripts, the MySQL script requires a configuration file `mysql.cnf` in the same directory as the extend or agent script with following content: ```php > /etc/snmp/snmpd.conf ``` ###### Linux ``` wget https://github.com/librenms/librenms-agent/raw/master/snmp/zfs-linux -O /etc/snmp/zfs-linux chmod +x /etc/snmp/zfs-linux echo "extend zfs /etc/snmp/zfs-linux" >> /etc/snmp/snmpd.conf ``` Now restart snmpd and you're all set.