def init_HTTP(self): if self.HTTPheaders == {}: GenericServer.init_HTTP(self) # special Opsview treatment, transmit username and passwort for XML requests # http://docs.opsview.org/doku.php?id=opsview3.4:api # this is only necessary when accessing the API and expecting a XML answer self.HTTPheaders["xml"] = { "Content-Type": "text/xml", "X-Username": self.get_username(), "X-Password": self.get_password(), } # get cookie to access Opsview web interface to access Opsviews Nagios part if len(self.Cookie) == 0: # put all necessary data into url string logindata = urllib.urlencode( { "login_username": self.get_username(), "login_password": self.get_password(), "back": "", "app": "", "login": "******", } ) # the following is necessary for Opsview servers # get cookie from login page via url retrieving as with other urls try: # login and get cookie urlcontent = self.urlopener.open(self.monitor_url + "/login", logindata) urlcontent.close() except: self.Error(sys.exc_info())
def init_HTTP(self): if self.HTTPheaders == {}: GenericServer.init_HTTP(self) # get cookie to access Opsview web interface to access Opsviews Nagios part if len(self.Cookie) == 0: if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Fetching Login token") # put all necessary data into url string logindata = urllib.urlencode({"username":self.get_username(),\ "password":self.get_password(),}) # the following is necessary for Opsview servers # get cookie from login page via url retrieving as with other urls try: # login and get cookie urlcontent = self.urlopener.open(self.monitor_url + "/rest/login", logindata) resp = literal_eval(urlcontent.read().decode("utf8", errors="ignore")) if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Login Token: " + resp.get('token') ) self.HTTPheaders["raw"] = {"Accept":"application/json","Content-Type":"application/json", "X-Opsview-Username":self.get_username(), "X-Opsview-Token":resp.get('token')} urlcontent.close() except: self.Error(sys.exc_info())
def init_HTTP(self): if self.HTTPheaders == {}: GenericServer.init_HTTP(self) # special Opsview treatment, transmit username and passwort for XML requests # http://docs.opsview.org/doku.php?id=opsview3.4:api # this is only necessary when accessing the API and expecting a XML answer self.HTTPheaders["xml"] = { "Content-Type": "text/xml", "X-Username": self.get_username(), "X-Password": self.get_password() } # get cookie to access Opsview web interface to access Opsviews Nagios part if len(self.Cookie) == 0: # put all necessary data into url string logindata = urllib.urlencode({"login_username":self.get_username(),\ "login_password":self.get_password(),\ "back":"",\ "app": "",\ "login":"******"}) # the following is necessary for Opsview servers # get cookie from login page via url retrieving as with other urls try: # login and get cookie urlcontent = self.urlopener.open(self.nagios_url + "/login", logindata) urlcontent.close() except: self.Error(sys.exc_info())
def init_HTTP(self): """ partly not constantly working Basic Authorization requires extra Autorization headers, different between various server types """ GenericServer.init_HTTP(self) #if self.HTTPheaders == {}: # for giveback in ["raw", "obj"]: # self.HTTPheaders[giveback] = {"Authorization": "Basic " + base64.b64encode(self.get_username() + ":" + self.get_password())} # only if cookies are needed if self.CookieAuth: # get cookie to access Check_MK web interface if len(self.Cookie) < 2: # put all necessary data into url string logindata = urllib.urlencode({"login":self.get_username(),\ "password":self.get_password(),\ "submit":"Login"}) # get cookie from login page via url retrieving as with other urls try: # login and get cookie # empty referer seems to be ignored so add it manually urlcontent = self.urlopener.open( self.monitor_cgi_url + "/login.cgi?", logindata + "&referer=") urlcontent.close() except: self.Error(sys.exc_info())
def init_HTTP(self): # add default auth for monitor.old GenericServer.init_HTTP(self) # self.Cookie is a CookieJar which is a list of cookies - if 0 then emtpy if len(self.Cookie) == 0: try: # Ninja Settings self.commit_url = self.nagios_url + '/index.php/command/commit' self.login_url = self.nagios_url + '/index.php/default/do_login' self.time_url = self.nagios_url + '/index.php/extinfo/show_process_info' # get a Ninja cookie via own method self.urlopener.open( self.login_url, urllib.urlencode({ 'username': self.get_username(), 'password': self.get_password() })) if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Cookie:" + str(self.Cookie)) except: self.Error(sys.exc_info())
def init_HTTP(self): """ partly not constantly working Basic Authorization requires extra Autorization headers, different between various server types """ GenericServer.init_HTTP(self) #if self.HTTPheaders == {}: # for giveback in ["raw", "obj"]: # self.HTTPheaders[giveback] = {"Authorization": "Basic " + base64.b64encode(self.get_username() + ":" + self.get_password())} # only if cookies are needed if self.CookieAuth: # get cookie to access Check_MK web interface if len(self.Cookie) < 2: # put all necessary data into url string logindata = urllib.urlencode({"login":self.get_username(),\ "password":self.get_password(),\ "submit":"Login"}) # get cookie from login page via url retrieving as with other urls try: # login and get cookie # empty referer seems to be ignored so add it manually urlcontent = self.urlopener.open(self.monitor_cgi_url + "/login.cgi?", logindata + "&referer=") urlcontent.close() except: self.Error(sys.exc_info())
def init_HTTP(self): """ initialize HTTP connection """ if self.HTTPheaders == {}: GenericServer.init_HTTP(self) # Centreon xml giveback method just should exist self.HTTPheaders["xml"] = {}
def init_HTTP(self): """ initialize HTTP connection """ if self.HTTPheaders == {}: GenericServer.init_HTTP(self) # Centreon xml giveback method just should exist self.HTTPheaders["xml"] = {}
def init_HTTP(self): """ Icinga 1.11 needs extra Referer header for actions """ GenericServer.init_HTTP(self) if not "Referer" in self.HTTPheaders: # to execute actions since Icinga 1.11 a Referer Header is necessary for giveback in ["raw", "obj"]: self.HTTPheaders[giveback]["Referer"] = self.monitor_cgi_url + "/cmd.cgi"
def init_HTTP(self): """ Icinga 1.11 needs extra Referer header for actions """ GenericServer.init_HTTP(self) if not "Referer" in self.HTTPheaders: # to execute actions since Icinga 1.11 a Referer Header is necessary for giveback in ["raw", "obj"]: self.HTTPheaders[giveback][ "Referer"] = self.monitor_cgi_url + "/cmd.cgi"
def init_HTTP(self): self.statemap = { 'UNREACH': 'UNREACHABLE', 'CRIT': 'CRITICAL', 'WARN': 'WARNING', 'UNKN': 'UNKNOWN', 'PEND': 'PENDING', '0': 'OK', '1': 'UNKNOWN', '2': 'WARNING', '5': 'CRITICAL', '3': 'WARNING', '4': 'CRITICAL'} GenericServer.init_HTTP(self)
def init_HTTP(self): # Fix eventually missing tailing "/" in url self.statemap = { "UNREACH": "UNREACHABLE", "CRIT": "CRITICAL", "WARN": "WARNING", "UNKN": "UNKNOWN", "PEND": "PENDING", "0": "OK", "1": "UNKNOWN", "2": "WARNING", "5": "CRITICAL", "3": "WARNING", "4": "CRITICAL", } GenericServer.init_HTTP(self)
def init_HTTP(self): self.statemap = { 'UNREACH': 'UNREACHABLE', 'CRIT': 'CRITICAL', 'WARN': 'WARNING', 'UNKN': 'UNKNOWN', 'PEND': 'PENDING', '0': 'OK', '1': 'UNKNOWN', '2': 'WARNING', '5': 'CRITICAL', '3': 'WARNING', '4': 'CRITICAL' } GenericServer.init_HTTP(self)
def init_HTTP(self): # add default auth for monitor.old GenericServer.init_HTTP(self) # self.Cookie is a CookieJar which is a list of cookies - if 0 then emtpy if len(self.Cookie) == 0: try: # Ninja Settings # get a Ninja cookie via own method self.urlopener.add_handler(urllib2.HTTPDefaultErrorHandler()) self.urlopener.open(self.login_url, urllib.urlencode({'username': self.get_username(), 'password': self.get_password(), 'csrf_token': self.csrf()})) if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Cookie:" + str(self.Cookie)) except: self.Error(sys.exc_info())
def init_HTTP(self): # add default auth for monitor.old GenericServer.init_HTTP(self) # self.Cookie is a CookieJar which is a list of cookies - if 0 then emtpy if len(self.Cookie) == 0: try: # Ninja Settings self.commit_url = self.nagios_url + '/index.php/command/commit' self.login_url = self.nagios_url + '/index.php/default/do_login' self.time_url = self.nagios_url + '/index.php/extinfo/show_process_info' # get a Ninja cookie via own method self.urlopener.open(self.login_url, urllib.urlencode({'username': self.get_username(), 'password': self.get_password()})) if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Cookie:" + str(self.Cookie)) except: self.Error(sys.exc_info())
def init_HTTP(self): if self.HTTPheaders == {}: GenericServer.init_HTTP(self) # get cookie to access Opsview web interface to access Opsviews Nagios part if len(self.Cookie) == 0: if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Fetching Login token") # put all necessary data into url string logindata = urllib.urlencode({"username":self.get_username(),\ "password":self.get_password(),}) # the following is necessary for Opsview servers # get cookie from login page via url retrieving as with other urls try: # login and get cookie urlcontent = self.urlopener.open( self.monitor_url + "/rest/login", logindata) resp = literal_eval(urlcontent.read().decode("utf8", errors="ignore")) if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Login Token: " + resp.get('token')) self.HTTPheaders["raw"] = { "Accept": "application/json", "Content-Type": "application/json", "X-Opsview-Username": self.get_username(), "X-Opsview-Token": resp.get('token') } urlcontent.close() except: self.Error(sys.exc_info())
def init_HTTP(self): # add default auth for monitor.old GenericServer.init_HTTP(self) # self.Cookie is a CookieJar which is a list of cookies - if 0 then emtpy if len(self.Cookie) == 0: try: # Ninja Settings # get a Ninja cookie via own method self.urlopener.add_handler(urllib2.HTTPDefaultErrorHandler()) self.urlopener.open( self.login_url, urllib.urlencode({ 'username': self.get_username(), 'password': self.get_password(), 'csrf_token': self.csrf() })) if str(self.conf.debug_mode) == "True": self.Debug(server=self.get_name(), debug="Cookie:" + str(self.Cookie)) except: self.Error(sys.exc_info())