安裝前的準備:
1. 我現在已經安裝了icinga,並且使用了mysql. check_mk要求事先安裝了全功能的nagios, 似乎我的已經算是全功能了。現在運行icinga也正常。
2. 檢查external command是否正常。開啟網頁,登入後勾選localhost的ping服務, 然後點擊右上的下拉框:
點擊Submit按鈕後,接著做一些後續操作。然後回到頁面發現Ping服務被禁止了。
所以external command工作正常。
3. 檢查python, UBuntu server已經安裝好了,剛好是2.x版本。
python --versionPython 2.7.3
4. xinetd 在之前安裝NSCA的時候就裝過了。
開始安裝:
1. 下載
root@icinga:/opt# wget http://mathias-kettner.com/download/check_mk-1.2.2p1.tar.gz
2. 解壓:
tar zxvf check_mk-1.2.2p1.tar.gz
3. 運行./setup.sh 程式,進入互動式安裝過程,一般都用預設值。下面是我的預設選擇:
You have chosen the following directories: Executable programs /usr/bin Check_MK configuration /etc/check_mk Check_MK software /usr/share/check_mk documentation /usr/share/doc/check_mk check manuals /usr/share/doc/check_mk/checks working directory of check_mk /var/lib/check_mk extensions for agents /usr/lib/check_mk_agent configuration dir for agents /etc/check_mk Name of Nagios user icinga User of Apache process www-data Common group of Nagios+Apache icinga-cmd Nagios binary /usr/local/icinga/bin/icinga Nagios main configuration file /usr/local/icinga/etc/icinga.cfg Nagios object directory /usr/local/icinga/etc/conf.d Nagios startskript /etc/init.d/icinga Nagios command pipe /usr/local/icinga/var/rw/icinga.cmd Check results directory /usr/local/icinga/var/spool/checkresults Nagios status file /usr/local/icinga/var/status.dat Path to check_icmp /usr/lib/nagios/plugins/check_icmp URL Prefix for Web addons / Apache config dir /etc/apache2/conf.d HTTP authentication file /usr/local/icinga/etc/htpasswd.users HTTP AuthName Icinga Access PNP4Nagios templates /usr/share/check_mk/pnp-templates compile livestatus module yes check_mk's binary modules /usr/lib/check_mk Unix socket for Livestatus /usr/local/icinga/var/rw/live Backends for other systems /usr/share/check_mk/livestatus Install Event Console no
這些資訊都存在了~/.check_mk_setup.conf檔案裡面。下次如果想重新安裝,可以先刪除這個檔案。
4. 重新啟動apache2和icinga服務後,開啟網頁:http://10.112.18.111/check_mk
看到錯誤資訊:
Check_mk: Incomplete Apache2 InstallationYou need mod_python in order to run the web interface of check_mk.Please install mod_python and restart Apache.
現在來安裝Apache2的模組mod_python.
apt-get install libapache2-mod-python
重新啟動apache2.
現在看到頁面了,但是有兩個錯誤:
5. 先不管上面的錯誤,安裝一下本機監控用的agent。
wget http://mathias-kettner.com/download/check-mk-agent_1.2.2p1-2_all.deb
dpkg -i check-mk-agent_1.2.2p1-2_all.deb Selecting previously unselected package check-mk-agent.(Reading database ... 65470 files and directories currently installed.)Unpacking check-mk-agent (from check-mk-agent_1.2.2p1-2_all.deb) ...Setting up check-mk-agent (1.2.2p1-2) ...Reloading xinetd...
6. 修改監控的host列表, 編輯/etc/check_mk/main.mk檔案,內容如下:
# Put your host names hereall_hosts = [ 'localhost' ]
7. 檢測一下, check_mk會讀取所有host並進行檢測,下面建立了11個檢測服務。
cmk -Icpu.loads 1 new checkscpu.threads 1 new checksdf 2 new checksdiskstat 1 new checkskernel 3 new checkskernel.util 1 new checkslnx_if 1 new checksmem.used 1 new checksmounts 2 new checkstcp_conn_stats 1 new checksuptime 1 new checks
8. 然後用check_mk -O 來自動修改icinga的設定檔:
check_mk -OGenerating Nagios configuration...OKValidating Nagios configuration...ERROR:Icinga 1.9.0Copyright (c) 2009-2013 Icinga Development Team (http://www.icinga.org)Copyright (c) 2009-2013 Nagios Core Development Team and Community ContributorsCopyright (c) 1999-2009 Ethan GalstadLast Modified: 05-07-2013License: GPLReading configuration data... Read main config file okay...Processing object config directory '/usr/local/icinga/etc/conf.d'...Processing object config file '/usr/local/icinga/etc/conf.d/check_mk_objects.cfg'...Processing object config file '/usr/local/icinga/etc/conf.d/check_mk_templates.cfg'...Processing object config file '/usr/local/icinga/etc/objects/commands.cfg'...Processing object config file '/usr/local/icinga/etc/objects/contacts.cfg'...Processing object config file '/usr/local/icinga/etc/objects/timeperiods.cfg'...Processing object config file '/usr/local/icinga/etc/objects/templates.cfg'...Processing object config file '/usr/local/icinga/etc/objects/localhost.cfg'...Warning: Duplicate definition found for host 'localhost' (config file '/usr/local/icinga/etc/objects/localhost.cfg', starting on line 23)Error: Could not add object property in file '/usr/local/icinga/etc/objects/localhost.cfg' on line 27. Error processing object config files!***> One or more problems was encountered while processing the config files... Check your configuration file(s) to ensure that they contain valid directives and data definitions. If you are upgrading from a previous version of Icinga, you should be aware that some variables/definitions may have been removed or modified in this version. Make sure to read the HTML documentation regarding the config files, as well as the 'Whats New' section and the Changelog CHANGES section as well to find out what has changed.Nagios configuration is invalid. Rolling back.
報錯了。因為icinga預設有localhost配置。最簡單的解決方案是把下面的檔案裡面的localhost的host定義注釋掉
/usr/local/icinga/etc/objects/localhost.cfg
#define host{ # use linux-server ; Name of host template to use # ; This host definition will inherit all variables that are defined # ; in (or inherited by) the linux-server host template definition. # host_name localhost # alias localhost # address 127.0.0.1 # }
再次運行check_mk -O ,成功。
root@icinga:/etc/check_mk# check_mk -OGenerating Nagios configuration...OKValidating Nagios configuration...OKPrecompiling host checks...OKReloading Nagios...OK