def run(self, service=None): ''' Switch to service object. Usage: service Show available services in current host object. Usage: service <name> Switch to service object. ''' host = self.cli.context.get() if not service: # Fancy formatter fancy = Fancy(self.cli.ui) self.cli.sendline('%s services for this host' % (len(host.services), )) self.cli.sendline('') for service in sorted(host.services): name = host.services[service].service_description self.cli.sendline( '%s: %s, %s' % (str(name).ljust(20, ' '), fancy.state(str(host.services[service].current_state)), str(host.services[service].plugin_output)[:48])) elif service in host.services: self.cli.context.add(host.services[service]) self.cli.setup_prompt() else: self.cli.error('Service "%s" not found' % (service, ))
def run(self, service=None): ''' Switch to service object. Usage: service Show available services in current host object. Usage: service <name> Switch to service object. ''' host = self.cli.context.get() if not service: # Fancy formatter fancy = Fancy(self.cli.ui) self.cli.sendline('%s services for this host' % (len(host.services),)) self.cli.sendline('') for service in sorted(host.services): name = host.services[service].service_description self.cli.sendline('%s: %s, %s' % (str(name).ljust(20, ' '), fancy.state(str(host.services[service].current_state)), str(host.services[service].plugin_output)[:48])) elif service in host.services: self.cli.context.add(host.services[service]) self.cli.setup_prompt() else: self.cli.error('Service "%s" not found' % (service,))
def run_host(self, instance): # Fancy formatter fancy = Fancy(self.cli.ui) # Show info about host fields = filter(None, self.cli.config.get('object.host.status').splitlines()) for field in fields: value = str(instance.get(field)) if field == 'current_state': value = fancy.state(value) self.cli.sendline('%s: %s' % (field.ljust(20, ' ').replace('_', ' '), self.cli.ui.color('.'.join(['host', field]), value))) # Show associated services and their status (in short version) for service in sorted(instance['services'].keys()): svc = instance['services'][service] self.cli.sendline('%s: %-20s %s' % ('service'.ljust(20, ' '), str(svc.service_description)[:20], fancy.state(str(svc.current_state))))
def run_service(self, instance): # Fancy formatter fancy = Fancy(self.cli.ui) # Show info about service fields = filter(None, self.cli.config.get('object.service.status').splitlines()) for field in fields: value = str(instance.get(field)) if field == 'current_state': value = fancy.state(value) self.cli.sendline('%s: %s' % (field.ljust(20, ' ').replace('_', ' '), self.cli.ui.color('.'.join(['service', field]), value)))
def run_host(self, instance): # Fancy formatter fancy = Fancy(self.cli.ui) # Show info about host fields = filter(None, self.cli.config.get('object.host.status').splitlines()) for field in fields: value = str(instance.get(field)) if field == 'current_state': value = fancy.state(value) self.cli.sendline( '%s: %s' % (field.ljust(20, ' ').replace('_', ' '), self.cli.ui.color('.'.join(['host', field]), value))) # Show associated services and their status (in short version) for service in sorted(instance['services'].keys()): svc = instance['services'][service] self.cli.sendline( '%s: %-20s %s' % ('service'.ljust(20, ' '), str(svc.service_description)[:20], fancy.state(str(svc.current_state))))
def show_host(self, host): date, clock = host.last_check.split(' ') if date != self.today: self.show_date(date) # Fancy formatter fancy = Fancy(self.cli.ui) output = ' '.join(host.plugin_output.splitlines()).strip() self.cli.sendline('%s %s:' % ( clock, host.host_name)) self.cli.sendline(' %s, %s' % ( fancy.state(host.current_state), output))
def run_service(self, instance): # Fancy formatter fancy = Fancy(self.cli.ui) # Show info about service fields = filter( None, self.cli.config.get('object.service.status').splitlines()) for field in fields: value = str(instance.get(field)) if field == 'current_state': value = fancy.state(value) self.cli.sendline( '%s: %s' % (field.ljust(20, ' ').replace('_', ' '), self.cli.ui.color('.'.join(['service', field]), value)))
def show_service(self, service): date, clock = service.last_check.split(' ') if date != self.today: self.show_date(date) # Fancy formatter fancy = Fancy(self.cli.ui) output = ' '.join(service.plugin_output.splitlines()).strip() self.cli.sendline('%s %s > %s:' % ( clock, service.host_name, service.service_description)) self.cli.sendline(' %s, %s' % ( fancy.state(service.current_state), output))