mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Add IP/Port
This commit is contained in:
parent
80dcbf7231
commit
fa1298bfde
0
plugins/rtorrent/rtom_allsessions_mem
Normal file → Executable file
0
plugins/rtorrent/rtom_allsessions_mem
Normal file → Executable file
99
plugins/rtorrent/rtom_allsessions_peers
Normal file → Executable file
99
plugins/rtorrent/rtom_allsessions_peers
Normal file → Executable file
@ -28,11 +28,16 @@
|
|||||||
#
|
#
|
||||||
# Configuration example
|
# Configuration example
|
||||||
#
|
#
|
||||||
# [rtom_peers]
|
# [rtom_allsessions_*]
|
||||||
# user username
|
# user username
|
||||||
# env.src socket
|
# env.src socket
|
||||||
# env.socket /home/usernametorrent/.socket/rpc.socket,/home/usernametorrent/.socket/rpc2.socket
|
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc.socket
|
||||||
# env.category Category
|
# env.category Category
|
||||||
|
#
|
||||||
|
# [rtom_allsessions_*]
|
||||||
|
# user username
|
||||||
|
# env.port 5000,5001,5002,5003
|
||||||
|
# env.category Category
|
||||||
#
|
#
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
|
|
||||||
@ -67,9 +72,10 @@ if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
|||||||
|
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
|
|
||||||
my @sockets = split /,/, $ENV{"socket"} || "";
|
|
||||||
my $mem = 0;
|
|
||||||
my $src = $ENV{"src"} || "";
|
my $src = $ENV{"src"} || "";
|
||||||
|
my @sockets = split /,/, $ENV{"socket"} || "";
|
||||||
|
my $ip = $ENV{"ip"} || "127.0.0.1";
|
||||||
|
my @ports = split /,/, $ENV{"port"} || "";
|
||||||
|
|
||||||
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
||||||
my $tpattern = qr/[0-9A-F]{20}/;
|
my $tpattern = qr/[0-9A-F]{20}/;
|
||||||
@ -78,7 +84,6 @@ my $line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>d.
|
|||||||
my $llen = length $line;
|
my $llen = length $line;
|
||||||
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||||
my $hlen = length $header;
|
my $hlen = length $header;
|
||||||
$line = "${hlen}:${header},${line}";
|
|
||||||
|
|
||||||
my $tor = 0;
|
my $tor = 0;
|
||||||
my $tot = 0;
|
my $tot = 0;
|
||||||
@ -89,34 +94,60 @@ my $ppline = "";
|
|||||||
my $out = 0;
|
my $out = 0;
|
||||||
my $pla = 0;
|
my $pla = 0;
|
||||||
|
|
||||||
for $socket (@sockets)
|
|
||||||
{
|
|
||||||
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
|
||||||
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 );
|
|
||||||
connect( SOCK, sockaddr_un( $socket ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
print SOCK $line;
|
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
||||||
flush SOCK;
|
for $socket (@sockets)
|
||||||
|
{
|
||||||
while ( $line = <SOCK> ) {
|
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
||||||
if ( $line =~ /$tpattern/ ) {
|
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
||||||
$tor += 1;
|
my $line = "${hlen}:${header},${line}";
|
||||||
} elsif ( $line =~ /$pattern/ ) {
|
print SOCK $line;
|
||||||
$tot += 1;
|
flush SOCK;
|
||||||
$enc += $2;
|
while ( $line = <SOCK> ) {
|
||||||
$line = <SOCK>;
|
if ( $line =~ /$tpattern/ ) {
|
||||||
$line =~ /$pattern/;
|
$tor += 1;
|
||||||
$inc += $2;
|
} elsif ( $line =~ /$pattern/ ) {
|
||||||
}
|
$tot += 1;
|
||||||
$ppline = $pline;
|
$enc += $2;
|
||||||
$pline = $line;
|
$line = <SOCK>;
|
||||||
}
|
$line =~ /$pattern/;
|
||||||
close (SOCK);
|
$inc += $2;
|
||||||
|
}
|
||||||
$out = $out + $tot - $inc;
|
$ppline = $pline;
|
||||||
$pla = $pla + $tot - $enc;
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print "torrents.value ${tor}\ntotal.value ${tot}\nencrypted.value ${enc}\nplain.value ${pla}\nincoming.value ${inc}\noutgoing.value ${out}\n";
|
print "torrents.value ${tor}\ntotal.value ${tot}\nencrypted.value ${enc}\nplain.value ${pla}\nincoming.value ${inc}\noutgoing.value ${out}\n";
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
95
plugins/rtorrent/rtom_allsessions_spdd
Normal file → Executable file
95
plugins/rtorrent/rtom_allsessions_spdd
Normal file → Executable file
@ -40,12 +40,16 @@
|
|||||||
#
|
#
|
||||||
# Configuration example
|
# Configuration example
|
||||||
#
|
#
|
||||||
# [rtom_spdd]
|
# [rtom_allsessions_*]
|
||||||
# user username
|
# user username
|
||||||
# env.src socket
|
# env.src socket
|
||||||
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user2/torrent/.socket/rpc2.socket
|
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc.socket
|
||||||
# env.category Sometext
|
# env.category Category
|
||||||
#
|
#
|
||||||
|
# [rtom_allsessions_*]
|
||||||
|
# user username
|
||||||
|
# env.port 5000,5001,5002,5003
|
||||||
|
# env.category Category
|
||||||
#
|
#
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
|
|
||||||
@ -82,43 +86,72 @@ if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
my @sockets = split /,/, $ENV{"socket"} || "";
|
|
||||||
my $src = $ENV{"src"} || "";
|
my $src = $ENV{"src"} || "";
|
||||||
|
my @sockets = split /,/, $ENV{"socket"} || "";
|
||||||
|
my $ip = $ENV{"ip"} || "127.0.0.1";
|
||||||
|
my @ports = split /,/, $ENV{"port"} || "";
|
||||||
|
|
||||||
|
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>([-]{0,1}\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
||||||
|
my $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>";
|
||||||
|
my $llen = length $line;
|
||||||
|
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||||
|
my $hlen = length $header;
|
||||||
|
|
||||||
my $up = -1;
|
my $up = -1;
|
||||||
my $down = -1;
|
my $down = -1;
|
||||||
|
|
||||||
for $socket (@sockets)
|
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
||||||
{
|
for $socket (@sockets)
|
||||||
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>([-]{0,1}\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
{
|
||||||
my $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>";
|
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
||||||
my $llen = length $line;
|
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
||||||
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
my $line = "${hlen}:${header},${line}";
|
||||||
my $hlen = length $header;
|
print SOCK $line;
|
||||||
$line = "${hlen}:${header},${line}";
|
flush SOCK;
|
||||||
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
my $up_tmp = -1;
|
||||||
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 );
|
my $down_tmp = -1;
|
||||||
connect( SOCK, sockaddr_un( $socket ) );
|
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
||||||
}
|
if ( $line =~ /$pattern/ ) {
|
||||||
|
$up_tmp = $2;
|
||||||
print SOCK $line;
|
}
|
||||||
flush SOCK;
|
|
||||||
my $up_tmp = -1;
|
|
||||||
my $down_tmp = -1;
|
|
||||||
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
|
||||||
if ( $line =~ /$pattern/ ) {
|
|
||||||
$up_tmp = $2;
|
|
||||||
}
|
}
|
||||||
}
|
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
||||||
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
if ( $line =~ /$pattern/ ) {
|
||||||
if ( $line =~ /$pattern/ ) {
|
$down_tmp = $2;
|
||||||
$down_tmp = $2;
|
}
|
||||||
}
|
}
|
||||||
|
close (SOCK);
|
||||||
|
$up = $up + $up_tmp;
|
||||||
|
$down = $down + $down_tmp;
|
||||||
|
}
|
||||||
|
} 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;
|
||||||
|
my $up_tmp = -1;
|
||||||
|
my $down_tmp = -1;
|
||||||
|
while (( $up_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
||||||
|
if ( $line =~ /$pattern/ ) {
|
||||||
|
$up_tmp = $2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (( $down_tmp == -1 ) && ( $line = <SOCK> ) ) {
|
||||||
|
if ( $line =~ /$pattern/ ) {
|
||||||
|
$down_tmp = $2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close (SOCK);
|
||||||
|
$up = $up + $up_tmp;
|
||||||
|
$down = $down + $down_tmp;
|
||||||
}
|
}
|
||||||
close (SOCK);
|
|
||||||
$up = $up + $up_tmp;
|
|
||||||
$down = $down + $down_tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "up.value ${up}\ndown.value ${down}\n";
|
print "up.value ${up}\ndown.value ${down}\n";
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
81
plugins/rtorrent/rtom_allsessions_vol
Normal file → Executable file
81
plugins/rtorrent/rtom_allsessions_vol
Normal file → Executable file
@ -28,11 +28,16 @@
|
|||||||
#
|
#
|
||||||
# Configuration example
|
# Configuration example
|
||||||
#
|
#
|
||||||
# [rtom_vol]
|
# [rtom_allsessions_*]
|
||||||
# user username
|
# user username
|
||||||
# env.src socket
|
# env.src socket
|
||||||
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc2.socket
|
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc.socket
|
||||||
# env.category Sometext
|
# env.category Category
|
||||||
|
#
|
||||||
|
# [rtom_allsessions_*]
|
||||||
|
# user username
|
||||||
|
# env.port 5000,5001,5002,5003
|
||||||
|
# env.category Category
|
||||||
#
|
#
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
|
|
||||||
@ -71,40 +76,50 @@ if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
|||||||
|
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
|
|
||||||
my @sockets = split /,/, $ENV{"socket"} || "";
|
|
||||||
my $src = $ENV{"src"} || "";
|
my $src = $ENV{"src"} || "";
|
||||||
|
my @sockets = split /,/, $ENV{"socket"} || "";
|
||||||
|
my $ip = $ENV{"ip"} || "127.0.0.1";
|
||||||
|
my @ports = split /,/, $ENV{"port"} || "";
|
||||||
|
|
||||||
my $pattern = qr/<value><string>([A-Z0-9]+)<\/string><\/value>/;
|
my $pattern = qr/<value><string>([A-Z0-9]+)<\/string><\/value>/;
|
||||||
|
|
||||||
my $line;
|
|
||||||
my $llenmy;
|
|
||||||
my $header;
|
|
||||||
my $hlen;
|
|
||||||
|
|
||||||
my $num;
|
|
||||||
foreach ( @views ) {
|
foreach ( @views ) {
|
||||||
$num = 0;
|
my $num = 0;
|
||||||
for $socket (@sockets){
|
my $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>";
|
||||||
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
my $llen = length $line;
|
||||||
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 );
|
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||||
connect( SOCK, sockaddr_un( $socket ) );
|
my $hlen = length $header;
|
||||||
}
|
|
||||||
|
|
||||||
$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>";
|
if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
||||||
$llen = length $line;
|
for $socket (@sockets)
|
||||||
$header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
{
|
||||||
$hlen = length $header;
|
socket( SOCK, PF_UNIX, SOCK_STREAM, 0 ) or die;
|
||||||
$line = "${hlen}:${header},${line}";
|
connect( SOCK, sockaddr_un( $socket ) ) or die $!;
|
||||||
|
my $line = "${hlen}:${header},${line}";
|
||||||
print SOCK $line;
|
print SOCK $line;
|
||||||
flush SOCK;
|
flush SOCK;
|
||||||
|
while ( $line = <SOCK> ) {
|
||||||
while ( $line = <SOCK> ) {
|
if ( $line =~ /$pattern/ ) {
|
||||||
if ( $line =~ /$pattern/ ) {
|
$num++;
|
||||||
$num++;
|
}
|
||||||
}
|
}
|
||||||
}
|
close (SOCK);
|
||||||
close (SOCK);
|
}
|
||||||
|
} 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 =~ /$pattern/ ) {
|
||||||
|
$num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close (SOCK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print "${_}.value ${num}\n";
|
print "${_}.value ${num}\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user