Пример #1
0
def get_dashboards(sdmonitor: SdMonitorClient, ids: List, format: AnyStr):
    ok, data = sdmonitor.get_dashboards()
    ids = set([str(id) for id in ids])
    if not ok:
        print(data)
        return EXIT_CODES.ERR_METHOD_NOT_FOUND

    dashboards = [
        dash for dash in data["dashboards"] if str(dash["id"]) in ids
    ]
    if len(dashboards) == 0:
        print("No dashboards found with these IDs")
        return EXIT_CODES.ERR_METHOD_NOT_FOUND

    if format == "yaml":
        print(yaml.dump(dashboards))
        return EXIT_CODES.OK

    print(json.dumps(dashboards, indent=2))
Пример #2
0
    print('You can find your token at https://app.sysdigcloud.com/#/settings/user')
    sys.exit(1)

sdc_token = sys.argv[1]
dashboard_state_file = sys.argv[2]
sysdig_dashboard_dir = 'sysdig-dashboard-dir'

#
# Instantiate the SDC client
#
sdclient = SdMonitorClient(sdc_token)

#
# 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)