Révision 121448e7
fix indentation, rename lagacy to pre09
| plugins/rtorrent/rtom_allsessions_mem | ||
|---|---|---|
| 27 | 27 |
# ip rTorrent's ip address - using scgi_port - needed, when "src" is NOT set to "socket" |
| 28 | 28 |
# port rTorrent's scgi port (scgi_port) - using scgi_port - needed, when "src" is NOT set to "socket" |
| 29 | 29 |
# category Change graph category |
| 30 |
# api use 'legacy' (pre 0.9.0) or current (0.9.0+) API calls
|
|
| 30 |
# api use 'pre09' (pre 0.9.0) or 'current' (0.9.0+) API calls
|
|
| 31 | 31 |
# |
| 32 | 32 |
# Configuration example |
| 33 | 33 |
# |
| ... | ... | |
| 47 | 47 |
|
| 48 | 48 |
|
| 49 | 49 |
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
| 50 |
exit 1;
|
|
| 50 |
exit 1; |
|
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 | 53 |
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
| 54 |
my $category = $ENV{"category"} || "";
|
|
| 55 |
print "graph_title rTorrent memory usage\n";
|
|
| 56 |
print "graph_args --base 1024 --lower-limit 0\n";
|
|
| 57 |
print "graph_vlabel Bytes\n";
|
|
| 58 |
print "graph_category filetransfer".${category}."\n";
|
|
| 59 |
print "mem.label Memory usage\n";
|
|
| 60 |
print "mem.info Memory usage of rTorrent\n";
|
|
| 61 |
print "mem.type GAUGE\n";
|
|
| 62 |
print "mem.draw LINE2\n";
|
|
| 63 |
exit 0;
|
|
| 54 |
my $category = $ENV{"category"} || "";
|
|
| 55 |
print "graph_title rTorrent memory usage\n"; |
|
| 56 |
print "graph_args --base 1024 --lower-limit 0\n"; |
|
| 57 |
print "graph_vlabel Bytes\n"; |
|
| 58 |
print "graph_category filetransfer".${category}."\n";
|
|
| 59 |
print "mem.label Memory usage\n"; |
|
| 60 |
print "mem.info Memory usage of rTorrent\n"; |
|
| 61 |
print "mem.type GAUGE\n"; |
|
| 62 |
print "mem.draw LINE2\n"; |
|
| 63 |
exit 0; |
|
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 | 66 |
use IO::Socket; |
| ... | ... | |
| 68 | 68 |
my @sockets = split /,/, $ENV{"socket"} || "";
|
| 69 | 69 |
my $ip = $ENV{"ip"} || "127.0.0.1";
|
| 70 | 70 |
my @ports = split /,/, $ENV{"port"} || "";
|
| 71 |
my $api = $ENV{"api"} || "legacy";
|
|
| 71 |
my $api = $ENV{"api"} || "pre09";
|
|
| 72 | 72 |
|
| 73 | 73 |
my $mem = 0; |
| 74 | 74 |
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/; |
| 75 | 75 |
my $line = ""; |
| 76 |
if ($api =~ /legacy/) {
|
|
| 76 |
if ($api =~ /pre09/) {
|
|
| 77 | 77 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>get_memory_usage</methodName></methodCall>"; |
| 78 | 78 |
} else {
|
| 79 | 79 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>pieces.memory.current</methodName></methodCall>"; |
| ... | ... | |
| 83 | 83 |
my $hlen = length $header; |
| 84 | 84 |
|
| 85 | 85 |
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
| 86 |
for $socket (@sockets)
|
|
| 87 |
{
|
|
| 88 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
|
| 89 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
|
| 90 |
my $line = "${hlen}:${header},${line}";
|
|
| 91 |
print SOCK $line;
|
|
| 92 |
flush SOCK;
|
|
| 93 |
while ( $line = <SOCK> ) {
|
|
| 94 |
if ( $line =~ /$pattern/ ) {
|
|
| 95 |
$mem = $mem + $2;
|
|
| 96 |
}
|
|
| 97 |
}
|
|
| 98 |
close (SOCK);
|
|
| 99 |
}
|
|
| 86 |
for $socket (@sockets) |
|
| 87 |
{
|
|
| 88 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die; |
|
| 89 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!; |
|
| 90 |
my $line = "${hlen}:${header},${line}";
|
|
| 91 |
print SOCK $line; |
|
| 92 |
flush SOCK; |
|
| 93 |
while ( $line = <SOCK> ) {
|
|
| 94 |
if ( $line =~ /$pattern/ ) {
|
|
| 95 |
$mem = $mem + $2; |
|
| 96 |
} |
|
| 97 |
} |
|
| 98 |
close (SOCK); |
|
| 99 |
} |
|
| 100 | 100 |
} else {
|
| 101 |
for $port (@ports)
|
|
| 102 |
{
|
|
| 103 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) );
|
|
| 104 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) );
|
|
| 105 |
my $line = "${hlen}:${header},${line}";
|
|
| 106 |
print SOCK $line;
|
|
| 107 |
flush SOCK;
|
|
| 108 |
while ( $line = <SOCK> ) {
|
|
| 109 |
if ( $line =~ /$pattern/ ) {
|
|
| 110 |
$mem = $mem + $2;
|
|
| 111 |
}
|
|
| 112 |
}
|
|
| 113 |
close (SOCK);
|
|
| 114 |
}
|
|
| 101 |
for $port (@ports) |
|
| 102 |
{
|
|
| 103 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) ); |
|
| 104 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) ); |
|
| 105 |
my $line = "${hlen}:${header},${line}";
|
|
| 106 |
print SOCK $line; |
|
| 107 |
flush SOCK; |
|
| 108 |
while ( $line = <SOCK> ) {
|
|
| 109 |
if ( $line =~ /$pattern/ ) {
|
|
| 110 |
$mem = $mem + $2; |
|
| 111 |
} |
|
| 112 |
} |
|
| 113 |
close (SOCK); |
|
| 114 |
} |
|
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 | 117 |
print "mem.value ${mem}\n";
|
| plugins/rtorrent/rtom_allsessions_peers | ||
|---|---|---|
| 17 | 17 |
# |
| 18 | 18 |
# Parameters: |
| 19 | 19 |
# |
| 20 |
# config required
|
|
| 20 |
# config required
|
|
| 21 | 21 |
# |
| 22 | 22 |
# |
| 23 | 23 |
# Configurable variables |
| 24 | 24 |
# |
| 25 |
# src "socket" when using scgi_socket, or anything else when using scgi_port
|
|
| 26 |
# socket rTorrent's rpc socket (scgi_local) - using scgi_local - needed, when "src" is set to "socket"
|
|
| 27 |
# category Change graph category
|
|
| 28 |
# api use 'legacy' (pre 0.9.0) or current (0.9.0+) API calls
|
|
| 25 |
# src "socket" when using scgi_socket, or anything else when using scgi_port
|
|
| 26 |
# socket rTorrent's rpc socket (scgi_local) - using scgi_local - needed, when "src" is set to "socket"
|
|
| 27 |
# category Change graph category
|
|
| 28 |
# api use 'pre09' (pre 0.9.0) or 'current' (0.9.0+) API calls
|
|
| 29 | 29 |
# |
| 30 | 30 |
# Configuration example |
| 31 | 31 |
# |
| ... | ... | |
| 45 | 45 |
|
| 46 | 46 |
|
| 47 | 47 |
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
| 48 |
exit 1;
|
|
| 48 |
exit 1;
|
|
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
| 52 |
my $category = $ENV{"category"} || "";
|
|
| 53 |
print "graph_title rTorrent peer statistics\n";
|
|
| 54 |
print "graph_args --base 1000 --lower-limit 0\n";
|
|
| 55 |
print "graph_vlabel peers\n";
|
|
| 56 |
print "graph_category filetransfer".${category}."\n";
|
|
| 57 |
print "outgoing.label outgoing\n";
|
|
| 58 |
print "outgoing.draw AREA\n";
|
|
| 59 |
print "outgoing.info number of outgoing connections\n";
|
|
| 60 |
print "incoming.label incoming\n";
|
|
| 61 |
print "incoming.draw STACK\n";
|
|
| 62 |
print "incoming.info number of incoming connections\n";
|
|
| 63 |
print "plain.label plain text\n";
|
|
| 64 |
print "plain.draw LINE2\n";
|
|
| 65 |
print "plain.info number of plain text connections\n";
|
|
| 66 |
print "encrypted.label encrypted\n";
|
|
| 67 |
print "encrypted.draw LINE2\n";
|
|
| 68 |
print "encrypted.info number of encrypted connections\n";
|
|
| 69 |
print "total.label total\n";
|
|
| 70 |
print "total.draw LINE2\n";
|
|
| 71 |
print "total.info total number of connections\n";
|
|
| 72 |
exit 0;
|
|
| 52 |
my $category = $ENV{"category"} || "";
|
|
| 53 |
print "graph_title rTorrent peer statistics\n";
|
|
| 54 |
print "graph_args --base 1000 --lower-limit 0\n";
|
|
| 55 |
print "graph_vlabel peers\n";
|
|
| 56 |
print "graph_category filetransfer".${category}."\n";
|
|
| 57 |
print "outgoing.label outgoing\n";
|
|
| 58 |
print "outgoing.draw AREA\n";
|
|
| 59 |
print "outgoing.info number of outgoing connections\n";
|
|
| 60 |
print "incoming.label incoming\n";
|
|
| 61 |
print "incoming.draw STACK\n";
|
|
| 62 |
print "incoming.info number of incoming connections\n";
|
|
| 63 |
print "plain.label plain text\n";
|
|
| 64 |
print "plain.draw LINE2\n";
|
|
| 65 |
print "plain.info number of plain text connections\n";
|
|
| 66 |
print "encrypted.label encrypted\n";
|
|
| 67 |
print "encrypted.draw LINE2\n";
|
|
| 68 |
print "encrypted.info number of encrypted connections\n";
|
|
| 69 |
print "total.label total\n";
|
|
| 70 |
print "total.draw LINE2\n";
|
|
| 71 |
print "total.info total number of connections\n";
|
|
| 72 |
exit 0;
|
|
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 | 75 |
use IO::Socket; |
| ... | ... | |
| 78 | 78 |
my @sockets = split /,/, $ENV{"socket"} || "";
|
| 79 | 79 |
my $ip = $ENV{"ip"} || "127.0.0.1";
|
| 80 | 80 |
my @ports = split /,/, $ENV{"port"} || "";
|
| 81 |
my $api = $ENV{"api"} || "legacy";
|
|
| 81 |
my $api = $ENV{"api"} || "pre09";
|
|
| 82 | 82 |
|
| 83 |
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
|
| 84 |
my $tpattern = qr/[0-9A-F]{20}/;
|
|
| 83 |
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
|
| 84 |
my $tpattern = qr/[0-9A-F]{20}/;
|
|
| 85 | 85 |
|
| 86 | 86 |
my $line = ""; |
| 87 |
if ($api =~ /legacy/) {
|
|
| 87 |
if ($api =~ /pre09/) {
|
|
| 88 | 88 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>d.multicall</methodName><params><param><value><string>main</string></value></param><param><value><string>d.get_hash=</string></value></param><param><value><string>p.multicall=,p.is_encrypted=,p.is_incoming=</string></value></param></params></methodCall>"; |
| 89 | 89 |
} else {
|
| 90 | 90 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>d.multicall2</methodName><params><param><value><string></string></value></param><param><value><string>main</string></value></param><param><value><string>d.hash=</string></value></param><param><value><string>p.multicall=,p.is_encrypted=,p.is_incoming=</string></value></param></params></methodCall>"; |
| 91 | 91 |
} |
| 92 |
my $llen = length $line;
|
|
| 93 |
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
|
| 94 |
my $hlen = length $header;
|
|
| 92 |
my $llen = length $line;
|
|
| 93 |
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
|
| 94 |
my $hlen = length $header;
|
|
| 95 | 95 |
|
| 96 | 96 |
my $tor = 0; |
| 97 | 97 |
my $tot = 0; |
| ... | ... | |
| 104 | 104 |
|
| 105 | 105 |
|
| 106 | 106 |
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
| 107 |
for $socket (@sockets)
|
|
| 108 |
{
|
|
| 109 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
|
| 110 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
|
| 111 |
my $line = "${hlen}:${header},${line}";
|
|
| 112 |
print SOCK $line;
|
|
| 113 |
flush SOCK;
|
|
| 114 |
while ( $line = <SOCK> ) {
|
|
| 115 |
if ( $line =~ /$tpattern/ ) {
|
|
| 116 |
$tor += 1;
|
|
| 117 |
} elsif ( $line =~ /$pattern/ ) {
|
|
| 118 |
$tot += 1;
|
|
| 119 |
$enc += $2;
|
|
| 120 |
$line = <SOCK>;
|
|
| 121 |
$line =~ /$pattern/;
|
|
| 122 |
$inc += $2;
|
|
| 123 |
}
|
|
| 124 |
$ppline = $pline;
|
|
| 125 |
$pline = $line;
|
|
| 126 |
}
|
|
| 127 |
close (SOCK);
|
|
| 128 |
$out = $out + $tot - $inc;
|
|
| 129 |
$pla = $pla + $tot - $enc;
|
|
| 130 |
}
|
|
| 107 |
for $socket (@sockets) |
|
| 108 |
{
|
|
| 109 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die; |
|
| 110 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!; |
|
| 111 |
my $line = "${hlen}:${header},${line}";
|
|
| 112 |
print SOCK $line; |
|
| 113 |
flush SOCK; |
|
| 114 |
while ( $line = <SOCK> ) {
|
|
| 115 |
if ( $line =~ /$tpattern/ ) {
|
|
| 116 |
$tor += 1;
|
|
| 117 |
} elsif ( $line =~ /$pattern/ ) {
|
|
| 118 |
$tot += 1;
|
|
| 119 |
$enc += $2;
|
|
| 120 |
$line = <SOCK>;
|
|
| 121 |
$line =~ /$pattern/;
|
|
| 122 |
$inc += $2;
|
|
| 123 |
}
|
|
| 124 |
$ppline = $pline;
|
|
| 125 |
$pline = $line;
|
|
| 126 |
}
|
|
| 127 |
close (SOCK);
|
|
| 128 |
$out = $out + $tot - $inc;
|
|
| 129 |
$pla = $pla + $tot - $enc;
|
|
| 130 |
} |
|
| 131 | 131 |
} else {
|
| 132 |
for $port (@ports)
|
|
| 133 |
{
|
|
| 134 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) );
|
|
| 135 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) );
|
|
| 136 |
my $line = "${hlen}:${header},${line}";
|
|
| 137 |
print SOCK $line;
|
|
| 138 |
flush SOCK;
|
|
| 139 |
while ( $line = <SOCK> ) {
|
|
| 140 |
if ( $line =~ /$tpattern/ ) {
|
|
| 141 |
$tor += 1;
|
|
| 142 |
} elsif ( $line =~ /$pattern/ ) {
|
|
| 143 |
$tot += 1;
|
|
| 144 |
$enc += $2;
|
|
| 145 |
$line = <SOCK>;
|
|
| 146 |
$line =~ /$pattern/;
|
|
| 147 |
$inc += $2;
|
|
| 148 |
}
|
|
| 149 |
$ppline = $pline;
|
|
| 150 |
$pline = $line;
|
|
| 151 |
}
|
|
| 152 |
close (SOCK);
|
|
| 153 |
$out = $out + $tot - $inc;
|
|
| 154 |
$pla = $pla + $tot - $enc;
|
|
| 155 |
}
|
|
| 132 |
for $port (@ports) |
|
| 133 |
{
|
|
| 134 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) ); |
|
| 135 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) ); |
|
| 136 |
my $line = "${hlen}:${header},${line}";
|
|
| 137 |
print SOCK $line; |
|
| 138 |
flush SOCK; |
|
| 139 |
while ( $line = <SOCK> ) {
|
|
| 140 |
if ( $line =~ /$tpattern/ ) {
|
|
| 141 |
$tor += 1;
|
|
| 142 |
} elsif ( $line =~ /$pattern/ ) {
|
|
| 143 |
$tot += 1;
|
|
| 144 |
$enc += $2;
|
|
| 145 |
$line = <SOCK>;
|
|
| 146 |
$line =~ /$pattern/;
|
|
| 147 |
$inc += $2;
|
|
| 148 |
}
|
|
| 149 |
$ppline = $pline;
|
|
| 150 |
$pline = $line;
|
|
| 151 |
}
|
|
| 152 |
close (SOCK);
|
|
| 153 |
$out = $out + $tot - $inc;
|
|
| 154 |
$pla = $pla + $tot - $enc;
|
|
| 155 |
} |
|
| 156 | 156 |
} |
| 157 | 157 |
|
| 158 | 158 |
|
| plugins/rtorrent/rtom_allsessions_spdd | ||
|---|---|---|
| 36 | 36 |
# src "socket" when using scgi_socket, or anything else when using scgi_port |
| 37 | 37 |
# socket rTorrent's rpc socket (scgi_local) - using scgi_local - needed, when "src" is set to "socket" |
| 38 | 38 |
# diff "yes" for using bps for upload and Bps for download, or anything else for using Bps for both |
| 39 |
# api use 'legacy' (pre 0.9.0) or current (0.9.0+) API calls
|
|
| 39 |
# api use 'pre09' (pre 0.9.0) or 'current' (0.9.0+) API calls
|
|
| 40 | 40 |
# |
| 41 | 41 |
# |
| 42 | 42 |
# Configuration example |
| ... | ... | |
| 46 | 46 |
# env.src socket |
| 47 | 47 |
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc.socket |
| 48 | 48 |
# env.category Category |
| 49 |
# env.api current
|
|
| 49 |
# env.api pre09
|
|
| 50 | 50 |
# |
| 51 | 51 |
# [rtom_allsessions_*] |
| 52 | 52 |
# user username |
| ... | ... | |
| 57 | 57 |
|
| 58 | 58 |
|
| 59 | 59 |
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
| 60 |
exit 1;
|
|
| 60 |
exit 1; |
|
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 | 63 |
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
| 64 |
my $diff = $ENV{"diff"} || "";
|
|
| 65 |
my $category = $ENV{"category"} || "";
|
|
| 66 |
print "graph_order down up\n";
|
|
| 67 |
print "graph_title rTorrent speeds\n";
|
|
| 68 |
print "graph_args --base 1024\n";
|
|
| 69 |
print "graph_vlabel Bytes per \${graph_period}\n";
|
|
| 70 |
print "graph_category filetransfer".${category}."\n";
|
|
| 71 |
print "down.label Download B/s\n";
|
|
| 72 |
print "down.info Download speed in Bytes per seconds\n";
|
|
| 73 |
print "down.type DERIVE\n";
|
|
| 74 |
print "down.min 0\n";
|
|
| 75 |
print "down.draw AREA\n";
|
|
| 76 |
if ( ( defined $diff ) && ( $diff eq "yes" ) ) {
|
|
| 77 |
print "up.label Upload b/s\n";
|
|
| 78 |
print "up.info Upload speed in bits per seconds\n";
|
|
| 79 |
print "up.cdef up,8,*\n";
|
|
| 80 |
} else {
|
|
| 81 |
print "up.label Upload B/s\n";
|
|
| 82 |
print "up.info Upload speed in Bytes per seconds\n";
|
|
| 83 |
}
|
|
| 84 |
print "up.type DERIVE\n";
|
|
| 85 |
print "up.min 0\n";
|
|
| 86 |
print "up.draw LINE2\n";
|
|
| 87 |
exit 0;
|
|
| 64 |
my $diff = $ENV{"diff"} || "";
|
|
| 65 |
my $category = $ENV{"category"} || "";
|
|
| 66 |
print "graph_order down up\n"; |
|
| 67 |
print "graph_title rTorrent speeds\n"; |
|
| 68 |
print "graph_args --base 1024\n"; |
|
| 69 |
print "graph_vlabel Bytes per \${graph_period}\n";
|
|
| 70 |
print "graph_category filetransfer".${category}."\n";
|
|
| 71 |
print "down.label Download B/s\n"; |
|
| 72 |
print "down.info Download speed in Bytes per seconds\n"; |
|
| 73 |
print "down.type DERIVE\n"; |
|
| 74 |
print "down.min 0\n"; |
|
| 75 |
print "down.draw AREA\n"; |
|
| 76 |
if ( ( defined $diff ) && ( $diff eq "yes" ) ) {
|
|
| 77 |
print "up.label Upload b/s\n"; |
|
| 78 |
print "up.info Upload speed in bits per seconds\n"; |
|
| 79 |
print "up.cdef up,8,*\n"; |
|
| 80 |
} else {
|
|
| 81 |
print "up.label Upload B/s\n"; |
|
| 82 |
print "up.info Upload speed in Bytes per seconds\n"; |
|
| 83 |
} |
|
| 84 |
print "up.type DERIVE\n"; |
|
| 85 |
print "up.min 0\n"; |
|
| 86 |
print "up.draw LINE2\n"; |
|
| 87 |
exit 0; |
|
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 | 90 |
use IO::Socket; |
| ... | ... | |
| 92 | 92 |
my @sockets = split /,/, $ENV{"socket"} || "";
|
| 93 | 93 |
my $ip = $ENV{"ip"} || "127.0.0.1";
|
| 94 | 94 |
my @ports = split /,/, $ENV{"port"} || "";
|
| 95 |
my $api = $ENV{"api"} || "legacy";
|
|
| 95 |
my $api = $ENV{"api"} || "pre09";
|
|
| 96 | 96 |
|
| 97 | 97 |
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>([-]{0,1}\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
| 98 | 98 |
my $line = ""; |
| 99 |
if ($api =~ /legacy/) {
|
|
| 99 |
if ($api =~ /pre09/) {
|
|
| 100 | 100 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>get_up_total</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>get_down_total</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>get_upload_rate</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>get_download_rate</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value></data></array></value></param></params></methodCall>"; |
| 101 | 101 |
} else {
|
| 102 | 102 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>throttle.global_up.total</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>throttle.global_down.total</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>throttle.global_up.max_rate</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>throttle.global_down.max_rate</string></value></member><member><name>params</name><value><array><data/></array></value></member></struct></value></data></array></value></param></params></methodCall>"; |
| ... | ... | |
| 110 | 110 |
my $down = -1; |
| 111 | 111 |
|
| 112 | 112 |
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
| 113 |
for $socket (@sockets)
|
|
| 114 |
{
|
|
| 115 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
|
| 116 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
|
| 117 |
my $line = "${hlen}:${header},${line}";
|
|
| 118 |
print SOCK $line;
|
|
| 119 |
flush SOCK;
|
|
| 120 |
my $up_tmp = -1;
|
|
| 121 |
my $down_tmp = -1;
|
|
| 122 |
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 123 |
if ( $line =~ /$pattern/ ) {
|
|
| 124 |
$up_tmp = $2;
|
|
| 125 |
}
|
|
| 126 |
}
|
|
| 127 |
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 128 |
if ( $line =~ /$pattern/ ) {
|
|
| 129 |
$down_tmp = $2;
|
|
| 130 |
}
|
|
| 131 |
}
|
|
| 132 |
close (SOCK);
|
|
| 133 |
$up = $up + $up_tmp;
|
|
| 134 |
$down = $down + $down_tmp;
|
|
| 135 |
}
|
|
| 113 |
for $socket (@sockets) |
|
| 114 |
{
|
|
| 115 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die; |
|
| 116 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!; |
|
| 117 |
my $line = "${hlen}:${header},${line}";
|
|
| 118 |
print SOCK $line; |
|
| 119 |
flush SOCK; |
|
| 120 |
my $up_tmp = -1; |
|
| 121 |
my $down_tmp = -1; |
|
| 122 |
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 123 |
if ( $line =~ /$pattern/ ) {
|
|
| 124 |
$up_tmp = $2; |
|
| 125 |
} |
|
| 126 |
} |
|
| 127 |
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 128 |
if ( $line =~ /$pattern/ ) {
|
|
| 129 |
$down_tmp = $2; |
|
| 130 |
} |
|
| 131 |
} |
|
| 132 |
close (SOCK); |
|
| 133 |
$up = $up + $up_tmp; |
|
| 134 |
$down = $down + $down_tmp; |
|
| 135 |
} |
|
| 136 | 136 |
} else {
|
| 137 |
for $port (@ports)
|
|
| 138 |
{
|
|
| 139 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) );
|
|
| 140 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) );
|
|
| 141 |
my $line = "${hlen}:${header},${line}";
|
|
| 142 |
print SOCK $line;
|
|
| 143 |
flush SOCK;
|
|
| 144 |
my $up_tmp = -1;
|
|
| 145 |
my $down_tmp = -1;
|
|
| 146 |
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 147 |
if ( $line =~ /$pattern/ ) {
|
|
| 148 |
$up_tmp = $2;
|
|
| 149 |
}
|
|
| 150 |
}
|
|
| 151 |
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 152 |
if ( $line =~ /$pattern/ ) {
|
|
| 153 |
$down_tmp = $2;
|
|
| 154 |
}
|
|
| 155 |
}
|
|
| 156 |
close (SOCK);
|
|
| 157 |
$up = $up + $up_tmp;
|
|
| 158 |
$down = $down + $down_tmp;
|
|
| 159 |
}
|
|
| 137 |
for $port (@ports) |
|
| 138 |
{
|
|
| 139 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) ); |
|
| 140 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) ); |
|
| 141 |
my $line = "${hlen}:${header},${line}";
|
|
| 142 |
print SOCK $line; |
|
| 143 |
flush SOCK; |
|
| 144 |
my $up_tmp = -1; |
|
| 145 |
my $down_tmp = -1; |
|
| 146 |
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 147 |
if ( $line =~ /$pattern/ ) {
|
|
| 148 |
$up_tmp = $2; |
|
| 149 |
} |
|
| 150 |
} |
|
| 151 |
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
| 152 |
if ( $line =~ /$pattern/ ) {
|
|
| 153 |
$down_tmp = $2; |
|
| 154 |
} |
|
| 155 |
} |
|
| 156 |
close (SOCK); |
|
| 157 |
$up = $up + $up_tmp; |
|
| 158 |
$down = $down + $down_tmp; |
|
| 159 |
} |
|
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
|
| plugins/rtorrent/rtom_allsessions_vol | ||
|---|---|---|
| 3 | 3 |
# xmlrpc based munin plugin for monitoring rtorrent's torrent count |
| 4 | 4 |
# prerequisites: |
| 5 | 5 |
# - rtorrent 0.7.5 or newer compiled with --with-xmlrpc-c |
| 6 |
# check http://libtorrent.rakshasa.no/wiki/RTorrentXMLRPCGuide for further informations
|
|
| 6 |
# check http://libtorrent.rakshasa.no/wiki/RTorrentXMLRPCGuide for further information |
|
| 7 | 7 |
# |
| 8 | 8 |
# written by Gabor Hudiczius |
| 9 | 9 |
# web: http://projects.cyla.homeip.net/rtwi/wiki/rTorrentOMeter |
| ... | ... | |
| 25 | 25 |
# src "socket" when using scgi_socket, or anything else when using scgi_port |
| 26 | 26 |
# socket rTorrent's rpc socket (scgi_local) - using scgi_local - needed, when "src" is set to "socket" |
| 27 | 27 |
# category Change graph category |
| 28 |
# api use 'legacy' (pre 0.9.0) or current (0.9.0+) API calls
|
|
| 28 |
# api use 'pre09' (pre 0.9.0) or 'current' (0.9.0+) API calls
|
|
| 29 | 29 |
# |
| 30 | 30 |
# Configuration example |
| 31 | 31 |
# |
| ... | ... | |
| 40 | 40 |
# user username |
| 41 | 41 |
# env.port 5000,5001,5002,5003 |
| 42 | 42 |
# env.category Category |
| 43 |
# env.api legacy
|
|
| 43 |
# env.api pre09
|
|
| 44 | 44 |
# |
| 45 | 45 |
#%# family=auto |
| 46 | 46 |
|
| 47 | 47 |
my @views = ( "default", "started", "stopped", "complete", "incomplete" ); |
| 48 | 48 |
|
| 49 | 49 |
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
| 50 |
exit 1;
|
|
| 50 |
exit 1; |
|
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 | 53 |
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
| 54 |
my $category = $ENV{"category"} || "";
|
|
| 55 |
print "graph_args --base 1000 -r --lower-limit 0\n";
|
|
| 56 |
print "graph_title rTorrent volume\n";
|
|
| 57 |
print "graph_vlabel active torrents\n";
|
|
| 58 |
print "graph_category torrent ".${category}."\n";
|
|
| 59 |
print "complete.label complete\n";
|
|
| 60 |
print "complete.draw AREA\n";
|
|
| 61 |
print "complete.info complete torrents\n";
|
|
| 62 |
print "incomplete.label incomplete\n";
|
|
| 63 |
print "incomplete.draw STACK\n";
|
|
| 64 |
print "incomplete.info incomplete torrents\n";
|
|
| 65 |
print "stopped.label stopped\n";
|
|
| 66 |
print "stopped.draw LINE2\n";
|
|
| 67 |
print "stopped.info stopped torrents\n";
|
|
| 68 |
print "started.label started\n";
|
|
| 69 |
print "started.draw LINE2\n";
|
|
| 70 |
print "started.info started torrents\n";
|
|
| 71 |
print "default.label total\n";
|
|
| 72 |
print "default.draw LINE2\n";
|
|
| 73 |
print "default.info all torrents\n";
|
|
| 74 |
print "hashing.graph no\n";
|
|
| 75 |
print "seeding.graph no\n";
|
|
| 76 |
print "active.graph no\n";
|
|
| 77 |
exit 0;
|
|
| 54 |
my $category = $ENV{"category"} || "";
|
|
| 55 |
print "graph_args --base 1000 -r --lower-limit 0\n"; |
|
| 56 |
print "graph_title rTorrent volume\n"; |
|
| 57 |
print "graph_vlabel active torrents\n"; |
|
| 58 |
print "graph_category torrent ".${category}."\n";
|
|
| 59 |
print "complete.label complete\n"; |
|
| 60 |
print "complete.draw AREA\n"; |
|
| 61 |
print "complete.info complete torrents\n"; |
|
| 62 |
print "incomplete.label incomplete\n"; |
|
| 63 |
print "incomplete.draw STACK\n"; |
|
| 64 |
print "incomplete.info incomplete torrents\n"; |
|
| 65 |
print "stopped.label stopped\n"; |
|
| 66 |
print "stopped.draw LINE2\n"; |
|
| 67 |
print "stopped.info stopped torrents\n"; |
|
| 68 |
print "started.label started\n"; |
|
| 69 |
print "started.draw LINE2\n"; |
|
| 70 |
print "started.info started torrents\n"; |
|
| 71 |
print "default.label total\n"; |
|
| 72 |
print "default.draw LINE2\n"; |
|
| 73 |
print "default.info all torrents\n"; |
|
| 74 |
print "hashing.graph no\n"; |
|
| 75 |
print "seeding.graph no\n"; |
|
| 76 |
print "active.graph no\n"; |
|
| 77 |
exit 0; |
|
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 | 80 |
use IO::Socket; |
| ... | ... | |
| 83 | 83 |
my @sockets = split /,/, $ENV{"socket"} || "";
|
| 84 | 84 |
my $ip = $ENV{"ip"} || "127.0.0.1";
|
| 85 | 85 |
my @ports = split /,/, $ENV{"port"} || "";
|
| 86 |
my $api = $ENV{"api"} || "legacy";
|
|
| 86 |
my $api = $ENV{"api"} || "pre09";
|
|
| 87 | 87 |
|
| 88 | 88 |
my $pattern = qr/<value><string>([A-Z0-9]+)<\/string><\/value>/; |
| 89 | 89 |
|
| 90 | 90 |
foreach ( @views ) {
|
| 91 |
my $num = 0;
|
|
| 92 |
my $line = "";
|
|
| 93 |
if ($api =~ /legacy/) {
|
|
| 94 |
$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>";
|
|
| 95 |
} else {
|
|
| 96 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>d.multicall2</methodName><params><param><value><string></string></value></param><param><value><string>${_}</string></value></param><param><value><string>d.hash=</string></value></param></params></methodCall>";
|
|
| 97 |
}
|
|
| 98 |
my $llen = length $line;
|
|
| 99 |
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
|
| 100 |
my $hlen = length $header;
|
|
| 91 |
my $num = 0; |
|
| 92 |
my $line = ""; |
|
| 93 |
if ($api =~ /pre09/) {
|
|
| 94 |
$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>";
|
|
| 95 |
} else {
|
|
| 96 |
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>d.multicall2</methodName><params><param><value><string></string></value></param><param><value><string>${_}</string></value></param><param><value><string>d.hash=</string></value></param></params></methodCall>";
|
|
| 97 |
} |
|
| 98 |
my $llen = length $line; |
|
| 99 |
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
|
| 100 |
my $hlen = length $header; |
|
| 101 | 101 |
|
| 102 |
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
|
| 103 |
for $socket (@sockets) |
|
| 104 |
{
|
|
| 105 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die; |
|
| 106 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!; |
|
| 107 |
my $line = "${hlen}:${header},${line}";
|
|
| 108 |
print SOCK $line; |
|
| 109 |
flush SOCK; |
|
| 110 |
while ( $line = <SOCK> ) {
|
|
| 111 |
if ( $line =~ /$pattern/ ) {
|
|
| 112 |
$num++; |
|
| 113 |
} |
|
| 114 |
} |
|
| 115 |
close (SOCK); |
|
| 116 |
} |
|
| 117 |
} else {
|
|
| 118 |
for $port (@ports) |
|
| 119 |
{
|
|
| 120 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) ); |
|
| 121 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) ); |
|
| 122 |
my $line = "${hlen}:${header},${line}";
|
|
| 123 |
print SOCK $line; |
|
| 124 |
flush SOCK; |
|
| 125 |
while ( $line = <SOCK> ) {
|
|
| 126 |
if ( $line =~ /$pattern/ ) {
|
|
| 127 |
$num++; |
|
| 128 |
} |
|
| 129 |
} |
|
| 130 |
close (SOCK); |
|
| 131 |
} |
|
| 102 |
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
|
| 103 |
for $socket (@sockets) |
|
| 104 |
{
|
|
| 105 |
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die; |
|
| 106 |
connect( SOCK, sockaddr_un( $socket ) ) or die $!; |
|
| 107 |
my $line = "${hlen}:${header},${line}";
|
|
| 108 |
print SOCK $line; |
|
| 109 |
flush SOCK; |
|
| 110 |
while ( $line = <SOCK> ) {
|
|
| 111 |
if ( $line =~ /$pattern/ ) {
|
|
| 112 |
$num++; |
|
| 113 |
} |
|
| 114 |
} |
|
| 115 |
close (SOCK); |
|
| 116 |
} |
|
| 117 |
} else {
|
|
| 118 |
for $port (@ports) |
|
| 119 |
{
|
|
| 120 |
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) ); |
|
| 121 |
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) ); |
|
| 122 |
my $line = "${hlen}:${header},${line}";
|
|
| 123 |
print SOCK $line; |
|
| 124 |
flush SOCK; |
|
| 125 |
while ( $line = <SOCK> ) {
|
|
| 126 |
if ( $line =~ /$pattern/ ) {
|
|
| 127 |
$num++; |
|
| 132 | 128 |
} |
| 133 |
print "${_}.value ${num}\n";
|
|
| 129 |
} |
|
| 130 |
close (SOCK); |
|
| 131 |
} |
|
| 132 |
} |
|
| 133 |
print "${_}.value ${num}\n";
|
|
| 134 | 134 |
} |
| 135 | 135 |
|
| 136 | 136 |
exit; |
Formats disponibles : Unified diff