コード例 #1
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        self.statemap = {
            '0': 'OK',
            '1': 'INFORMATION',
            '2': 'WARNING',
            '3': 'AVERAGE',
            '4': 'HIGH',
            '5': 'DISASTER'
        }

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = []
        # URLs for browser shortlinks/buttons on popup window
        self.BROWSER_URLS = {
            'monitor':
            '$MONITOR$',
            'hosts':
            '$MONITOR-CGI$/hosts.php?ddreset=1',
            'services':
            '$MONITOR-CGI$/zabbix.php?action=problem.view&fullscreen=0&page=1&filter_show=3&filter_set=1',
            'history':
            '$MONITOR-CGI$/zabbix.php?action=problem.view&fullscreen=0&page=1&filter_show=2&filter_set=1'
        }

        self.username = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password
        self.validate_certs = not conf.servers[self.get_name()].ignore_cert
コード例 #2
0
ファイル: IcingaWeb2.py プロジェクト: BenoitPoulet/Nagstamon
    def init_HTTP(self):
        """
            initializing of session object
        """
        GenericServer.init_HTTP(self)

        if not 'Referer' in self.session.headers:
            self.session.headers['Referer'] = self.monitor_cgi_url + '/icingaweb2/monitoring'

        # normally cookie out will be used
        if not self.no_cookie_auth:
            if len(self.session.cookies) == 0:
                # get login page, thus automatically a cookie
                login = self.FetchURL('{0}/authentication/login'.format(self.monitor_url))
                if login.error == '' and login.status_code == 200:
                    form = login.result.find('form')
                    form_inputs = {}
                    for form_input in ('redirect', 'formUID', 'CSRFToken', 'btn_submit'):
                        if not form.find('input', {'name': form_input}) is None:
                            form_inputs[form_input] = form.find('input', {'name': form_input})['value']
                        else:
                            form_inputs[form_input] = ''
                    form_inputs['username'] = self.username
                    form_inputs['password'] = self.password
    
                    # fire up login button with all needed data
                    self.FetchURL('{0}/authentication/login'.format(self.monitor_url), cgi_data=form_inputs)
コード例 #3
0
ファイル: SnagView3.py プロジェクト: HenriWahl/Nagstamon
    def init_HTTP(self):
        """
            Initializing of session object
        """
        GenericServer.init_HTTP(self)

        self.session.auth = NoAuth()

        if len(self.session.cookies) == 0:
            form_inputs = dict()
            if self.username.startswith('ldap:'):
                form_inputs['module'] = 'ldap'
                form_inputs['_username'] = self.username[5:]
            else:
                form_inputs['module'] = 'sv'
                form_inputs['_username'] = self.username

            form_inputs['urm:login:client'] = ''
            form_inputs['_password'] = self.password

            # call login page to get temporary cookie
            self.FetchURL('{0}/security/login'.format(self.monitor_url))
            # submit login form to retrieve authentication cookie
            self.FetchURL(
                '{0}/security/login_check'.format(self.monitor_url),
                cgi_data=form_inputs,
                multipart=True
            )
コード例 #4
0
ファイル: IcingaWeb2.py プロジェクト: BenoitPoulet/Nagstamon
    def init_HTTP(self):
        """
            initializing of session object
        """
        GenericServer.init_HTTP(self)

        if self.session and not 'Referer' in self.session.headers:
            self.session.headers[
                'Referer'] = self.monitor_cgi_url + '/icingaweb2/monitoring'

        # normally cookie auth will be used
        if not self.no_cookie_auth:
            if 'cookies' not in dir(self.session) or len(
                    self.session.cookies) == 0:
                # get login page, thus automatically a cookie
                login = self.FetchURL('{0}/authentication/login'.format(
                    self.monitor_url))
                if login.error == '' and login.status_code == 200:
                    form = login.result.find('form')
                    form_inputs = {}
                    for form_input in ('redirect', 'formUID', 'CSRFToken',
                                       'btn_submit'):
                        if not form.find('input',
                                         {'name': form_input}) is None:
                            form_inputs[form_input] = form.find(
                                'input', {'name': form_input})['value']
                        else:
                            form_inputs[form_input] = ''
                    form_inputs['username'] = self.username
                    form_inputs['password'] = self.password

                    # fire up login button with all needed data
                    self.FetchURL('{0}/authentication/login'.format(
                        self.monitor_url),
                                  cgi_data=form_inputs)
