def add_node(logger, args): logger.debug("action: add_node") p = argparse.ArgumentParser(usage="%(prog)s add_node IP PLUGIN [-u USERNAME] [-p PASSWORD]") p.add_argument("ip") p.add_argument("plugin") p.add_argument("-u", "--username") p.add_argument("-p", "--password") o, a = p.parse_known_args(args) logger.debug("action opts: %s", o) logger.debug("action args: %s", a) if o.ip and o.plugin: try: load_plugin(o.plugin) except ImportError: logger.error("%s is not a valid plugin", o.plugin) sys_exit(1) node = Node(o.ip, o.plugin) try: session.add(node) node.username = o.username node.password = o.password session.commit() logger.info("Node added") except IntegrityError: logger.error("Node already exists") sys_exit(1)
import simplejson as json except ImportError: print("ERROR: Unable to find a usable json module, is simplejson installed?") sys.exit(1) #ARTEMIS Components from artemis_core import grabData, load_plugin #Load config module from artemis_config import config, session, Node, Probe # Setup base nodes from store base_nodes = [] for n in session.query(Node).all(): base_nodes.append(load_plugin(n.plugin)(n.ip, n.username, n.password)) # Setup sensors from store sensors = {} for p in session.query(Probe).all(): sensors[p.id] = [p.name, float(p.x), float(p.y), float(p.z), float(p.w), float(p.h), float(p.d)] #Configuration this_dir = os.path.dirname(os.path.realpath( __file__ )) + "/" rrd_dir = this_dir + config.get("rrd","dir") print("Starting run...") #Start collection g = grabData(base_nodes)