#!/usr/bin/env python3

#--------------------------------------------
# Sample Custom Metric Script
#
# Copyright (c) 2020, 2022 by Cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------

import os
import json
from datetime import datetime


if __name__ == '__main__':

    metric_name = os.path.basename(__file__)
    data_file = '/harddisk:/custom_metrics/' + metric_name + '.json'

    metric = {}
    metric['custom_metric'] = {}
    metric['custom_metric']['name'] = metric_name
    metric['custom_metric']['health_state'] = 'Normal'
    metric['custom_metric']['health_msg'] = 'Health description'
    metric['custom_metric']['last_update'] = datetime.now().strftime('%d/%m/%y %I:%M %S %p')
    metric['custom_metric']['metric_info'] = {}
    metric['custom_metric']['metric_info']['paramFoo'] = 'Information foo'
    metric['custom_metric']['metric_info']['paramBar'] = 'Information bar'
 
    with open(data_file, 'w') as json_file:
        json.dump(metric, json_file, sort_keys=True, indent=4)
