Projet

Général

Profil

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

root / plugins / sickbeard / sickbeard_episodes @ 17f78427

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

1
#!/usr/bin/perl
2
#
3
# Munin plugins for Sick-Beard
4
#
5
# Copyright (C) 2012 - Blauwbek
6
# Copyright (C) 2012 - Thiago
7
#
8
# Sick-Beard       : http://sickbeard.com/
9
#
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
14
#
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
#
23
# Requires: JSON::Any
24
#           LWP::UserAgent
25
#
26
# Configuration example
27
# [sickbeard*]
28
# env.host http://host:port/
29
# env.api apikey
30
#
31

    
32
use strict;
33
use JSON::Any;
34
use LWP::UserAgent;
35

    
36
#defines
37
my $HOST = exists $ENV{'host'} ? $ENV{'host'} : "http://localhost:8081/";
38
my $API = exists $ENV{'api'} ? $ENV{'api'} : "";
39
my $URL = $HOST."/api/".$API."/?cmd=shows.stats";
40
my $sURL = sprintf $URL;
41

    
42
#config output
43
if(defined $ARGV[0] && $ARGV[0] eq 'config')
44
{
45
    print <<EOC
46
graph_title Episodes
47
graph_vlabel Episodes
48
graph_category tv
49
down.label Downloaded
50
snatched.label Snatched
51
total.label Total
52
EOC
53
;
54

    
55
exit 0;
56
}
57

    
58
my $get = LWP::UserAgent->new;
59
my $req = $get->get($sURL);
60
my $json = JSON::Any->jsonToObj($req->content());
61

    
62
if ($json->{result} eq 'success') {
63
	print "down.value $json->{data}->{ep_downloaded}\n";
64
	print "snatched.value $json->{data}->{ep_snatched}\n";
65
	print "total.value $json->{data}->{ep_total}\n";
66
	exit 0;
67
} else {
68
	print "$json->{message}\n";
69
	exit 1;
70
}
71