forked from sysdiglabs/sysdig-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_event_simple.py
More file actions
executable file
·47 lines (39 loc) · 916 Bytes
/
post_event_simple.py
File metadata and controls
executable file
·47 lines (39 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
#
# Post a user event to Sysdig Cloud
#
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import SdcClient
#
# Parse arguments
#
if len(sys.argv) < 4:
print 'usage: %s <sysdig-token> name description [severity]' % sys.argv[0]
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)
sdc_token = sys.argv[1]
name = sys.argv[2]
description = sys.argv[3]
scope='host.hostName = "foo" and container.name = "bar"'
tags={"tag1" : "value1"}
severity = 6
if len(sys.argv) < 4:
severity = int(sys.argv[4])
#
# Instantiate the SDC client
#
sdclient = SdcClient(sdc_token)
#
# Post the event
#
res = sdclient.post_event(name, description, severity, scope, tags)
#
# Return the result
#
if res[0]:
print 'Event Posted Successfully'
else:
print res[1]
sys.exit(1)