from raven import Client raven = Client(os.getenv("LITTLEFIELD_RAVEN_DSN")) try: from littlefield import Littlefield def avg(data, size): return sum(data[((size*-1)-1):-1])/size config = False if len(sys.argv) > 1: if sys.argv[1] == "config": config = True if config: print("""graph_title Station Utilitization graph_info Shows the utilitization of each station graph_category littlefield graph_scale no graph_args --upper-limit 100 -l 0 graph_vlabel %""") for station in range(1, 4): if config: print("station%s.label Station %s" % (station, station)) print("station%s.warning 10:80" % station) else: littlefield = Littlefield(os.getenv("LITTLEFIELD_USER"), os.getenv("LITTLEFIELD_PW")) util = littlefield.get_data("S%sUTIL" % station)['average'] print("station%s.value %s" % (station, util[-1]*100)) except: raven.captureException()
output_server("littlefield") datatypes = [ "JOBIN", # Number of jobs accepted per day "JOBQ", # Number of jobs waiting "INV", # Inventory levels "JOBOUT", # Number of completed jobs "JOBT", # Lead times "JOBREV", # Revenue "S1Q", # Number of kits queued for station 1 "S1UTIL", # Station 1 utilitization by day "S2Q", # number of kits queued for station 2 "S2UTIL", # Station 2 utilitization by day "S3Q", # number of kits queued for station 3 "S3UTIL" # Station 3 utilitization by day ] plots = [] for datatype in datatypes: print(datatype) data = littlefield.get_data(datatype) keys = list(data.keys()) p = figure(tools="pan,box_zoom,reset,save", title=datatype, x_axis_label=keys[1], y_axis_label=keys[0]) p.line(data[keys[1]], data[keys[0]], legend=datatype) plots.append(p) show(gridplot([plots], toolbar_location=None))
littlefield = Littlefield(config['littlefield']['user'], config['littlefield']['password']) output_server("littlefield") datatypes = [ "JOBIN", # Number of jobs accepted per day "JOBQ", # Number of jobs waiting "INV", # Inventory levels "JOBOUT", # Number of completed jobs "JOBT", # Lead times "JOBREV", # Revenue "S1Q", # Number of kits queued for station 1 "S1UTIL", # Station 1 utilitization by day "S2Q", # number of kits queued for station 2 "S2UTIL", # Station 2 utilitization by day "S3Q", # number of kits queued for station 3 "S3UTIL" # Station 3 utilitization by day ] plots = [] for datatype in datatypes: print(datatype) data = littlefield.get_data(datatype) keys = list(data.keys()) p = figure( tools="pan,box_zoom,reset,save", title=datatype, x_axis_label=keys[1], y_axis_label=keys[0] ) p.line(data[keys[1]], data[keys[0]], legend=datatype) plots.append(p) show(gridplot([plots], toolbar_location=None))
name = sys.argv[0].split("_")[1] else: name = sys.argv[-1] config = False if len(sys.argv) > 1: if sys.argv[1] == "config": config = True if config: print("graph_title %s" % titles[name]['title']) print("graph_info Shows the %s" % titles[name]['title']) print("graph_category littlefield") print("graph_vlabel %s" % titles[name]['unit']) if "scale" in titles[name]: print("graph_scale no") if config: print("%s.label %s" % (name, titles[name]['title'])) print("%s-3.label %s (3 day average)" % (name, titles[name]['title'])) print("%s-10.label %s (10 day average)" % (name, titles[name]['title'])) else: littlefield = Littlefield(os.getenv("LITTLEFIELD_USER"), os.getenv("LITTLEFIELD_PW")) data = littlefield.get_data(name) key = "average" print("%s.value %s" % (name, data[key][-1])) print("%s-3.value %s" % (name, avg(data[key], 3))) print("%s-10.value %s" % (name, avg(data[key], 10))) except: raven.captureException()
#!/usr/bin/env python from littlefield import Littlefield from configparser import ConfigParser import notify config = ConfigParser() config.read(["littlefield.ini"]) littlefield = Littlefield(config["littlefield"]["user"], config["littlefield"]["password"]) for i in range(1, 4): station = littlefield.get_station(i) utilitization = littlefield.get_data("S%sUTIL" % i)["average"][-1] if utilitization > float(config["littlefield"]["util_high"]): machines = station["number of machines"] + 1 notify.send( "Station %s has a utilitization of %s. Increasing machines from %s to %s" % (i, utilitization, station["number of machines"], machines) ) littlefield.update_machine_count(station, machines) elif utilitization < float(config["littlefield"]["util_low"]) and station["number of machines"] > 1: machines = station["number of machines"] - 1 notify.send( "Station %s has a utilitization of %s. Decreasing machines from %s to %s" % (i, utilitization, station["number of machines"], machines) ) littlefield.update_machine_count(station, machines)
#!/usr/bin/env python import sys import os lib = os.getenv("LITTLEFIELD_PATH") if lib is not None: sys.path.append(lib) from raven import Client raven = Client(os.getenv("LITTLEFIELD_RAVEN_DSN")) try: from littlefield import Littlefield config = False if len(sys.argv) > 1: if sys.argv[1] == "config": config = True if config: print("""graph_title Queue Size graph_info Shows the queue size graph_category littlefield graph_vlabel Kits""") littlefield = Littlefield(os.getenv("LITTLEFIELD_USER"), os.getenv("LITTLEFIELD_PW")) for station in range(1, 4): if config: print("station%s.label Station %s" % (station, station)) else: size = littlefield.get_data("S%sQ" % station)['average'] print("station%s.value %s" % (station, size[-1])) except: raven.captureException()
#!/usr/bin/env python from littlefield import Littlefield from configparser import ConfigParser import notify config = ConfigParser() config.read(['littlefield.ini']) littlefield = Littlefield(config['littlefield']['user'], config['littlefield']['password']) for i in range(1, 4): station = littlefield.get_station(i) utilitization = littlefield.get_data("S%sUTIL" % i)['average'][-1] if utilitization > float(config['littlefield']['util_high']): machines = station['number of machines'] + 1 notify.send( "Station %s has a utilitization of %s. Increasing machines from %s to %s" % (i, utilitization, station['number of machines'], machines)) littlefield.update_machine_count(station, machines) elif utilitization < float(config['littlefield']['util_low'] ) and station['number of machines'] > 1: machines = station['number of machines'] - 1 notify.send( "Station %s has a utilitization of %s. Decreasing machines from %s to %s" % (i, utilitization, station['number of machines'], machines)) littlefield.update_machine_count(station, machines)
#!/usr/bin/env python from littlefield import Littlefield from configparser import ConfigParser config = ConfigParser() config.read(['littlefield.ini']) littlefield = Littlefield(config['littlefield']['user'], config['littlefield']['password']) status = littlefield.get_status() for key, value in status.items(): print("%s:\t%s" % (key, value)) def avg(data, size): return sum(util[((size*-1)-1):-1])/size print("Station\t\t1 day avg\t\t3 day avg\t\t10 day avg") for station in range(1, 4): machines = littlefield.get_station(station)['number of machines'] util = littlefield.get_data("S%sUTIL" % station)['average'] queue = littlefield.get_data("S%sQ" % station)['average'] print("Station %s:\t[ %.2f%% | %.2f ]\t[ %.2f%% | %.2f ]\t[ %.2f%% | %.2f ] (%s machines)" % (station, (util[-1]*100), queue[-1], (avg(util, 3)*100), avg(queue, 3), (avg(util, 10)*100), avg(queue, 10), machines)) jobt = littlefield.get_data("JOBT")['average'] print("Job Times:\t[ %.2f ]\t\t[ %.2f ]\t\t[ %.2f ]" % (jobt[-1], avg(jobt, 3), avg(jobt, 10))) jobq = littlefield.get_data("JOBQ")['average'] print("Queue Size:\t[ %.2f ]\t\t[ %.2f ]\t\t[ %.2f ]" % (jobq[-1], avg(jobq, 3), avg(jobq, 10)))
littlefield = Littlefield(config['littlefield']['user'], config['littlefield']['password']) status = littlefield.get_status() for key, value in status.items(): print("%s:\t%s" % (key, value)) def avg(data, size): return sum(util[((size * -1) - 1):-1]) / size print("Station\t\t1 day avg\t\t3 day avg\t\t10 day avg") for station in range(1, 4): machines = littlefield.get_station(station)['number of machines'] util = littlefield.get_data("S%sUTIL" % station)['average'] queue = littlefield.get_data("S%sQ" % station)['average'] print( "Station %s:\t[ %.2f%% | %.2f ]\t[ %.2f%% | %.2f ]\t[ %.2f%% | %.2f ] (%s machines)" % (station, (util[-1] * 100), queue[-1], (avg(util, 3) * 100), avg(queue, 3), (avg(util, 10) * 100), avg(queue, 10), machines)) jobt = littlefield.get_data("JOBT")['average'] print("Job Times:\t[ %.2f ]\t\t[ %.2f ]\t\t[ %.2f ]" % (jobt[-1], avg(jobt, 3), avg(jobt, 10))) jobq = littlefield.get_data("JOBQ")['average'] print("Queue Size:\t[ %.2f ]\t\t[ %.2f ]\t\t[ %.2f ]" % (jobq[-1], avg(jobq, 3), avg(jobq, 10)))
else: name = sys.argv[-1] config = False if len(sys.argv) > 1: if sys.argv[1] == "config": config = True if config: print("graph_title %s" % titles[name]['title']) print("graph_info Shows the %s" % titles[name]['title']) print("graph_category littlefield") print("graph_vlabel %s" % titles[name]['unit']) if "scale" in titles[name]: print("graph_scale no") if config: print("%s.label %s" % (name, titles[name]['title'])) print("%s-3.label %s (3 day average)" % (name, titles[name]['title'])) print("%s-10.label %s (10 day average)" % (name, titles[name]['title'])) else: littlefield = Littlefield(os.getenv("LITTLEFIELD_USER"), os.getenv("LITTLEFIELD_PW")) data = littlefield.get_data(name) key = "average" print("%s.value %s" % (name, data[key][-1])) print("%s-3.value %s" % (name, avg(data[key], 3))) print("%s-10.value %s" % (name, avg(data[key], 10))) except: raven.captureException()