리눅스/기타

snmp 소스설치

Rohin 2020. 9. 29. 14:06
반응형

snmp 최신버전을 다운받는다

http://sourceforge.net/project/showfiles.php?group_id=12694&package_id=11571

[

net-snmp - Browse /net-snmp at SourceForge.net

×

sourceforge.net

](http://sourceforge.net/project/showfiles.php?group_id=12694&package_id=11571)

#tar zxvf net-snmp-5.9.tar.gz

#cd net-snmp-5.9

#./configure --prefix=/usr/local/snmp

## 도중 나오는 과정은 전부 enter ##

#make && make install

## snmpd.conf 파일이없으므로 하나 생성해준다. ##

#vi /usr/local/snmp/share/snmp/snmpd.conf

<내용은 알아서 수정>

설치후 snmp 구동법

#/usr/local/snmp/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a

혹은

#vi /etc/init.d/snmpd

 

#!/bin/bash
# ucd-snmp init file for snmpd
#
# chkconfig: - 50 50
# description: Simple Network Management Protocol (SNMP) Daemon
#
# processname: /usr/local/sbin/snmpd
# config: /etc/snmp/snmpd.conf
# config: /usr/share/snmp/snmpd.conf
# pidfile: /var/run/snmpd.pid

### BEGIN INIT INFO
# Provides: snmpd
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: start and stop Net-SNMP daemon
# Description: Simple Network Management Protocol (SNMP) Daemon
### END INIT INFO

# source function library
. /etc/init.d/functions

OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"
if [ -e /etc/sysconfig/snmpd ]; then
. /etc/sysconfig/snmpd
fi

RETVAL=0
prog="snmpd"
binary=/usr/local/sbin/snmpd
pidfile=/var/run/snmpd.pid

start() {
[ -x $binary ] || exit 5
echo -n $"Starting $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
daemon --pidfile=$pidfile $binary $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
killproc -p $pidfile $binary
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}

reload(){
echo -n $"Reloading $prog: "
killproc -p $pidfile $binary -HUP
RETVAL=$?
echo
return $RETVAL
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/snmpd ] && restart
return 0
}

case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart)
restart
RETVAL=$?
;;
reload|force-reload)
reload
RETVAL=$?
;;
condrestart|try-restart)
condrestart
RETVAL=$?
;;
status)
status snmpd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
RETVAL=2
esac

exit $RETVAL

#chmod 700 /etc/init.d/snmpd

#chkconfig --level 3 snmpd

작업후 

#/etc/init.d/snmpd start

#netstat -nltpu

위명령어로 161UDP 포트가 띄어져있는지 확인한다