Jump to: navigation, search

Monitoring your Mesh Potato Network with Munin

Set up Muninlite on an SECN 1.1 MP

  1. Change to the "/tmp" directory and get the xinetd and muninlite packages
    cd /tmp
    wget http://download.villagetelco.org/firmware/secn/unstable/mp01/packages/xinetd_2.3.14-1_mips.ipk
    wget http://download.villagetelco.org/firmware/secn/unstable/mp01/packages/muninlite_1.0.0-1_mips.ipk
    
  2. Install xinetd
    opkg install xinetd_2.3.14-1_mips.ipk
  3. Configure xinetd to start on boot with the following command
    ln -s /etc/init.d/xinetd /etc/rc.d/S70xinetd
    
  4. Install muninlite
    opkg install muninlite_1.0.0-1_mips.ipk
  5. Create the file /etc/xinetd.d/munin and insert the following text into it:
    service munin
    {
    	socket_type	= stream
    	protocol	= tcp
    	wait		= no
    	user		= root
    	group		= root
    	server		= /usr/sbin/munin-node
    	disable		= no
    }
    and save it
  6. Check to see that munin is registered as a service in /etc/services. You should see a line like
    munin  4949
    If this line is not present, add it.
  7. Start xinetd manually with the following command:
    /etc/init.d/xinetd start
    
  8. Check to see that munin-node is working by executing munin-node You should see output something like the following:
    # munin node at MP-xxx
    Type Ctrl-c to exit.
  9. Check that munin-node can be called through xinetd
    telnet localhost 4949
    You should see output similar to the previous command. Type 'quit' to exit

Set up Muninlite on an SECN 2.0 MP

  1. Change to the "/tmp" directory and get the xinetd and muninlite packages
    cd /tmp
    wget http://download.villagetelco.org/firmware/secn/unstable/mp01/SECN-2.0/SECN-2.0-RC3c/packages/xinetd_2.3.14-3_atheros.ipk
    wget http://download.villagetelco.org/firmware/secn/unstable/mp01/SECN-2.0/SECN-2.0-RC3c/packages/muninlite_1.0.4-2_atheros.ipk
    
  2. Install xinetd
    opkg install xinetd_2.3.14-3_atheros.ipk
  3. Configure xinetd to start on boot with the following command
    ln -s /etc/init.d/xinetd /etc/rc.d/S70xinetd
    
  4. Install muninlite
    opkg install muninlite_1.0.4-2_atheros.ipk
  5. Check to see that munin is registered as a service in /etc/services. You should see a line like
    munin  4949
    If this line is not present, add it.
  6. Start xinetd manually with the following command:
    /etc/init.d/xinetd start
    
  7. Check to see that munin-node is working by executing munin-node You should see output something like the following:
    /usr/sbin/munin-node
    # munin node at MP-xxx
    Type Ctrl-c to exit.
  8. Check that munin-node can be called through xinetd
    telnet localhost 4949
    You should see output similar to the previous command. Type 'quit' to exit

Install Munin on your server

Prerequisites

You should have a web server (apache, lighttpd, nginx, etc) installed. This page assumes your are using Ubuntu and that the document root for the web server is /var/www. Adjust accordingly if not.

Munin

  1. Install munin
    sudo apt-get install munin
    
  2. Edit the munin config file with:
    sudo vi /etc/munin/munin.conf 
    

    Find the line:

    # htmldir /var/cache/munin/www 
    
    Add this line following to configure the web root for munin:
    htmldir /var/www/villagetelco/web/monitoring
  3. Find these lines (towards the end of the file):
    # a simple host tree
    #[localhost.localdomain]
    #    address 127.0.0.1
    #    use_node_name yes 
    

    Add the following lines after to add Mesh Potato nodes to be monitored:

    [MP-20]                   <-- insert name of MP here
        address 10.130.1.20   <-- insert IP address of MP here
        use_node_name yes
    
  4. Create the munin directory under the web server directory e.g.
    sudo mkdir -p /var/www/villagetelco/web/monitoring
    
  5. Restart munin
    sudo service munin-node restart
  6. Wait a few minutes and browse to
    http://localhost/villagetelco/web/monitoring/MP-20/index.html
    

    Change localhost to the ip address of your server if you are not working directly on your web server.

    MP-20 in the above url should correspond with what you set up in /etc/munin/munin.conf

Customise MuninLite

You can write your own plugins to customise muninlite. Here is an example plugin to monitor Asterisk memory and cpu use.

  1. Create the plugin directory on the MP
    mkdir /usr/sbin/munin-node-plugin.d
  2. Edit /usr/sbin/munin-node at line 24 to add the plugindir_ option
    PLUGINS="cpu if_ if_err_ load memory processes netstat uptime plugindir_"
    You can also take this opportunity to delete any monitoring tests you are not interested in. Deleting tests will reduce any unnecessary load on the MP from Munin.
  3. Create a script called "asterisk" in /usr/sbin/munin-node-plugin.d
    vi /usr/sbin/munin-node-plugin.d/asterisk
  4. Insert the following lines
    #!/bin/ash
    case $1 in
    config)
    cat <<'EOM'
    graph_title Asterisk
    graph_vlabel %
    asteriskmem.label mem
    asteriskcpu.label cpu
    EOM
    exit 0;;
    esac
    echo -n "asteriskmem.value " 
    top -b -n1  | grep "asterisk -f" | grep -v grep | awk '{sub("%","",$6); print  $6}'
    echo -n "asteriskcpu.value " 
    top -b -n1  | grep "asterisk -f" | grep -v grep | awk '{sub("%","",$7); print  $7}'
    
  5. Make the script executable
    chmod +x /usr/sbin/munin-node-plugin.d/asterisk
  6. Test the script by telneting to the MP on port 4949 and issue the command "fetch asterisk". You should see something like:
    ~$ telnet  xxx.xxx.xxx.xxx 4949
    Trying xxx.xxx.xxx.xxx...
    Connected to xxx.xxx.xxx.xxx.
    Escape character is '^]'.
    # munin node at XXX
    fetch asterisk
    asteriskmem.value 58
    asteriskcpu.value 0
    .