標籤:說明 檔案 無法 lib64 where 守護 中斷連線 blog emd
1. 概述
NDOUTILS,Nagios Data Output Utils,Nagios資料輸出工具,允許使用者從Nagios匯出狀態和事件資訊到資料庫中,便於以後的檢索和加工
它包括幾個部分:
- NDOMOD
- NDO2DB
- FILE2SOCK
- LOG2NDO
2. 組件介紹2.1 NDOMOD
NDOMOD是事件中斷模組。這個模組在Nagios進程運行時載入。
它唯一的角色就是轉存Nagios所有事件和資料到TCP通訊端,或者普通檔案,或者Unix域通訊端。
如果使用者想即時轉寄資料至MySQL,可以通過轉存資料至TCP通訊端或者Unix域通訊端。如果想延遲轉寄資料至MySQL資料庫,可以通過轉存資料至普通檔案。
2.2 NDO2DB
NDO2DB守護進程。這是一個標準的守護進程,從TCP通訊端或者Unix通訊端讀取輸入資料(通過NDOMOD事件中斷模組輸出)。
NDO2DB分析這些資料,並把他們存入一個或者多個MySQL資料中。NDO2DB具有同時處理多個用戶端的串連的能力,因此使用者同時可以配置多個通過TCP或者Unix通訊端輸出資料的NDOMOD模組執行個體。
2.3 FILE2SOCK
FILE2SOCK特性從普通的檔案讀取資料,將其通過TCP或者Unix通訊端轉存。
這在NDOMOD模組將資料寫入普通檔案時,但希望將其轉存至資料庫的使用情境非常有用。
如果NDOMOD模組輸出的資料和NDO2DB運行進程不在同一台主機上時,使用者可以通過SSH協議轉寄存放資料的普通檔案至運行NDO2DB進程的主機上,然後通過FILE2SOCK特性轉寄普通檔案的內容至TCP或者Unix連接埠(NDO2DB從這些連接埠中擷取資料)
2.4 LOG2NDO
LOG2NDO特性用於將Nagios和NetSaint的曆史日誌歸檔並轉寄給NDO2DB進程。同樣也是將一個記錄檔發送至TCP或者Unix通訊端完成資料轉存。
3. 編譯安裝
configure
./configure --prefix=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3 --enable-mysql --with-opsys=linux --with-dist-type=rh --with-init-type=sysv --with-inetd-type=xinetd --with-mysql-lib=/usr/lib64/mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
註:--with-mysql-lib的選項提示無法識別,但是可以正確配置MySQL庫;但是以--with-mysql選項配置時,實際無法生效
make
直接執行make,提示選擇make的選項,這裡選擇make all
[[email protected] ndoutils-2.1.3]# makePlease enter make [option] where [option] is one of: all builds the NDO Utilities ndo2db builds the ndo2db daemon ndomod builds the ndomod nagios module file2sock builds the file2sock utility log2ndo builds the log2ndo utility sockdebug builds the sockdebug utility install-groups-users add the user and group if they do not exist install installs the module and programs install-config installs the sample configuration files install-inetd install the startup files for inetd, launchd, etc. install-init install the startup files for init, systemd, etc. fullinstall runs install-groups-users, install,install-config and install-init
make install
執行make install之後,提示安裝了適配Nagios v4.x的模組。按照文檔說明,如果需要安裝Nagios v3.x 和v2.x的模組,還需要執行make install-3x和make install-2x,但是會替代。
本篇部落格編譯全部模組,然後都拷貝到對應的目錄下,在設定檔中指定要採用的模組的絕對路徑。
註:在當前解壓目錄下,無法執行make install-3x,無makefile
截至到這裡,NDOUtils已經編譯安裝完成。
安裝database
這一步需要首先建立一個資料庫並授權。
本篇略此過程,具體參閱部落格《MySQL資料庫伺服器(YUM)安裝.md》,部落格園地址:https://www.cnblogs.com/liwanliangblog/p/9194704.html
然後進入到db目錄下,執行./installdb指令碼,結果
執行make install-init,安裝啟動指令碼
執行make install-inetd,安裝超級進程設定檔
這一步需要將5668連接埠添加至/etc/services,即在/etc/services最後一行添加:
ndo2db 5668/tcp # ndo2db
執行make install-config,安裝ndo2db.cfg設定檔
至此,在安裝路徑/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/下,能看到三個目錄,即:
- bin目錄,存放ndomod.o,ndo2db,log2ndo,file2sock,sockdebug程式或者庫
- etc目錄,存放ndo2db.cfg-sample配置模板和ndomod.cfg-sample配置模板
- var目錄,可變資料存放目錄
4. Nagios配置NDOUtils4.1 拷貝設定檔
在/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/下,執行cp ndo2db.cfg-sample ndo2db.cfg和cp ndomod.cfg-sample ndomod.cfg
4.2 Nagios主設定檔修改
修改Nagios主設定檔,如下:
event_broker_options=1broker_module=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/bin/ndomod-4x.o config_file=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/ ndomod.cfg
4.3 NDO2DB設定檔修改
在/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/下,ndomod.cfg為NDOMOD模組設定檔,該檔案不用修改即可使用。修改ndo2db.cfg設定檔內容:
db_user=nagiosdb_pass=liwanliang
註:這裡的db_user和db_pass是建立nagios資料庫時的資料庫使用者和密碼
4.4 啟動
因為在configure的過程中,已經指定了NDO2DB採用sysv模式啟動進程,因此可以通過service ndo2db start啟動服務
通過ps -ef | grep ndo,可以查看到進程已經運行啟動,通過lsof -p pid命令,查看到進程開啟了sock檔案。
注意:此時如果沒有重啟或者重新載入nagios配置,那麼資料庫不會存在資料
如果已經重啟了nagios,但是通過資料庫視覺化檢視未探索資料更新,可以中斷連線,然後重新登陸資料庫查看
4.5 查看4.5.1 資料庫查看
通過資料庫視覺化檢視,串連到MySQL查看nagios資料庫是否存在資料
確認配置資訊,對象配置,警示資訊等均能夠正常儲存
Nagios資料存放區外掛程式NDOUtils的部署和測試