Munin
Jump to navigation
Jump to search
Description
This explains how to install Munin with nginx and fastcgi. If you're interested in using it with Apache, some commands will be different.
Installation
Munin
Install munin with following command:
$ sudo aptitude install munin munin-node munin-plugins-extra spawn-fcgi
FCGI processes
Create the systemd scripts that will spawn your FCGI processes:
$ cat /usr/lib/systemd/system/munin-fcgi-graph.service [Unit] Description=Munin FastCGI Graph Documentation=man:spawn-fcgi [Service] Type=forking PIDFile=/var/run/munin/fcgi-graph.pid ExecStart=/usr/bin/spawn-fcgi -s /var/run/munin/fcgi-graph.sock -U www-data -u www-data -g www-data /usr/lib/munin/cgi/munin-cgi-graph -P /var/run/munin/fcgi-graph.pid [Install] WantedBy=multi-user.target
$ cat /usr/lib/systemd/system/munin-fcgi-html.service [Unit] Description=Munin FastCGI HTML Documentation=man:spawn-fcgi [Service] Type=forking PIDFile=/var/run/munin/fcgi-html.pid ExecStart=/usr/bin/spawn-fcgi -s /var/run/munin/fcgi-html.sock -U www-data -u www-data -g munin /usr/lib/munin/cgi/munin-cgi-html -P /var/run/munin/fcgi-html.pid [Install] WantedBy=multi-user.target
Register and start the processes:
$ sudo systemctl daemon-reload $ sudo systemctl enable munin-fcgi-graph.service $ sudo systemctl enable munin-fcgi-html.service $ sudo systemctl start munin-fcgi-graph.service $ sudo systemctl start munin-fcgi-html.service
Configuration
munin.conf
Modify the config file as follows:
$ cat /etc/munin/munin.conf dbdir /var/lib/munin htmldir /var/cache/munin/www logdir /var/log/munin rundir /var/run/munin tmpldir /etc/munin/templates includedir /etc/munin/munin-conf.d graph_strategy cgi html_strategy cgi [localhost.localdomain] address 127.0.0.1 use_node_name yes
nginx
Modify /etc/nginx/sites-available/default as follows:
server { listen 80; server_name localhost.local; auth_basic "Restricted Access"; auth_basic_user_file /etc/nginx/htpasswd.users; ### MUNIN location ^~ /munin-cgi/munin-cgi-graph/ { access_log off; fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*); fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass unix:/var/run/munin/fcgi-graph.sock; include fastcgi_params; } location /munin/static/ { alias /etc/munin/static/; } location /munin/ { fastcgi_split_path_info ^(/munin)(.*); fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass unix:/var/run/munin/fcgi-html.sock; include fastcgi_params; } }
Restart services:
$ sudo systemctl restart munin-node.service $ sudo systemctl restart nginx.service
Plugins
CPU temp
If you wish to monitor your CPU temperature, proceed as follows:
$ sudo aptitude install lm-sensors $ sudo sensors-detect
Answer yes to all questions of the above command. Then:
$ sudo service kmod start
Below is the plugin I've created to monitor my CPU:
$ cat /data/scripts/munin_temp_cpu #!/bin/sh case $1 in config) cat << 'EOM' graph_period 20 graph_category sensors graph_title Temperatures graph_vlabel Celsius cpu_temp_0.label Core_0 cpu_temp_2.label Core_2 EOM exit 0;; esac echo -n "cpu_temp_0.value "; sensors | grep 'Core 0' | awk '{ print $3 }' | grep -o '[0-9\.:]*' echo -n "cpu_temp_2.value "; sensors | grep 'Core 2' | awk '{ print $3 }' | grep -o '[0-9\.:]*'
Install the plugin:
$ cd /etc/munin/plugins/ $ ln -s /data/script/munin_temp_cpu
You can test it:
$ sudo munin-run munin_temp_cpu cpu_temp_0.value 33.0 cpu_temp_2.value 25.0
Fan speed
Below is the plugin I wrote to control the fan speed:
$ cat /data/script/munin_fan_speed #!/bin/sh case $1 in config) cat << 'EOM' graph_period 20 graph_category sensors graph_title Fan Speed graph_vlabel RPM fan_speed_0.label FanSpeed_0 EOM exit 0;; esac echo -n "fan_speed_0.value "; sensors | grep fan2 | awk '{ print $2 }'
Install the plugin:
$ cd /etc/munin/plugins/ $ ln -s /data/script/munin_fan_speed
Comments
Keywords: munin nginx fastcgi monitoring server