|
15 | 15 | if len(sys.argv) < 3: |
16 | 16 | print 'usage: %s <sysdig-token> <name> [description] [severity] [scope] [tags]' % sys.argv[0] |
17 | 17 | 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"}\'' |
21 | 21 | sys.exit(1) |
22 | 22 |
|
23 | 23 | sdc_token = sys.argv[1] |
24 | 24 | name = sys.argv[2] |
| 25 | +kwargs = {} |
25 | 26 |
|
26 | | -description = '' |
27 | 27 | if len(sys.argv) > 3: |
28 | | - description = sys.argv[3] |
29 | | -# print description |
| 28 | + kwargs['description'] = sys.argv[3] |
30 | 29 |
|
31 | | -severity = 6 |
32 | 30 | if len(sys.argv) > 4: |
33 | | - severity = int(sys.argv[4]) |
34 | | -# print severity |
| 31 | + kwargs['severity'] = int(sys.argv[4]) |
35 | 32 |
|
36 | | -scope = '' |
37 | 33 | 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] |
41 | 35 |
|
42 | | -tags = {} |
43 | 36 | 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]) |
46 | 38 |
|
47 | 39 | # |
48 | 40 | # Instantiate the SDC client |
|
52 | 44 | # |
53 | 45 | # Post the event using post_event(self, name, description=None, severity=6, event_filter=None, tags=None) |
54 | 46 | # |
55 | | -res = sdclient.post_event(name, description, severity, scope, tags) |
| 47 | +res = sdclient.post_event(name, **kwargs) |
56 | 48 |
|
57 | 49 | # |
58 | 50 | # Return the result |
|
0 commit comments