mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-08-01 05:43:44 +00:00
drop seperate files and make api version configureable
This commit is contained in:
parent
91fc3e72c2
commit
8bfb81806d
8 changed files with 115 additions and 628 deletions
|
@ -27,6 +27,7 @@
|
|||
# ip rTorrent's ip address - using scgi_port - needed, when "src" is NOT set to "socket"
|
||||
# port rTorrent's scgi port (scgi_port) - using scgi_port - needed, when "src" is NOT set to "socket"
|
||||
# category Change graph category
|
||||
# api use 'legacy' (pre 0.9.0) or current (0.9.0+) API calls
|
||||
#
|
||||
# Configuration example
|
||||
#
|
||||
|
@ -35,6 +36,7 @@
|
|||
# env.src socket
|
||||
# env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc.socket
|
||||
# env.category Category
|
||||
# env.api current
|
||||
#
|
||||
# [rtom_allsessions_*]
|
||||
# user username
|
||||
|
@ -66,10 +68,16 @@ 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 $mem = 0;
|
||||
my $mem = 0;
|
||||
my $pattern = qr/<value><(int|i4|i8|ex\.i8)>(\d+)<\/(int|i4|i8|ex\.i8)><\/value>/;
|
||||
my $line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>get_memory_usage</methodName></methodCall>";
|
||||
my $line = "";
|
||||
if ($api =~ /legacy/) {
|
||||
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>get_memory_usage</methodName></methodCall>";
|
||||
} else {
|
||||
$line = "<?xml version=\"1.0\" encoding=\"utf-8\"?><methodCall><methodName>pieces.memory.current</methodName></methodCall>";
|
||||
}
|
||||
my $llen = length $line;
|
||||
my $header = "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
|
||||
my $hlen = length $header;
|
||||
|
@ -88,10 +96,10 @@ if ( ( defined $src ) && ( $src eq "socket" ) ) {
|
|||
}
|
||||
}
|
||||
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}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue