Projet

Général

Profil

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

root / plugins / sickbeard / sickbeard_shows @ 0147f805

Historique | Voir | Annoter | Télécharger (1,66 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 Shows
47
graph_vlabel Shows
48
graph_category other
49
active.label Active
50
total.label Total
51
EOC
52
;
53

    
54
exit 0;
55
}
56

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

    
61
if ($json->{result} eq 'success') {
62
	print "active.value $json->{data}->{shows_active}\n";
63
	print "total.value $json->{data}->{shows_total}\n";
64
	exit 0;
65
} else {
66
	print "$json->{message}\n";
67
	exit 1;
68
}
69