-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomuteus
executable file
·59 lines (48 loc) · 1.51 KB
/
automuteus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl -w
use Munin::Plugin;
use LWP;
use JSON;
# Set GALACTUS_HOST and GALACTUS_EXTERNAL_PORT
my $path = $ENV{'GALACTUS_ENDPOINT'} || 'http://localhost:8123';
if ($ARGV[0]){
if ($ARGV[0] eq 'autoconf') {
print "no\n";
exit 0;
}
if ($ARGV[0] eq "config"){
print "multigraph automuteus_active\n";
print "graph_title AutoMuteUs Active Counts\n";
print "graph_order activeConnections activeGames\n";
print "graph_vlabel count\n";
print "graph_category automuteus\n";
print "activeConnections.label Active Connections\n";
print "activeGames.label Active Games\n";
# ---
print "multigraph automuteus_total\n";
print "graph_title AutoMuteUs Total Counts\n";
print "graph_order totalGames totalGuilds totalUsers\n";
print "graph_vlabel count\n";
print "graph_category automuteus\n";
print "totalGames.label Total Games\n";
print "totalGuilds.label Total Guilds\n";
print "totalUsers.label Total Users\n";
exit 0;
}
}
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $path);
my $res = $ua->request($req);
if ($res->is_error()){
print STDERR $res->message();
exit 1;
}
$json = JSON->new()->decode($res->content());
print "multigraph automuteus_active\n";
print "activeConnections.value $json->{activeConnections}\n";
print "activeGames.value $json->{activeGames}\n";
print "multigraph automuteus_total\n";
print "totalGames.value $json->{totalGames}\n";
print "totalGuilds.value $json->{totalGuilds}\n";
print "totalUsers.value $json->{totalUsers}\n";
exit 0;
# vim:syntax=perl