MON问题

### Extremely basic mon.cf file

### global options
cfbasedir = /etc/mon
pidfile = /var/run/mon.pid
statedir = /var/lib/mon/state.d
logdir = /var/lib/mon/log.d
dtlogfile = /var/lib/mon/log.d/downtime.log
alertdir = /usr/lib/mon/alert.d
mondir = /usr/lib/mon/mon.d
maxprocs = 20
histlength = 100
randstart = 60s
authtype = pam
userfile = /etc/mon/userfile

### group definitions (hostnames or IP addresses)
hostgroup servers localhost

watch servers
service http
interval 10s
monitor http.monitor -p 80 localhost
period all_the_time:wd{Sun-Sat}
alert test.alert
### See /usr/doc for the original example...
以上是我的mon.cf想测试httpd
但是我关闭了httpd却没有生成test.alert.log
请问是什么问题
还有watch servers中的servers名称是hostname还是随便写

Forums:

找到原因因为没有http.monitor
装上后可以了

现在的问题是我的mon.cf
### Extremely basic mon.cf file

### global options
cfbasedir = /etc/mon
pidfile = /var/run/mon.pid
statedir = /var/lib/mon/state.d
logdir = /var/lib/mon/log.d
dtlogfile = /var/lib/mon/log.d/downtime.log
alertdir = /usr/lib/mon/alert.d
mondir = /usr/lib/mon/mon.d
maxprocs = 20
histlength = 100
randstart = 60s
authtype = pam
userfile = /etc/mon/userfile

### group definitions (hostnames or IP addresses)
hostgroup server1 192.168.1.224
hostgroup server2 192.168.1.225

watch server1
service http
interval 10s
monitor http.monitor
period wd {Sun-Sat}
alert lvs.alert -P tcp -V 192.168.1.220:80 -R 192.168.1.224 -W 5 -F dr
upalert lvs.alert -P tcp -V 192.168.1.220:80 -R 192.168.1.224 -W 5 -F dr -u 1

watch server2
service http
interval 10s
monitor http.monitor
period wd {Sun-Sat}
alert lvs.alert -P tcp -V 192.168.1.220:80 -R 192.168.1.225 -W 5 -F dr
upalert lvs.alert -P tcp -V 192.168.1.220:80 -R 192.168.1.225 -W 5 -F dr -u 1

其中lvs.alert内容如下
#!/usr/bin/perl
#
# lvs.alert - Linux Virtual Server alert for mon
#
# It can be activated by mon to remove a real server when the
# service is down , or add the server when the service is up
#
#
use Getopt::Std;
getopts("s:g:h:t:l:P:V:R:W:F:u");
$ipvsadm = "/sbin/ipvsadm";
$protocol = $opt_P;
$virtual_services = $opt_V;
$remote = $opt_R;
if($opt_u){
$weight = $opt_W;
if($opt_F eq "nat"){
$forwarding = "-m";
}elsif($opt_F eq "tun"){
$forwarding = "-i";
}else{
$forwarding = "-g";
}

if($protocol eq "tcp"){
system(
"$ipvsadm -a -t $virtual_services -r $remote -w $weight $forwarding");
} else {
system(
"$ipvsadm -a -u $virtual_services -r $remote -w $weight $forwarding");
}
} else {
if($protocol eq "tcp"){
system("$ipvsadm -d -t $virtual_services -r $remote");
} else {
system("$ipvsadm -d -u $virtual_services -r $remote");
}
}

我现在执行ipvsadm
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.220:http rr
-> Loader:http Local 1 0 0
-> 192.168.1.225:http Route 0 0 0
-> 192.168.1.224:http Route 0 0 0
然后执行mon后,再执行ipvsadm
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.220:http rr
-> Loader:http Local 1 0 0

10s后我的real服务器被删除了,我的real服务器httpd进程都在,不清楚是什么原因.

查出原因

我的两台real监听的是192.168.1.220
换为本地监听OK

但是看许多文章说要监听VIP的端口,怎么做才能使MON好用,有同时监听VIP的80端口