Freebsd下安装snmp
/ / 点击 /要用到cacti通过net-snmp监控各个服务器的运行情况,这样要为每一台服务器安装snmp,虽然安装比较简单,还是偷偷懒写个脚本吧,CentOS下安装要换用yum来安装了。
!/bin/sh
SNMPD_CONF_DIR=/usr/local/share/snmp
if [ -f ‘/usr/local/sbin/snmpd’ ]
then
echo ‘snmpd already installed!’
else
cd /usr/ports/net-mgmt/net-snmp
echo “Installing…”
make install > /dev/null
cd ~/manage_tools
echo “Setting…”
sleep 3
cat <
syslocation beijing
syscontact jiangjian jianzi0307@gmail.com
sysservices 77
rocommunity jiangjian
load 12 12 12
EOF
mv snmpd.conf $SNMPD_CONF_DIR
cat <
!/bin/sh
/usr/local/sbin/snmpd
EOF
cat <
!/bin/sh
killall snmpd
EOF
chmod a+x snmpd.start snmpd.stop
run snmpd
echo “Run snmpd…”
sleep 3
/bin/sh snmpd.start
echo ok!
fi
另:用cacti监控Mysql的方法:
a> 下载Cacti监控Mysql所需要的脚本和模版,按下面步骤来
wget http://www.faemalia.net/mysqlUtils/teMySQLcacti-20060810.tar.gz
cd /data/src/teMySQLcacti
./convertXmlTo5minutePollingInterval.sh
These graphs assume a1-minute Poller cron frequency! If you use the default 5-minuteinterval, run convertXmlTo5minutePollingInterval.sh, which will make astep=300, heartbeat=600 version of the XML file for you to import.
cp mysql_stats.php /data/cacti/scripts/
cp dumpMemcachedStats.php /data/cacti/scripts/ 这个脚本貌似是监控memcached的,刚好用到!
在cacti管理界面导入cacti_host_template_temysql_host-step300-heartbeat600.xml与cacti_host_template_memcached_host-step300-heartbeat600.xml模板文件。
在被监控机的msql数据库服务器需要加入监控机的操作权限:
mysql> grant process,super on . to ‘cacti’@’cacti server ip’ identified by ‘password’;
貌似只需要process权限即可。
by the way:安全手则说不许将process或super权限付给非管理用户,该mysqladmin processlist可以列举出当前执行的查询文本;super权限可用于切断客户端连接、改变服务器运行参数状态、控制拷贝复制数据库的服务器;