Munin Installation - Joyent Accelerators
There is a standard package for Munin available from the Joyent package repository. The version currently provided is 1.3.4. There are two distinct packages, one for the Munin node and one for the Munin server. Typically you'll want to deploy the server package on the Accelerator that will serve the Munin web stats, and node on each of your Accelerators that you want to have monitored.
Setting up a server
pkg_add munin-server
pkg_add http://pkgsrc.joyent.com/2008Q3/All/rrdtool-1.3.4.tgz
Fix the Munin user
The package install already pre-creates the 'munin' user and group, which is used to execute tasks on the Munin server. To make it work properly on a Solaris system, he user needs to be made more real-like:
usermod -d /var/munin -s /usr/bin/bash munin cp /home/admin/.profile /var/munin chown munin:munin /var/munin/.profile passwd munin
The last line prompts for a password. You can use any - you will not be logging in as 'munin' at all, but Solaris mandates a valid password for any user that needs Cron jobs to run (and you do want that, to pick up monitoring stats unattended).
Set up a Cron job
Create a cron-entry to run the “munin-cron” command as the user “munin” every 5 minutes (use 'crontab -e munin' to open the default crontab editor):
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /opt/local/bin/munin-cron
Link Munin data with your website
By default, Munin generates graphs and pages under /opt/local/www/munin/data. To make this directory source of any web page, you can create a completely separate virtual host profile for your Apache instance. E.g. put something like this into a /opt/local/etc/httpd/virtualhosts/munin.conf file:
<VirtualHost *:80> ServerName munin.yourdomain.com DocumentRoot /opt/local/www/munin/data <Directory /opt/local/www/munin/data> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Adjust any part as necessary to make it work under your Accelerator envinronment. Also, you can make a very simple symlink instead, to make Munin work as a subdirectory of a site you already have running on your Accelerator, e.g.:
ln -s /opt/local/www/munin/data /home/jill/web/public/munin
If using Apache, you can use a standard .htaccess based password protection scheme to prevent unathorized access to your data.
Setting up a node
To add the packages, simply run this (as root, do a 'su -' first if you're logged in as a regular user):
pkg_add munin-node
Fix the Munin user
The package install already pre-creates the 'munin' user and group, which is used to execute tasks on the Munin server. To make it work properly on a Solaris system, he user needs to be made more real-like:
usermod -d /var/munin -s /usr/bin/bash munin cp /home/admin/.profile /var/munin chown munin:munin /var/munin/.profile passwd munin
The last line prompts for a password. You can use any - you will not be logging in as 'munin' at all, but Solaris mandates a valid password for any user that needs Cron jobs to run (and you do want that, to pick up monitoring stats unattended).
Pre-configure the node
This command probes all default node plugins and automatically enables them:
/opt/local/sbin/munin-node-configure --shell | sh
Launch the node daemon
This command executes the Munin node daemon (that listens for requests from the server instance) and forks it into background:
/opt/local/sbin/munin-node
Write a simple SMF manifest for the daemon here
<?xml version='1.0'?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <service_bundle type='manifest' name='export'> <service name='network/munin-node' type='service' version='0'> <create_default_instance enabled='true'/> <single_instance/> <dependency name='fs' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/system/filesystem/local'/> </dependency> <dependency name='net' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/network/service'/> </dependency> <exec_method name='start' type='method' exec='/opt/local/sbin/munin-node' timeout_seconds='60'> <method_context working_directory='/var/munin'> <method_credential user='root' group='munin'/> <method_environment> <envvar name='PATH' value='/usr/bin:/bin:/opt/local/bin'/> </method_environment> </method_context> </exec_method> <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'> <method_context/> </exec_method> </service> </service_bundle>
Test your node locally
To test a munin-node locally, you can open a telnet session at your command prompt:
telnet localhost 4949
It will show you that it connected successfully, e.g.:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'
# munin node at 127.0.0.1
Now you can use 'list' to give you a list of available plugins, and e.g. 'fetch cpu' to get the current CPU stats. Use 'quit' to end the session.
Configuring and installing plugins
To configure the plugins (e.g. to have any postfix_* plugin execute under the 'postfix' user in order to have access to the Postfix directories), use the munin-node file under /opt/local/etc/munin/plugin-conf.d/. See the official Munin site for help on this.
For any plugin you want to add to you node(s), store the script file under /opt/local/etc/munin/plugins and make sure the script is executable. (This is different from the default plugins which come with the binary Munin package, are stored under /opt/local/lib/munin/plugins, and are only symlinked into the live location that Munin reads from.)
Custom Plugins
add information here about custom Joyent Accelerator related plugins
Accelerator memory usage
Here's a quick plugin to track memory usage (RSS and swap) on your accelerator.
Phusion Passenger
Not Joyent-related really, but useful. Dan Manges wrote this plugin that provides a bit of passenger-related data. Another of his plugins, passenger-memory-stats, only runs on linux currently.
You'll probably have to:
- make sure the path to the passenger binaries is correct in the plugin
- make sure the munin user can run the passenger binaries, and
- make sure you're running the plugin as the munin user (in plugin-conf.d/somefilename.conf, have a [passenger_*] section with the line “user munin”.)
Disk Usage
Matthew Willman at SolutionSet sent me the following plugin modification for Munin on a Joyent Accelerator. I'll just paste the whole script in and figure you'll know what to do with it. Thank you Matt!
#!/usr/xpg4/bin/sh # -*- sh -*- # #s $Id: df.in 1415 2008-01-26 21:52:41Z matthias $ # # Script to monitor disk usage. # # Parameters understood: # # config (required) # autoconf (optional - used by munin-config) # # Environment: # warning Warning percentage, default 92 # critical Critical percentage, default 98 # # Magic markers (optional - used by munin-config and installation # scripts): # MAXLABEL=20 if [ "$1" = "autoconf" ]; then if [ `uname -s` = SunOS ]; then echo no exit 1 else echo yes exit 0 fi fi if [ "$1" = "config" ]; then echo 'graph_title Filesystem usage (in %)' echo 'graph_args --upper-limit 100 -l 0' echo 'graph_vlabel %' df -l -k | sed 1d | grep -v "//" | sort | while read i; do name=`echo $i | sed 's/[\/.-]/_/g'| awk '{ print $1 }'` printf "$name.label " echo $i | awk "{ dir=\$6 if (length(dir) <= $MAXLABEL) print dir else printf (\"...%s\n\", substr (dir, length(dir)-$M AXLABEL+4, $MAXLABEL-3)) }" echo "$name.warning ${warning:-92}" echo "$name.critical ${critical:-98}" done exit 0 fi df -l -k | sed 1d | grep -v "//" | while read i; do name=`echo $i | sed 's/[\/.-]/_/g'| awk '{ print $1 ".value " }'` printf "$name " echo $i | awk '{ print $5 }' | cut -f1 -d% done
