Cacti與Nagios網(wǎng)絡(luò)監(jiān)控的區(qū)別-Nagios的安裝
Cacti與Nagios進(jìn)行網(wǎng)絡(luò)監(jiān)控的區(qū)別
本文講述的是:Cacti與Nagios網(wǎng)絡(luò)監(jiān)控的區(qū)別——返回大綱
5. 安裝Nagios
這一部分相對(duì)來說比較復(fù)雜一點(diǎn),因?yàn)橐约壕幾g程序,但是一旦會(huì)了,也是很簡(jiǎn)單的事情。
一開始先要安裝Nagios需要的兩個(gè)package
- apt-get install build-essential libgd2-xpm-dev
添加編輯用戶和組
- useradd nagios
- groupadd nagios
- groupadd nagcmd
- usermod -G nagcmd nagios
- usermod -G nagcmd www-data
下載并編譯安裝Nagios
mkdir ~/nagios
cd ~/nagios
wget http://osdn.dl.sourceforge.net/s ... nagios-3.0.2.tar.gz
我用的是3.0.2。
- tar nagios-3.0.2.tar.gz
- cd ~/nagios/nagios-3.0.2
- ./configure --with-command-group=nagcmd
- make all
- make install
- make install-init
- make install-config
- make install-commandmode
- make install-webconf
然后給nagios一個(gè)web的密碼
- htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
重啟apache
- /etc/init.d/apache2 restart
下面就是做個(gè)link,具體有什么用我也不清楚,但是不用不行,有知道的請(qǐng)告訴我。
- ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
然后安裝nagios plugins
這個(gè)plugins里面主要是有很多用來check host和service的文件
- cd ~/nagios
- wget http://osdn.dl.sourceforge.net/s ... ugins-1.4.11.tar.gz
- tar xzf nagios-plugins-1.4.11.tar.gz
- ./configure --with-nagios-user=nagios --with-nagios-gourp=nagios
- make
- make install
***是關(guān)于nagios的mail alarm,我試了本機(jī)發(fā)送一直都沒有成功,所以走了我們公司的smtp服務(wù)器,用了一個(gè)perl的script來發(fā):
- #!/usr/bin/perl
- use Getopt::Std;
- use Net::SMTP;
- #f:mail from s:subject t:rcpt to
- Getopt::Std::getopts('f:s:t:',\%options);
- my $from=$options{f};
- my $subject=$options{s};
- my $to=$options{t};
- while(defined($line=;)){
- $content.=$line;
- }
- open(LOG,">>/var/log/notify.log");
- $smtp=Net::SMTP->new('yourSMTPserverAddress');
- $smtp->mail($from);
- $smtp->to($to);
- $smtp->data();
- $smtp->datasend("To:$to\n");
- $smtp->datasend("Subject:$subject\n");
- $smtp->datasend("Content-Type:text/plain;charset=utf-8\n");
- $smtp->datasend("\n");
- $smtp->datasend("$content\n");
- $smtp->dataend();
- $smtp->quit;
- my $date_command="/bin/date";
- my $date='$date_command';chop($date);
- print LOG "$date:Sent Msg $content to $to\n";
- close(LOG);
- exit(0);
下面是我用在Nagios里面的notify-host-by-email的command:
- /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | perl /usr/local/nagios/etc/mail1.pl -f nagios@infor.com -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -t $CONTACTEMAIL$
關(guān)于Naigos的alarm,我研究過還可以用短消息的,但是僅限于移動(dòng)用戶,使用一個(gè)linux下的飛信的軟件,還可以。Nagios飛信Linux系統(tǒng)免費(fèi)短信報(bào)警配置
【編輯推薦】
MRTG、Cacti、Rrdtool、Nagios、Zabbix大比拼