From 05ae4729f39d9afe92aeca28effb5a295829caea Mon Sep 17 00:00:00 2001 From: "Zhang, Jialing" Date: Wed, 31 Aug 2016 16:55:34 +0800 Subject: [PATCH] =?UTF-8?q?[Bug=20#2881]=20=E7=BD=91=E5=8D=A1=E6=B5=81?= =?UTF-8?q?=E9=87=8F=E5=BC=82=E5=B8=B8=E8=AF=AF=E6=8A=A5,=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF,=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=89=88=E6=9C=AC=E5=8F=B71.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 要提交的变更: 修改: common.c 修改: proc_inv.h 修改: read_netcard.c 修改: version.h Signed-off-by: Zhang, Jialing --- code/trunk/sys_nicmonitor/src/sys_nicmonitor/common.c | 6 +++++- .../sys_nicmonitor/src/sys_nicmonitor/proc_inv.h | 8 ++++---- .../sys_nicmonitor/src/sys_nicmonitor/read_netcard.c | 11 ++++++++++- .../trunk/sys_nicmonitor/src/sys_nicmonitor/version.h | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/common.c b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/common.c index e2e9a7d..6c1e605 100644 --- a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/common.c +++ b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/common.c @@ -1,3 +1,5 @@ +#include +#include static pthread_mutex_t lock_record_logpath = PTHREAD_MUTEX_INITIALIZER; #define LOGPATH_LOCK pthread_mutex_lock(&lock_record_logpath) @@ -26,7 +28,7 @@ void create_dir(char *create_path) { if(tmp_path[i]=='/') { - tmp[i] = 0; + tmp_path[i] = 0; if( access(tmp_path, F_OK)!=0 ) { if(mkdir(tmp_path, 0755)==-1) @@ -45,6 +47,7 @@ static void *record_log_thread( void *arg ) char *log_str; FILE *log_fp = NULL; char **tmp = NULL; + char tmp_path[256]; int i = 0; LOGPATH_LOCK; strcpy(tmp_path,log_path); @@ -173,6 +176,7 @@ void record_log(char *str) log_prepare[log_idx] = keepstr; log_idx++; } + } LOG_UNLOCK; } diff --git a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/proc_inv.h b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/proc_inv.h index 945622c..87e985b 100644 --- a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/proc_inv.h +++ b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/proc_inv.h @@ -34,12 +34,12 @@ #include "const.h" //for alarm ................................ -typedef struct MESS_BH +struct MESS_BH { unsigned char mtype; int length; }; -typedef struct PROCESS_ALM +struct PROCESS_ALM { char context_name[MAX_STRING_LEN]; char app_name[MAX_STRING_LEN]; @@ -50,12 +50,12 @@ typedef struct PROCESS_ALM //for mmi.................................... const int MAX_BUFFER_LEN = 500; -typedef struct MESS_BLOCK +struct MESS_BLOCK { unsigned char num; char buffer[MAX_BUFFER_LEN]; }; -typedef struct MESS_PROC +struct MESS_PROC { char context_name[MAX_STRING_LEN]; char app_name[MAX_STRING_LEN]; diff --git a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/read_netcard.c b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/read_netcard.c index c745f48..e8579e3 100644 --- a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/read_netcard.c +++ b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/read_netcard.c @@ -1,5 +1,6 @@ #include "mnic.h" +static int sys_nic_debug=0; static char *prase_digit(char **s) { char *retp = NULL; @@ -54,9 +55,13 @@ char *get_name(char *name, char *p) int get_dev_fields(char *str, NETCARD_INFO *ife) { + if( getenv("SYS_NIC_DEBUG") ) { + sys_nic_debug = 1; + } + int i = 0; char *retp[16]; - + char error_str[1024]; while((retp[i] = prase_digit(&str)) != NULL){i++;if(i > 15)break;} ife->rx_bytes = atoll(retp[0]); ife->rx_packets = atoll(retp[1]); @@ -71,6 +76,10 @@ int get_dev_fields(char *str, NETCARD_INFO *ife) ife->tx_fifo_errors = atol(retp[12]); ife->collisions = atol(retp[13]); ife->tx_carrier_errors = atol(retp[14]); + if( 0 ) { + snprintf(error_str, sizeof(error_str), "ife->rx_bytes%lld:\tife->tx_bytes=%lld\n",ife->rx_bytes,ife->tx_bytes); + record_log(error_str); + } return 0; } diff --git a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/version.h b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/version.h index 7f7620d..3e49ad4 100644 --- a/code/trunk/sys_nicmonitor/src/sys_nicmonitor/version.h +++ b/code/trunk/sys_nicmonitor/src/sys_nicmonitor/version.h @@ -1,5 +1,5 @@ // version=1.14 #ifndef MNIC_VERSION - #define MNIC_VERSION "1.14" + #define MNIC_VERSION "1.20" #endif