コード例 #5
0
    def login(self):
        """
            use pure session instead of FetchURL to get Thruk session
        """
        if self.session is None:
            self.refresh_authentication = False
            GenericServer.init_HTTP(self)

        if self.use_autologin is True:
            req = self.session.post(self.monitor_cgi_url + '/user.cgi?', data={}, headers={'X-Thruk-Auth-Key':self.autologin_key.strip()})
            if conf.debug_mode == True:
                self.Debug(server=self.get_name(), debug='Auto Login status: ' + req.url + ' http code : ' + str(req.status_code))
            if req.status_code != 200:
                self.refresh_authentication = True
                return Result(result=None, error="Login failed")
        else:
            # set thruk test cookie to in order to directly login
            self.session.cookies.set('thruk_test', '***')
            req = self.session.post(self.monitor_cgi_url + '/login.cgi?',
                            data={'login': self.get_username(),
                                    'password': self.get_password(),
                                    'submit': 'Login'})
            if conf.debug_mode == True:
                self.Debug(server=self.get_name(), debug='Login status: ' + req.url + ' http code : ' + str(req.status_code))
            if req.status_code != 200:
                self.refresh_authentication = True
                return Result(result=None, error="Login failed")
コード例 #6
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Prepare all urls needed by nagstamon -
        self.urls = {}
        # self.statemap = {}
        self.statemap = {
            'UNREACH': 'UNREACHABLE',
            'CRIT': 'CRITICAL',
            'WARN': 'WARNING',
            'UNKN': 'UNKNOWN',
            'PEND': 'PENDING',
            '0': 'OK',
            '1': 'INFORMATION',
            '2': 'WARNING',
            '3': 'AVERAGE',
            '4': 'HIGH',
            '5': 'DISASTER'
        }

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]
        self.username = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password
        self.ignore_cert = conf.servers[self.get_name()].ignore_cert
        self.use_description_name_service = conf.servers[
            self.get_name()].use_description_name_service
        if self.ignore_cert is True:
            self.validate_certs = False
        else:
            self.validate_certs = True
コード例 #7
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Prepare all urls needed by nagstamon -
        self.urls = {}
        # self.statemap = {}
        self.statemap = {
            'UNREACH': 'UNREACHABLE',
            'CRIT': 'CRITICAL',
            'WARN': 'WARNING',
            'UNKN': 'UNKNOWN',
            'PEND': 'PENDING',
            '0': 'OK',
            '1': 'INFORMATION',
            '2': 'WARNING',
            '3': 'AVERAGE',
            '4': 'HIGH',
            '5': 'DISASTER'}

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Acknowledge", "Downtime"]
        # URLs for browser shortlinks/buttons on popup window
        self.BROWSER_URLS = {'monitor': '$MONITOR$',
                             'hosts': '$MONITOR-CGI$/hosts.php?ddreset=1',
                             'services': '$MONITOR-CGI$/zabbix.php?action=problem.view&fullscreen=0&page=1&filter_show=3&filter_set=1',
                             'history':  '$MONITOR-CGI$/zabbix.php?action=problem.view&fullscreen=0&page=1&filter_show=2&filter_set=1'}

        self.username = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password
        self.ignore_cert = conf.servers[self.get_name()].ignore_cert
        self.use_description_name_service = conf.servers[self.get_name()].use_description_name_service
        if self.ignore_cert is True:
            self.validate_certs = False
        else:
            self.validate_certs = True
