1、ndoutils的編譯當萬事具備,開始要編譯安裝的時候,仍需要注意三點:1、要指明使用的資料庫類型,資料庫的lib庫,資料庫的標頭檔。./configure –enable-mysql --with-mysql-inc=… –with-mysql-lib=…2、編譯時間如出現類似於 ”xxxxxx ceil” 的錯誤,請在src下的Makefile中修改CFLAGS的值,增加-lm參數。注意,Makefile中有兩個CFLAGS,需修改第二個,因為它會把第一個給覆蓋了。或者把其中一個mark掉也可以。3、installdb這一步必須進入db目錄下執行./installdb 因為程式需要讀取該目錄下的指令碼。按要求執行這一步之後,如出現未能產生相應的資料庫,請確認資料庫使用者的許可權是否正確;如果出現類似於”…./mysqld/mysqld.sock”的錯誤,請察看mysql的設定檔my.cnf確認mysql的串連池在該目錄下,若不是,請使用ln –s與之建立串連;若出現資料庫表已存在報告,可drop該資料庫然後重新create再執行installdb(這時要確保以存在的資料庫不再使用)。
2、ndoutils的db中有表沒資料
按照安裝文檔正確編譯ndoutils,將可執行檔和設定檔拷貝到指定目錄並正確配置後。使用以下命令啟動ndoutils: /usr/local/nagios/bin/ndo2db –c /usr/local/nagios/etc/ndo2db.cfg這時,可能出現兩個比較棘手的問題:
2.1、不能載入資料庫出現如下的報錯:"Support for the specified database server is either not yet supported, or was not found on your system."請察看./configure的結果,應該是沒找到mysql.h等標頭檔,請確保所必須的庫已安裝,並在./configure時指定標頭檔目錄(參考ndoutils的編譯)。
Ndoutils需要用到mysql,然而前段時間很多問題出現在對mysql本身的使用上,我自己也在這兒跌了不少跟鬥。
屢次碰到類似於”Support for the specified database server is either not yet supported, or was not found on your system.”是由於mysql的庫不全或者路徑不對,而導致ndoutils找不到mysql相應的標頭檔和庫造成。
解決辦法就是上來把mysql和perl的庫裝上。
libmysql++-dev - mysql C++ library bindings (development)
libmysql++2c2a - mysql C++ library bindings (runtime)
libmysqlclient15-dev - mysql database development files
libmysqlclient15off - mysql database client library
libclass-dbi-mysql-perl -Class::DBI::mysql-Extensions to Class::DBI for MySQL
libdatetime-format-mysql-perl - Parse and format MySQL dates and times
libdbd-mysql-perl -A Perl5 database interface to the MySQL database
libtime-piece-mysql-perl -Time::Piece::MySQL - Adds MySQL-specific methods to Time::Piece
libpam-mysql -PAM module allowing authentication from a MySQL server
libpam-modules - Pluggable Authentication Modules for PAM
libpam-runtime - Runtime support for the PAM library
libpam0g - Pluggable Authentication Modules library
libpam0g-dev - Development files for PAM
kaffe-pthreads - A POSIX threads enabled version of the Kaffe VM
另外,在ndoutils編譯的時候,如果./configure這步提示找不到mysql.h,在前面這些都已正確安裝之後,可以從別處將libmysql的庫和標頭檔目錄考來,並指定為./configure –with-mysql-lib和—with-mysql-lib的目錄即可。
注意:在重新./configure之後,在make之前千萬記住要先make clean,否則最後會發生讓你鬱悶好幾天的事情!
2.2、ndo2db正常啟動,表中卻沒有資料首先,請確保資料庫中的表已產生。執行改名之後如果沒有出現任何提示資訊,說明ndo2db已正常啟動,並向資料寫資料。如果此時從資料庫察看錶資訊,正常的話應該是已經有了nagios的資訊。如果此時仍沒有資料。那原因只有一個,就是資料庫的許可權問題:請察看前設定檔中指定的db_user在db_name,在保證db_pass正確的前提下,察看資料庫mysql中db表中的資訊,並確保db_user對db_name具有update,insert,select和delete的許可權。可參考mysql許可權系統和mysql文檔。以root身份登陸mysqlmysql>use mysql;mysql>select * from db;將看到db_user對db_name的許可權詳情,可用update修改。如果沒有db_user對應db_name的授權,可用insert添加。