def __init__(self): # prepare mysql target database # TODO: make this more generic later on # prepare database connection and create required collection objects db = backend.databackend.getBackendObject(config.data_backend, config.data_backend_host, config.data_backend_port, config.data_backend_user, config.data_backend_password, config.data_backend_snmp_table, "UPDATE") for name, fields in csv_configurator.read_field_dict_from_csv(config.data_backend, "../config/events.csv").items(): db.prepareCollection(name, fields) self.events = db.getCollection("events")
def __init__(self, last_timestamp = -1): # prepare database connection and create required collection objects self.db = backend.databackend.getBackendObject(config.data_backend, config.data_backend_host, config.data_backend_port, config.data_backend_user, config.data_backend_password, config.data_backend_snmp_table) measurement_map_filename = os.path.join(os.path.dirname(__file__), "..", "config", "oidmap.csv") for name, fields in csv_configurator.read_field_dict_from_csv(config.data_backend, measurement_map_filename).items(): self.db.prepareCollection(name, fields) interface_phy = self.db.getCollection("interface_phy") # get all timestamps self.timestamps = sorted(interface_phy.distinct("timestamp", {"timestamp": {"$gt": last_timestamp}}))
def __init__(self): # prepare mysql target database # TODO: make this more generic later on # prepare database connection and create required collection objects db = backend.databackend.getBackendObject( config.data_backend, config.data_backend_host, config.data_backend_port, config.data_backend_user, config.data_backend_password, config.data_backend_snmp_table, "UPDATE") for name, fields in csv_configurator.read_field_dict_from_csv( config.data_backend, "../config/events.csv").items(): db.prepareCollection(name, fields) self.events = db.getCollection("events")
"location_file", help= "CSV file that contains a list of locations/networks that should be included into the monitoring process" ) args = parser.parse_args() # prepare the target database dst_db = backend.databackend.getBackendObject(args.backend, args.dst_host, args.dst_port, args.dst_user, args.dst_password, args.dst_database) measurement_map_filename = os.path.join(os.path.dirname(__file__), "..", "config", "monitoring_devices.csv") for name, fields in csv_configurator.read_field_dict_from_csv( args.backend, measurement_map_filename).items(): dst_db.prepareCollection(name, fields) location_table = dst_db.getCollection("location_table") # now try to read the CSV file csv_file_handle = None try: csv_file_handle = open(args.location_file, 'r') except Exception as e: print "ERROR: Failed to open input CSV file \"%s\":", e sys.exit(-1) csv_content = {} location_reader = csv.reader(csv_file_handle) insert_time = time.time()
import backend if __name__ == "__main__": parser = common.get_default_argument_parser("Script for importing a device list into the monitoring process") parser.add_argument("location_file", help="CSV file that contains a list of locations/networks that should be included into the monitoring process") args = parser.parse_args() # prepare the target database dst_db = backend.databackend.getBackendObject( args.backend, args.dst_host, args.dst_port, args.dst_user, args.dst_password, args.dst_database) measurement_map_filename = os.path.join(os.path.dirname(__file__), "..", "config", "monitoring_devices.csv") for name, fields in csv_configurator.read_field_dict_from_csv(args.backend, measurement_map_filename).items(): dst_db.prepareCollection(name, fields) location_table = dst_db.getCollection("location_table") # now try to read the CSV file csv_file_handle = None try: csv_file_handle = open(args.location_file, 'r') except Exception as e: print "ERROR: Failed to open input CSV file \"%s\":", e sys.exit(-1) csv_content = {} location_reader = csv.reader(csv_file_handle) insert_time = time.time()