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
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";
?>