git-svn-id: http://172.17.0.253/svn/soft_pkgs/sys_nicmonitor@799 09c3743a-b0dd-45d3-b506-aa74c7a2a6ef
This commit is contained in:
jli
2011-09-19 04:34:41 +00:00
parent d93d3a6040
commit 26e9bef94f

View File

@@ -17,7 +17,7 @@
#define IPLEN 16
#define CONF_FILE "/conf/nic/sys_netcard_conf.txt"
#define MNIC_VERSION "1.5"
#define MNIC_VERSION "1.6"
#define NIC_UNKNOWN 0
#define NIC_DOWN 1
@@ -622,8 +622,10 @@ static char *parse_str(char **s)
int ping_gw(char *devname)
{
FILE *fp;
int i, ret = -1, j, k;
char buf[64];
char buf[128];
char getbuf[64];
i = find_nic_config(devname);
if( i == -1 )
@@ -634,20 +636,31 @@ int ping_gw(char *devname)
for(k=0; k<conf.pingnum; ++k){
for(j=0; j<conf.nic[i].gw_num; ++j){
snprintf(buf, sizeof(buf), "ping -c 1 -w %d %s > /dev/null 2>&1", conf.pinglap,conf.nic[i].ping_ip[j]);
ret=system(buf);
#if 0
if (WIFSIGNALED(ret) &&
(WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
exit(0);
#endif
if(ret == 0)
return 0;
//snprintf(buf, sizeof(buf), "ping -c 1 -w %d %s > /dev/null 2>&1", conf.pinglap,conf.nic[i].ping_ip[j]);
snprintf(buf,sizeof(buf),"ping -c 1 -w %d %s|grep received|awk -F, '{print $2}'|awk '{print $1}'", conf.pinglap,conf.nic[i].ping_ip[j]);
if((fp = popen(buf,"r")) == NULL)
{
perror("popen");
return 0;
}else{
fgets(getbuf,sizeof(getbuf),fp);
if(strncmp(getbuf,"1",1) == 0)
{
pclose(fp);
return 0;
}else{
pclose(fp);
return -1;
}
}
pclose(fp);
return 0;
}
}
return -1;
return 0;
}
static void *check_inc_switch(void *ptr)