-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99fa508
commit 8dcea4e
Showing
8 changed files
with
226 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Creates a sysdig capture, waits for termination and prints the download URL. | ||
# | ||
|
||
import os | ||
import sys | ||
import time | ||
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) 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) | ||
|
||
res = sdclient.create_sysdig_capture(hostname, capture_name, int(duration), capture_filter) | ||
|
||
# | ||
# Show the list of metrics | ||
# | ||
if res[0]: | ||
capture = res[1] | ||
else: | ||
print res[1] | ||
sys.exit(1) | ||
|
||
while True: | ||
res = sdclient.poll_sysdig_capture(capture) | ||
if res[0]: | ||
capture = res[1] | ||
else: | ||
print res[1] | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Print the list of sysdig captures. | ||
# | ||
|
||
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) != 2: | ||
print 'usage: %s <sysdig-token>' % sys.argv[0] | ||
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user' | ||
sys.exit(1) | ||
|
||
sdc_token = sys.argv[1] | ||
|
||
# | ||
# Instantiate the SDC client | ||
# | ||
sdclient = SdcClient(sdc_token) | ||
|
||
# | ||
# Fire the request. | ||
# | ||
res = sdclient.get_sysdig_captures() | ||
|
||
# | ||
# Show the list of metrics | ||
# | ||
if res[0]: | ||
data = res[1] | ||
else: | ||
print res[1] | ||
sys.exit(1) | ||
|
||
for capture in data: | ||
print "Folder %s, Name %s, Host: %s, Size: %d, Status: %s" % \ | ||
(capture['folder'], capture['name'], capture['agent']['hostName'], capture['size'], capture['status']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters