def test_start_and_end_fields_are_allowed(self): with json_file({}) as credentials_path: with json_file({}) as query_path: parse_args(args=[ "-c", credentials_path, "-q", query_path, "-s", "2013-10-10", "-e", "2013-10-10" ])
def test_start_and_end_fields_are_allowed(self): with json_file({}) as credentials_path: with json_file({}) as query_path: parse_args( args=[ "-c", credentials_path, "-q", query_path, "-s", "2013-10-10", "-e", "2013-10-10"])
def main(): configure_logging() args = arguments.parse_args(name="Pingdom") start_dt, end_dt = parse_time_range(args.start_at, args.end_at) pingdom = Pingdom(args.credentials) check_name = args.query['query']['name'] pingdom_stats = pingdom.stats(check_name, start_dt, end_dt) push_stats_to_data_set( pingdom_stats, check_name, data_set_url=args.query['target']['data_set'], data_set_token=args.query['target']['token'])
def test_happy_path(self): with json_file({}) as credentials_path: with json_file({}) as query_path: parse_args( args=["-c", credentials_path, "-q", query_path] )
import json import logging import os from backdrop.collector import arguments from backdrop.collector.logging_setup import set_up_logging from os.path import realpath, dirname from collector import realtime def _load_json_file(path): with open(path) as f: return json.load(f) if __name__ == '__main__': args = arguments.parse_args('Google Analytics realtime') logfile_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'log') set_up_logging('ga-realtime', logging.DEBUG, logfile_path) collector = realtime.Collector(args.credentials) targets_json_path = '/config/targets.json' targets = _load_json_file(dirname(realpath(__file__)) + targets_json_path) target = targets.get(args.query['target']) if not target: logging.error("ERROR: Entry for `%s` not found in %s" % (args.query['target'], targets_json_path))
#! /usr/bin/env python2 import logging import os from backdrop.collector import arguments from backdrop.collector.logging_setup import set_up_logging if __name__ == '__main__': this_dir = os.path.dirname(os.path.realpath(__file__)) repo_root = os.path.abspath(os.path.join(this_dir, "..")) logfile_path = os.path.join(repo_root, 'log') logging.basicConfig(level=logging.DEBUG) set_up_logging('ga_collector_contrib_content', logging.INFO, logfile_path) # FIXME I do not condone path injection hacks like this. I would prefer if # this was setuptools-installed, but current consensus is that fixing this # would require updating too many other things to be consistent. from sys import path path[0:0] = [repo_root] from collector.contrib.content.table import main args = arguments.parse_args('Google Analytics') main(args)
'downtime': pingdom_stats['downtime'], 'unmonitored': pingdom_stats['unmonitored'], 'check': name_of_check } def truncate_hour_fraction(a_datetime): return a_datetime.replace(minute=0, second=0, microsecond=0) if __name__ == '__main__': app_path = os.path.dirname(os.path.realpath(__file__)) logfile_path = os.path.join(app_path, 'log') set_up_logging('pingdom', logging.DEBUG, logfile_path) args = arguments.parse_args(name="Pingdom") collection_date = datetime.now() if args.end_at: collection_date = args.end_at pingdom = Pingdom(args.credentials) check_name = args.query['query']['name'] timestamp = truncate_hour_fraction(collection_date) pingdom_stats = pingdom.stats_for_24_hours(check_name, timestamp) bucket_url = args.query['target']['bucket'] bucket_token = args.query['target']['token'] bucket = Bucket(url=bucket_url, token=bucket_token) bucket.post([convert_from_pingdom_to_backdrop(thing, check_name) for
def test_happy_path(self): with json_file({}) as credentials_path: with json_file({}) as query_path: parse_args(args=["-c", credentials_path, "-q", query_path])
import logging import os from backdrop.collector import arguments from backdrop.collector.logging_setup import set_up_logging from collector.trending import compute if __name__ == '__main__': logfile_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'log') set_up_logging('ga_trending_collector', logging.DEBUG, logfile_path) args = arguments.parse_args('Google Analytics Trending') compute(vars(args))