mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-08-12 16:55:47 +00:00
fix indentation, rename lagacy to pre09
This commit is contained in:
parent
8bfb81806d
commit
121448e72d
4 changed files with 269 additions and 269 deletions
|
@ -17,15 +17,15 @@
|
|||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config required
|
||||
# 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
|
||||
# api use 'legacy' (pre 0.9.0) or current (0.9.0+) API calls
|
||||
# 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
|
||||
# api use 'pre09' (pre 0.9.0) or 'current' (0.9.0+) API calls
|
||||
#
|
||||
# Configuration example
|
||||
#
|
||||
|
@ -45,31 +45,31 @@
|
|||
|
||||
|
||||
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
||||
exit 1;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
||||
my $category = $ENV{"category"} || "";
|
||||
print "graph_title rTorrent peer statistics\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel peers\n";
|
||||
print "graph_category filetransfer".${category}."\n";
|
||||
print "outgoing.label outgoing\n";
|
||||
print "outgoing.draw AREA\n";
|
||||
print "outgoing.info number of outgoing connections\n";
|
||||
print "incoming.label incoming\n";
|
||||
print "incoming.draw STACK\n";
|
||||
print "incoming.info number of incoming connections\n";
|
||||
print "plain.label plain text\n";
|
||||
print "plain.draw LINE2\n";
|
||||
print "plain.info number of plain text connections\n";
|
||||
print "encrypted.label encrypted\n";
|
||||
print "encrypted.draw LINE2\n";
|
||||
print "encrypted.info number of encrypted connections\n";
|
||||
print "total.label total\n";
|
||||
print "total.draw LINE2\n";
|
||||
print "total.info total number of connections\n";
|
||||
exit 0;
|
||||
my $category = $ENV{"category"} || "";
|
||||
print "graph_title rTorrent peer statistics\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel peers\n";
|
||||
print "graph_category filetransfer".${category}."\n";
|
||||
print "outgoing.label outgoing\n";
|
||||
print "outgoing.draw AREA\n";
|
||||
print "outgoing.info number of outgoing connections\n";
|
||||
print "incoming.label incoming\n";
|
||||
print "incoming.draw STACK\n";
|
||||
print "incoming.info number of incoming connections\n";
|
||||
print "plain.label plain text\n";
|
||||
print "plain.draw LINE2\n";
|
||||
print "plain.info number of plain text connections\n";
|
||||
print "encrypted.label encrypted\n";
|
||||
print "encrypted.draw LINE2\n";
|
||||
print "encrypted.info number of encrypted connections\n";
|
||||
print "total.label total\n";
|
||||
print "total.draw LINE2\n";
|
||||
print "total.info total number of connections\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
use IO::Socket;
|
||||
|
@ -78,20 +78,20 @@ my $src = $ENV{"src"} || "";
|
|||
my @sockets = split /,/, $ENV{"socket"} || "";
|
||||
my $ip = $ENV{"ip"} || "127.0.0.1";
|
||||
my @ports = split /,/, $ENV{"port"} || "";
|
||||
my $api = $ENV{"api"} || "legacy";
|
||||
my $api = $ENV{"api"} || "pre09";
|
||||
|
||||
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
||||
my $tpattern = qr/[0-9A-F]{20}/;
|
||||
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
||||
my $tpattern = qr/[0-9A-F]{20}/;
|
||||
|
||||
my $line = "";
|
||||
if ($api =~ /legacy/) {
|
||||
if ($api =~ /pre09/) {
|
||||
$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>";
|
||||
} else {
|
||||
$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>";
|
||||
}
|
||||
my $llen = length $line;
|
||||
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||
my $hlen = length $header;
|
||||
my $llen = length $line;
|
||||
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||
my $hlen = length $header;
|
||||
|
||||
my $tor = 0;
|
||||
my $tot = 0;
|
||||
|
@ -104,55 +104,55 @@ my $pla = 0;
|
|||
|
||||
|
||||
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
||||
for $socket (@sockets)
|
||||
{
|
||||
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
||||
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
||||
my $line = "${hlen}:${header},${line}";
|
||||
print SOCK $line;
|
||||
flush SOCK;
|
||||
while ( $line = <SOCK> ) {
|
||||
if ( $line =~ /$tpattern/ ) {
|
||||
$tor += 1;
|
||||
} elsif ( $line =~ /$pattern/ ) {
|
||||
$tot += 1;
|
||||
$enc += $2;
|
||||
$line = <SOCK>;
|
||||
$line =~ /$pattern/;
|
||||
$inc += $2;
|
||||
}
|
||||
$ppline = $pline;
|
||||
$pline = $line;
|
||||
}
|
||||
close (SOCK);
|
||||
$out = $out + $tot - $inc;
|
||||
$pla = $pla + $tot - $enc;
|
||||
}
|
||||
for $socket (@sockets)
|
||||
{
|
||||
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
||||
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
||||
my $line = "${hlen}:${header},${line}";
|
||||
print SOCK $line;
|
||||
flush SOCK;
|
||||
while ( $line = <SOCK> ) {
|
||||
if ( $line =~ /$tpattern/ ) {
|
||||
$tor += 1;
|
||||
} elsif ( $line =~ /$pattern/ ) {
|
||||
$tot += 1;
|
||||
$enc += $2;
|
||||
$line = <SOCK>;
|
||||
$line =~ /$pattern/;
|
||||
$inc += $2;
|
||||
}
|
||||
$ppline = $pline;
|
||||
$pline = $line;
|
||||
}
|
||||
close (SOCK);
|
||||
$out = $out + $tot - $inc;
|
||||
$pla = $pla + $tot - $enc;
|
||||
}
|
||||
} else {
|
||||
for $port (@ports)
|
||||
{
|
||||
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) );
|
||||
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) );
|
||||
my $line = "${hlen}:${header},${line}";
|
||||
print SOCK $line;
|
||||
flush SOCK;
|
||||
while ( $line = <SOCK> ) {
|
||||
if ( $line =~ /$tpattern/ ) {
|
||||
$tor += 1;
|
||||
} elsif ( $line =~ /$pattern/ ) {
|
||||
$tot += 1;
|
||||
$enc += $2;
|
||||
$line = <SOCK>;
|
||||
$line =~ /$pattern/;
|
||||
$inc += $2;
|
||||
}
|
||||
$ppline = $pline;
|
||||
$pline = $line;
|
||||
}
|
||||
close (SOCK);
|
||||
$out = $out + $tot - $inc;
|
||||
$pla = $pla + $tot - $enc;
|
||||
}
|
||||
for $port (@ports)
|
||||
{
|
||||
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname( "tcp" ) );
|
||||
connect( SOCK, sockaddr_in( $port, inet_aton( $ip ) ) );
|
||||
my $line = "${hlen}:${header},${line}";
|
||||
print SOCK $line;
|
||||
flush SOCK;
|
||||
while ( $line = <SOCK> ) {
|
||||
if ( $line =~ /$tpattern/ ) {
|
||||
$tor += 1;
|
||||
} elsif ( $line =~ /$pattern/ ) {
|
||||
$tot += 1;
|
||||
$enc += $2;
|
||||
$line = <SOCK>;
|
||||
$line =~ /$pattern/;
|
||||
$inc += $2;
|
||||
}
|
||||
$ppline = $pline;
|
||||
$pline = $line;
|
||||
}
|
||||
close (SOCK);
|
||||
$out = $out + $tot - $inc;
|
||||
$pla = $pla + $tot - $enc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue