Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 1 addition & 55 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,8 @@ install:
- sudo apt-get install linux-headers-$(uname -r) dkms gcc-multilib g++-multilib
- pip install pyyaml requests
script:
- echo "Testing source version"
- examples/create_alert.py $DEMO_KUBE_API_TOKEN
- examples/update_alert.py $DEMO_KUBE_API_TOKEN
- examples/delete_alert.py $DEMO_KUBE_API_TOKEN
- examples/dashboard.py $DEMO_KUBE_API_TOKEN
- examples/create_dashboard.py $DEMO_KUBE_API_TOKEN
- examples/delete_dashboard.py $DEMO_KUBE_API_TOKEN
- examples/get_data_advanced.py $DEMO_KUBE_API_TOKEN ip-10-0-1-140.ec2.internal
- examples/get_data_datasource.py $DEMO_KUBE_API_TOKEN
- examples/get_data_simple.py $DEMO_KUBE_API_TOKEN
- examples/list_alerts.py $DEMO_KUBE_API_TOKEN
- examples/list_alert_notifications.py $DEMO_KUBE_API_TOKEN
- examples/resolve_alert_notifications.py $DEMO_KUBE_API_TOKEN 1
- examples/list_dashboards.py $DEMO_KUBE_API_TOKEN
- examples/list_hosts.py $DEMO_KUBE_API_TOKEN
- examples/list_metrics.py $DEMO_KUBE_API_TOKEN
- examples/post_event.py $DEMO_KUBE_API_TOKEN "test_event_name" -d "test event description"
- examples/post_event_simple.py $DEMO_KUBE_API_TOKEN "test_event_name" "test event description"
- examples/list_events.py $DEMO_KUBE_API_TOKEN
- examples/delete_event.py $DEMO_KUBE_API_TOKEN
- examples/print_data_retention_info.py $DEMO_KUBE_API_TOKEN
- examples/print_explore_grouping.py $DEMO_KUBE_API_TOKEN
- examples/print_user_info.py $DEMO_KUBE_API_TOKEN
- examples/list_users.py $DEMO_KUBE_API_TOKEN
- examples/list_sysdig_captures.py $DEMO_KUBE_API_TOKEN
- examples/create_sysdig_capture.py $DEMO_KUBE_API_TOKEN ip-10-0-1-115.ec2.internal apicapture 10
- examples/notification_channels.py $DEMO_KUBE_API_TOKEN
- examples/user_team_mgmt.py $DEMO_KUBE_API_TOKEN example-team example-user@example-domain.com
- unset SDC_TOKEN
- bash test/test_monitor_apis.sh
- bash test/test_secure_apis.sh
- echo "Testing pip version"
- rm -rf sdcclient
- pip install sdcclient
# - examples/create_alert.py $DEMO_KUBE_API_TOKEN
# - examples/delete_alert.py $DEMO_KUBE_API_TOKEN
# - examples/dashboard.py $DEMO_KUBE_API_TOKEN
# - examples/create_dashboard.py $DEMO_KUBE_API_TOKEN
# - examples/delete_dashboard.py $DEMO_KUBE_API_TOKEN
# - examples/get_data_advanced.py $DEMO_KUBE_API_TOKEN ip-10-0-2-180.ec2.internal
# - examples/get_data_datasource.py $DEMO_KUBE_API_TOKEN
# - examples/get_data_simple.py $DEMO_KUBE_API_TOKEN
# - examples/list_alerts.py $DEMO_KUBE_API_TOKEN
# - examples/list_alert_notifications.py $DEMO_KUBE_API_TOKEN
# - examples/resolve_alert_notifications.py $DEMO_KUBE_API_TOKEN 1
# - examples/list_dashboards.py $DEMO_KUBE_API_TOKEN
# - examples/list_hosts.py $DEMO_KUBE_API_TOKEN
# - examples/list_metrics.py $DEMO_KUBE_API_TOKEN
# - examples/post_event.py $DEMO_KUBE_API_TOKEN "test event name" -d "test event description"
# - examples/post_event_simple.py $DEMO_KUBE_API_TOKEN "test event name" "test event description"
# - examples/list_events.py $DEMO_KUBE_API_TOKEN
# - examples/delete_event.py $DEMO_KUBE_API_TOKEN
# - examples/print_data_retention_info.py $DEMO_KUBE_API_TOKEN
# - examples/print_explore_grouping.py $DEMO_KUBE_API_TOKEN
# - examples/print_user_info.py $DEMO_KUBE_API_TOKEN
# - examples/list_sysdig_captures.py $DEMO_KUBE_API_TOKEN
# - examples/create_sysdig_capture.py $DEMO_KUBE_API_TOKEN ip-10-0-2-202.ec2.internal apicapture 10
notifications:
slack:
secure: GJ0H2wAaW67t3+x+cCjOVLw/b+YAZjH9rebAfluCFJklJS9u+V6/qqIyiNDAkMPIcgilFyhiyOQCZYXapgthQ1ieFbZZo//mrRtuGo2wuxCAwcOx2mXAZpZ4I5b3+Q/znVqSuqkwFRid1d138z4TW7sYSIburouDX3QUNoUOy+g7VJxCFQCcqlN8LYxGJHQYdOZa9zIGCtKrOtZ/B8C1TLgXmDMwAAVNO2WzL4GiBTLCGuMsQWMTLw2Qmv1ayZPztmeDWo1C9oa7HIH8Bg2YVjssR87el28X+EqEO533mgYjPmW2/hii30WVFOUE5hMdvKeQLBvy5N3/OCch1np0RQBd8eYEtaPv38rc5L2wAnUq9G5Zzr252z7vnwSLi6lap9jWU8tOerSTEPU+jG05PnuCnufVDXVNPyiPsH6BDP4qxHmLjooNpxfe63Df7NNyUi2I3QoroLj/UzI7zZVQjJEqsTrr5BbsH4z6NTGY91+ZqobBn62+hV3ESAam0ivQgC7s2AKko0qkKyIUGjj7ozU8ebo1UpagNvKC/J9szMqtdXJgKtG8BeonyLMeN6MEEyEvcMJbB4dCcfet+1Sb9AZWnGvYVdajhVLb1HE6OrbzZyhC3KqCe06J9O5BCY9ncy+l16i7MyIfcKTibHQlxPU+Id/VijD97JSRXxnd2i4=
27 changes: 21 additions & 6 deletions examples/create_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
#