コード例 #8
0
ファイル: Opsview.py プロジェクト: BenoitPoulet/Nagstamon
    def init_HTTP(self):
        """
            things to do if HTTP is not initialized
        """
        GenericServer.init_HTTP(self)

        # prepare for JSON
        self.session.headers.update({'Accept': 'application/json',
                                     'Content-Type': 'application/json'})

        # get cookie to access Opsview web interface to access Opsviews Nagios part
        if len(self.session.cookies) == 0:

            if conf.debug_mode:
                self.Debug(server=self.get_name(), debug="Fetching Login token")

            logindata = json.dumps({'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
                resp = literal_eval(self.FetchURL(self.monitor_url + "/rest/login",
                                    giveback='raw',
                                    cgi_data=logindata).result)

                if conf.debug_mode:
                    self.Debug(server=self.get_name(), debug="Login Token: " + resp.get('token') )

                self.session.headers.update({'X-Opsview-Username': self.get_username(),
                                             'X-Opsview-Token':resp.get('token')})
            except:
                self.Error(sys.exc_info())
コード例 #9
0
ファイル: Opsview.py プロジェクト: xmarot/Nagstamon
    def init_HTTP(self):
        """
            things to do if HTTP is not initialized
        """
        GenericServer.init_HTTP(self)

        # prepare for JSON
        self.session.headers.update({'Accept': 'application/json',
                                     'Content-Type': 'application/json'})

        # get cookie to access Opsview web interface to access Opsviews Nagios part
        if len(self.session.cookies) == 0:

            if conf.debug_mode:
                self.Debug(server=self.get_name(), debug="Fetching Login token")

            logindata = json.dumps({'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
                resp = literal_eval(self.FetchURL(self.monitor_url + "/rest/login",
                                    giveback='raw',
                                    cgi_data=logindata).result)

                if conf.debug_mode:
                    self.Debug(server=self.get_name(), debug="Login Token: " + resp.get('token') )

                self.session.headers.update({'X-Opsview-Username': self.get_username(),
                                             'X-Opsview-Token':resp.get('token')})
            except:
                self.Error(sys.exc_info())
コード例 #10
0
    def init_HTTP(self):
        # general initialization
        if not self.session:
            GenericServer.init_HTTP(self)

        # Fix eventually missing tailing '/' in url
        if self.monitor_url.endswith('/'):
            self.monitor_url.rstrip('/')

        # Prepare all urls needed by nagstamon if not yet done
        if len(self.urls) == len(self.statemap):
            self.urls = {
              'api_services':    self.monitor_url + '/view.py?view_name={0}&output_format=python&lang=&limit=hard'.\
                                                                          format(self.checkmk_view_services),
              'human_services':  self.monitor_url + '/index.py?%s' % \
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name={0}'.\
                                                                          format(self.checkmk_view_services)}),
              'human_service':   self.monitor_url + '/index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name=service'}),

              'api_hosts':       self.monitor_url + '/view.py?view_name={0}&output_format=python&lang=&limit=hard'.\
                                                                          format(self.checkmk_view_hosts),
              'human_hosts':     self.monitor_url + '/index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name={0}'.\
                                                                           format(self.checkmk_view_services)}),
              'human_host':      self.monitor_url + '/index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name=hoststatus'}),
              # URLs do not need pythonic output because since werk #0766 API does not work with transid=-1 anymore
              # thus access to normal webinterface is used
              'api_host_act':    self.monitor_url + '/view.py?_transid=-1&_do_actions=yes&_do_confirm=Yes!&view_name=hoststatus&filled_in=actions&lang=',
              'api_service_act': self.monitor_url + '/view.py?_transid=-1&_do_actions=yes&_do_confirm=Yes!&view_name=service&filled_in=actions&lang=',
              'api_svcprob_act': self.monitor_url + '/view.py?_transid=-1&_do_actions=yes&_do_confirm=Yes!&view_name=svcproblems&filled_in=actions&lang=',
              'human_events':    self.monitor_url + '/index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name=events'}),
              'transid':         self.monitor_url + '/view.py?actions=yes&filled_in=actions&host=$HOST$&service=$SERVICE$&view_name=service'
            }

            self.statemap = {
                'UNREACH': 'UNREACHABLE',
                'CRIT':    'CRITICAL',
                'WARN':    'WARNING',
                'UNKN':    'UNKNOWN',
                'PEND':    'PENDING',
            }

        if self.CookieAuth and not self.refresh_authentication:
            # get cookie to access Checkmk web interface
            if 'cookies' in dir(self.session):
                if len(self.session.cookies) == 0:
                    # if no cookie yet login
                    self._get_cookie_login()
            elif self.session == None:
                # if no cookie yet login
                self._get_cookie_login()
        elif self.CookieAuth and self.refresh_authentication:
            if self.session is None:
                self.session = self.create_session()

            # force re-auth
            self._get_cookie_login()
