def collect(self, config): log.debug('Starting ISAM Device collect') ip_address = config.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", device.id) returnValue(None) log.debug('ds: {}'.format(config.datasources)) ds0 = config.datasources[0] basicAuth = base64.encodestring('{}:{}'.format(ds0.zISAMUsername, ds0.zISAMPassword)) authHeader = "Basic " + basicAuth.strip() headers = { "Accept": ["application/json"], "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) results = {} for datasource in config.datasources: timespan = max(120, 2 * datasource.cycletime) url = self.urls[datasource.datasource].format(ip_address, timespan) try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results[datasource.datasource] = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(datasource, e)) returnValue(results)
def collect(self, config): log.debug('Starting MemoryStatus collect') ip_address = config.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", device.id) returnValue(None) ds0 = config.datasources[0] url = "https://{}:{}/mgmt/status/default/MemoryStatus".format( ip_address, ds0.zDataPowerPort) log.debug('url: {}'.format(url)) basicAuth = base64.encodestring('{}:{}'.format(ds0.zDataPowerUsername, ds0.zDataPowerPassword)) authHeader = "Basic " + basicAuth.strip() headers = { "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results = json.loads(response_body) except: log.error('{}: {}'.format(device.id, e)) returnValue(results)
def collect(self, device, log): log.debug('{}: Modeling collect'.format(device.id)) username = getattr(device, 'zISAMUsername', None) password = getattr(device, 'zISAMPassword', None) ip_address = device.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", device.id) returnValue(None) basicAuth = base64.encodestring('{}:{}'.format(username, password)) authHeader = "Basic " + basicAuth.strip() headers = { "Accept": ["application/json"], "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) results = {} for component, url_pattern in self.components: url = url_pattern.format(ip_address) try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results[component] = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(device.id, e)) returnValue(results)
def collect(self, config): log.debug('Starting ISAMFileSystem collect') ds0 = config.datasources[0] cycletime = ds0.cycletime ip_address = config.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", config.id) returnValue(None) url = 'https://{}/statistics/systems/storage.json?timespan={}'.format( ip_address, 3 * cycletime) basicAuth = base64.encodestring('{}:{}'.format(ds0.zISAMUsername, ds0.zISAMPassword)) authHeader = "Basic " + basicAuth.strip() headers = { "Accept": ["application/json"], "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) results = {} try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(datasource, e)) returnValue(results)
def collect(self, config): log.debug('Starting ISAM Interface collect') ds0 = config.datasources[0] ip_address = config.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", device.id) returnValue(None) basicAuth = base64.encodestring('{}:{}'.format(ds0.zISAMUsername, ds0.zISAMPassword)) authHeader = "Basic " + basicAuth.strip() headers = { "Accept": ["application/json"], "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) results = {} for datasource in config.datasources: component = datasource.component cycletime = datasource.cycletime url = 'https://{}/analysis/interface_statistics.json?prefix={}×pan={}s'.format(ip_address, component, 3*cycletime ) try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results[datasource.component] = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(datasource, e)) returnValue(results)
def collect(self, config): log.debug('Starting ISAMJunctionServer collect') ds0 = config.datasources[0] url = self.ws_url_get(config) basicAuth = base64.encodestring('{}:{}'.format(ds0.zISAMUsername, ds0.zISAMPassword)) authHeader = "Basic " + basicAuth.strip() headers = { "Accept": ["application/json"], "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) results = {} try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(ds0, e)) returnValue(results)
def collect(self, device, log): log.debug('{}: Modeling collect'.format(device.id)) port = getattr(device, 'zDataPowerPort', None) username = getattr(device, 'zDataPowerUsername', None) if not username: log.error("%s: zDataPowerUsername is not defined", device.id) returnValue(None) password = getattr(device, 'zDataPowerPassword', None) if not password: log.error("%s: zDataPowerPassword is not defined", device.id) returnValue(None) ip_address = device.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", device.id) returnValue(None) url = "https://{}:{}/mgmt/status/default/NetworkInterfaceStatus".format( ip_address, port) log.debug('url: {}'.format(url)) basicAuth = base64.encodestring('{}:{}'.format(username, password)) authHeader = "Basic " + basicAuth.strip() headers = { "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results = json.loads(response_body) except: log.error('{}: {}'.format(device.id, e)) returnValue(results)
def collect(self, device, log): log.debug('{}: Modeling collect'.format(device.id)) port = getattr(device, 'zDataPowerPort', None) username = getattr(device, 'zDataPowerUsername', None) if not username: log.error("%s: zDataPowerUsername is not defined", device.id) returnValue(None) password = getattr(device, 'zDataPowerPassword', None) if not password: log.error("%s: zDataPowerPassword is not defined", device.id) returnValue(None) ip_address = device.manageIp if not ip_address: log.error("%s: IP Address cannot be empty", device.id) returnValue(None) url = "https://{}:{}/mgmt/status/default/DomainStatus".format( ip_address, port) log.debug('url: {}'.format(url)) basicAuth = base64.encodestring('{}:{}'.format(username, password)) authHeader = "Basic " + basicAuth.strip() headers = { "Authorization": [authHeader], "User-Agent": ["Mozilla/3.0Gold"], } agent = Agent(reactor, contextFactory=SkipCertifContextFactory()) results = {} try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results['domains'] = json.loads(response_body) except: log.error('{}: {}'.format(device.id, e)) domains = [d['Domain'] for d in results['domains']['DomainStatus']] log.debug('domains: {}'.format(domains)) results['gateways'] = {} for domain in domains: try: url = "https://{}:{}/mgmt/config/{}/APIConnectGatewayService".format( ip_address, port, domain) response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results['gateways'][domain] = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(device.id, e)) url = "https://{}:{}/mgmt/config/default/HostAlias".format( ip_address, port) try: response = yield agent.request('GET', url, Headers(headers)) response_body = yield readBody(response) results['hostalias'] = json.loads(response_body) except Exception as e: log.error('{}: {}'.format(device.id, e)) returnValue(results)