1. 程式人生 > >Nagios下的NDOUtils插件

Nagios下的NDOUtils插件

nagios ndoutils

NDOUtils插件是用於Nagios中的事件和配置信息數據導入數據庫用於在數據庫中記錄其相關的關聯關系,在以前有使用NagiosQL(http://jim123.blog.51cto.com/4763600/1970398)有些類似,不過不同的是在NagiosQL中是已經有用php文件寫好的前端頁面以及和定義的配置文件與數據庫交互,而在NDOUtils中僅僅是把Nagios中事件和配置信息記錄於數據庫中,這使得可以根據存入數據庫中的記錄狀態用於監控或者做其他觸發等等,在這裏就簡單的說一說NDOUtils的安裝部署,NDOUtils安裝部署還是比較簡單的,在這裏使用的數據庫建議MySQL,NDOUtils可以在Nagios的社區中下載最新穩定版https://exchange.nagios.org/directory/Addons/Database-Backends/NDOUtils/details:

[[email protected] ndoutils-2.1.3]# yum -y install perl-DBD-MySQL perl-DBI
[[email protected] ndoutils-2.1.3]# tar -zxvf ndoutils-2.1.3.tar.gz && cd ndoutils-2.1.3
[[email protected] ndoutils-2.1.3]# ./configure --enable-mysql --with-mysql=/usr/local/mysql --with-ndo2db-user=nagios -with-ndo2db-group=nagios
[[email protected] ndoutils-2.1.3]# make all && make fullinstall
[[email protected] ndoutils-2.1.3]# cp -arp startup/default-init /etc/init.d/ndo2db
[[email protected] ndoutils-2.1.3]# chmod +x /etc/init.d/ndo2db
[[email protected] ndoutils-2.1.3]# cd db/
#建庫導入數據
mysql> CREATE DATABASE nagios;
mysql> GRANT ALL ON `nagios`.* TO [email protected]‘localhost‘ IDENTIFIED BY "youpassword";
mysql> use nagios;
mysql> source mysql.sql
[[email protected] db]# cd /usr/local/nagios/etc/
[[email protected] etc]# mv ndo2db.cfg-sample ndo2db.cfg && mv ndomod.cfg-sample ndomod.cfg
#ndo2db.cfg是用於連接數據庫的相關配置,根據實際數據庫用戶密碼連接
#ndomod.cfg使用於配置相關日誌及使用相關模式的配置文件
[[email protected] db]# vim nagios.cfg
…略…
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
event_broker_options=-1
[[email protected] etc]# /etc/init.d/ndo2db start

在這裏需要註意的是在安裝的MySQL下需要定義好MySQL的lib文件導入系統目錄後用ldconfig,還有在不同版本中的NDOUtils編譯參數都不太相同,在編譯前可以./configure --help查看,這裏需要註意的是在每次添加修改重啟Nagios後都需要重啟ndo2db重新把配置信息及事件記錄於數據庫中

本文出自 “Jim的技術隨筆” 博客,謝絕轉載!

Nagios下的NDOUtils插件