import getopt
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
Expand All @@ -14,12 +15,26 @@
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
def usage():
print 'usage: %s [-a|--alert <name>] <sysdig-token>' % sys.argv[0]
print '-a|--alert: Set name of alert to create'
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)

sdc_token = sys.argv[1]
try:
opts, args = getopt.getopt(sys.argv[1:],"a:",["alert="])
except getopt.GetoptError:
usage()

alert_name = "tomcat cpu > 80% on any host"
for opt, arg in opts:
if opt in ("-a", "--alert"):
alert_name = arg

if len(args) != 1:
usage()

sdc_token = args[0]

#
# Instantiate the SDC client
Expand All @@ -29,8 +44,8 @@
#
# Find notification channels (you need IDs to create an alert).
#
notify_channels = [ {'type': 'SLACK', 'channel': 'sysdig-demo2-alerts'},
{'type': 'EMAIL', 'emailRecipients': ['demo-kube@draios.com', 'test@sysdig.com']},
notify_channels = [ {'type': 'SLACK', 'channel': '#python-sdc-test-alert'},
{'type': 'EMAIL', 'emailRecipients': ['python-sdc-testing@draios.com', 'test@sysdig.com']},
{'type': 'SNS', 'snsTopicARNs': ['arn:aws:sns:us-east-1:273107874544:alarms-stg']}
]

Expand All @@ -44,7 +59,7 @@
#
# Create the alert.
#
res = sdclient.create_alert('tomcat cpu > 80% on any host', # Alert name.
res = sdclient.create_alert(alert_name, # Alert name.
'this alert was automatically created using the python Sysdig Cloud library', # Alert description.
6, # Syslog-encoded severity. 6 means 'info'.
60, # The alert will fire if the condition is met for at least 60 seconds.
Expand Down
30 changes: 21 additions & 9 deletions examples/create_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# will monitor.
#

import getopt
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
Expand All @@ -14,12 +15,27 @@
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
def usage():
print 'usage: %s [-d|--dashboard <name>] <sysdig-token>' % sys.argv[0]
print '-d|--dashboard: Set name of dashboard to create'
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)

sdc_token = sys.argv[1]
try:
opts, args = getopt.getopt(sys.argv[1:],"d:",["dashboard="])
except getopt.GetoptError:
usage()

# Name for the dashboard to create
dashboardName = "API test - cassandra in prod"
for opt, arg in opts:
if opt in ("-d", "--dashboard"):
dashboardName = arg

if len(args) != 1:
usage()

sdc_token = args[0]

#
# Instantiate the SDC client
Expand All @@ -30,8 +46,6 @@
# Create the new dashboard, applying to cassandra in production
#

# Name for the dashboard to create
dashboardName = "API test - cassandra in prod"
# Name of the view to copy
viewName = "Overview by Process"
# Filter to apply to the new dashboard.
Expand All @@ -56,14 +70,12 @@
# the dev namespace
#

# Name for the dashboard to create
dashboardName = "API test - cassandra in dev"
# Name of the dashboard to copy
dashboardToCopy = "API test - cassandra in prod"
dashboardCopy = "Copy Of {}".format(dashboardName)
# Filter to apply to the new dashboard. Same as above.
dashboardFilter = "kubernetes.namespace.name = dev and proc.name = cassandra"

res = sdclient.create_dashboard_from_dashboard(dashboardName, dashboardToCopy, dashboardFilter)
res = sdclient.create_dashboard_from_dashboard(dashboardCopy, dashboardName, dashboardFilter)

#
# Check the result
Expand Down
24 changes: 19 additions & 5 deletions examples/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# edit the content, and then delete it.
#

import getopt
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
Expand All @@ -12,12 +13,26 @@
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
def usage():
print 'usage: %s [-d|--dashboard <name>] <sysdig-token>' % sys.argv[0]
print '-d|--dashboard: Set name of dashboard to create'
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)

sdc_token = sys.argv[1]
try:
opts, args = getopt.getopt(sys.argv[1:],"d:",["dashboard="])
except getopt.GetoptError:
usage()

dashboard_name = "My Dashboard"
for opt, arg in opts:
if opt in ("-d", "--dashboard"):
dashboard_name = arg

if len(args) != 1:
usage()

sdc_token = args[0]

#
# Instantiate the SDC client
Expand All @@ -28,7 +43,6 @@
#
# Create an empty dashboard
#
dashboard_name = 'My Dashboard'
dashboard_configuration = None
res = sdclient.create_dashboard(dashboard_name)

Expand Down Expand Up @@ -142,4 +156,4 @@
print 'Dashboard deleted successfully'
else:
print res[1]
sys.exit(1)
sys.exit(1)
23 changes: 19 additions & 4 deletions examples/delete_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This example shows how to delete an alert
#

import getopt
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
Expand All @@ -11,12 +12,26 @@
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
def usage():
print 'usage: %s [-a|--alert <name>] <sysdig-token>' % sys.argv[0]
print '-a|--alert: Set name of alert to delete'
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)

