Munin plugins for Gitorious

45 views
Skip to first unread message

Marius Mårnes Mathiesen

unread,
Nov 1, 2012, 9:17:47 AM11/1/12
to other
Hi all,
I just started work on a set of Munin plugins for Gitorious, which is
something we'll be using on the new servers we're setting up on
gitorious.org.

I'm creating it as a gem, and it's already possible to install an
early version on your server, using `gem install
gitorious-munin-plugins`. This will result in a single binary
`gitorious-munin-plugin` provides a CLI for working with
the plugins:

- list available plugins and which have been "installed" on your
server
- "Install" new plugins
- "Uninstall" plugins that have been installed

The gitorious-munin-plugin is also the actual binary that you
symlink into /etc/munin/plugins on your server, and it will check
which name it was called as to load the actual plugin code from inside
the gem. You don't need to think too much about this, however, just
use the binary to install and uninstall the plugins. But if you want
to contribute your own plugins, this information will probably save
you some wtf's.

Assumptions
-----------
This gem assumes your Munin plugins are installed in
/etc/munin/plugins - YMMW.

Furthermore, in order to use the plugin you will need to create
/etc/gitorious.conf, which will need to contain at least:

GITORIOUS_HOME=/where/you/installed/gitorious

Furthermore, you may define RAILS_ENV in that file if you're not
running with the default ("production").

Based on this single source of information, there's infrastructure in
the library to load the Mysql parameters from your database.yml file
in order to query the database.

Report types
------------
We'll be migrating many more plugins, but at the time being there is
one plugin for SSH keys and one for users.

Source
------
If you use Munin with Gitorious, we'd love to include your reports in
the library. The source is at

https://gitorious.org/gitorious/gitorious-munin-plugins

and any files inside lib/gitorious-munin-plugins/plugins in the source
are made available as plugins. Have a look at

https://gitorious.org/gitorious/gitorious-munin-plugins/blobs/master/lib/gitorious-munin-plugins/plugins/gitorious_users.rb

to see the code for the users plugin. It's really very simple.

Looking forward to your contributions!

Cheers,
- Marius

Daniel Pfeilsticker

unread,
Feb 6, 2014, 5:37:13 AM2/6/14
to gito...@googlegroups.com, zmall...@zmalltalker.com
installed the plugins into an new installed v 3.0 gitorious but the plugins are not working

found this /etc/gitorious.conf after the installation:
GITORIOUS_HOME=/var/www/gitorious
RAILS_ENV=production
PATH=/opt/ruby-enterprise/bin:$PATH
export GITORIOUS_HOME
export RAILS_ENV

obviously not made for v 3.0, so changed to:
GITORIOUS_HOME=/var/www/gitorious/app/
RAILS_ENV=production
PATH=/opt/rubies/ruby-1.9.3-p484/bin:$PATH
export GITORIOUS_HOME
export RAILS_ENV


munin-run gitorious_clones config
is working as expected, but munin-run gitorious_clones:

/opt/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/gems/gitorious-munin-plugins-0.10.0/lib/gitorious-munin-plugins/config.rb:22:in `database_yaml': uninitialized constant GitoriousMuninPlugins::Config::NotFound (NameError)
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/gems/gitorious-munin-plugins-0.10.0/lib/gitorious-munin-plugins/database.rb:12:in `load_database_configuration'

...


/var/www/gitorious/app/config/database.yml is configured (else gitorious would not run...)

Similar error messages for:
gitorious_disk_usage, gitorious_projects, gitorious_repositories, gitorious_ssh_keys, gitorious_users,

No output for:
gitorious_poller_usage, gitorious_sphinx


munin-run git_proxy
/var/www/gitorious/run/git-proxy-1.pid not found

find /var/www/gitorious/ -name "*.pid"
/var/www/gitorious/app/log/git-daemons.pid
/var/www/gitorious/app/log/production.sphinx.pid
/var/www/gitorious/app/tmp/pids/resque-worker1.pid
/var/www/gitorious/app/tmp/pids/unicorn.pid

So i wrote this simple shell-script-plugin:

#!/bin/bash

## run as root / setup
## echo '[gitorious-munin-status]' >> /etc/munin/plugin-conf.d/munin-node
## echo 'user root' >> /etc/munin/plugin-conf.d/munin-node

checks=('Unicorn' 'Resque' 'Nginx' 'Git-daemons' 'Sphinx' 'Memcached' 'SSH-daemon' 'Mysqld')

case $1 in
config)
echo "graph_title Gitorious health-check"
# echo "graph_vlabel"
echo "graph_category gitorious"
echo "graph_info 1 = running/ok"

echo "gitorious_unicorn.label gitorious_unicorn"
echo "gitorious_unicorn.critical 0.5:"
for check in "${checks[@]}" ; do
echo "$check.label $check"
echo "$check.critical 0.5:"
done
exit 0;;
esac

## gitorious_unicorn:
gitorious_unicorn=`/etc/init.d/gitorious-unicorn status`
if echo "$gitorious_unicorn" | grep "OK" 1>/dev/null ; then
echo "gitorious_unicorn.value 1"
else
echo "gitorious_unicorn.value 0"
fi

## gitorious_status
gitorious_status=`/usr/bin/gitorious_status`
for check in "${checks[@]}" ; do
if echo "$gitorious_status" | grep "$check" | grep "UP" 1>/dev/null ; then
echo "$check.value 1"
else
echo "$check.value 0"
fi
done

exit 0

Reply all
Reply to author
Forward
0 new messages