I would like to monitor NGinx stats through Munin but the Nginx plugins show no data. Is it possible to diagnose why only one of the munin nginx plugins seems to be working?
If you see following output, you are good to go ahead.
with-http_stub_status_module
Otherwise, you have to re-compile nginx with the required module enabled or install from different source (In my case, the default Debian repo had the right version).
2. Check nginx configuration
I am assuming you have placed and enabled the required config. To see if it's working, you can ssh to your server and run
wget http://localhost/nginx_status
If you get no errors here, then the problem is plugin configuration. If server returns error here, you can debug by modifying configuration:
Check the plugin file for any hard coded paths and verify they are correct for your system:
grep '/' PLUGINNAME
The nginx plugin may rely on Nginx being compiled with certain modules or log output in a certain format. Is there any documentation page for the plugins?
If you need to set a different URL than http://localhost/nginx_status, make sure to add the plugin configuration to the correct file (munin.conf is the wrong one).
Best, create a new file /etc/munin/plugin-conf.d/nginx
[nginx*]
env.url http://localhost/status.pool1
Of course, the correct URL is defined in the PHP-FPM pool configuration (e.g., /etc/php/7.4/fpm/pool.d/www.conf) and access is granted in the webserver's configuration (see answers above).
Using sudo munin-run nginx_status may be helpful to search for additional errors.
The nginx plugins rely on the following URL to get the status info:
Usually, nginx does not have this URL configured to show status data.
From the documentation of the plugins, I see that nginx needs to be configured to show status data in a spesific URL.
You need to enable nginx status by adding the following lines to the site's configuration:
Don't forget to restart the server after adding this configuration, and make sure the stus URL returns the status data.
For the complete documentation of each plugin, you can run:
Hope this helps.
In my experience, these plugins are likely not working due to nginx misconfiguration. Here's a shortlist of what to do in this case:
1. Check nginx installation
Nginx must be compiled with HttpStubStatusModule module. You can check that by running following command (under sudo or root):
If you see following output, you are good to go ahead.
Otherwise, you have to re-compile nginx with the required module enabled or install from different source (In my case, the default Debian repo had the right version).
2. Check nginx configuration
I am assuming you have placed and enabled the required config. To see if it's working, you can
ssh
to your server and runIf you get no errors here, then the problem is plugin configuration. If server returns error here, you can debug by modifying configuration:
After that, in the file
/var/log/nginx/status.error.log
you can see the exact reason why server returned an error:In my case (as you can see from the log) the problem was
client: ::1
, while configuration only allowed access from127.0.0.1
To resolve the issue, you can either follow cepharum's suggestion or modify virtual host configuration:
(Notice that I also replaced
listen: 127.0.0.1
with port 80 (ipv4+ipv6) because the former also didn't work)3. Check system config and dependencies
To check if plugin itself is working, run
(note that plugin must be "turned on" - a symlink must be present at
/etc/munin/plugins
- read the manual if not)If you get errors with
LWP
library (e.g.LWP::UserAgent
orLWP::VERSION
), your system is missing a package required bynginx_status
plugin.On Debian / Ubuntu, run
On CentOS
After that test the plugin again using
munin-run
. The expected output (numbers will be different):Possibly helpful:
Additionally use the debug option to munin-run.
Check the plugin file for any hard coded paths and verify they are correct for your system:
The nginx plugin may rely on Nginx being compiled with certain modules or log output in a certain format. Is there any documentation page for the plugins?
Key thing is the url in munin config.
You will need
Note
Not
Install libwww-perl then run the command
munin-run nginx_status
to see stats.Restart muni-node service.
If you need to set a different URL than
http://localhost/nginx_status
, make sure to add the plugin configuration to the correct file (munin.conf
is the wrong one).Best, create a new file
/etc/munin/plugin-conf.d/nginx
Of course, the correct URL is defined in the PHP-FPM pool configuration (e.g.,
/etc/php/7.4/fpm/pool.d/www.conf
) and access is granted in the webserver's configuration (see answers above).Using
sudo munin-run nginx_status
may be helpful to search for additional errors.