Difference between revisions of "LibreNMS - snmp extend php-fpm"

From wiki.1001solutions.net
(Created page with "Category:Post-It = NginX LibreNMS script = Get the script: <nowiki> wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O /etc/snmp/phpfpmsp</no...")
 
 
(5 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
  
= NginX LibreNMS script =
+
= PHP-fpm LibreNMS script =
  
Get the script:
+
Get the script and make it executable:
 
  <nowiki>
 
  <nowiki>
wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O /etc/snmp/phpfpmsp</nowiki>
+
wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O /etc/snmp/phpfpmsp && chmod +x /etc/snmp/phpfpmsp</nowiki>
  
Unzip and copy it where you need. Make it executable.
+
Adapt the script to your configuration:
 
 
Adapt:
 
 
  <nowiki>
 
  <nowiki>
 
url="http://127.0.0.1/status?full"</nowiki>
 
url="http://127.0.0.1/status?full"</nowiki>
Line 21: Line 19:
 
Adapt your ''/etc/sudoers'' with:
 
Adapt your ''/etc/sudoers'' with:
 
  <nowiki>
 
  <nowiki>
Debian-snmp ALL=(ALL) NOPASSWD: /etc/snmp/fail2ban</nowiki>
+
Debian-snmp ALL=(ALL) NOPASSWD: /etc/snmp/phpfpmsp</nowiki>
  
  
  
= SNMP Configuration =
+
= PHP Configuration =
  
Adapt your ''/etc/snmp/snmpd.conf'' with:
+
In ''/etc/php/7.3/fpm/pool.d/www.conf'', uncomment:
 
  <nowiki>
 
  <nowiki>
extend fail2ban /usr/bin/sudo /etc/snmp/fail2ban -c -U</nowiki>
+
pm.status_path = /status</nowiki>
 
Restart the service.
 
Restart the service.
  
  
  
= Crontab =
+
= vHOST =
  
Add to the crontab:
+
Adapt your config with:
 
  <nowiki>
 
  <nowiki>
*/3   *    *    *    *    root    /etc/snmp/fail2ban -u</nowiki>
+
location ~ ^/(status|ping)$ {
 +
        allow 127.0.0.1;
 +
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 +
        fastcgi_index index.php;
 +
        include fastcgi_params;
 +
        #fastcgi_pass 127.0.0.1:9000;
 +
        fastcgi_pass  unix:/var/run/php7.3-fpm.sock;
 +
}</nowiki>
 +
'''Be careful of the fastcgi_pass path.'''
 +
 
 +
Restart the service.
 +
 
 +
Test the vhost with:
 +
<nowiki>
 +
curl http://127.0.0.1/status</nowiki>
 +
 
 +
 
 +
 
 +
= SNMP Configuration =
 +
 
 +
Adapt your ''/etc/snmp/snmpd.conf'' with:
 +
<nowiki>
 +
extend phpfpmsp /usr/bin/sudo /etc/snmp/phpfpmsp</nowiki>
 +
Restart the service.
  
  
Line 46: Line 67:
 
Adapt the user and path to your configuration:
 
Adapt the user and path to your configuration:
 
  <nowiki>
 
  <nowiki>
sudo -u Debian-snmp /etc/snmp/fail2ban</nowiki>
+
sudo -u Debian-snmp /etc/snmp/phpfpmsp</nowiki>
 
 
In case of bug with the Perl @NIC, execute:
 
<nowiki>
 
cpan JSON</nowiki>
 
  
  
Line 56: Line 73:
 
= Sources =
 
= Sources =
  
* https://docs.librenms.org/Extensions/Applications/#fail2ban
+
* https://docs.librenms.org/Extensions/Applications/#php-fpm
 +
* https://www.tecmint.com/enable-monitor-php-fpm-status-in-nginx/
  
  
  
 
----
 
----

Latest revision as of 09:46, 4 May 2020



PHP-fpm LibreNMS script

Get the script and make it executable:

wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O /etc/snmp/phpfpmsp && chmod +x /etc/snmp/phpfpmsp

Adapt the script to your configuration:

url="http://127.0.0.1/status?full"


sudo Configuration

Adapt your /etc/sudoers with:

Debian-snmp ALL=(ALL) NOPASSWD: /etc/snmp/phpfpmsp


PHP Configuration

In /etc/php/7.3/fpm/pool.d/www.conf, uncomment:

pm.status_path = /status

Restart the service.


vHOST

Adapt your config with:

location ~ ^/(status|ping)$ {
        allow 127.0.0.1;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass   unix:/var/run/php7.3-fpm.sock;
}

Be careful of the fastcgi_pass path.

Restart the service.

Test the vhost with:

curl http://127.0.0.1/status


SNMP Configuration

Adapt your /etc/snmp/snmpd.conf with:

extend phpfpmsp /usr/bin/sudo /etc/snmp/phpfpmsp

Restart the service.


Check Command

Adapt the user and path to your configuration:

sudo -u Debian-snmp /etc/snmp/phpfpmsp


Sources