SNMP

From Hurlster Wiki
Jump to navigation Jump to search

Prerequisites

apt-get install mbmon snmp snmpd

snmpd.conf

disk  / 10000
disk  /var/local/storage 10000
disk /var/local/backup 10000

load  12 12 12

rocommunity  SNMPSTRING  

############################################
# Executables/scripts
#
# Monitoring exec scripts
# mbmon -r
# mbmon -f -I -c1 -T2

# CPU TEMP0 && CPU TEMP1
exec temp0 /usr/bin/mbmon -f -I -c1 -T1
exec temp1 /usr/bin/mbmon -f -I -c1 -T2

# FAN0 && FAN1
exec fan0 /usr/bin/mbmon -I -c1 -F1
exec fan1 /usr/bin/mbmon -I -c1 -F2

#
exec disksda /usr/local/sbin/disksda.sh
exec disksdb /usr/local/sbin/disksdb.sh
exec disksdc /usr/local/sbin/disksdc.sh

/usr/local/disksda.sh

#!/bin/sh
## hddtemp -uF /dev/sda | cut -c27-29
## netcat localhost 7634 | mawk -F "|" '{ print $19 }'
sda=`hddtemp -nuF /dev/sda`
#echo "0"
echo $sda
  • CentOS snmpd log fix

Change /etc/sysconfig/snmpd.options

# snmpd command line options
# OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a"
OPTIONS="-LS 0-4 d -Lf /dev/null -p /var/run/snmpd.pid -a"

Restart snmpd

SNMPd Proxy

  • snmpd.conf
agentAddress udp:161,udp6:[::1]:161

rocommunity SnMpStRiNg

# Define a simple view 'systemview', which includes everthing under .1.3.6.1
view    systemview     included      .1.3.6.1

# Map 'public' community to the 'notConfigUser'
com2sec notConfigUser  default       SnMpStRiNg

# Map 'notConfigUser' to 'notConfigGroup'
group   notConfigGroup v1            notConfigUser
group   notConfigGroup v2c           notConfigUser

# Give 'notConfigGroup' read access to objects in the view 'systemview'
access  notConfigGroup ""            any       noauth    exact  systemview none none

# v1/v2c community string for each proxied host  #com string to poll
com2sec -Cn ctx_db3 notConfigUser  default       db3

# Allow the 'notConfigUser' (a member of 'notConfigGroup') access for these contexts
access  notConfigGroup ctx_db3        any     noauth  prefix  systemview none none

# Setting up the proxy configuration
proxy -Cn ctx_db3 -v 2c -c destSnMpStRiNg X.X.X.X .1.3

##
com2sec -Cn ctx_db4 notConfigUser  default       db4
access  notConfigGroup ctx_db4        any     noauth  prefix  systemview none none
proxy -Cn ctx_db4 -v 2c -c destSnMpStRiNg Y.Y.Y.Y .1.3
snmpget -v2c -cdb3 127.0.0.1 SNMPv2-MIB::sysName.0