mkdir log
cd log
touch ./run
chmod 755 ./run
vi ./run
#!/bin/sh
exec setuidgid logadmin multilog t s1000000 n100 ./main
mkdir main
chmod 777 main
chown nagios.nagios main
touch status
chown nagios.nagios status
svc -u /service/nagios/
svstat /service/nagios/
root@## ps auxww | grep nagios
root 23276 0.0 0.1 1176 488 ?? I 5:00PM 0:01.71 supervise nagios
nagios 34251 0.0 0.3 2316 1552 ?? S 6:06PM 0:00.10 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
root@##
ok,現在把nagios服務做成自動啟動的服務。
通過svc命令可以啟動或者停止服務。
———————————————————————————
svc opts services
opts is a series of getopt-style options. services consists of any number of arguments, each argument naming a directory used by supervise.
-u: Up. If the service is not running, start it. If the service stops, restart it.
-d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.
-o: Once. If the service is not running, start it. Do not restart it if it stops.
-p: Pause. Send the service a STOP signal.
-c: Continue. Send the service a CONT signal.
-h: Hangup. Send the service a HUP signal.
-a: Alarm. Send the service an ALRM signal.
-i: Interrupt. Send the service an INT signal.
-t: Terminate. Send the service a TERM signal.
-k: Kill. Send the service a KILL signal.
-x: Exit. supervise will exit as soon as the service is down. If you use this option on a stable system, you’re doing something wrong; supervise is designed to run forever.
———————————————————————————
比如:
停止nagios--svc -d /service/nagios/
重啟nagios--svc -t /service/nagios/
啟動nagios--svc -u /service/nagios/
當然,你也可以使用inited的方式進行:
/usr/local/etc/rc.d/nagios start/stop
好,反正daemontools很強大,以後慢慢熟悉,轉入正題。
現在打開網頁:http://localhost/nagios/
一定會讓你大吃一驚,呵呵,俺的伺服器和服務狀態都清楚的看到。
現在俺們的nagios中只有一個,那就是它自己,localhost,呵呵,等會俺們添加別的主機和主機服務,ok,俺們認識一下nagios的廬山真面目:
配置nagios:
1)為主機添加服務
2)添加主機並添加服務
3)停止一個服務
4)刪除一台主機和服務
5)查看所有主機的故障
6)查看一台特定的主機狀態
7)改變報警的時間間隔
8)改變發現故障的重試次數
9)如何在nagios中使用外部命令
1)為主機添加一個服務
為localhost主機添加qmail服務的監控,方法如下:
vi minimal.cfg
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description qmail_smtp
is_volatile 0
check_period 24×7
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24×7
check_command check_smtp!20%!10%!/
}
以下文章點擊率最高
Loading…