Ejemplo n.º 1
0
def sendSingleTrap(eng, cfg, liTrap):
    SnmpTraps.sendTrap(eng, cfg, liTrap)
Ejemplo n.º 2
0
 
 sendTrapThisRound = False
 liIsSendTrap = isSendTrap.strip().split(',')
 log0.critical('The flags which show that if we will send trap this round: ' + str(liIsSendTrap))
 if(len(liIsSendTrap) >= iTemplate):
     try:
         if(int(liIsSendTrap[iTemplate - 2]) > 0):
             sendTrapThisRound = True
     except Exception as e:
         log0.warn('Try to get the flag of send trap or not failed, will not send trap by default. Exception: ' + str(e))
 
 snmpEng = None
 snmpCfg = None
 if(sendTrapThisRound):
     log0.warn('This round with template file number ' + str(iTemplate - 1) + ' will send SNMP trap.')
     snmpEng, snmpCfg = SnmpTraps.initTarget(host, port)
     log0.info('SNMP trap send Engine has been setup.')
 else:
     log0.warn('The flag show that this round will not send the alarm traps, template file number is: ' + str(iTemplate - 1))
 
 startTime = datetime.now()
 log0.info('Random numbers are: ' + str(iRan))
 for i in range(0, len(iRan)):
     while True:
         nowTime = datetime.now()
         tgtTime = startTime + timedelta(seconds = int(iRan[i]))
         if(nowTime.day == tgtTime.day and nowTime.hour == tgtTime.hour and nowTime.minute == tgtTime.minute and nowTime.second == tgtTime.second):
             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