#try to kill the process if exists try: p.kill() except Exception as e: msg = 'The "PS" process has already been killed, please ignore this log.' for line in sLi: if(line.find(moduleName) > -1 and line.find('grep ' + name) == -1): return int(line.split()[1]) return -1 if __name__ == '__main__': #print os.path.split(sys.argv[0])[1].split('.')[0] #print os.getpid() print datetime.now().second h,x = CommonFunc.getHexNow() print x '''print getPidByName('54352') i = 0 while True: time.sleep(1) i += 1 print i if(i > 10): sys.exit(1)''' #getPidByName('pmFileGen1020.py -t OCGAS') #i, h = CommonFunc.getHexNow() #print os.listdir('/xcom/alarm') #print type(time.localtime(os.path.getmtime('/xcom/alarm/' + os.listdir('/xcom/alarm')[0])))
log0.info('Time is correct, we may try to send a trap.') #log0.critical('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$' + str(liAlarm5Min[i]) + '&&&&&&&&&&&&&&&' + str(i)) #Below part will try to send the alarm trap id += 1 alarmSplit = liAlarm5Min[i].strip().split('|') if(len(alarmSplit) > 8): alarmid = None #This means this alarm is the has peer alarm if(peerAlarm.has_key(alarmSplit[8].strip())): #change the alarmid to the it's peer's id -= 1 alarmid = peerAlarm.get(alarmSplit[8].strip()) else: alarmid = datetime.now().strftime('%Y%m%d%H%M%S') + str(id) peerAlarm[alarmSplit[8].strip()] = alarmid x, h = CommonFunc.getHexNow() alarmSplit[3] = ':'.join(h[i:i+2] for i in range(0, len(h), 2)) liAlarm5Min[i] = alarmid + '|' + '|'.join(alarmSplit[1:8]) if(sendTrapThisRound): log0.warn('Send a trap now.') sendSingleTrap(snmpEng, snmpCfg, liAlarm5Min[i]) else: log0.warn('Time is right, but will not send trap since the flag show we cannot send trap this round.') #sendSingleTrap('Send a trap: ' + liAlarm5Min[i]) else: x, h = CommonFunc.getHexNow() alarmSplit[3] = ':'.join(h[i:i+2] for i in range(0, len(h), 2)) liAlarm5Min[i] = datetime.now().strftime('%Y%m%d%H%M%S') + str(id) + '|' + '|'.join(alarmSplit[1:8]) if(sendTrapThisRound): sendSingleTrap(snmpEng, snmpCfg, liAlarm5Min[i]) #sendSingleTrap('Send a trap: ' + liAlarm5Min[i])