Exemplo n.º 1
0
'''
Locate series that have no data during the interval for one day before entity last_insert_date.
'''

# Connect to ATSD server
#connection = connect('/path/to/connection.properties')
connection = connect_url('https://atsd_hostname:8443', 'username', 'password')

# set grace interval in hours
grace_interval_hours = 1

# list of the agents (entities)
agents = ['nurswgvml007', 'nurswgvml010']

entities_service = EntitiesService(connection)
metrics_service = MetricsService(connection)

for agent in agents:
    # query agent meta information
    entity = entities_service.get(agent)
    if entity is None:
        print('Agent %s not found' % agent)
        continue
    date = entity.last_insert_date
    # query all metrics collecting by agent
    metrics = entities_service.metrics(entity, use_entity_insert_time=True)
    for metric in metrics:
        # check actual data existence
        if date - metric.last_insert_date > timedelta(seconds=grace_interval_hours * 3600):
            print("%s, %s" % (metric.name, agent))
Exemplo n.º 2
0
# query required metric meta data
metric = metrics_service.get(metric_name)
if metric is None:
    print('No metric with name %s' % metric_name)
    sys.exit()
elif metric.last_insert_date is None:
    print('No data for metric name %s' % metric_name)
    sys.exit()

# calculate the upper boundary for the allowed last_insert_date values excluding grace interval
max_insert_date = metric.last_insert_date - timedelta(
    seconds=grace_interval_hours * 3600)

# query series list for the metric
series_list = metrics_service.series(metric,
                                     min_insert_date=min_insert_date,
                                     max_insert_date=max_insert_date)

# make dictionary from entity and last_insert_date, store maximum value of last_insert_date
various_entities = dict()
for series in series_list:
    last_insert_date = various_entities.get(series.entity)
    if last_insert_date is None or last_insert_date < series.last_insert_date:
        various_entities[series.entity] = series.last_insert_date

print('entity_name,entity_label,last_insert_date')
for entity in various_entities:
    label = entities_service.get(entity).label
    last_insert_date = various_entities[entity]
    print('%s,%s,%s' % (entity, print_str(label), last_insert_date))
entities_service = EntitiesService(connection)
metrics_service = MetricsService(connection)

# query required metric meta data
metric = metrics_service.get(metric_name)
if metric is None:
    print('No metric with name %s' % metric_name)
    sys.exit()
elif metric.last_insert_date is None:
    print('No data for metric name %s' % metric_name)
    sys.exit()

# calculate the upper boundary for the allowed last_insert_date values excluding grace interval
max_insert_date = metric.last_insert_date - timedelta(seconds=grace_interval_hours * 3600)

# query series list for the metric
series_list = metrics_service.series(metric, min_insert_date=min_insert_date, max_insert_date=max_insert_date)

# make dictionary from entity and last_insert_date, store maximum value of last_insert_date
various_entities = dict()
for series in series_list:
    last_insert_date = various_entities.get(series.entity)
    if last_insert_date is None or last_insert_date < series.last_insert_date:
        various_entities[series.entity] = series.last_insert_date

print('entity_name,entity_label,last_insert_date')
for entity in various_entities:
    label = entities_service.get(entity).label
    last_insert_date = various_entities[entity]
    print('%s,%s,%s' % (entity, print_str(label), last_insert_date))
Exemplo n.º 4
0
metric = args.metric_name
tag_expression = None
if args.tag_expression is not None:
    tag_expression = args.tag_expression
start_date = args.start_datetime
dry_run = False
if args.dry_run is not None:
    dry_run = True
batch_size = int(args.batch_size)


connection = connect('/path/to/connection.properties')

entity_service = EntitiesService(connection)

if entity_service.get(source_entity) is None:
    logging.warning("'" + source_entity + "' entity does not exist")
    exit(1)

if entity_service.get(dst_entity) is None:
    logging.warning("'" + dst_entity + "' entity does not exist")
    exit(1)

metric_service = MetricsService(connection)

if metric_service.get(metric) is None:
    logging.warning("'" + metric + "' metric does not exist")
    exit(1)

series_service = SeriesService(connection)