From d6cb721e8a449107c61c7176d67f647e63976284 Mon Sep 17 00:00:00 2001 From: mischa Date: Fri, 23 Apr 2021 23:57:34 +0200 Subject: [PATCH] Replaced snmpctl with snmp, thank you for the reminder Rafael --- cores.sh | 4 ++-- cpu_load.sh | 4 ++-- interface.sh | 10 +++++----- ticks.sh | 5 +++-- uptime.sh | 4 ++-- version.sh | 4 ++-- wrapper.sh | 10 +++++----- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/cores.sh b/cores.sh index a42eb1b..72fe4d5 100755 --- a/cores.sh +++ b/cores.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019-2020 Mischa Peters +# Copyright (c) 2019-2021 Mischa Peters # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -45,7 +45,7 @@ ${RRDTOOL} create ${RRDFILES}/${HOST}-cores.rrd \ RRA:MAX:0.5:1:20000 fi -snmpctl snmp walk ${HOST} community ${COMMUNITY} oid hrProcessorLoad | cut -d= -f2 > ${CPUINFO} +snmp walk -c ${COMMUNITY} ${HOST} hrProcessorLoad | awk '{print $4}' > ${CPUINFO} CORES=$(cat ${CPUINFO} | wc -l) ACT_CORES=$((${CORES}/2)) CPU_LOAD=$(cat ${CPUINFO} | paste -s -d: - | cut -d: -f1-${ACT_CORES}) diff --git a/cpu_load.sh b/cpu_load.sh index a8e8846..be4731c 100755 --- a/cpu_load.sh +++ b/cpu_load.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019-2020 Mischa Peters +# Copyright (c) 2019-2021 Mischa Peters # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -35,7 +35,7 @@ ${RRDTOOL} create ${RRDFILES}/${HOST}-cpu.rrd \ RRA:MAX:0.5:1:20000 fi -snmpctl snmp walk ${HOST} community ${COMMUNITY} oid hrProcessorLoad | cut -d= -f2 > ${CPUINFO} +snmp walk -c ${COMMUNITY} ${HOST} hrProcessorLoad | awk '{print $4}' > ${CPUINFO} CORES=$(grep -cv "^0$" ${CPUINFO}) CPU_LOAD_SUM=$(awk '{sum += $1} END {print sum}' ${CPUINFO}) CPU_LOAD=$(echo "scale=2; ${CPU_LOAD_SUM}/${CORES}" | bc -l) diff --git a/interface.sh b/interface.sh index e75f056..2fac403 100755 --- a/interface.sh +++ b/interface.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019-2020 Mischa Peters +# Copyright (c) 2019-2021 Mischa Peters # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -14,7 +14,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -# Get list of interfaces with: snmpctl snmp walk community public oid ifDescr +# Get list of interfaces with: snmp walk -c public ifDescr # test -n "$1" || exit 1 test -n "$2" || exit 1 @@ -46,9 +46,9 @@ ${RRDTOOL} create ${RRDFILES}/${HOST}-${INTERFACE}.rrd \ RRA:MAX:0.5:288:797 fi -IN=$(snmpctl snmp get ${HOST} community ${COMMUNITY} oid ifInOctets.${INTERFACE} | cut -d= -f2) -OUT=$(snmpctl snmp get ${HOST} community ${COMMUNITY} oid ifOutOctets.${INTERFACE} | cut -d= -f2) -DESCR=$(snmpctl snmp get ${HOST} community ${COMMUNITY} oid ifDescr.${INTERFACE} | cut -d= -f2 | tr -d '"') +IN=$(snmp walk -c ${COMMUNITY} ${HOST} ifInOctets.${INTERFACE} | awk '{print $4}') +OUT=$(snmp walk -c ${COMMUNITY} ${HOST} ifOutOctets.${INTERFACE} | awk '{print $4}') +DESCR=$(snmp walk -c ${COMMUNITY} ${HOST} ifDescr.${INTERFACE} | awk '{print $4}') ${RRDTOOL} update ${RRDFILES}/${HOST}-${INTERFACE}.rrd N:${IN}:${OUT} diff --git a/ticks.sh b/ticks.sh index 3e44469..3122970 100755 --- a/ticks.sh +++ b/ticks.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019 Mischa Peters +# Copyright (c) 2019-2021 Mischa Peters # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -15,6 +15,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # HOST="s1.obsda.ms" +COMMUNITY="public" #15259107187 / 8640000 = days (+remainder) = 176.6107855324074 #0.6107855324074 * 24 = hours (+remainder) = 14.65885277777778 @@ -22,7 +23,7 @@ HOST="s1.obsda.ms" #0.53116666666667 * 60 = seconds.milliseconds = 31.87 echo -TICKS=$(snmpctl snmp get ${HOST} oid hrSystemUptime.0 | cut -d= -f2) +TICKS=$(snmp get -c ${COMMUNITY} ${HOST} hrSystemUptime.0 | awk -F"[()]" '{print $2}') echo "TICKS: $TICKS" TICKS="1193085988" diff --git a/uptime.sh b/uptime.sh index e57e4cc..e6a57c4 100755 --- a/uptime.sh +++ b/uptime.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019-2020 Mischa Peters +# Copyright (c) 2019-2021 Mischa Peters # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -20,7 +20,7 @@ COMMUNITY="public" UPTIMEINFO="/tmp/${HOST}-uptime.txt" rm -rf ${UPTIMEINFO} -TICKS=$(snmpctl snmp get ${HOST} community ${COMMUNITY} oid hrSystemUptime.0 | cut -d= -f2) +TICKS=$(snmp get -c ${COMMUNITY} ${HOST} hrSystemUptime.0 | awk -F"[()]" '{print $2}') DAYS=$(echo "${TICKS}/8640000" | bc -l) HOURS=$(echo "0.${DAYS##*.} * 24" | bc -l) MINUTES=$(echo "0.${HOURS##*.} * 60" | bc -l) diff --git a/version.sh b/version.sh index 76489f8..ac539f2 100755 --- a/version.sh +++ b/version.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019-2020 Mischa Peters +# Copyright (c) 2019-2021 Mischa Peters # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -19,4 +19,4 @@ HOST="$1" COMMUNITY="public" VERSIONINFO="/tmp/${HOST}-version.txt" -snmpctl snmp get ${HOST} community ${COMMUNITY} oid sysDescr.0 | awk '{print $3,$4}' > ${VERSIONINFO} +snmp get -c ${COMMUNITY} ${HOST} sysDescr.0 | awk '{print $6,$7}' > ${VERSIONINFO} diff --git a/wrapper.sh b/wrapper.sh index 7a41e8f..411fe8c 100755 --- a/wrapper.sh +++ b/wrapper.sh @@ -16,7 +16,7 @@ # #*/5 * * * * -n /home/mischa/rrdtool/wrapper.sh # -HOSTS="12 2" +HOSTS="14 1" SCRIPTS="/home/mischa/rrdtool" for i in $(jot ${HOSTS}); do @@ -34,9 +34,9 @@ for i in $(jot ${HOSTS}); do done wait -${SCRIPTS}/interface.sh s1.obsda.ms 12 & -${SCRIPTS}/interface.sh s2.obsda.ms 6 & -${SCRIPTS}/interface.sh s3.obsda.ms 12 & +${SCRIPTS}/interface.sh s1.obsda.ms 8 & +${SCRIPTS}/interface.sh s2.obsda.ms 8 & +${SCRIPTS}/interface.sh s3.obsda.ms 8 & ${SCRIPTS}/interface.sh s4.obsda.ms 12 & ${SCRIPTS}/interface.sh s5.obsda.ms 12 & ${SCRIPTS}/interface.sh s6.obsda.ms 12 & @@ -47,4 +47,4 @@ ${SCRIPTS}/interface.sh s10.obsda.ms 12 & ${SCRIPTS}/interface.sh s11.obsda.ms 12 & ${SCRIPTS}/interface.sh s12.obsda.ms 8 & ${SCRIPTS}/interface.sh s13.obsda.ms 8 & -#${SCRIPTS}/interface.sh s14.obsda.ms 8 & +${SCRIPTS}/interface.sh s14.obsda.ms 9 &