File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 37
37
alert_found = True
38
38
print 'Updating alert. Configuration before changing timespan, description, and notification channels:'
39
39
print json .dumps (alert , sort_keys = True , indent = 4 )
40
- alert ['notificationChannelIds' ] = alert ['notificationChannelIds' ][0 :- 1 ]
41
- alert ['description' ] = 'this alert has been updated via update_alert in the python Sysdig Monitor library'
42
- alert ['timespan' ] = 120 * 1000000 # 2 minutes
40
+ if 'notificationChannelIds' in alert :
41
+ alert ['notificationChannelIds' ] = alert ['notificationChannelIds' ][0 :- 1 ]
42
+ update_txt = ' (changed by update_alert)'
43
+ if alert ['description' ][- len (update_txt ):] != update_txt :
44
+ alert ['description' ] = alert ['description' ] + update_txt
45
+ alert ['timespan' ] = alert ['timespan' ] * 2 # Note: Expressed in seconds * 1000000
43
46
res_update = sdclient .update_alert (alert )
44
47
48
+ if not res_update [0 ]:
49
+ print res_update [1 ]
50
+ sys .exit (1 )
51
+
45
52
# Validate and print the results
46
53
print '\n Alert after modification:'
47
54
print json .dumps (res_update [1 ], sort_keys = True , indent = 4 )
48
- if not res_update [0 ]:
49
- sys .exit (1 )
50
55
51
56
if not alert_found :
52
57
print 'Alert to be updated not found'
You can’t perform that action at this time.
0 commit comments