Esempio n. 1
0
start_time = time.time()

try:
    requests.packages.urllib3.disable_warnings()
except AttributeError:
    pass

(config, config_file) = cccommon.initialize()
print("{me}: Loaded configuration from {path}".format(me=me,
                                                      path=os.path.abspath(
                                                          config_file.name)),
      file=sys.stderr)

if not 'token' in config or not cccommon.check_token(config['token']):
    config['token'] = cccommon.authenticate(config, None)
    config_file.seek(0)
    config_file.truncate()
    json.dump(config, config_file, indent=4, sort_keys=True)
    print("{me}: Got token {token}".format(me=me, token=config['token']),
          file=sys.stderr)
else:
    print("{me}: Loaded valid token {token} from config".format(
        me=me, token=config['token']),
          file=sys.stderr)

if not 'app-info' in config:
    print("{me}: Getting app names...".format(me=me), file=sys.stderr)
    config['app-info'] = cccommon.get_app_info(config['token'])
    config_file.seek(0)
    config_file.truncate()
start_time = time.time();

try:
		requests.packages.urllib3.disable_warnings()
except AttributeError:
		pass

(config, config_file) = cccommon.initialize()
if not 'transactions' in config:
	print("{me}: No transactions in config. Exiting.".format(me=me), file=sys.stderr)
	os._exit(0)

print("{me}: Loaded configuration from {path}".format(me=me, path=os.path.abspath(config_file.name)), file=sys.stderr)

if not 'token' in config or not cccommon.check_token(config['token']):
	config['token'] = cccommon.authenticate(config, None)
	config_file.seek(0)
	config_file.truncate()
	json.dump(config, config_file, indent=4, sort_keys=True)
	print("{me}: Got token {token}".format(me=me, token=config['token']), file=sys.stderr)
else:
	print("{me}: Loaded valid token {token} from config".format(me=me, token=config['token']), file=sys.stderr)

if not 'app-info' in config:
	print("{me}: Getting app names...".format(me=me), file=sys.stderr)
	config['app-info'] = cccommon.get_app_info(config['token'])
	config_file.seek(0)
	config_file.truncate()
	json.dump(config, config_file, indent=4, sort_keys=True)

for txn in config['transactions']:
print("configuration for you, which you can then edit as you see fit. Note that this script")
print("will store your REST API Client ID and Crittercism username and password in the config")
print("file. You can remove them and the collector will still function using the generated OAuth2")
print("token until it expires.")
print("")
clientID = raw_input("Crittercism REST API Client ID: ")
username = raw_input("Crittercism username: "******"Crittercism password: "******"username": username,
	"password": password,
	"clientID": clientID
}

config['token'] = cccommon.authenticate(config, None)

print("")
print("Getting the list of apps...")
apps = cccommon.list_apps(config['token'])

appids = apps.keys()

for index, id in enumerate(appids):
	print("[{index}]: {appName} - {appType} (app id: {id})".format(index=index, appName=apps[id]['appName'], appType=apps[id]['appType'], id=id))

print("")
print("Type the the number for each app you want to monitor, separated by spaces (e.g., 0 3 5 6 7)")
chosenstr = raw_input("Choose which apps to monitor: ")

endpoints_limit_str = raw_input("Number of endpoints to monitor for each app [default 10]: ")
Esempio n. 4
0
try:
    requests.packages.urllib3.disable_warnings()
except AttributeError:
    pass

(config, config_file) = cccommon.initialize()
print("{me}: Loaded configuration from {path}".format(me=me, path=os.path.abspath(config_file.name)), file=sys.stderr)

if not "trends" in config:
    sys.exit("{me}: No trends found in config - nothing to do".format(me=me))

my_stats["trends.configured"] += len(config["trends"])

if not "token" in config or not cccommon.check_token(config["token"]):
    config["token"] = cccommon.authenticate(config, None)
    config_file.seek(0)
    config_file.truncate()
    json.dump(config, config_file, indent=4, sort_keys=True)
    print("{me}: Got token {token}".format(me=me, token=config["token"]), file=sys.stderr)
else:
    print("{me}: Loaded valid token {token} from config".format(me=me, token=config["token"]), file=sys.stderr)

if not "app-info" in config:
    print("{me}: Getting app names...".format(me=me), file=sys.stderr)
    config["app-info"] = cccommon.get_app_info(config["token"])
    config_file.seek(0)
    config_file.truncate()
    json.dump(config, config_file, indent=4, sort_keys=True)

for trend in config["trends"]:
)
print(
    "will store your REST API Client ID and Crittercism username and password in the config"
)
print(
    "file. You can remove them and the collector will still function using the generated OAuth2"
)
print("token until it expires.")
print("")
clientID = raw_input("Crittercism REST API Client ID: ")
username = raw_input("Crittercism username: "******"Crittercism password: "******"username": username, "password": password, "clientID": clientID}

config['token'] = cccommon.authenticate(config, None)

print("")
print("Getting the list of apps...")
apps = cccommon.list_apps(config['token'])

appids = apps.keys()

for index, id in enumerate(appids):
    print("[{index}]: {appName} - {appType} (app id: {id})".format(
        index=index,
        appName=apps[id]['appName'],
        appType=apps[id]['appType'],
        id=id))

print("")
print("{me}: Starting...".format(me=me), file=sys.stderr)
timeout_timer = threading.Timer(SCRIPT_TIMEOUT, time_expired)
timeout_timer.start()

start_time = time.time();

try:
		requests.packages.urllib3.disable_warnings()
except AttributeError:
		pass

(config, config_file) = cccommon.initialize()
print("{me}: Loaded configuration from {path}".format(me=me, path=os.path.abspath(config_file.name)), file=sys.stderr)

if not 'token' in config or not cccommon.check_token(config['token']):
	config['token'] = cccommon.authenticate(config, None)
	config_file.seek(0)
	config_file.truncate()
	json.dump(config, config_file, indent=4, sort_keys=True)
	print("{me}: Got token {token}".format(me=me, token=config['token']), file=sys.stderr)
else:
	print("{me}: Loaded valid token {token} from config".format(me=me, token=config['token']), file=sys.stderr)

if not 'app-info' in config:
	print("{me}: Getting app names...".format(me=me), file=sys.stderr)
	config['app-info'] = cccommon.get_app_info(config['token'])
	config_file.seek(0)
	config_file.truncate()
	json.dump(config, config_file, indent=4, sort_keys=True)

stuff_to_monitor = []
Esempio n. 7
0
except AttributeError:
    pass

(config, config_file) = cccommon.initialize()
if not 'transactions' in config:
    print("{me}: No transactions in config. Exiting.".format(me=me),
          file=sys.stderr)
    os._exit(0)

print("{me}: Loaded configuration from {path}".format(me=me,
                                                      path=os.path.abspath(
                                                          config_file.name)),
      file=sys.stderr)

if not 'token' in config or not cccommon.check_token(config['token']):
    config['token'] = cccommon.authenticate(config, None)
    config_file.seek(0)
    config_file.truncate()
    json.dump(config, config_file, indent=4, sort_keys=True)
    print("{me}: Got token {token}".format(me=me, token=config['token']),
          file=sys.stderr)
else:
    print("{me}: Loaded valid token {token} from config".format(
        me=me, token=config['token']),
          file=sys.stderr)

if not 'app-info' in config:
    print("{me}: Getting app names...".format(me=me), file=sys.stderr)
    config['app-info'] = cccommon.get_app_info(config['token'])
    config_file.seek(0)
    config_file.truncate()