Nagios 安裝 部署 說明
Nagios是一個用來監控主機、服務和網路的開放原始碼軟體,可以在發生故障時傳送報警簡訊和郵件,只要Nagios監控的物件發生故障,系統就會自動傳送簡訊到手機上。所以應用十分廣泛。
Nagios is an open source host, service and.network monitoring program. Who uses it? Lots of people, including many big companies and organizations。
一. 相關包的下載:
可以先下載到windows在通過mount 掛載到redhat上,也可以通過wget 直接下載:
下載地址:http://www.nagios.org/download
Nagios Core OSS consists of various Open Source components that provide the foundation for rock-solid IT infrastructure monitoring. Download all the components you need to get started.
Step 1 - Get Nagios Core
Required. Contains the core monitoring application and web interface.
# ./wget http://ncu.dl.sourceforge.net/project/nagios/nagios-3.x/nagis-3.2.1/nagios-3.2.1.tar.gz
Step 2 - Get Nagios Plugins
Also Required. Allows you to monitor services, applications, metrics, and more.
# ./wget http://ncu.dl.sourceforge.net/project/nagiosplug/nagiosplug/.4.14/nagios-plugins-1.4.14.tar.gz
Step 3 - Get Nagios Addons
Trick out your Nagios install by extending its capabilities with hundreds of community-contributed addons.
# ./wget http://ncu.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-212/nrpe-2.12.tar.gz
# ./wget http://ncu.dl.sourceforge.net/project/nagios/nsca-2.x/nsca-27.2/nsca-2.7.2.tar.gz
# ./wget http://ncu.dl.sourceforge.net/project/nagios/ndoutils-1.x/ndutils-1.4b9/ndoutils-1.4b9.tar.gz
NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with Windows agent addons like NSClient++, so you can check metrics on remote Windows machines as well.
NSCA allows you to integrate passive alerts and checks from remote machines and applications with Nagios. Useful for processing security alerts, as well as deploying redundant and distributed Nagios setups.
NDOUtils allows you to export current and historical data from one or more Nagios instances to a MySQL database. Experimental/beta at this point in time, but several community addons use this as one of their data sources.
監控windows 需要NSClient,下載:
http://sourceforge.net/projects/nscplus/
windows上客戶端的配置請參考blog:
How To Monitor Remote Windows Machine Using Nagios on Linux
http://space.itpub.net/?uid-15880878-action-viewspace-itemid-723057
監控Linux,需要安裝NRPE 包 和 plugins 程式。
Web 伺服器:
httpd-2.2.15.tar.gz
#wget http://apache.freelamp.com/httpd/httpd-2.2.15.tar.gz
二. Nagios 安裝
2.1 linux 下軟體安裝步驟
1)解壓:Tar zxvf *.gz
2)執行: ./configure,會生成makefile檔案。
3)編譯: ./make all
4)安裝軟體: ./make install,
2.2 安裝順序:
1). 安裝Nagios
./configure
... ...
Creating sample config files in sample-config/ ...
*** Configuration summary for nagios 3.2.1 03-09-2010 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
--建立使用者和組
#groupadd nagios
#useradd -g nagios nagios
#passwd nagios
[root@Dave nagios-3.2.1]# cd ./base
[root@Dave base]# pwd
/nagios/nagios-3.2.1/base
[root@Dave base]#./make all
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
根據上面的提示,在make install 的時候我們要分別執行:
make install
make install-init
make install-commandmode
make install-config
make install-webconf
驗證程式是否被正確安裝。切換目錄到安裝路徑(這裡是/usr/local/nagios),看是否存在 etc、bin、 sbin、 share、 var這五個目錄,如果存在則可以表明程式被正確的安裝到系統了。
五個目錄功能的簡要說明:
bin | Nagios執行程式所在目錄,這個目錄只有一個檔案nagios |
etc | Nagios配置檔案位置,初始安裝完後,只有幾個*.cfg-sample檔案 |
sbin | Nagios Cgi檔案所在目錄,也就是執行外部命令所需檔案所在的目錄 |
Share | Nagios網頁檔案所在的目錄 |
Var | Nagios日誌檔案、spid 等檔案所在的目錄 |
2). 外掛安裝:
./configure
Make
Make install
安裝完成後,將在目錄/usr/local/nagios生成目錄libexec目錄(裡面有很多檔案)。
3). 安裝web伺服器apache
Web服務不是nagios所必須的,但是如果nagios沒有web,只有通過檢視nagios的日誌來判斷狀態。
在unix/linux世界,apache是web伺服器的首選物件,其下載網站為www.apache.org 。建議下載原始碼。因為我們不需要很複雜的web功能,因此簡單的執行一下幾個步驟就可以正確的把apache安裝到系統:
1、 解包、配置:tar zxvf httpd-*.tar.gz ; ./configure –prefix=/usr/local/apache 。
2、 編譯安裝: make ; make install 。
安裝完成後,執行命令 ./usr/local/apache/bin/apachectl –t 檢查一下apache是否正確安裝
4) -Get Nagios Addons。 在待監控的機子上安裝NRPE for linux. NSClient for windows 這個在後面配置的時候有說明
./configure
Make
Make install
三.Nagios 配置前的準備
最主要的工作是建立nagios使用者及其屬組,讓nagios的執行使用者為nagios而不是root。再把目錄/usr/local/nagios的屬主設定為nagios,以保證系統的安全。Nagios可以以root使用者執行,但並不推薦這樣做。用下面的步驟來完成上述過程:
1、新增系統帳戶nagios, 在安裝Nagios的時候,已經做過這一步.
--建立使用者和組
#groupadd nagios
#useradd -g nagios nagios
#passwd nagios
在實際的運用場景,nagios使用者並沒有必要作為系統使用者來登入linux系統,因此可以不必設定nagios的使用者密碼,甚至可以把nagios使用者的登入shell設定成/bin/false。
2、更改目錄屬組:chown –R nagios.nagios /usr/local/nagios 。請注意,有的unix/linux的版本使用者和屬組分隔符號不是“.”,可能會是這樣的形式 chown -R nagios:nagios /usr/local/nagios 。
3、sendmail。我們需要使用sendmail來傳送故障報警資訊,所以這個包必須能夠正常工作。 現在一般的Linux系統都自帶了sendmail,我們只需要啟動sendmail即可。
4、手機簡訊傳送工具。
如果公司有傳送簡訊的平臺,那麼直接呼叫就可以了,如果沒有,我們可以讓手機接收郵件,或者使用飛信來傳送。
四. Nagios 的配置
4.1 Apache 配置:
A sample Apache config file snippet is created when you run the configure script - you can find the sample config file (named httpd.conf) in the sample-config/ subdirectory of the Nagios distribution. You will need to add the contents of this file to your Apache configuration files before you can access the Nagios web interface. The instructions found below detail how to manually add the appropriate configuration entries to Apache.
Configure Aliases and Directory Options For The Web Interface
First you'll need to create appropriate entries for the Nagios web interface (HTML and CGIs) in your web server config file. Add the following snippet to your web server configuration file (i.e. httpd.conf), changing it to match any directory differences on your system.
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios /usr/local/nagios/share
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Note: The default Nagios installation expects to find the HTML files and CGIs at http://yourmachine/nagios/ and http://yourmachine/nagios/cgi-bin/, respectively. These locations can be changed using the --with-htmurl and --with-cgiurl options in the configure script.
Important! If you are installing Nagios on a multi-user system, you may want use CGIWrap to provide additional security between the CGIs and the external command file. If you decide to use CGIWrap, the ScriptAlias you'll end up using will most likely be different from that mentioned above. More information on doing this can be found here.
Restart The Web Server
Once you've finished editing the Apache configuration file, you'll need to restart the web server with a command like this...
/etc/rc.d/init.d/httpd restart
Configure Web Authentication
Once you have installed the web interface properly, you'll need to specify who can access the Nagios web interface.
If you haven't done so already, you'll need to add the appropriate entries to your web server config file to enable basic authentication for the CGI and HTML portions of the Nagios web interface. Instructions for doing so can be found here.
Now that you've configured your web server to require authentication for the Nagios web interface, you'll need to specify who has access. This is done by using the htpasswd command supplied with Apache.
Running the following command will create a new file called htpasswd.users in the /usr/local/nagios/etc directory. It will also create an username/password entry for nagiosadmin. You will be asked to provide a password that will be used when nagiosadmin authenticates to the web server.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Continue adding more users until you've created an account for everyone you want to access the CGIs. Use the following command to add additional users, replacing
htpasswd /usr/local/nagios/etc/htpasswd.users
Okay, so you're done with the first part of what needs to be done. At this point you should be prompted for a username and password if you point your web browser to the Nagios web interface. If you have problems getting user authentication to work at this point, read your webserver documentation for more info.
Verify Your Changes
Don't forget to check and see if the changes you made to Apache work. You should be able to point your web browser at http://yourmachine/nagios/ and get the web interface for Nagios. The CGIs may not display any information, but this will be remedied once you configure everything and start Nagios.
The information from :Setting Up The Web Interface
http://nagios.sourceforge.net/docs/2_0/installweb.html
4.2 Nagios 的配置檔案
Nagios在安裝完會預設生成一些簡單的配置檔案,但是如果要滿足我們需求我們還需要自己新增一些檔案。
Objects are all the elements that are involved in the monitoring and notification logic. Types of objects
include:
Services
Service Groups
Hosts
Host Groups
Contacts
Contact Groups
Commands
Time Periods
Notification Escalations
Notification and Execution Dependencies
1)/usr/local/nagios/etc/nagios.cfg。 -- Nagios 的主要配置檔案
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# Definitions for monitoring a router/switch
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
# Definitions for monitoring a network printer
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg
裡面還有與是否傳送警告的相關配置引數. 預設都是啟動的。
先註釋掉相關的控制檔案,在修改對應的的檔案。
Nagios 的配置修改之後要
[root@Dave objects]# service nagios restart
#配置機器啟動時自動啟動Nagios
#chkconfig nagios on
2) /usr/local/nagios/etc/cgi.cfg
cgi.cfg 內容如下:
main_config_file=/usr/local/nagios/etc/nagios.cfg
physical_html_path=/usr/local/nagios/share
url_html_path=/nagios
use_authentication=1
authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
#authorized_for_read_only=user1,user2
如果有多個使用者,用逗號隔開, 這些使用者就是在apache配置中新增的:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
3) /usr/local/nagios/etc/objects/timeperiods.cfg
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
define timeperiod{
timeperiod_name none
alias No Time Is A Good Time
}
define timeperiod{
name us-holidays
timeperiod_name us-holidays
alias U.S. Holidays
january 1 00:00-00:00 ; New Years
monday -1 may 00:00-00:00 ; Memorial Day (last Monday in May)
july 4 00:00-00:00 ; Independence Day
monday 1 september 00:00-00:00 ; Labor Day (first Monday in Sep tember)
thursday -1 november 00:00-00:00 ; Thanksgiving (last Thursday in November)
december 25 00:00-00:00 ; Christmas
}
define timeperiod{
timeperiod_name 24x7_sans_holidays
alias 24x7 Sans Holidays
use us-holidays ; Get holiday exceptions from ot her timeperiod
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
4) /usr/local/nagios/etc/objects/Commands.cfg
該檔案儲存了寫如傳送郵件的命令,可以根據自己的需求進行擴充套件。
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****/n/nNotification
Type: $NOTIFICATIONTYPE$/nHost: $HOSTNAME$/nState: $HOSTSTATE$/nAddress: $HOSTA
DDRESS$/nInfo: $HOSTOUTPUT$/n/nDate/Time: $LONGDATETIME$/n" | /bin/mail -s "** $
NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****/n/nNotification
Type: $NOTIFICATIONTYPE$/n/nService: $SERVICEDESC$/nHost: $HOSTALIAS$/nAddress:
$HOSTADDRESS$/nState: $SERVICESTATE$/n/nDate/Time: $LONGDATETIME$/n/nAdditional
Info:/n/n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert:
$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
5) /usr/local/nagios/etc/objects/contacts.cfg 檔案, 該檔案儲存是接收報警聯絡人的資訊
define contact{
contact_name Dave
use generic-contact
alias Dave
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email tianlesoftware@vip.qq.com
}
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email tianlesoftware@qq.com
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,Dave
}
上面的檔案定義了2個聯絡人,如果有更多聯絡人的話,照這個格式在後面追加即可。在contactgroup裡, 多個成員之間用逗號做分界符,如果有更多的聯絡組,就依相同的格式在檔案中追加餘下的組。
Table 1. Service notification options
Notify on transition | Option |
WARNING service states | w |
UNKNOWN service states | u |
CRITICAL service states | c |
Service RECOVERY states | r |
Send NO service notifications | n |
Table 2. Host notification options
Notify on transition | Option |
DOWN host states | d |
UNREACHABLE host states | u |
HOST RECOVERIES (return to UP state) | r |
Send NO host notifications | n |
7 ) /usr/local/nagios/etc/objects/windows.cfg 監控windows的客戶端及監控配置檔案
這些檔案的引數可以可以參考templates.cfg 檔案。 Windows 和Linux 的格式有些出入, 這點要注意。
define host{
use windows-server
host_name 192.168.1.80
alias My Windows Server
address 192.168.1.80
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,u,r
contact_groups admins
hostgroups windows-servers
}
define host{
use windows-server
host_name 10.85.10.80
alias My Windows
address 10.85.10.80
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,u,r
contact_groups admins
hostgroups windows-servers
}
define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
members 10.85.10.80,192.168.1.80
}
define service{
use generic-service
host_name 10.85.10.80
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
define service{
use generic-service
host_name 10.85.10.80
service_description Uptime
check_command check_nt!UPTIME
}
define service{
use generic-service
host_name 10.85.10.80
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service{
use generic-service
host_name 10.85.10.80
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
define service{
use generic-service
host_name 10.85.10.80
service_description C:/ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
host_name 10.85.10.80
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
define service{
use generic-service
host_name 10.85.10.80
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
如果有多臺windows PC, 只需要把相關的屬性複製一下,然後把host_name改成對應PC的就可以了。
在安裝windows 客戶端的時候NSClient 引數也需要做一些,具體參考blog:
How To Monitor Remote Windows Machine Using Nagios on Linux
http://space.itpub.net/?uid-15880878-action-viewspace-itemid-723057
8 ) /usr/local/nagios/etc/objects/localhost.cfg 監控Linux的客戶端及監控配置檔案, 這個問題檔名也可以自己指定,在nagios.cfg 中修改即可。
# Define a host for the local machine
define host{
use linux-server
host_name localhost
alias 10.85.10.78
address 127.0.0.1
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 120
notification_options d,u,r
contact_groups admins
}
define host{
use linux-server
host_name 10.85.9.150
alias 10.85.9.150
address 10.85.9.150
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 120
notification_options d,u,r
contact_groups admins
}
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members localhost,10.85.9.150
}
# Define a service to "ping" the local machine
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if
#
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
# Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users.
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description Current Users
check_command check_local_users!20!50
}
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
# Define a service to check the load on the local machine.
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description Swap Usage
check_command check_local_swap!20!10
}
# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description SSH
check_command check_ssh
notifications_enabled 0
}
# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.
define service{
use local-service ; Name of service template to use
host_name 10.85.9.150
service_description HTTP
check_command check_http
notifications_enabled 0
}
如果有多臺Linux, 只需要把相關的屬性複製一下,然後把host_name改成對應PC的就可以了。Linux的客戶端需要安裝NRPE 包 和 plugins 程式。
9) 驗證:
執行程式/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg來檢查所有配置檔案的正確性。如果執行完畢將在輸出尾部出現
Total Warnings: 0
Total Errors: 0
則配置正確,如果有錯誤,提示也是很明顯。 修改過來即可。
如:
Error: Invalid hostgroup object directive 'membes'.
Error: Could not add object property in file '/usr/local/nagios/etc/objects/windows.cfg' on line 58.
Error processing object config files!
4.3 配置Nagios,通過飛信將警報傳送到手機
4.3.1 飛信安裝
飛信官方網站:http://www.it-adv.net/
fetion20091117
wget http://www.it-adv.net/fetion/downng/library_linux.tar.gz
wget http://www.it-adv.net/fetion/downng/fetion20090406003-linux.tar.gz
wget http://www.it-adv.net/fetion/downng/fetion20091117-linux.tar.gz
#在安裝飛信之前需要在/usr/lib目錄下加上libACE庫檔案,以便使飛信能夠正常使用
[root@localhost src]# tar zxvf library_linux.tar.gz
[root@localhost src]# mv libACE* libcrypto.so.0.9.8 libssl.so.0.9.8 /usr/lib
#正式安裝飛信
[root@localhost src]# tar zxvf fetion20090406003-linux.tar.gz
[root@localhost src]# mv install /usr/local/fetion
[root@localhost src]# chmod -R 755 /usr/local/fetion
[root@localhost src]# chown -R nagios:nagios /usr/local/fetion
#移動伺服器更新,需要更新軟體
[root@localhost src]# tar zxvf fetion20091117-linux.tar.gz
[root@localhost src]# cp fx/* /usr/local/fetion
[root@localhost src]# vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/fetion #增加目錄
[root@localhost src]# ldconfig
[root@localhost src]#/usr/local/fetion/fetion --mobile=138***** --pwd=*** --to=138***** --msg-utf8="test" --debug
注意:這裡的password 是飛信的登陸密碼。 如果能收到簡訊,飛信就安裝完成了。
[root@localhost src]#/usr/local/fetion/fetion ##幫助
[root@localhost src]#cp /usr/local/fetion/fetion /usr/bin/
4.3.2 Nagios 中的飛信配置
1)在commads.cfg 檔案中新增2個選項
define command {
command_name notify-host-by-fetion
command_line /usr/bin/fetion --mobile=13865997399 --pwd=woshidmm --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$
}
define command {
command_name notify-service-by-fetion
command_line /usr/bin/fetion --mobile=13865997399 --pwd=woshidmm --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
}
2) 在contacts.cfg 的聯絡人中新增 pager 選項, 和相關命令的呼叫。
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email,notify-service-by-fetion
host_notification_commands notify-host-by-email,notify-host-by-fetion
email daimm@sf-express.com
pager 13888888888,13888888888
}
重啟Nagios: service nagios reload
啟動apache 服務:
[root@Dave bin]# service httpd start
啟動nagios 服務:
[root@Dave bin]# service nagios start
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15880878/viewspace-723059/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Nagios+PNP安裝部署iOS
- Nagios安裝步驟iOS
- tesseract安裝說明
- Kibana安裝及使用說明
- Camtasia Studio 9 安裝說明
- VNC安裝配置詳細說明VNC
- CentOS原始碼安裝、配置Nagios(core)+PluginsCentOS原始碼iOSPlugin
- npm說明和node.js安裝NPMNode.js
- ELK 之 Kibana 安裝及使用說明
- 360企業版終端安裝說明
- Gungho專案管理軟體手工安裝說明專案管理
- Oracle安裝光碟內容的檔案說明Oracle
- Eclipse安裝教程 ——史上最詳細安裝java &python教程說明 【附視訊安裝演示】EclipseJavaPython
- 【彙總】EMQX 函式API、安裝與使用說明MQ函式API
- IDEA Maven Helper 外掛的安裝與使用說明IdeaMaven
- 如何在 CentOS 8/RHEL 8 上安裝和配置 Nagios CoreCentOSiOS
- linux安裝mysql的步驟和方法詳細說明LinuxMySql
- 3568F-Docker容器部署方法說明Docker
- Hadoop的叢集環境部署說明Hadoop
- Fujitsu富士通 DPK系列印表機程式安裝說明
- Prometheus和node exporter的安裝與監控資料說明PrometheusExport
- Oracle 11gR2(11.2.0.4)安裝包(7個)作用說明Oracle
- Anbox安卓apk應用安裝及使用說明和常見問題安卓APK
- mac怎麼解除安裝軟體 蘋果mac解除安裝軟體實用教程說明Mac蘋果
- Hadoop安裝部署Hadoop
- keepalived 安裝部署
- Doris安裝部署
- chromedriver安裝部署Chrome
- ELK安裝部署
- Zabbix安裝部署
- canal安裝部署
- SQOOP安裝部署OOP
- Linux安裝部署Linux
- 一臺電腦如何安裝多個版本的JDK及其說明JDK
- Centos7安裝安裝部署dockerCentOSDocker
- GitBook簡明安裝教程Git
- ClickHouse學習系列之四【副本&分片部署說明】
- AI 在用| GPT-4、Claude 3 帶你看懂宜家安裝說明書AIGPT
- Splunk實戰(一)——索引器配置以及轉發器安裝配置說明索引