Projet

Général

Profil

Révision f519cf3a

IDf519cf3ad40f0c68bb33250b9589db1d473b79cc
Parent acba1189
Enfant 134200b2, 80dcbf72

Ajouté par XciD il y a presque 12 ans

Create rtom_allsessions_vol

For all sessions

Voir les différences:

plugins/rtorrent/rtom_allsessions_vol
1
#!/usr/bin/perl -w
2
#
3
# xmlrpc based munin plugin for monitoring rtorrent's torrent count
4
# prerequisites:
5
#  - rtorrent 0.7.5 or newer compiled with --with-xmlrpc-c
6
# check http://libtorrent.rakshasa.no/wiki/RTorrentXMLRPCGuide for further informations
7
#
8
# written by Gabor Hudiczius
9
# web: http://projects.cyla.homeip.net/rtwi/wiki/rTorrentOMeter
10
# email: ghudiczius@gmail.com
11
#
12
# 0.2.0 - 080619
13
#  support for scgi_port and scgi_local
14
#  configurable via munin env variables
15
#  initial release
16
#
17
#
18
# Parameters:
19
#
20
#	config		required
21
#
22
#
23
# Configurable variables
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
#
29
# Configuration example
30
#
31
#	[rtom_vol]
32
#	user username
33
#	env.src socket
34
#	env.socket /home/user/torrent/.socket/rpc.socket,/home/user/torrent/.socket/rpc2.socket
35
#	env.category Sometext
36
#
37
#%# family=auto
38

  
39
my @views = ( "default", "started", "stopped", "complete", "incomplete" );
40

  
41
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
42
	exit 1;
43
}
44

  
45
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
46
	my $category = $ENV{"category"} || "";
47
	print "graph_args --base 1000 -r --lower-limit 0\n";
48
	print "graph_title rTorrent volume\n";
49
	print "graph_vlabel active torrents\n";
50
	print "graph_category rTorrent ".${category}."\n";
51
	print "complete.label complete\n";
52
	print "complete.draw AREA\n";
53
	print "complete.info complete torrents\n";
54
	print "incomplete.label incomplete\n";
55
	print "incomplete.draw STACK\n";
56
	print "incomplete.info incomplete torrents\n";
57
	print "stopped.label stopped\n";
58
	print "stopped.draw LINE2\n";
59
	print "stopped.info stopped torrents\n";
60
	print "started.label started\n";
61
	print "started.draw LINE2\n";
62
	print "started.info started torrents\n";
63
	print "default.label total\n";
64
	print "default.draw LINE2\n";
65
	print "default.info all torrents\n";
66
	print "hashing.graph no\n";
67
	print "seeding.graph no\n";
68
	print "active.graph no\n";
69
	exit 0;
70
}
71

  
72
use IO::Socket;
73

  
74
my @sockets = split /,/, $ENV{"socket"} || "";
75
my $src         = $ENV{"src"} || "";
76

  
77
my $pattern	= qr/<value><string>([A-Z0-9]+)<\/string><\/value>/;
78

  
79
my $line;
80
my $llenmy;
81
my $header;
82
my $hlen;
83

  
84
my $num;
85
foreach ( @views ) {
86
	$num = 0;
87
	for $socket (@sockets){
88
		if ( ( defined $src ) && ( $src eq "socket" ) ) {
89
			socket( SOCK, PF_UNIX, SOCK_STREAM, 0 );
90
			connect( SOCK, sockaddr_un( $socket ) );
91
		}
92

  
93
		$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>";
94
		$llen	= length $line;
95
		$header	= "CONTENT_LENGTH\000${llen}\000SCGI\001\000";
96
		$hlen	= length $header;
97
		$line	= "${hlen}:${header},${line}";
98

  
99
		print SOCK $line;
100
		flush SOCK;
101

  
102
		while ( $line = <SOCK> ) {
103
			if ( $line =~ /$pattern/ ) {
104
				$num++;
105
			}
106
		}
107
		close (SOCK);
108
	}
109
	print "${_}.value ${num}\n";
110
}
111

  
112
exit;

Formats disponibles : Unified diff