Replaced snmpctl with snmp, thank you for the reminder Rafael

This commit is contained in:
mischa 2021-04-23 23:57:34 +02:00
parent a5c4099f58
commit d6cb721e8a
7 changed files with 21 additions and 20 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019-2020 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2021 Mischa Peters <mischa @ openbsd.amsterdam>
#
# 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})

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019-2020 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2021 Mischa Peters <mischa @ openbsd.amsterdam>
#
# 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)

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019-2020 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2021 Mischa Peters <mischa @ openbsd.amsterdam>
#
# 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 <host> community public oid ifDescr
# Get list of interfaces with: snmp walk -c public <host> 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}

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2021 Mischa Peters <mischa @ openbsd.amsterdam>
#
# 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"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019-2020 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2021 Mischa Peters <mischa @ openbsd.amsterdam>
#
# 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)

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2019-2020 Mischa Peters <mischa @ openbsd.amsterdam>
# Copyright (c) 2019-2021 Mischa Peters <mischa @ openbsd.amsterdam>
#
# 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}

View File

@ -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 &