def main(): # take some input parser = argparse.ArgumentParser(description="collect metrics from VNX and import into InfluxDB. Assumes naviseccli is in the PATH") parser.add_argument('--vnx', required=True, action='append', help="VNX SP to connect to") parser.add_argument('--vnx-username', default="admin", help="navisec username") parser.add_argument('--vnx-password', default="changeme", help="navisec password") parser.add_argument('--influx-dsn', default=influx_dsn_default, help="InfluxDB DSN, eg. %s" % influx_dsn_default) parser.add_argument('--debug', '-d', action='store_true', help="enable debugging") args = parser.parse_args() # loop over vCenters and collect metrics for vnx in args.vnx: meas = "vnxprop.%s" % (convert_to_alnum(vnx)) results = build_vnx(vnx, vnx_tags, vnx_fields, measurement=meas, args=args) if args.debug: print "Results of VNX query:" for ts in results: print "Measurement:", ts.measurement print "Tags:", ts.tags print "Fields:", ts.fields print else: write_results(args.influx_dsn, results)
def main(): # take some input parser = argparse.ArgumentParser(description="synthesize zero-sized data points for vm growth tracking") parser.add_argument('--influx-dsn', default=influx_dsn_default, help="InfluxDB DSN, eg. %s" % influx_dsn_default) parser.add_argument('--search-interval', default=None, help="Length of time to search (e.g. 10m, 4h, 30d)") parser.add_argument('--debug', '-d', action='store_true', help="enable debugging") args = parser.parse_args() # find the first point in each series within the last search interval search = "/vmprop.*/" first_points = find_first_point(args.influx_dsn, search, interval=args.search_interval) synth_points = [] for ts in first_points: # whether we need to synthesize a zero point or not needs_synth = False for field in data_fields: if ts.fields[field] != 0: needs_synth = True if needs_synth: synth_ts = InfluxResult08(ts.measurement) synth_ts.timestamp = ts.timestamp - 600 # 10 minutes into the past synth_ts.fields = copy(ts.fields) synth_ts.tags = copy(ts.tags) for field in data_fields: synth_ts.fields[field] = 0 synth_points.append(synth_ts) if args.debug: print "Synthesized points:" for ts in synth_points: print "Measurement:", ts.measurement print "Tags:", ts.tags print "Fields:", ts.fields print "Timestamp:", ts.timestamp print else: write_results(args.influx_dsn, synth_points)
def main(): # take some input parser = argparse.ArgumentParser(description="collect metrics from XtremIO and import into InfluxDB") parser.add_argument('--xms', required=True, action='append', help="XtremIO XMS to connect to") parser.add_argument('--xmsadmin-username', default="xmsadmin", help="xmsadmin username") parser.add_argument('--xmsadmin-password', default="changeme", help="xmsadmin password") parser.add_argument('--xms-username', default="admin", help="xms user username") parser.add_argument('--xms-password', default="changeme", help="xms user password") parser.add_argument('--influx-dsn', default=influx_dsn_default, help="InfluxDB DSN, eg. %s" % influx_dsn_default) parser.add_argument('--debug', '-d', action='store_true', help="enable debugging") args = parser.parse_args() # loop over vCenters and collect metrics for xms in args.xms: meas = "xioprop.%s" % (convert_to_alnum(xms)) results = build_xiocluster(xms, xio_tags, xio_fields, measurement=meas, args=args) if args.debug: print "Results of XMS query:" for ts in results: print "Measurement:", ts.measurement print "Tags:", ts.tags print "Fields:", ts.fields print else: write_results(args.influx_dsn, results)
def main(): # take some input parser = argparse.ArgumentParser(description="collect metrics from vSphere and import into InfluxDB") parser.add_argument('--vcenter', required=True, action='append', help="vCenter to connect to") parser.add_argument('--vs-username', default="admin", help="vSphere username") parser.add_argument('--vs-password', default="changeme", help="vSphere password") parser.add_argument('--vs-port', type=int, default=443, help="vSphere port") parser.add_argument('--influx-dsn', default=influx_dsn_default, help="InfluxDB DSN, eg. %s" % influx_dsn_default) parser.add_argument('--debug', '-d', action='store_true', help="enable debugging") args = parser.parse_args() silence_warnings() # loop over vCenters and collect metrics for vcenter in args.vcenter: service_instance = None try: service_instance = connect.SmartConnect(host=vcenter, user=args.vs_username, pwd=args.vs_password, port=args.vs_port) atexit.register(connect.Disconnect, service_instance) except Exception as e: print "Unable to connect to %s" % vcenter continue meas = "vmprop.%s" % (convert_to_alnum(vcenter)) results = build_vmresultset(service_instance, vm_tags, vm_fields, measurement=meas) for ts in results: ts.tags['vcenter'] = vcenter if len(ts.tags['folderPath'].split('/')) >= 2: ts.tags['topLevelFolder'] = ts.tags['folderPath'].split('/')[1] else: ts.tags['topLevelFolder'] = "None" # collect the results and some aggregates output = [] output.extend(results) output.extend(agg_by_topLevelFolder(results)) output.extend(agg_by_vcenter(results)) # now write the output to the database if args.debug: print "Results of vSphere query:" for ts in output: print "Measurement:", ts.measurement print "Tags:", ts.tags print "Fields:", ts.fields print else: write_results(args.influx_dsn, output)