From 166d1022f3671815af7d2d2cd6ae42b6d5d7f2d0 Mon Sep 17 00:00:00 2001 From: Kovrinic Date: Tue, 9 Apr 2019 22:04:26 -0500 Subject: [PATCH] Moved sudo command into the snmpd.conf. Added notes for settings to change if using older ZoL zfs. --- snmp/zfs-linux | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snmp/zfs-linux b/snmp/zfs-linux index 87677d0..122eb9b 100755 --- a/snmp/zfs-linux +++ b/snmp/zfs-linux @@ -109,12 +109,12 @@ def main(args): ## account for variations between ZoL zfs versions proc = subprocess.run(zpool_cmd_list, **std) - if (proc.returncode == 1) and (('root' in proc.stderr) or ('admin' in proc.stderr)): - zpool_cmd = ['sudo'] + zpool_cmd # elevate zpool with sudo - zpool_cmd_list = zpool_cmd + ['list', '-p', '-H'] - proc = subprocess.run(zpool_cmd_list, **std) if (proc.returncode == 2): # -p option is not present in older versions + # edit snmpd.conf zfs extend section to the following: + # extend zfs /usr/bin/sudo /etc/snmp/zfs-linux + # make sure to edit your sudo users (usually visudo) and add at the bottom: + # snmp ALL=(ALL) NOPASSWD: /etc/snmp/zfs-linux del zpool_cmd_list[zpool_cmd_list.index('-p')] # try removing -p to fix the issue proc = subprocess.run(zpool_cmd_list, **std) exact_size = False