Version 1.8.1, 1)修改BUG:ping_gw函数当PING失败时没有尝试对余下的GW进行PING操作; 2)增加环境变量SYS_NIC_DEBUG用于调试流量抖动问题。

git-svn-id: http://172.17.0.253/svn/soft_pkgs/sys_nicmonitor@1400 09c3743a-b0dd-45d3-b506-aa74c7a2a6ef
This commit is contained in:
rbqiu
2013-06-25 08:22:43 +00:00
parent b374395e85
commit af5b85babe
11 changed files with 92 additions and 13 deletions

View File

@@ -20,7 +20,7 @@
#define IPLEN 16
#define CONF_FILE "/conf/nic/sys_netcard_conf.txt"
#define MNIC_VERSION "1.8"
#define MNIC_VERSION "1.8.1"
#define NIC_UNKNOWN 0
#define NIC_DOWN 1
@@ -153,6 +153,10 @@ static const configoption_t options[] = {
{myconf[15], ARG_INT, cb_int, NULL, CTX_ALL},
LAST_OPTION
};
/* 1 for output more debug information, from getenv(SYS_NIC_DEBUG) */
static int sys_nic_debug = 0;
/****dotconf****/
void create_dir(char *create_path);
@@ -674,9 +678,15 @@ static void *cacu_flow(void *p)
count_t = 1;
}
summit = (unsigned int)(curr->info.average_flow*8*100/1024/1024/ptr->mem.conf->flow_peak/count_t);
#if 0
printf("%s:\tcount=%d\tsummit=%d\tflow_limit:%d\taverage_flow:%d\n", curr->info.charname, count_t, summit, conf.flow_limit, curr->info.average_flow);
if( sys_nic_debug ) {
#if 1
printf("%s:\tcount=%d\tsummit=%d\tflow_limit:%d\taverage_flow:%lld\n", curr->info.charname, count_t, summit, conf.flow_limit, curr->info.average_flow);
#endif
snprintf(error_str, sizeof(error_str), "%s:\tcount=%d\tsummit=%d\tflow_limit:%d\taverage_flow:%lld\n", curr->info.charname, count_t, summit, conf.flow_limit, curr->info.average_flow);
record_log(error_str);
}
if(summit >= ptr->mem.conf->flow_limit){
memset(ptr->env.Malarm.tSysNetcardAlarm.fault_devname, 0, NIC_NAME_LEN);
strncpy(ptr->env.Malarm.tSysNetcardAlarm.fault_devname, ptr->env.host_name, ptr->env.host_name_size);
@@ -695,8 +705,13 @@ static void *cacu_flow(void *p)
count_no[i]--;
if(count_no[i] == 0){
send_inc_info_one(&curr->info, ptr->mem.semid, ptr->mem.shm_ptr);
//snprintf(error_str, sizeof(error_str), "NOTICE: %s flow is abnormal, summit is %d, average flow is %lld !\n", curr->info.charname, summit, curr->info.average_flow);
snprintf(error_str, sizeof(error_str), "NOTICE: %s flow is abnormal !\n", curr->info.charname);
if( sys_nic_debug ) {
snprintf(error_str, sizeof(error_str),
"NOTICE: %s flow is abnormal, summit is %d, average flow is %lld !\n",
curr->info.charname, summit, curr->info.average_flow);
} else {
snprintf(error_str, sizeof(error_str), "NOTICE: %s flow is abnormal !\n", curr->info.charname);
}
record_log(error_str);
}
}
@@ -767,8 +782,9 @@ int ping_gw(char *devname)
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;
//perror("popen");
//return 0;
continue;
}else{
fgets(getbuf,sizeof(getbuf),fp);
if(strncmp(getbuf,"0",1) != 0)
@@ -777,7 +793,8 @@ int ping_gw(char *devname)
return 0;
}else{
pclose(fp);
return -1;
//return -1;
continue;
}
}
pclose(fp);
@@ -1443,6 +1460,10 @@ int main(int argc, char ** argv)
char log_record[125]={0};
if( getenv("SYS_NIC_DEBUG") ) {
sys_nic_debug = 1;
}
memset(&conf, 0, sizeof(CONFIG_FILE_ST));
if(isrun(argv[0]) == 1){
printf("the program is already started!\n");