-
Notifications
You must be signed in to change notification settings - Fork 2
/
graphite-purestats.pl
executable file
·61 lines (46 loc) · 1.52 KB
/
graphite-purestats.pl
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
60
61
#!/usr/bin/env perl
#
# A generic check to poll graphite data from Pure arrays.
# it reports overall and volume usage on arrays.
#
# By: Phillip Pollard <[email protected]>
use API::PureStorage;
use strict;
### Config
# pureadmin create --api-token
my %api_tokens = (
'my-pure-array1.company.com' => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'my-pure-array2.company.com' => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
);
### Start
my $client;
my $debug = 0;
for my $host ( sort keys %api_tokens ) {
my $token = $api_tokens{$host};
my $pure;
eval { $pure = new API::PureStorage($host, $token); };
if ($@) {
warn "ERROR on $host : $@" if $debug;
next;
}
### Check the Array overall
my $array_info = $pure->array_info();
for my $param (qw/system capacity total/) {
next if defined $array_info->{$param};
die "Array data lacks parameter: $param";
}
print join(' ', "purity.$host.used", $array_info->{total}, time )."\n";
print join(' ', "purity.$host.max", $array_info->{capacity}, time )."\n";
### Check the volumes
my $vol_info = $pure->volume_info();
for my $vol (@$vol_info) {
for my $param (qw/total size name/) {
next if defined $vol->{$param};
die "Volume data lacks parameter: $param";
}
}
for my $vol ( sort { ($b->{total}/$b->{size}) <=> ($a->{total}/$a->{size}) } @$vol_info) {
print join(' ', "purity.$host.vol.$vol->{name}.used", $vol->{total}, time )."\n";
print join(' ', "purity.$host.vol.$vol->{name}.max", $vol->{size}, time )."\n";
}
}