From 278f1a2f4c2993724e4aebdb7fdd6868b3c90339 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Fri, 25 Oct 2024 15:03:27 -0500 Subject: [PATCH] linux_softnet_stat nolonger uses Gzip::Faster... uses IO::Compress::Gzip as it comes default --- snmp/linux_softnet_stat | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/snmp/linux_softnet_stat b/snmp/linux_softnet_stat index f7987a391..cc547a1f3 100755 --- a/snmp/linux_softnet_stat +++ b/snmp/linux_softnet_stat @@ -1,10 +1,15 @@ #!/usr/bin/env perl +use strict; +use warnings; + =head1 DESCRIPTION This is a SNMP extend for monitoring /proc/net/softnet_stat on Linux for use with LibreNMS. -For more information, see L. +This just needs added to snmpd.conf like below. + + extend linux_softnet_stat /etc/snmp/linux_softnet_stat -b =head1 SWITCHES @@ -16,24 +21,29 @@ Pretty print the JSON. If used with -b, this switch will be ignored. Gzip the output and convert to Base64. +=head1 VERSION + +0.1.0 + =cut -use strict; -use warnings; +our $VERSION = '0.1.0'; + use JSON; use Getopt::Std; use File::Slurp; use MIME::Base64; -use Gzip::Faster; +use IO::Compress::Gzip qw(gzip $GzipError); +use Pod::Usage; $Getopt::Std::STANDARD_HELP_VERSION = 1; sub main::VERSION_MESSAGE { - print "Linux softnet stats extend 0.0.1\n"; + print 'Linux softnet stats extend ' . $VERSION . "\n"; } sub main::HELP_MESSAGE { - + pod2usage( -exitval => 255, -verbose => 2, -output => \*STDOUT, ); } #this will be dumped to json at the end @@ -132,13 +142,11 @@ if ( !$opts{p} && !$opts{b} ) { exit 0; } -my $compressed = encode_base64( gzip($return_string) ); +my $toReturnCompressed; +gzip \$return_string => \$toReturnCompressed; +my $compressed = encode_base64($toReturnCompressed); $compressed =~ s/\n//g; $compressed = $compressed . "\n"; -if ( length($compressed) > length($return_string) ) { - print $return_string. "\n"; -} else { - print $compressed; -} +print $compressed; exit 0;