コード例 #11
0
    def init_HTTP(self):
        """
            Initializing of session object
        """

        GenericServer.init_HTTP(self)

        self.session.auth = NoAuth()
        if self.use_autologin is False:
            if len(self.session.cookies) == 0:
                form_inputs = dict()
                if '@' in self.username:
                    user = self.username.split('@')
                    form_inputs['module'] = 'ldap'
                    form_inputs['_username'] = user[0]
                else:
                    form_inputs['module'] = 'sv'
                    form_inputs['_username'] = self.username

                form_inputs['urm:login:client'] = ''
                form_inputs['_password'] = self.password

                # call login page to get temporary cookie
                self.FetchURL('{0}/security/login'.format(self.monitor_url))
                # submit login form to retrieve authentication cookie
                self.FetchURL('{0}/security/login_check'.format(
                    self.monitor_url),
                              cgi_data=form_inputs,
                              multipart=True)
コード例 #12
0
ファイル: Sensu.py プロジェクト: rwha/Nagstamon
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

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

        self.api_url = conf.servers[self.get_name()].monitor_cgi_url
        self.uchiwa_url = conf.servers[self.get_name()].monitor_url
        self.uchiwa_datacenter = conf.servers[self.get_name()].monitor_site
        self.username = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password

        self.BROWSER_URLS = {
            'monitor': '$MONITOR$',
            'hosts': '$MONITOR$/#/clients',
            'services': '$MONITOR$/#/checks',
            'history': '$MONITOR$/#/clients'
        }

        self.SEVERITY_CODE_TEXT_MAP = {
            0: 'OK',
            1: 'WARNING',
            2: 'CRITICAL',
            3: 'UNKNOWN'
        }
        # SEVERITY_STATUS_TEXT_MAP is a Case-Insensitive dict
        self.SEVERITY_STATUS_TEXT_MAP['OK'] = 0
        self.SEVERITY_STATUS_TEXT_MAP['WARNING'] = 1
        self.SEVERITY_STATUS_TEXT_MAP['CRITICAL'] = 2
        self.SEVERITY_STATUS_TEXT_MAP['UNKNOWN'] = 3
コード例 #13
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']
コード例 #14
0
ファイル: Centreon.py プロジェクト: MaikL/Nagstamon
    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']
コード例 #15
0
    def init_HTTP(self):
        """
            Icinga 1.11 needs extra Referer header for actions
        """
        GenericServer.init_HTTP(self)

        if not "Referer" in self.session.headers:
            # to execute actions since Icinga 1.11 a Referer Header is necessary
            self.session.headers["Referer"] = self.monitor_cgi_url + "/cmd.cgi"
コード例 #16
0
ファイル: Icinga.py プロジェクト: BenoitPoulet/Nagstamon
    def init_HTTP(self):
        """
            Icinga 1.11 needs extra Referer header for actions
        """
        GenericServer.init_HTTP(self)

        if not "Referer" in self.session.headers:
            # to execute actions since Icinga 1.11 a Referer Header is necessary
            self.session.headers["Referer"] = self.monitor_cgi_url + "/cmd.cgi"
