mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Create rtom_allsessions_vol
For all sessions
This commit is contained in:
parent
acba118937
commit
f519cf3ad4
1 changed files with 112 additions and 0 deletions
112
plugins/rtorrent/rtom_allsessions_vol
Normal file
112
plugins/rtorrent/rtom_allsessions_vol
Normal file
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# xmlrpc based munin plugin for monitoring rtorrent's torrent count
|
||||
# prerequisites:
|
||||
# - rtorrent 0.7.5 or newer compiled with --with-xmlrpc-c
|
||||
# check http://libtorrent.rakshasa.no/wiki/RTorrentXMLRPCGuide for further informations
|
||||
#
|
||||
# written by Gabor Hudiczius
|
||||
# web: http://projects.cyla.homeip.net/rtwi/wiki/rTorrentOMeter
|
||||
# email: ghudiczius@gmail.com
|
||||
#
|
||||
# 0.2.0 - 080619
|
||||
# support for scgi_port and scgi_local
|
||||
# configurable via munin env variables
|
||||
# initial release
|
||||
#
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config required
|
||||
#
|
||||
#
|
||||
# Configurable variables
|
||||
#
|
||||
# src "socket" when using scgi_socket, or anything else when using scgi_port
|
||||
# socket rTorrent's rpc socket (scgi_local) - using scgi_local - needed, when "src" is set to "socket"
|
||||
# category Change graph category
|
||||
#
|
||||
# Configuration example
|
||||
#
|
||||
# [rtom_vol]
|
||||
# user username
|
||||
# env.src socket
|
||||
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc2.socket
|
||||
# env.category Sometext
|
||||
#
|
||||
#%# family=auto
|
||||
|
||||
my @views = ( "default", "started", "stopped", "complete", "incomplete" );
|
||||
|
||||
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
||||
my $category = $ENV{"category"} || "";
|
||||
print "graph_args --base 1000 -r --lower-limit 0\n";
|
||||
print "graph_title rTorrent volume\n";
|
||||
print "graph_vlabel active torrents\n";
|
||||
print "graph_category rTorrent ".${category}."\n";
|
||||
print "complete.label complete\n";
|
||||
print "complete.draw AREA\n";
|
||||
print "complete.info complete torrents\n";
|
||||
print "incomplete.label incomplete\n";
|
||||
print "incomplete.draw STACK\n";
|
||||
print "incomplete.info incomplete torrents\n";
|
||||
print "stopped.label stopped\n";
|
||||
print "stopped.draw LINE2\n";
|
||||
print "stopped.info stopped torrents\n";
|
||||
print "started.label started\n";
|
||||
print "started.draw LINE2\n";
|
||||
print "started.info started torrents\n";
|
||||
print "default.label total\n";
|
||||
print "default.draw LINE2\n";
|
||||
print "default.info all torrents\n";
|
||||
print "hashing.graph no\n";
|
||||
print "seeding.graph no\n";
|
||||
print "active.graph no\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
use IO::Socket;
|
||||
|
||||
my @sockets = split /,/, $ENV{"socket"} || "";
|
||||
my $src = $ENV{"src"} || "";
|
||||
|
||||
my $pattern = qr/<value><string>([A-Z0-9]+)<\/string><\/value>/;
|
||||
|
||||
my $line;
|
||||
my $llenmy;
|
||||
my $header;
|
||||
my $hlen;
|
||||
|
||||
my $num;
|
||||
foreach ( @views ) {
|
||||
$num = 0;
|
||||
for $socket (@sockets){
|
||||
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
||||
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 );
|
||||
connect( SOCK, sockaddr_un( $socket ) );
|
||||
}
|
||||
|
||||
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>d.multicall</methodName><params><param><value><string>${_}</string></value></param><param><value><string>d.get_hash=</string></value></param></params></methodCall>";
|
||||
$llen = length $line;
|
||||
$header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||
$hlen = length $header;
|
||||
$line = "${hlen}:${header},${line}";
|
||||
|
||||
print SOCK $line;
|
||||
flush SOCK;
|
||||
|
||||
while ( $line = <SOCK> ) {
|
||||
if ( $line =~ /$pattern/ ) {
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
close (SOCK);
|
||||
}
|
||||
print "${_}.value ${num}\n";
|
||||
}
|
||||
|
||||
exit;
|
Loading…
Add table
Add a link
Reference in a new issue