-
-
Save perlpunk/4aec2d85c51b22261c0717afc896aa4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use v5.22; | |
use Data::Dumper; | |
my @states = qw/ active delayed failed inactive /; | |
if ( defined $ARGV[0] and $ARGV[0] eq "config" ) { | |
config(); | |
exit; | |
} | |
my @data = qx{curl -s https://openqa.opensuse.org/admin/influxdb/minion}; | |
my %values; | |
for my $line (@data) { | |
my ($metric, $url, $values) = $line =~ m/^(\w+),url=(\S+) (\S+)/; | |
next unless $metric eq 'openqa_minion_jobs'; | |
%values = map { s/i$//r } map { split m/=/, $_ } split m/,/, $values; | |
} | |
my $total = 0; | |
for my $state (@states) { | |
my $value = $values{ $state } // 0; | |
$total += $value; | |
print <<"EOM"; | |
$state.value $value | |
EOM | |
} | |
print <<"EOM"; | |
total.value $total | |
EOM | |
sub config { | |
print <<"EOM"; | |
graph_title Minion Jobs | |
graph_args --base 1000 -l 0 | |
graph_category minion | |
graph_order @states | |
graph_vlabel minion_jobs | |
EOM | |
for my $state (@states) { | |
print <<"EOM"; | |
$state.label $state | |
$state.draw LINE | |
EOM | |
} | |
print <<"EOM"; | |
total.label Total | |
total.graph no | |
EOM | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment