• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python Generic.GenericServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中Nagstamon.Servers.Generic.GenericServer的典型用法代码示例。如果您正苦于以下问题:Python GenericServer类的具体用法?Python GenericServer怎么用?Python GenericServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了GenericServer类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: init_HTTP

    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())
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:34,代码来源:Opsview.py


示例2: init_HTTP

    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)
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:27,代码来源:IcingaWeb2.py


示例3: init_HTTP

    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
            )
开发者ID:HenriWahl,项目名称:Nagstamon,代码行数:28,代码来源:SnagView3.py


示例4: __init__

    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
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:35,代码来源:Zabbix.py


示例5: __init__

    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']
开发者ID:MaikL,项目名称:Nagstamon,代码行数:8,代码来源:Centreon.py


示例6: init_HTTP

    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"
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:9,代码来源:Icinga.py


示例7: __init__

    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)
开发者ID:minibbjd,项目名称:Nagstamon,代码行数:10,代码来源:op5Monitor.py


示例8: __init__

    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
开发者ID:minibbjd,项目名称:Nagstamon,代码行数:11,代码来源:Zabbix.py


示例9: init_HTTP

    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()
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:53,代码来源:Multisite.py


示例10: __init__

    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
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:12,代码来源:Multisite.py


示例11: init_HTTP

    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)
开发者ID:minibbjd,项目名称:Nagstamon,代码行数:15,代码来源:Zabbix.py


示例12: init_HTTP

    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())
开发者ID:MedicMomcilo,项目名称:Nagstamon,代码行数:18,代码来源:Thruk.py


示例13: __init__

    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"]
开发者ID:BenoitPoulet,项目名称:Nagstamon,代码行数:19,代码来源:Zenoss.py


示例14: init_HTTP

    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': 'Sign in',
                                                '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())
开发者ID:MaikL,项目名称:Nagstamon,代码行数:38,代码来源:Opsview.py


示例15: __init__

    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
开发者ID:MedicMomcilo,项目名称:Nagstamon,代码行数:23,代码来源:Zabbix.py


示例16: __init__

    def __init__(self, **kwds):
        GenericServer.__init__(self, **kwds)

        # flag for newer cookie authentication
        self.CookieAuth = False
开发者ID:MedicMomcilo,项目名称:Nagstamon,代码行数:5,代码来源:Thruk.py


示例17: init_HTTP

 def init_HTTP(self):
     """
     initialize HTTP connection
     """
     if self.session == None:
         GenericServer.init_HTTP(self)
开发者ID:MaikL,项目名称:Nagstamon,代码行数:6,代码来源:Centreon.py


示例18: init_HTTP

    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
开发者ID:idl0r,项目名称:Nagstamon,代码行数:62,代码来源:Centreon.py



注:本文中的Nagstamon.Servers.Generic.GenericServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python network.HTTP类代码示例发布时间:2022-05-24
下一篇:
Python Generic.GenericServer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap