1

Initial commit

This commit is contained in:
eleksir
2018-09-23 14:24:20 +03:00
commit d6e2f9f211
9 changed files with 470 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#!/usr/bin/perl
use strict;
use warnings "all";
my $str = `ceph osd pool stats`;
my @arr = split(/\n\n/, $str);
my $msg = "{\n \"data\": [\n";
foreach my $p (@arr) {
my @str = split(/\s+/, $p);
next if ((not defined($str[1])) or ($str[1] eq ''));
next if ((not defined($str[3])) or ($str[3] eq ''));
{# in jinja template engine this is comment, so in real script fix this #}
$msg .= sprintf(" {\n \"\{#POOLID}\": \"%s\",\n", $str[3]);
$msg .= sprintf(" \"\{#POOLNAME}\": \"%s\"\n },\n", $str[1]);
}
chop($msg);
chop($msg);
$msg .= "\n ]\n}\n";
print $msg;