From 7088534f0874c18cf8dcbb034674f97b2b479c35 Mon Sep 17 00:00:00 2001 From: Sven Putteneers Date: Fri, 15 Jul 2022 11:46:08 +0200 Subject: [PATCH 1/2] Allow Zabbix time spec instead of just seconds for check-delay and disc-delay In Zabbix, the item check interval and discovery intervals can be specified not just with a number of seconds, but with more convenient units using time suffixes as well. See https://www.zabbix.com/documentation/current/en/manual/appendix/suffixes for a list of supported suffixes. By allowing strings as arguments to --check-delay and --disc-delay, these interval specifications can be used. No checking for correct syntax (i.e. valid time suffixes) is done; if required, this can be added to the code as well. --- README.md | 4 ++-- mib2zabbix.pl | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9886db2..4066971 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ tree in a SNMP MIB file. Zabbix item configuration - --check-delay=SECONDS check interval in seconds (default: 60) - --disc-delay=SECONDS discovery interval in seconds (default: 3600) + --check-delay=TIME check interval in Zabbix time units (default: 1m) + --disc-delay=TIME discovery interval in Zabbix time units (default: 1h) --history=DAYS history retention in days (default: 7) --trends=DAYS trends retention in days (default: 365) diff --git a/mib2zabbix.pl b/mib2zabbix.pl index 46ac243..d3f5233 100755 --- a/mib2zabbix.pl +++ b/mib2zabbix.pl @@ -173,8 +173,8 @@ my $snmpv3_sec_protocol_map = { # Default command line options my $opts = { - delay => 60, # 1 minute check interval - disc_delay => 3600, # Hourly discovery + delay => '1m', # 1 minute check interval + disc_delay => '1h', # Hourly discovery enableitems => 0, # Disable items group => 'Templates', history => 7, @@ -222,8 +222,8 @@ GetOptions( 'x|privacy=s' => \$opts->{ v3sec_protocol }, # SNMPv3 Privacy protocol 'X|privpass=s' => \$opts->{ v2sec_pass}, # SNMPv3 Privacy passphrase - 'check-delay=i' => \$opts->{ delay }, # Update interval in seconds - 'disc-delay=i' => \$opts->{ disc_delay }, # Update interval in seconds + 'check-delay=s' => \$opts->{ delay }, # Update interval in seconds + 'disc-delay=s' => \$opts->{ disc_delay }, # Update interval in seconds 'history=i' => \$opts->{ history }, # History retention in days 'trends=i' => \$opts->{ trends }, # Trends retention in days From dfaf64c3b7f99c313b4b21e4189768ef5a69581a Mon Sep 17 00:00:00 2001 From: Sven Putteneers Date: Fri, 15 Jul 2022 11:48:00 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Fix=20"Smartmatch=20is=20experimental=20at?= =?UTF-8?q?=20=E2=80=A6"=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added the "no warnings" pragma to suppress warnings about smartmatch being an experimental feature. --- mib2zabbix.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mib2zabbix.pl b/mib2zabbix.pl index d3f5233..f3c7d2c 100755 --- a/mib2zabbix.pl +++ b/mib2zabbix.pl @@ -75,6 +75,7 @@ http://www.webnms.com/snmp/help/snmpapi/snmpv3/table_handling/snmptables_basics. use strict; #use warnings; +no warnings 'experimental::smartmatch'; use Cwd 'abs_path'; use Data::Dumper;