コード例 #17
0
ファイル: Prometheus.py プロジェクト: stearz/Nagstamon
    def init_HTTP(self):
        """
        things to do if HTTP is not initialized
        """
        GenericServer.init_HTTP(self)

        # prepare for JSON
        self.session.headers.update({'Accept': 'application/json',
                                     'Content-Type': 'application/json'})
コード例 #18
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'}

        # Op5Monitor gives a 500 when auth is wrong
        self.STATUS_CODES_NO_AUTH.append(500)
コード例 #19
0
ファイル: op5Monitor.py プロジェクト: minibbjd/Nagstamon
    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'}

        # Op5Monitor gives a 500 when auth is wrong
        self.STATUS_CODES_NO_AUTH.append(500)
コード例 #20
0
ファイル: Zabbix.py プロジェクト: oN0/Nagstamon
    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 = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password
コード例 #21
0
ファイル: Zabbix.py プロジェクト: minibbjd/Nagstamon
    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 = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password
コード例 #22
0
ファイル: Multisite.py プロジェクト: stearz/Nagstamon
    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 = ['Monitor', 'Recheck', 'Acknowledge', 'Downtime']

        # flag for newer cookie authentication
        self.CookieAuth = False
コード例 #23
0
ファイル: Sensu.py プロジェクト: rwha/Nagstamon
    def init_HTTP(self):
        """
            things to do if HTTP is not initialized
        """
        GenericServer.init_HTTP(self)

        try:
            self.sensu_api = SensuAPI(self.api_url,
                                      username=self.username,
                                      password=self.password)
        except SensuAPIException:
            self.Error(sys.exc_info())
コード例 #24
0
ファイル: Multisite.py プロジェクト: BenoitPoulet/Nagstamon
    def init_HTTP(self):
        # general initialization
        GenericServer.init_HTTP(self)

        # Fix eventually missing tailing '/' in url
        if self.monitor_url[-1] != '/':
            self.monitor_url += '/'

        # Prepare all urls needed by nagstamon if not yet done
        if len(self.urls) == len(self.statemap):
            self.urls = {
              'api_services':    self.monitor_url + 'view.py?view_name={0}&output_format=python&lang=&limit=hard'.\
                                                                          format(self.check_mk_view_services),
              'human_services':  self.monitor_url + 'index.py?%s' % \
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name={0}'.\
                                                                          format(self.check_mk_view_services)}),
              'human_service':   self.monitor_url + 'index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name=service'}),

              'api_hosts':       self.monitor_url + 'view.py?view_name={0}&output_format=python&lang=&limit=hard'.\
                                                                          format(self.check_mk_view_hosts),
              'human_hosts':     self.monitor_url + 'index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name={0}'.\
                                                                           format(self.check_mk_view_services)}),
              'human_host':      self.monitor_url + 'index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name=hoststatus'}),
              # URLs do not need pythonic output because since werk #0766 API does not work with transid=-1 anymore
              # thus access to normal webinterface is used
              'api_host_act':    self.monitor_url + 'view.py?_transid=-1&_do_actions=yes&_do_confirm=Yes!&view_name=hoststatus&filled_in=actions&lang=',
              'api_service_act': self.monitor_url + 'view.py?_transid=-1&_do_actions=yes&_do_confirm=Yes!&view_name=service&filled_in=actions&lang=',
              'api_svcprob_act': self.monitor_url + 'view.py?_transid=-1&_do_actions=yes&_do_confirm=Yes!&view_name=svcproblems&filled_in=actions&lang=',
              'human_events':    self.monitor_url + 'index.py?%s' %
                                                   urllib.parse.urlencode({'start_url': 'view.py?view_name=events'}),
              'transid':         self.monitor_url + 'view.py?actions=yes&filled_in=actions&host=$HOST$&service=$SERVICE$&view_name=service'
            }

            self.statemap = {
                'UNREACH': 'UNREACHABLE',
                'CRIT':    'CRITICAL',
                'WARN':    'WARNING',
                'UNKN':    'UNKNOWN',
                'PEND':    'PENDING',
            }

        if self.CookieAuth:
            # get cookie to access Check_MK web interface
            if 'cookies' in dir(self.session):
                if len(self.session.cookies) == 0:
                    # if no cookie yet login
                    self._get_cookie_login()
            elif self.session == None:
                # if no cookie yet login
                self._get_cookie_login()
