FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sysdig-sdk-python/examples/create_sysdig_capture.py at master · dnwe/sysdig-sdk-python · GitHub
dnwe
sysdig-sdk-python
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sysdig-sdk-python
/
examples
/
create_sysdig_capture.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
61 lines (50 loc) · 1.36 KB
Breadcrumbs
sysdig-sdk-python
/
examples
/
create_sysdig_capture.py
Copy path
File metadata and controls
executable file
·
61 lines (50 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
#
# Creates a sysdig capture, waits for termination and prints the download URL.
#
import
sys
import
time
from
sdcclient
import
SdcClient
#
# Parse arguments
#
if
len
(
sys
.
argv
)
not
in
(
5
,
6
):
print
((
'usage: %s <sysdig-token> hostname capture_name duration [filter]'
%
sys
.
argv
[
0
]))
print
(
'You can find your token at https://app.sysdigcloud.com/#/settings/user'
)
sys
.
exit
(
1
)
sdc_token
=
sys
.
argv
[
1
]
hostname
=
sys
.
argv
[
2
]
capture_name
=
sys
.
argv
[
3
]
duration
=
sys
.
argv
[
4
]
capture_filter
=
''
if
len
(
sys
.
argv
)
==
6
:
capture_filter
=
sys
.
argv
[
5
]
#
# Instantiate the SDC client
#
sdclient
=
SdcClient
(
sdc_token
)
ok
,
res
=
sdclient
.
create_sysdig_capture
(
hostname
,
capture_name
,
int
(
duration
),
capture_filter
)
#
# Show the list of metrics
#
if
ok
:
capture
=
res
[
'dump'
]
else
:
print
(
res
)
sys
.
exit
(
1
)
while
True
:
ok
,
res
=
sdclient
.
poll_sysdig_capture
(
capture
)
if
ok
:
capture
=
res
[
'dump'
]
else
:
print
(
res
)
sys
.
exit
(
1
)
print
((
'Capture is in state '
+
capture
[
'status'
]))
if
capture
[
'status'
]
in
(
'requested'
,
'capturing'
,
'uploading'
):
pass
elif
capture
[
'status'
]
in
(
'error'
,
'uploadingError'
):
sys
.
exit
(
1
)
elif
capture
[
'status'
]
in
(
'done'
,
'uploaded'
):
print
((
'Download at: '
+
sdclient
.
url
+
capture
[
'downloadURL'
]))
sys
.
exit
(
0
)
time
.
sleep
(
1
)
Back
|
FazBrowse Home
|
New Git URL