Correct parsing
Response isn't an array, just check for a suitable line instead. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
53190e1a42
commit
c50e4a3a60
@ -23,9 +23,14 @@ my $response = HTTP::Tiny->new->get('http://' . $buddy . ':' . $port . '/metrics
|
|||||||
|
|
||||||
say "$response->{protocol} $response->{status} $response->{reason}" unless $response->{status} == 200;
|
say "$response->{protocol} $response->{status} $response->{reason}" unless $response->{status} == 200;
|
||||||
|
|
||||||
my $metric = grep {/^node_systemd_system_running/} $response->{content};
|
# match any of the following:
|
||||||
|
# node_systemd_system_running 0
|
||||||
|
# node_systemd_system_running 1
|
||||||
|
# node_systemd_system_running{label="value", ...} 0
|
||||||
|
# node_systemd_system_running{label="value", ...} 1
|
||||||
|
$response->{content} =~ /^node_systemd_system_running(?:\{.*\})?\s([01])/m;
|
||||||
|
|
||||||
if ($metric == 1) {
|
if ($1 == 1) {
|
||||||
say "Buddy is healthy"
|
say "Buddy is healthy"
|
||||||
} else {
|
} else {
|
||||||
say "Buddy is sick";
|
say "Buddy is sick";
|
||||||
|
Loading…
Reference in New Issue
Block a user