You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
466 B
26 lines
466 B
#!/usr/bin/perl -w
|
|
|
|
use warnings;
|
|
use strict;
|
|
use File::Which;
|
|
use JSON;
|
|
|
|
my $json;
|
|
@{$json->{data}} = ();
|
|
my $drbdoverview = which('drbd-overview');
|
|
|
|
if ($drbdoverview){
|
|
open RES, "$drbdoverview |" || die "Couldn't execute $drbdoverview";
|
|
foreach my $l (<RES>){
|
|
if ($l =~ m{(\d+):(\w+)/\d+}){
|
|
push @{$json->{data}}, {
|
|
"{#DRBD_RES_ID}" => $1,
|
|
"{#DRBD_RES_NAME}" => $2
|
|
};
|
|
}
|
|
}
|
|
close RES;
|
|
}
|
|
|
|
print to_json($json);
|
|
exit(0);
|
|
|