Skip to content

[Munin] Install on Pi

kreisklasse edited this page Jul 26, 2018 · 3 revisions

Install Munin on a RaspberryPI with Rasbian Stretch Lite

What is Munin and my experiences

Munin (Wikipedia) - Munin is a free and open-source computer system monitoring, network monitoring and infrastructure monitoring software application.

I am running it on a RaspberryPi 1 with 4 Nodes, so collecting data from 5 computer.
The pi1 is more or less on the power limit collecting data from these 5 nodes. It's good usable, but don't expect to monitor a lot more than this 5 nodes.

Used Tutorials

https://debian-blog.org/munin-als-monitoring-system/
https://www.cyberciti.biz/tips/installing-and-configuring-lighttpd-webserver-howto.html


Step-by-step

on host pi

sudo apt-get install munin munin-node
sudo nano /etc/munin/munin.conf
change to
htmldir /var/www/munin

# host tree
  [munin.p1]
    address 127.0.0.1
    use_node_name yes

install lighttpd
sudo apt-get install lighttpd
then
sudo nano /etc/lighttpd/lighttpd.conf change to
server.document-root ="/var/www"
then
sudo mkdir /var/www/munin
sudo chown munin:munin /var/www/munin

sudo /etc/init.d/lighttpd restart

sudo nano /etc/munin/munin-node.conf
insert
allow ^192\.168\.0\.123$ #your munin server ip

sudo service munin-node restart
sudo /etc/init.d/lighttpd restart


on a node pi

sudo apt-get install munin-node
sudo nano /etc/munin/munin-node.conf
insert
allow ^192\.168\.0\.123$ #your munin server ip

sudo service munin-node restart

Insatlling pihole plugin on pihole-Pi (Node)

https://github.com/Rauks/MuninPiholePlugins
cd /etc/munin/plugins/
sudo nano pihole_cache
copy:


# Sample setup for '/etc/munin/plugin-conf.d/munin-node':
#
# [pihole_*]
# user root
# env.host 127.0.0.1
# env.port 80
# env.api /admin/api.php

envhost=${host:-127.0.0.1}
envport=${port:-80}
envapi=${api:-/admin/api.php}

apicall=$(curl -s "$envhost:$envport$envapi" 2>/dev/null)
stats=$(echo $apicall | sed 's/[{}"]//g' | tr "," "\n")

case $1 in
  config)
    echo "graph_title Pihole Queries Cache"
    echo "graph_vlabel queries rate"
    echo "graph_category pihole"
    echo "graph_info This graph shows the Pihole queries cache statistics."

    for stat in $stats
    do
        uid=$(echo $stat | sed 's/:.*//')
        if [ $uid = "queries_forwarded" ] || [ $uid = "queries_cached" ]; then
            echo "$uid.label $uid"
            echo "$uid.type DERIVE"
            echo "$uid.min 0"
        fi
    done

  exit 0;;
esac

for stat in $stats
do
    uid=$(echo $stat | sed 's/:.*//')
    if [ $uid = "queries_forwarded" ] || [ $uid = "queries_cached" ]; then
        value=$(echo $stat | sed 's/.*://')
        echo "$uid.value $value"
    fi
done


sudo nano pihole_clients

#!/bin/sh

# Sample setup for '/etc/munin/plugin-conf.d/munin-node':
#
# [pihole_*]
# user root
# env.host 127.0.0.1
# env.port 80
# env.api /admin/api.php

envhost=${host:-127.0.0.1}
envport=${port:-80}
envapi=${api:-/admin/api.php}

apicall=$(curl -s "$envhost:$envport$envapi" 2>/dev/null)
stats=$(echo $apicall | sed 's/[{}"]//g' | tr "," "\n")

case $1 in
  config)
    echo "graph_title Pihole Clients"
    echo "graph_vlabel count"
    echo "graph_category pihole"
    echo "graph_info This graph shows the Pihole unique clients statistics."

    for stat in $stats
    do
        uid=$(echo $stat | sed 's/:.*//')
        if [ $uid = "unique_clients" ]; then
            echo "$uid.label $uid"
            echo "$uid.min 0"
        fi
    done

  exit 0;;
esac

for stat in $stats
do
    uid=$(echo $stat | sed 's/:.*//')
    if [ $uid = "unique_clients" ]; then
        value=$(echo $stat | sed 's/.*://')
        echo "$uid.value $value"
    fi
done

sudo nano pihole_queries

#!/bin/sh

# Sample setup for '/etc/munin/plugin-conf.d/munin-node':
#
# [pihole_*]
# user root
# env.host 127.0.0.1
# env.port 80
# env.api /admin/api.php

envhost=${host:-127.0.0.1}
envport=${port:-80}
envapi=${api:-/admin/api.php}

apicall=$(curl -s "$envhost:$envport$envapi" 2>/dev/null)
stats=$(echo $apicall | sed 's/[{}"]//g' | tr "," "\n")

case $1 in
  config)
    echo "graph_title Pihole Queries"
    echo "graph_vlabel queries rate"
    echo "graph_category pihole"
    echo "graph_info This graph shows the Pihole queries statistics."

    for stat in $stats
    do
        uid=$(echo $stat | sed 's/:.*//')
        if [ $uid = "dns_queries_today" ] || [ $uid = "ads_blocked_today" ]; then
            echo "$uid.label $(echo $uid | sed 's/_today//')"
            echo "$uid.type DERIVE"
            echo "$uid.min 0"
        fi
    done

  exit 0;;
esac

for stat in $stats
do
    uid=$(echo $stat | sed 's/:.*//')
    if [ $uid = "dns_queries_today" ] || [ $uid = "ads_blocked_today" ]; then
        value=$(echo $stat | sed 's/.*://')
        echo "$uid.value $value"
    fi
done

sudo chmod a+x pihole_cache
sudo chmod a+x pihole_clients
sudo chmod a+x pihole_queries

sudo nano /etc/munin/plugin-conf.d/munin-node
add

[pihole_*]
user root
env.host 127.0.0.1
env.port 80
env.api /admin/api.php

sudo service munin-node restart