diff --git a/category/get_net_info.py b/category/get_net_info.py index aed1ba2d885b34f0f1537f3ff344afc6f5653e63..dad3fb1f2ad38dab4b408337bc37cde385fcbfa4 100644 --- a/category/get_net_info.py +++ b/category/get_net_info.py @@ -12,6 +12,7 @@ if sys.getdefaultencoding() != 'utf-8': from common.decorator_wrap import DecoratorWrap from common.file import FileOperation +from common.global_parameter import GlobalParameter from common.log import Logger from common.command import Command @@ -30,6 +31,11 @@ class NetInfo: self.__netdev_ring = [] # #网卡连接状态信息 self.__link_status = {} + + # 默认时间间隔为1s + self.__interval = GlobalParameter().get_net_interval() + # 默认执行5次 + self.__times = GlobalParameter().get_net_times() def __get_devices(self): ''' diff --git a/common/global_parameter.py b/common/global_parameter.py index 665d3d86eadb58f68c335eb83e19f2ab9f79e649..2122e68efa6397bdeb4d0d21e3cfc7848ead2595 100644 --- a/common/global_parameter.py +++ b/common/global_parameter.py @@ -33,6 +33,12 @@ class GlobalParameter: # 默认执行5次 self.g_disk_times = GlobalCall.get_json_value("Getting.Common.Disk.times" , 5, Config.get_json_dict()) + + # *-----------------------get net info------------------- + # 默认时间间隔为1s + self.g_net_interval = GlobalCall.get_json_value("Getting.Common.Net.interval", 1, Config.get_json_dict()) + # 默认执行5次 + self.g_net_times = GlobalCall.get_json_value("Getting.Common.Net.times", 5, Config.get_json_dict()) # -------------------cpu parameters----------------------- @property @@ -59,4 +65,12 @@ class GlobalParameter: @property def get_disk_times(self): - return self.g_disk_times \ No newline at end of file + return self.g_disk_times + + # -------------------net parameters----------------------- + def get_net_interval(self): + return self.g_net_interval + + def get_net_times(self): + return self.g_net_times + \ No newline at end of file