def monitorHardSpace(monitorSystemObject,saveDbMsgDict): """ 1.根据硬盘配置的告警阀值,发送报警信息 @monitorSystemObject {'cpu_idle_limit':cpu_idle_limit,'memory_avi_limit':memory_avi_limit,'hardspace_name':hardspace_name,'hardspace_limit':hardspace_limit} """ hardSpaceList=SystemInfo.getHardSpace()#[(文件系统,总计大小,已用空间,可用空间,已用%,挂载点)] saveDbMsgDict['hardSpace']=hardSpaceList warnToPersonList=[] monitorDiskObjectList=[] if monitorSystemObject.has_key('hardspace_name')==False or monitorSystemObject.has_key('hardspace_limit')==False: return warnToPersonList elif len(monitorSystemObject['hardspace_name'].split('||'))<>len(monitorSystemObject['hardspace_limit'].split('||')): log.info('磁盘监控:monitor_pt_system_info表的hardspace_name值与hardspace_limit值配置的不完全匹配') return warnToPersonList for i in range(len(monitorSystemObject['hardspace_name'].split('||'))): monitorDiskObjectList.append({'hardspace_name':monitorSystemObject['hardspace_name'].split('||')[i],'hardspace_limit':monitorSystemObject['hardspace_limit'].split('||')[i]}) for monitorDiskObject in monitorDiskObjectList: try: if monitorDiskObject.has_key('hardspace_name') and monitorDiskObject['hardspace_limit'].isdigit(): for hardSpace in hardSpaceList:#(文件系统,已用空间,可用空间,已用%,挂载点) if monitorDiskObject['hardspace_name']==hardSpace[0] and float(hardSpace[4])>=float(monitorDiskObject['hardspace_limit']): log.info("磁盘空间告警: hardspace_name:%s,limit_used_percent:%s,real_used_percent:%s",monitorDiskObject['hardspace_name'],monitorDiskObject['hardspace_limit'],hardSpace[4]) warnStr=MONITOR_NAME+' 磁盘空间告警:hardspace_name:'+monitorDiskObject['hardspace_name']+' limit_used_percent:'+monitorDiskObject['hardspace_limit']+' real_used_percent:'+hardSpace[4] warnToPersonList.append(warnStr) elif monitorDiskObject['hardspace_name']==hardSpace[0]: log.info("磁盘空间:达不到告警阀值 hardspace_name:%s,limit_used_percent:%s,real_used_percent:%s",monitorDiskObject['hardspace_name'],monitorDiskObject['hardspace_limit'],hardSpace[4]) except Exception: log.exception('磁盘监控报错:%s,告警阀值为:%s',monitorDiskObject['hardspace_name'],monitorDiskObject['hardspace_limit']) return warnToPersonList