Example #1
0
CONF = config.CONF

print CONF

config.parse_args(['--use-stderr', '--debug'])
logging.setup('alerta')
db = Mongo()

#print db.save_alert({''})
alert3 = Alert('router55', 'Node_Down', severity=severity.INDETERMINATE, value='FAILED', timeout=600,
               environment=['PROD'], receive_time="2013-02-23T09:18:05.303Z", last_receive_time="2013-02-23T09:18:05.303Z",
               service=['Network', 'Common'], tags=['london', 'location:london', 'dc:location=london'],
               text="Node is not responding via ping.", origin="test3", correlate=['Node_Up', 'Node_Down'],
               event_type='myAlert', trend_indication='moreSevere')
print alert3
print alert3.get_id()

print alert3.get_header()
print alert3.get_body()

print 'Saving alert...'
print db.save_alert(alert3)


print 'Get alert...'
print db.get_alert('PROD', 'router55', 'Node_Down', 'Indeterminate')

print 'Check for duplicate...'
print db.is_duplicate('PROD', 'router55', 'Node_Down', 'Indeterminate')
print db.is_duplicate('PROD', 'res1', 'event1', 'critical')