Example #1
0
    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())
Example #2
0
    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())
Example #3
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Monitor", "Recheck", "Acknowledge", "Downtime"]
        self.STATUS_SVC_MAPPING = {"0": "OK", "1": "WARNING", "2": "CRITICAL", "3": "UNKNOWN"}
        self.STATUS_HOST_MAPPING = {"0": "UP", "1": "DOWN", "2": "UNREACHABLE"}
Example #4
0
    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())
Example #5
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Monitor", "Recheck", "Acknowledge", "Downtime"]
        self.STATUS_SVC_MAPPING = {'0':'OK', '1':'WARNING', '2':'CRITICAL', '3':'UNKNOWN'}
        self.STATUS_HOST_MAPPING = {'0':'UP', '1':'DOWN', '2':'UNREACHABLE'}
Example #6
0
    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())
Example #7
0
    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())
Example #8
0
    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())
Example #9
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # dictionary to translate status bitmaps on webinterface into status flags
        # this are defaults from Nagios

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Monitor", "Recheck", "Acknowledge", "Downtime"]
Example #10
0
    def __init__(self, **kwds):
        # add all keywords to object, every mode searchs inside for its favorite arguments/keywords
        for k in kwds: self.__dict__[k] = kwds[k]

        GenericServer.__init__(self, **kwds)

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Monitor", "Recheck", "Acknowledge", "Downtime"]
Example #11
0
 def init_HTTP(self):
     """
     initialize HTTP connection
     """
     if self.HTTPheaders == {}:
         GenericServer.init_HTTP(self)
         # Centreon xml giveback method just should exist
         self.HTTPheaders["xml"] = {}
Example #12
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # dictionary to translate status bitmaps on webinterface into status flags
        # this are defaults from Nagios

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Monitor", "Recheck", "Acknowledge", "Downtime"]
Example #13
0
 def init_HTTP(self):
     """
     initialize HTTP connection
     """
     if self.HTTPheaders == {}:
         GenericServer.init_HTTP(self)
         # Centreon xml giveback method just should exist
         self.HTTPheaders["xml"] = {}
Example #14
0
    def __init__(self, **kwds):
        # add all keywords to object, every mode searchs inside for its favorite arguments/keywords
        for k in kwds: self.__dict__[k] = kwds[k]

        GenericServer.__init__(self, **kwds)

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Monitor", "Recheck", "Acknowledge", "Downtime"]
Example #15
0
    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"
Example #16
0
    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"
Example #17
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Prepare all urls needed by nagstamon -
        self.urls = {}
        self.statemap = {}

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]
        self.username = self.conf.servers[self.get_name()].username
        self.password = self.conf.servers[self.get_name()].password
Example #18
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Prepare all urls needed by nagstamon - 
        self.urls = {}
        self.statemap = {}

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]
        self.username = self.conf.servers[self.get_name()].username
        self.password = self.conf.servers[self.get_name()].password
Example #19
0
    def __init__(self, **kwds):
        # add all keywords to object, every mode searchs inside for its favorite arguments/keywords
        for k in kwds: self.__dict__[k] = kwds[k]

        GenericServer.__init__(self, **kwds)
        
        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]        

        # cache MD5 username + password to reduce load
        self.MD5_username = Actions.MD5ify(self.conf.servers[self.get_name()].username)   
        self.MD5_password = Actions.MD5ify(self.conf.servers[self.get_name()].password)
Example #20
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # dictionary to translate status bitmaps on webinterface into status flags
        # this are defaults from Nagios
        self.STATUS_MAPPING = { "acknowledged.png" : "acknowledged",\
                                "active-checks-disabled.png" : "passiveonly",\
                                "notify-disabled.png" : "notifications_disabled",\
                                "scheduled_downtime.png" : "scheduled_downtime",\
                                "flapping.gif" : "flapping" }

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]
Example #21
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)
        
        # dictionary to translate status bitmaps on webinterface into status flags
        # this are defaults from Nagios
        self.STATUS_MAPPING = { "acknowledged.png" : "acknowledged",\
                                "active-checks-disabled.png" : "passiveonly",\
                                "notify-disabled.png" : "notifications_disabled",\
                                "scheduled_downtime.png" : "scheduled_downtime",\
                                "flapping.gif" : "flapping" }   

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]      
Example #22
0
    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)
Example #23
0
    def __init__(self, **kwds):
        # add all keywords to object, every mode searchs inside for its favorite arguments/keywords
        for k in kwds:
            self.__dict__[k] = kwds[k]

        GenericServer.__init__(self, **kwds)

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]

        # cache MD5 username + password to reduce load
        self.MD5_username = Actions.MD5ify(
            self.conf.servers[self.get_name()].username)
        self.MD5_password = Actions.MD5ify(
            self.conf.servers[self.get_name()].password)
Example #24
0
 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)
Example #25
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)
        self.States = ["UP", "UNKNOWN", "WARNING", "CRITICAL", "UNREACHABLE", "DOWN", "CRITICAL", "HIGH", "AVERAGE"]
        self.nagitems_filtered = {
            "services": {"CRITICAL": [], "HIGH": [], "AVERAGE": [], "WARNING": [], "INFORMATION": [], "UNKNOWN": []},
            "hosts": {"DOWN": [], "UNREACHABLE": []},
        }
        # Prepare all urls needed by nagstamon -
        self.urls = {}
        self.statemap = {}

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]
        self.username = self.conf.servers[self.get_name()].username
        self.password = self.conf.servers[self.get_name()].password
        self.min_severity = self.conf.servers[self.get_name()].min_severity
Example #26
0
    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)
Example #27
0
    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())
Example #28
0
    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())
Example #29
0
    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())
Example #30
0
    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())
Example #31
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)
	self.MENU_ACTIONS = []
Example #32
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # flag for newer cookie authentication
        self.CookieAuth = False
Example #33
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        self.ws = None
Example #34
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # flag for newer cookie authentication
        self.CookieAuth = False