10. How to enable SNMP on Windows for CPU-load monitoring with ascript and snmpload.sh

The following steps are necessary on the Windows target server:

  • Invoke the Control Panel.
  • Double click the Add/Remove Programsicon.
  • Select Add/Remove Windows Components(The Windows Component Wizard is displayed).
  • Check the Management and Monitoring Tools box.
  • Click the Details button.
  • Check the SNMP box and click OK, then Next.
  • Additionally Port 161 for UDP needs to be added as an exeption at the Windows Firewall settings.
  • Reboot the machine.

For German Windows the click-path is as follows:

  • Systemsteuerung ->
  • Software ->
  • Windows-Komponenten hinzufügen und entfernen ->
  • Verwaltungs und Überwachungsprogramme ->
  • Details ->
  • SNMP.

The snmpload.sh source code is as follows:

#/bin/sh

VALUES=`snmpwalk -v1 -c public -O qv $1 .1.3.6.1.2.1.25.3.3.1.2 2>/dev/null`

if [ "$?" != "0" ]
then
  echo 101
  exit 0
fi

SUM=0
COUNT=0

for VALUE in $VALUES
do
  COUNT=`expr $COUNT + 1`
  SUM=`expr $SUM + $VALUE`
done

if [ "$COUNT" = 0 ]
then
  echo 101
  exit 0
else
  RESULT=`expr $SUM / $COUNT`
  RESULT=`expr $RESULT + 1`
  echo $RESULT
  exit 0
fi