SNMP & Check MK Agent
資訊
Librenms需要SNMP才能監控,另外也可以使用check_mk_agent來輔助
但是我現在已經沒在用Librenms,也許哪天想不開又要用的時候會裝上
參考資料
bsnmp
FreeBSD有內建的bsnmp
-
vi /etc/rc.conf
# /etc/rc.conf
--------------------------------------------------------------------------------------------------------------------------------
bsnmpd_enable="YES"
-
pkg install bsnmp-ucd -
vi /etc/snmpd.conf
# /etc/snmpd.conf 加上以下內容
--------------------------------------------------------------------------------------------------------------------------------
begemotSnmpdModulePath."ucd" = "/usr/local/lib/snmp_ucd.so"
%ucd
updateInterval = 500
extCheckInterval = 100
extUpdateInterval = 3000
extTimeout = 60
memMinimumSwap = 1600
memSwapErrorMsg = "No free swap!"
laConfig.1 = "6.0"
laConfig.2 = "5.0"
laConfig.3 = "4.0"
laErrMessage.1 = "1min load average is high!"
laErrMessage.2 = "5min load average is high!"
laErrMessage.3 = "15min load average is high!"
# Process table
prNames.0 = "httpd"
prMin.0 = 3
prMax.0 = 100
prErrFix.0 = 1
prErrFixCmd.0 = "/usr/local/etc/rc.d/apache22 restart"
# Extension commands (extTable)
extNames.0 = "uname"
extCommand.0 = "/usr/bin/uname -a"
extNames.1 = "uptime"
extCommand.1 = "/usr/bin/uptime"
# example of extension with fix command
extNames.2 = "apache"
extCommand.2 = "/usr/local/etc/rc.d/apache status"
extErrFix.2 = 1
extErrFixCmd.2 = "/usr/local/etc/rc.d/apache restart"
-
/etc/rc.d/bsnmpd restart -
bsnmpwalk -v 2c -c public
確認有取得資料就是OK了
check_mk_agent
pre-install needed
pkg install bash ipmitool libstatgrab git
因為check_mk_agent需要用bash跑,沒有bash是不會動的
Install and setup
-
取得check_mk_agent & 賦予執行權限
git clone https://github.com/librenms/librenms-agent.git
cp librenms-agent/check_mk_agent_freebsd /usr/local/bin/check_mk_agent
chmod +x /usr/local/bin/check_mk_agent
上述的方法過時了..因為現在port裡面就有支援
/usr/ports/net-mgmt/check_mk_agent/
cd /usr/ports/net-mgmt/check_mk_agent/
make install clean
-
vi /etc/services
# /etc/services
--------------------------------------------------------------------------------------------------------------------------------
check_mk 6556/tcp #check_mk agent
這個是加進去 的
-
vi /etc/inetd.conf
#/etc/inetd.conf
--------------------------------------------------------------------------------------------------------------------------------
check_mk stream tcp nowait root /usr/local/bin/check_mk_agent check_mk_agent
這個也是加進去的
-
vi /etc/rc.conf
#/etc/rc.conf
--------------------------------------------------------------------------------------------------------------------------------
inetd_enable=yes
inetd_flags=-wW
這個也是加進去的
-
vi /etc/hosts.allow
#/etc/hosts.allow
--------------------------------------------------------------------------------------------------------------------------------
# Allow nagios server to access us
check_mk_agent : 192.168.56.3 : allow
check_mk_agent : ALL : deny
這個也是加進去
-
/etc/rc.d/inetd start -
telnet確認一下
telnet bsdhost 6556
<<<check_mk>>>
Version: 1.1.13i1
AgentOS: freebsd
這樣就好了
結論
雖然我不是很喜歡開inetd 來跑,不過這些機器跟port基本上都用FW限制死了連線,加上librenms架在裡面,所以問題應該沒有那麼大
勉強還是可以這樣用的