# # Fire the request. # ok, res = sdclient.get_dashboards() # # Show the list of dashboards # if not ok: print(res) sys.exit(1) # Clean up any state in the tmp directory cleanup_dir(sysdig_dashboard_dir) # Creating sysdig dashboard directory to store dashboards if not os.path.exists(sysdig_dashboard_dir): os.makedirs(sysdig_dashboard_dir) for db in res['dashboards']: sdclient.save_dashboard_to_file(db, os.path.join(sysdig_dashboard_dir, str(db['id']))) print(("Name: %s" % (db['name']))) zipf = zipfile.ZipFile(dashboard_state_file, 'w', zipfile.ZIP_DEFLATED) zipdir(sysdig_dashboard_dir, zipf) zipf.close() # Clean up any state in the directory cleanup_dir(sysdig_dashboard_dir)
# # Instantiate the SDC client # sdclient = SdMonitorClient(sdc_token) # # Serialize the first user dashboard to disk # ok, res = sdclient.get_dashboards() if not ok: print(res) sys.exit(1) if len(res['dashboards']) > 0: sdclient.save_dashboard_to_file(res['dashboards'][0], 'dashboard.json') else: print('the user has no dashboards. Exiting.') sys.exit(0) # # Now create the dashboard from the file. We use a filter for the Cassandra process # as an example. # dashboardFilter = 'proc.name = "cassandra"' ok, res = sdclient.create_dashboard_from_file('test dasboard from file', 'dashboard.json', dashboardFilter) if ok: