Skip to content

Commit 8036f2e

Browse files
committed
no defaults in post_event.py
1 parent 310c39a commit 8036f2e

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

examples/post_event.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,26 @@
1515
if len(sys.argv) < 3:
1616
print 'usage: %s <sysdig-token> <name> [description] [severity] [scope] [tags]' % sys.argv[0]
1717
print ' sysdig-token: You can find your token at https://app.sysdigcloud.com/#/settings/user'
18-
print ' severity: syslog style (from 0 to 7)'
19-
print ' scope: Sysdig Cloud format metadata to associate with the event, eg: \'host.hostName = "ip-10-1-1-1" and container.name = "foo"\''
20-
print ' tags: dictionary of key-value pairs, eg: \'{"app":"my_app", "file":"text.py"}\''
18+
print ' severity: syslog style from 0 (high) to 7 (low)'
19+
print ' scope: metadata, in Sysdig Cloud format, of nodes to associate with the event, eg: \'host.hostName = "ip-10-1-1-1" and container.name = "foo"\''
20+
print ' tags: dictionary of arbitrary key-value pairs, eg: \'{"app":"my_app", "file":"text.py"}\''
2121
sys.exit(1)
2222

2323
sdc_token = sys.argv[1]
2424
name = sys.argv[2]
25+
kwargs = {}
2526

26-
description = ''
2727
if len(sys.argv) > 3:
28-
description = sys.argv[3]
29-
# print description
28+
kwargs['description'] = sys.argv[3]
3029

31-
severity = 6
3230
if len(sys.argv) > 4:
33-
severity = int(sys.argv[4])
34-
# print severity
31+
kwargs['severity'] = int(sys.argv[4])
3532

36-
scope = ''
3733
if len(sys.argv) > 5:
38-
scope = sys.argv[5]
39-
# scope = "'host.hostName = 'ip-10-1-1-1'"
40-
# print scope
34+
kwargs['event_filter'] = sys.argv[5]
4135

42-
tags = {}
4336
if len(sys.argv) > 6:
44-
tags = json.loads(sys.argv[6])
45-
# print json.dumps(tags)
37+
kwargs['tags'] = json.loads(sys.argv[6])
4638

4739
#
4840
# Instantiate the SDC client
@@ -52,7 +44,7 @@
5244
#
5345
# Post the event using post_event(self, name, description=None, severity=6, event_filter=None, tags=None)
5446
#
55-
res = sdclient.post_event(name, description, severity, scope, tags)
47+
res = sdclient.post_event(name, **kwargs)
5648

5749
#
5850
# Return the result

0 commit comments

Comments
 (0)