def collect(self, config): ds0 = config.datasources[0] hostname = ds0.params['hostname'] timeout = int(ds0.params['timeout']) port = int(ds0.params['port']) useSsl = ast.literal_eval(ds0.params['useSsl']) url = ds0.params['url'] ipaddress = ds0.params['ipAddress'] regex = ds0.params['regex'] caseSensitive = ds0.params['caseSensitive'] invert = ds0.params['invert'] onRedirect = ds0.params['onRedirect'] onRedirect = str(onRedirect) if onRedirect in ('False', ''): onRedirect = "fail" elif onRedirect == "True": onRedirect = "follow" basicAuthUser = ds0.params['basicAuthUser'] basicAuthPass = ds0.params['basicAuthPass'] proxyAuthUser = ds0.params['proxyAuthUser'] proxyAuthPassword = ds0.params['proxyAuthPassword'] log.info("HTTPMonitor collecting started for: {}".format(hostname or ipaddress or url)) chttp = HTTPMonitor(ipAddr=ipaddress, hostname=hostname, url=url, port=port, timeout=timeout, ssl=useSsl, follow=onRedirect) if proxyAuthUser: chttp.useProxy(proxyAuthUser, proxyAuthPassword) if basicAuthUser: chttp.useAuth(basicAuthUser, basicAuthPass) if regex: chttp.regex(regex, ast.literal_eval(caseSensitive), ast.literal_eval(invert)) return chttp.connect()
def collect(self, config): ds0 = config.datasources[0] hostname = ds0.params['hostname'] timeout = int(ds0.params['timeout']) port = int(ds0.params['port']) useSsl = ast.literal_eval(ds0.params['useSsl']) url = ds0.params['url'] ipaddress = ds0.params['ipAddress'] onRedirect = ast.literal_eval(ds0.params['onRedirect']) basicAuthUser = ds0.params['basicAuthUser'] basicAuthPass = ds0.params['basicAuthPass'] proxyAuthUser = ds0.params['proxyAuthUser'] proxyAuthPassword = ds0.params['proxyAuthPassword'] log.info("HTTPMonitor collecting started for a host: {}".format(hostname)) chttp = HTTPMonitor(ipAddr=ipaddress, hostname=hostname, url=url, port=port, timeout=timeout, ssl=useSsl, follow=onRedirect) if proxyAuthUser: chttp.useProxy(proxyAuthUser, proxyAuthPassword) if basicAuthUser: chttp.useAuth(basicAuthUser, basicAuthPass) return chttp.connect()