From 18c6f057805f0afd9b58ba21b1a7ed351f10b817 Mon Sep 17 00:00:00 2001 From: Prins Geryha Date: Wed, 17 Aug 2022 19:38:25 +0200 Subject: [PATCH 1/3] Permission fix and SMART changed method. Switched from root folder to opt because of permission issues with root. Fixed SMART status by switching from tail to grep method. --- snmp-smart-status.sh | 2 +- snmpd.conf | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/snmp-smart-status.sh b/snmp-smart-status.sh index ae6cf92..52e019a 100644 --- a/snmp-smart-status.sh +++ b/snmp-smart-status.sh @@ -3,6 +3,6 @@ if [ "$1" = "-g" ] then echo .1.3.6.1.2.1.25.1.10 echo STRING -smartctl -H /dev/sda | tail -2 | nawk '{print $6}' +smartctl -H /dev/sda | grep "PASSED" | nawk '{print $6}' fi exit 0 diff --git a/snmpd.conf b/snmpd.conf index 1146223..8869523 100644 --- a/snmpd.conf +++ b/snmpd.conf @@ -1,16 +1,20 @@ #Listen on all interfaces, IPv4 only agentAddress udp:161 + #ACCESS CONTROL view all included .1.3.6.1.2.1.1 view all included .1.3.6.1.2.1.25.1 + #SNMP v2 (Read only) with community "public" restricted to Network #Please change IP 192.168.1.0/24 to your Network. rocommunity public 192.168.1.0/24 sysLocation YourCity sysContact YourName + #Run as root agentuser root + #Add commands -pass .1.3.6.1.2.1.25.1.8 /bin/sh /root/snmp-cpu-temp.sh -pass .1.3.6.1.2.1.25.1.9 /bin/sh /root/snmp-lvm-used.sh -pass .1.3.6.1.2.1.25.1.10 /bin/sh /root/snmp-smart-status.sh +pass .1.3.6.1.2.1.25.1.8 /bin/sh /opt/snmp-cpu-temp.sh +pass .1.3.6.1.2.1.25.1.9 /bin/sh /opt/snmp-lvm-used.sh +pass .1.3.6.1.2.1.25.1.10 /bin/sh /opt/snmp-smart-status.sh From 0e6ea86930425fa0920364035cb857a4e7af318b Mon Sep 17 00:00:00 2001 From: Prins Geryha Date: Wed, 17 Aug 2022 19:58:28 +0200 Subject: [PATCH 2/3] Changed thermal_zone Changed form thermal_zone7 to 2. My Proxmox installation did not use more than 0,1,2 folders. Number 2 was CPU. --- snmp-cpu-temp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snmp-cpu-temp.sh b/snmp-cpu-temp.sh index cd9e81e..78efbb7 100644 --- a/snmp-cpu-temp.sh +++ b/snmp-cpu-temp.sh @@ -3,6 +3,6 @@ if [ "$1" = "-g" ] then echo .1.3.6.1.2.1.25.1.8 echo gauge -echo `cat /sys/class/thermal/thermal_zone7/temp | sed 's/\(.\)..$/.\1/'` +echo `cat /sys/class/thermal/thermal_zone2/temp | sed 's/\(.\)..$/.\1/'` fi exit 0 From 761000c44101826e1ead834c23bccda6d773232a Mon Sep 17 00:00:00 2001 From: Prins Geryha Date: Wed, 17 Aug 2022 20:50:23 +0200 Subject: [PATCH 3/3] Added NVME SMART Status support NVME disks are located elsewhere. Added command for nvme. --- snmp-smart-status.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snmp-smart-status.sh b/snmp-smart-status.sh index 52e019a..4c4ef54 100644 --- a/snmp-smart-status.sh +++ b/snmp-smart-status.sh @@ -3,6 +3,7 @@ if [ "$1" = "-g" ] then echo .1.3.6.1.2.1.25.1.10 echo STRING -smartctl -H /dev/sda | grep "PASSED" | nawk '{print $6}' +if +smartctl -H /dev/sda | grep "PASSED" | nawk '{print $6}' && smartctl -H /dev/nvme0n1p3 | grep "PASSED" | nawk '{print $6}' fi exit 0