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 3737 alert_found = True
3838 print 'Updating alert. Configuration before changing timespan, description, and notification channels:'
3939 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
4346 res_update = sdclient .update_alert (alert )
4447
48+ if not res_update [0 ]:
49+ print res_update [1 ]
50+ sys .exit (1 )
51+
4552 # Validate and print the results
4653 print '\n Alert after modification:'
4754 print json .dumps (res_update [1 ], sort_keys = True , indent = 4 )
48- if not res_update [0 ]:
49- sys .exit (1 )
5055
5156if not alert_found :
5257 print 'Alert to be updated not found'
You can’t perform that action at this time.
0 commit comments