Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

Munin - Set up the NGINX status plugin on Ubuntu 12.04

Published: 31-01-2013 | Author: Remy van Elst | Text only version of this article


❗ This post is over eleven years old. It may no longer be up to date. Opinions may have changed.

This post will show you how to set up the Munin plugin to monitor NGINX (nginx_request and nginx_status) and graph it. You need to change some URLs in the config because by default this is wrong.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!

For this tutorial you need to have a munin server and a NGINX server. All commands need to be run as root or a superuser.

First enable the nginx status page:

## Edit your nginx configuration (vhost) and add this in a server {} block
location /nginx_status {
    stub_status on;
    access_log off;
    allow 127.0.0.1;
    deny all;
}

The above config will enable the status module only for the localhost, without access logging. This means that nobody other than munin can access the status page.

Execute this command to change the munin configuration to have the correct URL for the plugin:

if [[ $(cat /etc/munin/plugin-conf.d/munin-node | grep "nginx") = "" ]]; then echo -e "\n[nginx*]\nenv.url http://localhost/nginx_status" >> /etc/munin/plugin-conf.d/munin-node; fi

Then configure the munin plugins:

munin-node-configure --suggest --shell | sh

This creates the symlinks in the /etc/munin/plugins/ folder. If they are note there, ln -s them yourself.

Finally restart munin:

/etc/init.d/munin-node restart

Done. You will now have nice nginx ghraps like below:

munin

Tags: debian , monitoring , munin , nginx , snippets , ubuntu