Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / sabnzbd / sabnzbd_dataleft @ c3660c2a

Historique | Voir | Annoter | Télécharger (1,65 ko)

1 33670ad2 Blauwbek
#!/usr/bin/perl
2
#
3
# Munin plugins for sabnzbd
4
#
5
# Copyright (C) 2012 - Blauwbek
6
#
7
# SABnzbd       : http://sabnzbd.org/
8
#
9
# This program is free software: you can redistribute it and/or modify 
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
#
22
# Requires: XML::Simple
23
#			LWP::UserAgent
24
#
25
# Configuration example
26
# [sabnzbd*]
27
# env.host http://host:port/
28
# env.api apikey
29
# 
30
31
use strict;
32
use XML::Simple;
33
use LWP::UserAgent;
34
35
#defines
36
my $HOST = exists $ENV{'host'} ? $ENV{'host'} : "http://localhost:8080/";
37
my $API = exists $ENV{'api'} ? $ENV{'api'} : "";
38
my $URL = $HOST."/sabnzbd/api?mode=qstatus&output=xml&apikey=".$API;
39
my $sURL = sprintf $URL;
40
41
#config output
42
if(defined $ARGV[0] && $ARGV[0] eq 'config')
43
{
44
    print <<EOC
45
graph_title Data Remaining
46
graph_vlabel Data Remaining (MB)
47
graph_category sabnzbd
48
rem.label Remaining
49
EOC
50
;
51
52
exit 0;
53
}
54
55
#data handlers
56
my $xml = new XML::Simple;
57
my $get = LWP::UserAgent->new;
58
$get->agent('Munin_GetXML_sabnzbd_left ');
59
60
#get xml and xml->perl
61
my $req = $get->get($sURL);
62
my $vals = $req->content();
63
my $xmlvals = $xml->XMLin($vals);
64
65
#get/output vals 
66
my $left = $xmlvals->{mbleft};
67
$left =~ /(\d+)\./;
68
print "rem.value ".$1."\n";