分享:snmp一键安装脚本
1、新建snmp.sh,输入以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #!/bin/bash printf " #################################################### # # # This is a Shell-Based tool of SNMP installation # # # #################################################### " echo "Command is running, please wait....." yum install -y gcc gcc-c++ openssl openssl-devel myusername="yishanhome" echo "Please Your UserName:" read -p "(Default : yishanhome):" myusername if [ "$myusername" = "" ]; then myusername="yishanhome" fi myuserpws="yishanpws" echo "Please input myuserpws(Less than 8 characters):" read -p "(Default UserPassword: yishanpws):" myuserpws if [ "$myuserpws" = "" ]; then myuserpws="yishanpws" fi myip="60.195.249.83" echo "Please input Authorized IP:" read -p "(Default Authorized IP: 60.195.249.83):" myip if [ "$myip" = "" ]; then myip="60.195.249.83" fi clear wget http://lnmpsh.googlecode.com/files/net-snmp-5.6.1.tar.gz tar zxvf net-snmp-5.6.1.tar.gz cd net-snmp-5.6.1 ./configure --prefix=/usr/local/snmp --with-openssl=/usr/ --with-mib-modules=ucd-snmp/diskio make make install echo "rouser $myusername auth" >>/usr/local/snmp/share/snmp/snmpd.conf echo "createUser $myusername MD5 $myuserpws" >>/usr/local/snmp/share/snmp/snmpd.conf iptables -A INPUT -i eth0 -p udp -s $myip --dport 161 -j ACCEPT /usr/local/snmp/sbin/snmpd echo "Your Authorized UserName:$myusername" echo "Your Authorized Password:$myuserpws" echo "Your Authorized IP:$myip" echo "/usr/local/snmp/sbin/snmpd" >>/etc/rc.local |
执行并进行相关设置:
chmod 777 snmp.sh
./snmp.sh
代码转载于:http://www.yishanhome.com/