start work on base64+gzip support

This commit is contained in:
Zane C. B-H 2022-08-03 17:51:53 -05:00
parent 1d7b293701
commit 9ae3a214e9
3 changed files with 20 additions and 6 deletions

View File

@ -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 => 'Suricata-Monitoring-*' },

View File

@ -20,7 +20,7 @@ suricata_stats_check B<-m> manual B<-1> <manual> [B<-d> <drop percent warn>]
[B<-4> <manual>] [B<-5> <manual>] [B<-6> <manual>] [B<-7> <manual>]
[B<-8> <manual>] [B<-9> <manual>] [B<-0> <manual>]
suricata_stats_check -c
suricata_stats_check B<-c> [B<-b>]
=head1 DESCRIPTION
@ -34,7 +34,7 @@ cron...
snmp.conf...
extend suricata-stats /usr/local/bin/suricata_stat_check -c
extend suricata-stats /usr/local/bin/suricata_stat_check -c -b
=head1 FLAGS
@ -196,9 +196,11 @@ use warnings;
use Getopt::Long;
use File::Slurp;
use Suricata::Monitoring;
use MIME::Base64;
use Gzip::Faster;
sub version {
print "suricata_stat_check v. 0.0.1\n";
print "suricata_stat_check v. 0.1.0\n";
}
sub help {
@ -315,6 +317,7 @@ my $error_delta_crit = '2';
my $error_percent_warn = '.05';
my $error_percent_crit = '.1';
my $print_cache;
my $compress;
Getopt::Long::Configure('no_ignore_case');
Getopt::Long::Configure('bundling');
GetOptions(
@ -345,6 +348,7 @@ GetOptions(
'r=s' => \$error_percent_warn,
'R=s' => \$error_percent_crit,
'c' => \$print_cache,
'b' => \$compress,
);
# print version or help if requested
@ -359,7 +363,15 @@ if ($version) {
# prints the cache and exists if requested
if ($print_cache) {
my $cache=read_file('/var/cache/suricata-monitoring/stats.json');
my $cache = read_file('/var/cache/suricata-monitoring/stats.json');
my $compressed = encode_base64( gzip($cache) );
$compressed =~ s/\n//g;
$compressed = $compressed . "\n";
if ( length($compressed) < length($cache) ) {
print $compressed;
}
print $cache;
exit;
}

View File

@ -16,11 +16,11 @@ Suricata::Monitoring - LibreNMS JSON SNMP extend and Nagios style check for Suri
=head1 VERSION
Version 0.1.3
Version 0.2.0
=cut
our $VERSION = '0.1.3';
our $VERSION = '0.2.0';
=head1 SYNOPSIS