bump version and add support base64+gzip support
This commit is contained in:
parent
c3a0facefd
commit
13493dd0d4
|
@ -24,6 +24,8 @@ my %WriteMakefileArgs = (
|
|||
'Carp' => '0',
|
||||
'File::Slurp' => '0',
|
||||
'Time::Piece' => '0',
|
||||
'MIME::Base64' => '3.16',
|
||||
'Gzip::Faster' => '0.21',
|
||||
},
|
||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||
clean => { FILES => 'Sagan-Monitoring-*' },
|
||||
|
|
|
@ -182,9 +182,11 @@ use warnings;
|
|||
use Getopt::Long;
|
||||
use File::Slurp;
|
||||
use Sagan::Monitoring;
|
||||
use MIME::Base64;
|
||||
use Gzip::Faster;
|
||||
|
||||
sub version {
|
||||
print "sagan_stat_check v. 0.1.1\n";
|
||||
print "sagan_stat_check v. 0.2.0\n";
|
||||
}
|
||||
|
||||
sub help {
|
||||
|
@ -293,6 +295,7 @@ my $drop_percent_warn = '.75';
|
|||
my $drop_percent_crit = '1';
|
||||
my $print_cache;
|
||||
my $max_age;
|
||||
my $compress;
|
||||
Getopt::Long::Configure('no_ignore_case');
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions(
|
||||
|
@ -320,6 +323,7 @@ GetOptions(
|
|||
'D=s' => \$drop_percent_crit,
|
||||
'c' => \$print_cache,
|
||||
'a=s' => \$max_age,
|
||||
'b' => \$compress,
|
||||
);
|
||||
|
||||
# print version or help if requested
|
||||
|
@ -335,6 +339,18 @@ if ($version) {
|
|||
# prints the cache and exists if requested
|
||||
if ($print_cache) {
|
||||
my $cache = read_file('/var/cache/sagan_monitoring.json');
|
||||
|
||||
if ($compress) {
|
||||
my $compressed = encode_base64( gzip($cache) );
|
||||
$compressed =~ s/\n//g;
|
||||
$compressed = $compressed . "\n";
|
||||
|
||||
if ( length($compressed) < length($cache) ) {
|
||||
print $compressed;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
print $cache;
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ Sagan::Monitoring - LibreNMS JSON SNMP extend and Nagios style check for Sagan s
|
|||
|
||||
=head1 VERSION
|
||||
|
||||
Version 1.1.1
|
||||
Version 1.2.0
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '1.1.1';
|
||||
our $VERSION = '1.2.0';
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
|
Loading…
Reference in New Issue