transmission-daemon graphs with munin

Discussion of Transmission that doesn't fit in the other categories
Post Reply
ajf88

transmission-daemon graphs with munin

Post by ajf88 »

Hi all,

This afternoon I was messing around with munin (kind of like nagios, a tool for making various graphs about a system). This guide was pretty helpful for setting it up: http://waste.mandragor.org/munin_tutori ... node_setup

It was very straightforward to make a transmission-daemon plugin for munin. This is an early prototype which is very basic, but you'll get the idea. I might make it into something more robust and with more data when I have more free time, or maybe this will spark someone else's interest to do it. :)

It's a very basic shell script which either provides config data for the plugin, or will use lynx to make the request and then pipe it into a PHP script (this is the simplest way I could think of doing it, but I'd rather use a single python/perl script) which then totals up the download rates and outputs them to munin. Put these files in /etc/munin/plugins (on ubuntu at least) and make them executable.

/etc/munin/plugins/transmission (the lynx command will need changing)

Code: Select all

#!/bin/sh

case $1 in
   config)
        cat <<'EOM'
graph_title Transmission up/down rate
graph_vlabel Rate (KB/s)
graph_category Transmission
downRate.label Download rate
upRate.label Upload rate
EOM
        exit 0;;
esac

echo '{"method":"torrent-get","tag":1,"arguments":{"fields":["rateUpload","rateDownload"]}}' | lynx -dump -post_data -auth=alan:k5uc8svb http://localhost:9091/transmission/rpc | php /etc/munin/plugins/transmission-parser.php
/etc/munin/plugins/transmission-parser.php

Code: Select all

<?php
  $fd = fopen("php://stdin", "r");

  $jsonStr = "";
  while (!feof($fd)) {
    $jsonStr .= fread($fd, 1024);
  }
  fclose($fd);

$json = json_decode($jsonStr, true);
$totalDown = 0;
$totalUp = 0;
foreach($json['arguments']['torrents'] as $torrent)
{
        $totalDown += $torrent['rateDownload']/1024;
        $totalUp += $torrent['rateUpload']/1024;
}
echo "downRate.value ".round($totalDown,2)."\n";
echo "upRate.value ".round($totalUp,2)."\n";
?>
Let me know if anyone uses or improves this. I might post a generated graph when it's had time to look interesting.
eztrans
Posts: 18
Joined: Fri Dec 19, 2008 2:30 am

Re: transmission-daemon graphs with munin

Post by eztrans »

For another go at graphing the data, refer to:

http://forum.transmissionbt.com/viewtop ... 300#p34300

It's working for me well enough.

eztrans
Adrien
Posts: 1
Joined: Sun Aug 02, 2009 1:15 pm

Re: transmission-daemon graphs with munin

Post by Adrien »

Hi,

It seems that your plugin for munin doesn't work with the version 1.72 of transmission-daemon…

I have adapt your plugin to use the transmission-remote command to retrieve the upload and download rates, instead of using php and lynx:

Code: Select all

#!/bin/sh

case $1 in
   config)
        cat <<'EOM'
graph_title Transmission up/down rate
graph_vlabel Rate (KB/s)
graph_category Transmission
downRate.label Download rate
upRate.label Upload rate
EOM
        exit 0;;
esac

echo '{"method":"torrent-get","tag":1,"arguments":{"fields":["rateUpload","rateDownload"]}}' | transmission-remote -n login:password -l |grep Sum |awk '{print "downRate.value "$(NF)"\nupRate.value "$(NF-1)}'
Cheers,

Adrien
Post Reply