def run(args): """Process 'show' command. Args: args: Argparse arguments Returns: None """ # Show help if no arguments provided if args.qualifier is None: general.cli_help() # Process 'show api' command if args.qualifier == 'api': api(args) elif args.qualifier == 'poller': poller(args) elif args.qualifier == 'hostnames': _hostnames() elif args.qualifier == 'configuration': _configuration() # Show help if there are no matches general.cli_help()
def poller(args): """Process 'show poller' commands. Args: args: Argparse arguments Returns: None """ if args.subqualifier == 'logs': # Process logs config = configuration.Config() filename = config.log_file() tail = input_output.File(filename) tail.tail() # Done sys.exit(0) elif args.subqualifier == 'status': # Create agent objects agent_poller = Agent(POLLER_EXECUTABLE) # Get agent status daemon_poller = AgentDaemon(agent_poller) daemon_poller.status() # Done sys.exit(0) # Show help if there are no matches general.cli_help()
def run(args): """Process 'test' command. Args: parser: Argparse parser args: Argparse arguments Returns: None """ # Process the config snmp_config = CONFIG_SNMP config = CONFIG # Show help if no arguments provided if args.qualifier is None: general.cli_help() # Test a single host if bool(args.hostname) is True: hostname = args.hostname test_hostname(hostname, snmp_config) sys.exit(0) # Test all hosts elif bool(args.all) is True: hosts = config.hostnames() if isinstance(hosts, list) is True: if len(hosts) > 0: for host in hosts: test_hostname(host, snmp_config) sys.exit(0) else: # No hosts found log_message = 'No hosts found in configuration' log.log2see(1038, log_message) else: # No hosts found log_message = 'No hosts found in configuration' log.log2see(1039, log_message) # Show help if there are no matches general.cli_help()
def run(args): """Process 'start' command. Args: args: Argparse arguments Returns: None """ # Show help if no arguments provided if args.qualifier is None: general.cli_help() # Process 'show api' command if args.qualifier == 'api': api() elif args.qualifier == 'poller': poller() # Show help if there are no matches general.cli_help()
def api(args): """Process 'show api' commands. Args: args: Argparse arguments Returns: None """ if args.subqualifier == 'logs': # Process logs config = configuration.Config() filename = config.web_log_file() tail = input_output.File(filename) tail.tail() # Done sys.exit(0) elif args.subqualifier == 'status': # Create agent objects agent_gunicorn = Agent(API_GUNICORN_AGENT) agent_api = AgentAPI(API_EXECUTABLE, API_GUNICORN_AGENT) # Get agent status daemon_gunicorn = AgentDaemon(agent_gunicorn) daemon_gunicorn.status() daemon_api = AgentDaemon(agent_api) daemon_api.status() # Done sys.exit(0) # Show help if there are no matches general.cli_help()