sdc_token = sys.argv[1]
try:
opts, args = getopt.getopt(sys.argv[1:],"a:",["alert="])
except getopt.GetoptError:
usage()

alert_name = "tomcat cpu > 80% on any host"
for opt, arg in opts:
if opt in ("-a", "--alert"):
alert_name = arg

if len(args) != 1:
usage()

sdc_token = args[0]

#
# Instantiate the SDC client
Expand All @@ -29,7 +44,7 @@
sys.exit(1)

for alert in res[1]['alerts']:
if alert['name'] == "tomcat cpu > 80% on any host":
if alert['name'] == alert_name:
print "Deleting alert"
res = sdclient.delete_alert(alert)
if not res[0]:
Expand Down
25 changes: 20 additions & 5 deletions examples/delete_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This example shows how to delete a dashboard
#

import getopt
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
Expand All @@ -11,12 +12,26 @@
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
def usage():
print 'usage: %s [-p|--pattern <name>] <sysdig-token>' % sys.argv[0]
print '-p|--pattern: Delete all dashboards containing the provided pattern'
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)

sdc_token = sys.argv[1]
try:
opts, args = getopt.getopt(sys.argv[1:],"p:",["pattern="])
except getopt.GetoptError:
usage()

pattern = "API Test"
for opt, arg in opts:
if opt in ("-p", "--pattern"):
pattern = arg

if len(args) != 1:
usage()

sdc_token = args[0]

#
# Instantiate the SDC client
Expand All @@ -32,10 +47,10 @@
sys.exit(1)

#
# Delete all the dashboards containing "API test"
# Delete all the dashboards containing pattern
#
for dashboard in res[1]['dashboards']:
if 'API test' in dashboard['name']:
if pattern in dashboard['name']:
print "Deleting " + dashboard['name']
res = sdclient.delete_dashboard(dashboard)
if not res[0]:
Expand Down
23 changes: 19 additions & 4 deletions examples/delete_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Delete user events from Sysdig Cloud
#

import getopt
import json
import os
import sys
Expand All @@ -12,12 +13,26 @@
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
def usage():
print 'usage: %s [-e|--event <name>] <sysdig-token>' % sys.argv[0]
print '-e|--event: Name of event to delete'
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
sys.exit(1)

sdc_token = sys.argv[1]
try:
opts, args = getopt.getopt(sys.argv[1:],"e:",["event="])
except getopt.GetoptError:
usage()

event_name = "test_event_name"
for opt, arg in opts:
if opt in ("-e", "--event"):
event_name = arg

if len(args) != 1:
usage()

sdc_token = args[0]

#
# Instantiate the SDC client
Expand All @@ -27,7 +42,7 @@
#
# Get the events that match a name
#
res = sdclient.get_events(name='test_event_name')
res = sdclient.get_events(name=event_name)

if not res[0]:
print res[1]
Expand Down
Loading