From f6b45619ecbb87b12f64c1a5c34fa1796520e8f6 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 20 May 2020 16:29:22 +0200 Subject: [PATCH] Do not rely on distrib version to check if --output-format is needed for check_pve_sudo --- zabbix_scripts/check_pve_sudo | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/zabbix_scripts/check_pve_sudo b/zabbix_scripts/check_pve_sudo index 646b0f4..2875727 100644 --- a/zabbix_scripts/check_pve_sudo +++ b/zabbix_scripts/check_pve_sudo @@ -29,20 +29,8 @@ GetOptions( 'cache-dir=s' => \$cache_dir ); -# Before Buster / PVE6, pvesh don't support (or need) --output-format=json -# So try to detect previous version and adapt opt -my $pvesh_opt = '--output-format=json'; -if (-f '/etc/os-release'){ - open my $fh, '<', '/etc/os-release'; - foreach my $line (<$fh>){ - my ($var, $val) = split(/=/, $line); - $val =~ s/"(.*)"/$1/; - if ($var eq 'VERSION_ID' and int $val < 10){ - $pvesh_opt = ''; - last; - } - } -} +# Old versions do not support, nore need --output-format=json +my $pvesh_opt = (system("$pvesh ls / --output-format=json 2>&1 > /dev/null") == 0) ? '--output-format=json' : ''; if ($cluster){ my $cluster = get_api_data('/cluster/status');