2012-10-27 23:30:28 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# Munin plugins for Sick-Beard
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 - Blauwbek
|
|
|
|
# Copyright (C) 2012 - Thiago
|
|
|
|
#
|
|
|
|
# Sick-Beard : http://sickbeard.com/
|
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2012-10-27 23:30:28 +02:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# Requires: JSON::Any
|
|
|
|
# LWP::UserAgent
|
|
|
|
#
|
|
|
|
# Configuration example
|
|
|
|
# [sickbeard*]
|
|
|
|
# env.host http://host:port/
|
|
|
|
# env.api apikey
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2012-10-27 23:30:28 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use JSON::Any;
|
|
|
|
use LWP::UserAgent;
|
|
|
|
|
|
|
|
#defines
|
|
|
|
my $HOST = exists $ENV{'host'} ? $ENV{'host'} : "http://localhost:8081/";
|
|
|
|
my $API = exists $ENV{'api'} ? $ENV{'api'} : "";
|
|
|
|
my $URL = $HOST."/api/".$API."/?cmd=shows.stats";
|
|
|
|
my $sURL = sprintf $URL;
|
|
|
|
|
|
|
|
#config output
|
|
|
|
if(defined $ARGV[0] && $ARGV[0] eq 'config')
|
|
|
|
{
|
|
|
|
print <<EOC
|
|
|
|
graph_title Episodes
|
|
|
|
graph_vlabel Episodes
|
2018-08-01 23:56:56 +02:00
|
|
|
graph_category tv
|
2012-10-27 23:30:28 +02:00
|
|
|
down.label Downloaded
|
2016-10-17 11:13:28 +02:00
|
|
|
snatched.label Snatched
|
2012-10-27 23:30:28 +02:00
|
|
|
total.label Total
|
|
|
|
EOC
|
|
|
|
;
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $get = LWP::UserAgent->new;
|
|
|
|
my $req = $get->get($sURL);
|
|
|
|
my $json = JSON::Any->jsonToObj($req->content());
|
|
|
|
|
|
|
|
if ($json->{result} eq 'success') {
|
|
|
|
print "down.value $json->{data}->{ep_downloaded}\n";
|
2016-07-15 14:23:24 +02:00
|
|
|
print "snatched.value $json->{data}->{ep_snatched}\n";
|
2012-10-27 23:30:28 +02:00
|
|
|
print "total.value $json->{data}->{ep_total}\n";
|
|
|
|
exit 0;
|
|
|
|
} else {
|
|
|
|
print "$json->{message}\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|