懒惰
#!/bin/bash
# created by "XXB" on idclayer.com
# SNMP Installer Projects
service snmpd stop
echo "Please enter Server Location: "
echo "Like DC,City,Country"
read LOC
echo "Location: $LOC"
yum -y install net-snmp net-snmp-devel net-snmp-utils
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf_$(date +"%N").bak
echo -n "
rocommunity oooo 1.1.1.1
view all included .1 80
syslocation $LOC
syscontact Matt<support######idclayer.com>
extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
">> /etc/snmp/snmpd.conf
#/etc/snmp/snmpd.conf
service snmpd start
chkconfig snmpd on
#回调 使用CURL请求监控API接口 自动添加监控目标
IP=$(host $(uname -n) | grep "address" | grep -v "IPv6" | head -n 1 | awk '{print $4}')
echo "Server IP is $IP"
RESULT=`curl -s "http://www.test.com/add?ip=$IP" | grep -o -E "adderror|pingerror"`
echo $RESULT;
# ./add_device.php ip nnn v2c
echo "Dot forget open IPTables 161 UDP Port!!!"