コード例 #25
0
ファイル: Multisite.py プロジェクト: BenoitPoulet/Nagstamon
    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 = ['Monitor', 'Recheck', 'Acknowledge', 'Downtime']

        # flag for newer cookie authentication
        self.CookieAuth = False
コード例 #26
0
ファイル: Zabbix.py プロジェクト: minibbjd/Nagstamon
    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)
コード例 #27
0
    def init_HTTP(self):
        """
            partly not constantly working Basic Authorization requires extra Autorization headers,
            different between various server types
        """
        if self.session is None:
            GenericServer.init_HTTP(self)

        # get cookie from login page via url retrieving as with other urls
        try:
            # login and get cookie
            if self.session is None or self.session.cookies.get('thruk_auth') is None:
                self.login()
        except:
            self.Error(sys.exc_info())
コード例 #28
0
    def init_HTTP(self):
        """
            things to do if HTTP is not initialized
        """
        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()}
        """
        self.session.headers.update({
            "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.session.cookies) == 0:
            # put all necessary data into url string
            logindata = urllib.parse.urlencode({
                'login_username':
                self.get_username(),
                'login_password':
                self.get_password(),
                'back':
                '',
                'app':
                'OPSVIEW',
                'login':
                '******',
                'noscript':
                '1'
            })

            # the following is necessary for Opsview servers
            # get cookie from login page via url retrieving as with other urls
            try:
                # login and get cookie
                self.FetchURL(self.monitor_url + "/login",
                              cgi_data=logindata,
                              giveback='raw')
            except:

                import traceback
                traceback.print_exc(file=sys.stdout)

                self.Error(sys.exc_info())
コード例 #29
0
ファイル: Zabbix.py プロジェクト: oN0/Nagstamon
    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)
コード例 #30
0
    def init_HTTP(self):
        """
            things to do if HTTP is not initialized
        """
        GenericServer.init_HTTP(self)

        if self.custom_cert_use:
            verify = self.custom_cert_ca_file
        else:
            verify = not self.ignore_cert

        try:
            self.sensu_api = SensuAPI(self.api_url,
                                      username=self.username,
                                      password=self.password,
                                      verify=verify)
        except SensuAPIException:
            self.Error(sys.exc_info())
コード例 #31
0
    def init_HTTP(self):
        """
            partly not constantly working Basic Authorization requires extra Autorization headers,
            different between various server types
        """
        GenericServer.init_HTTP(self)

        # only if cookies are needed
        if self.CookieAuth:
            # get cookie to access Thruk web interface
            # Thruk first send a test cookie, later an auth cookie
            if len(self.session.cookies) < 2:
                # get cookie from login page via url retrieving as with other urls
                try:
                    # login and get cookie
                    self.login()
                except:
                    self.Error(sys.exc_info())
コード例 #32
0
ファイル: Thruk.py プロジェクト: MedicMomcilo/Nagstamon
    def init_HTTP(self):
        """
            partly not constantly working Basic Authorization requires extra Autorization headers,
            different between various server types
        """
        GenericServer.init_HTTP(self)

        # only if cookies are needed
        if self.CookieAuth:
            # get cookie to access Thruk web interface
            # Thruk first send a test cookie, later an auth cookie
            if len(self.session.cookies) < 2:
                # get cookie from login page via url retrieving as with other urls
                try:
                    # login and get cookie
                    self.login()
                except:
                    self.Error(sys.exc_info())
コード例 #33
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

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

        self.server = Server()
        if ":" in conf.servers[self.get_name()].monitor_url:
            self.server.server_url, self.server.server_port = conf.servers[self.get_name()].monitor_url.split(':')
        else:
            self.server.server_url = conf.servers[self.get_name()].monitor_url
            self.server.server_port = 8080 #the default is 8080

        self.server.username = conf.servers[self.get_name()].username
        self.server.password = conf.servers[self.get_name()].password
        
        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Acknowledge"]
コード例 #34
0
    def __init__(self, **kwds):
        """
        Prepare all urls needed by nagstamon and icinga
        """
        GenericServer.__init__(self, **kwds)

        self.url = conf.servers[self.get_name()].monitor_url
        self.username = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password

        self.SERVICE_SEVERITY_CODE_TEXT_MAP = {
            0: 'OK',
            1: 'WARNING',
            2: 'CRITICAL',
            3: 'UNKNOWN'
        }
        self.HOST_SEVERITY_CODE_TEXT_MAP = {
            0: 'UP',
            1: 'DOWN',
            2: 'UNREACHABLE'
        }
コード例 #35
0
ファイル: Opsview.py プロジェクト: MaikL/Nagstamon
    def init_HTTP(self):
        """
            things to do if HTTP is not initialized
        """
        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()}
        """
        self.session.headers.update({"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.session.cookies) == 0:
            # put all necessary data into url string
            logindata = urllib.parse.urlencode({'login_username': self.get_username(),
                                                'login_password': self.get_password(),
                                                'back': '',
                                                'app': 'OPSVIEW',
                                                'login': '******',
                                                'noscript': '1'})

            # the following is necessary for Opsview servers
            # get cookie from login page via url retrieving as with other urls
            try:
                # login and get cookie
                self.FetchURL(self.monitor_url + "/login", cgi_data=logindata, giveback='raw')
            except:

                import traceback
                traceback.print_exc(file=sys.stdout)

                self.Error(sys.exc_info())
コード例 #36
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # Prepare all urls needed by nagstamon - 
        self.urls = {}
        ###self.statemap = {}
        self.statemap = {
            'UNREACH': 'UNREACHABLE',
            'CRIT': 'CRITICAL',
            'WARN': 'WARNING',
            'UNKN': 'UNKNOWN',
            'PEND': 'PENDING',
            '0': 'OK',
            '1': 'UNKNOWN',
            '2': 'WARNING',
            '5': 'CRITICAL',
            '3': 'WARNING',
            '4': 'CRITICAL'}

        # Entries for monitor default actions in context menu
        self.MENU_ACTIONS = ["Recheck", "Acknowledge", "Downtime"]
        self.username = conf.servers[self.get_name()].username
        self.password = conf.servers[self.get_name()].password
コード例 #37
0
ファイル: Thruk.py プロジェクト: MedicMomcilo/Nagstamon
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # flag for newer cookie authentication
        self.CookieAuth = False
コード例 #38
0
ファイル: SensuGo.py プロジェクト: wolneykien/Nagstamon
 def __init__(self, **kwds):
     GenericServer.__init__(self, **kwds)
     self._api_url = conf.servers[self.get_name()].monitor_cgi_url
     self.reset_HTTP()
コード例 #39
0
ファイル: SensuGo.py プロジェクト: wolneykien/Nagstamon
 def init_HTTP(self):
     GenericServer.init_HTTP(self)
     self._setup_sensugo_api()
コード例 #40
0
ファイル: Centreon.py プロジェクト: idl0r/Nagstamon
    def init_HTTP(self):
        """
        initialize HTTP connection
        """
        if self.session == None:
            GenericServer.init_HTTP(self)

        if self.centreon_version == None:
            result_versioncheck = self.FetchURL(self.monitor_cgi_url + '/index.php', giveback='raw')
            raw_versioncheck, error_versioncheck = result_versioncheck.result, result_versioncheck.error
            if error_versioncheck == '':
                if re.search('2\.2\.[0-9]', raw_versioncheck):
                    self.centreon_version = 2.2
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.2')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?p=1',\
                                    'hosts': '$MONITOR$/main.php?p=20103&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20202&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                elif re.search('2\.[3-6]\.[0-5]', raw_versioncheck):
                    self.centreon_version = 2.3456
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.6.5 <=> 2.3')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?p=1',\
                                    'hosts': '$MONITOR$/main.php?p=20103&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20202&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                elif re.search('2\.6\.[6-9]', raw_versioncheck):
                    self.centreon_version = 2.66
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.6.6')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?p=1',\
                                    'hosts': '$MONITOR$/main.php?p=20103&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20202&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                elif re.search('2\.7\.[0-9]', raw_versioncheck):
                    # Centreon 2.7 only support C. Broker
                    self.centreon_version = 2.7
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.7')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?',\
                                    'hosts': '$MONITOR$/main.php?p=20202&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20201&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                else:
                    # unsupported version or unable do determine
                    self.centreon_version = 2.7
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version unknown : supposed to be >= 2.7')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?',\
                                    'hosts': '$MONITOR$/main.php?p=20202&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20201&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
            else:
                if conf.debug_mode == True:
                    self.Debug(server=self.get_name(), debug='Error getting the home page : ' + error_versioncheck)
            del result_versioncheck, raw_versioncheck, error_versioncheck
コード例 #41
0
    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # flag for newer cookie authentication
        self.CookieAuth = False
コード例 #42
0
 def __init__(self, **kwds):
     GenericServer.__init__(self, **kwds)
コード例 #43
0
    def init_HTTP(self):
        """
        initialize HTTP connection
        """
        if self.session == None:
            GenericServer.init_HTTP(self)

        if self.centreon_version == None:
            result_versioncheck = self.FetchURL(self.monitor_cgi_url + '/index.php', giveback='raw')
            raw_versioncheck, error_versioncheck = result_versioncheck.result, result_versioncheck.error
            if error_versioncheck == '':
                if re.search('2\.2\.[0-9]', raw_versioncheck):
                    self.centreon_version = 2.2
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.2')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?p=1',\
                                    'hosts': '$MONITOR$/main.php?p=20103&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20202&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                elif re.search('2\.[3-6]\.[0-5]', raw_versioncheck):
                    self.centreon_version = 2.3456
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.6.5 <=> 2.3')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?p=1',\
                                    'hosts': '$MONITOR$/main.php?p=20103&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20202&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                elif re.search('2\.6\.[6-9]', raw_versioncheck):
                    self.centreon_version = 2.66
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.6.6')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?p=1',\
                                    'hosts': '$MONITOR$/main.php?p=20103&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20202&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                elif re.search('2\.7\.[0-9]', raw_versioncheck):
                    # Centreon 2.7 only support C. Broker
                    self.centreon_version = 2.7
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version detected : 2.7')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?',\
                                    'hosts': '$MONITOR$/main.php?p=20202&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20201&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
                else:
                    # unsupported version or unable do determine
                    self.centreon_version = 2.7
                    if conf.debug_mode == True:
                        self.Debug(server=self.get_name(), debug='Centreon version unknown : supposed to be >= 2.7')
                    # URLs for browser shortlinks/buttons on popup window
                    self.BROWSER_URLS= { 'monitor': '$MONITOR$/main.php?',\
                                    'hosts': '$MONITOR$/main.php?p=20202&o=hpb',\
                                    'services': '$MONITOR$/main.php?p=20201&o=svcpb',\
                                    'history': '$MONITOR$/main.php?p=203'}
            else:
                if conf.debug_mode == True:
                    self.Debug(server=self.get_name(), debug='Error getting the home page : ' + error_versioncheck)
            del result_versioncheck, raw_versioncheck, error_versioncheck
コード例 #44
0
 def init_HTTP(self):
     if self.session is None:
         GenericServer.init_HTTP(self)
         self.session.headers.update({'Content-Type': 'application/json'})
         self.token = self.get_token().result
コード例 #45
0
ファイル: Centreon.py プロジェクト: MaikL/Nagstamon
 def init_HTTP(self):
     """
     initialize HTTP connection
     """
     if self.session == None:
         GenericServer.init_HTTP(self)