当前位置: 首页>>代码示例>>Python>>正文


Python pyzabbix.ZabbixAPI方法代码示例

本文整理汇总了Python中pyzabbix.ZabbixAPI方法的典型用法代码示例。如果您正苦于以下问题:Python pyzabbix.ZabbixAPI方法的具体用法?Python pyzabbix.ZabbixAPI怎么用?Python pyzabbix.ZabbixAPI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyzabbix的用法示例。


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

示例1: set_zabbix

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def set_zabbix(self):

        zabbix_host_text = self.zabbix_host.text()
        zabbix_user_text = self.zabbix_user.text()
        zabbix_pass_text = self.zabbix_pass.text()

        try:

            zapi = ZabbixAPI(str(zabbix_host_text))
            zapi.login(str(zabbix_user_text), str(zabbix_pass_text))
            self.connect_test.setStyleSheet("color: rgb(16, 172, 132)")
            self.connect_test.setText("OK")
            self.set_conf('Zabbix', 'zabbix_host', zabbix_host_text)
            self.set_conf('Zabbix', 'zabbix_user', zabbix_user_text)
            self.set_conf('Zabbix', 'zabbix_pass', zabbix_pass_text)

        except:

            self.connect_test.setStyleSheet("color: rgb(238, 82, 83)")
            self.connect_test.setText("Invalid Credentials") 
开发者ID:Warflop,项目名称:Telebix,代码行数:22,代码来源:jobs.py

示例2: __init__

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def __init__(self, base_url, login, password, verify_tls=True, timeout=None, **options):
        self.options = options
        self.key_patterns = {prepare_regex(metric['key']): metric
                             for metric in options.get('metrics', [])}

        self.zapi = pyzabbix.ZabbixAPI(base_url, timeout=timeout)
        if not verify_tls:
            import requests.packages.urllib3 as urllib3
            urllib3.disable_warnings()
            self.zapi.session.verify = verify_tls

        def measure_api_request(r, *args, **kwargs):
            api_requests_total.inc()
            api_bytes_total.inc(len(r.content))
            api_seconds_total.inc(r.elapsed.total_seconds())
        self.zapi.session.hooks = {'response': measure_api_request}

        self.zapi.login(login, password)

        self.host_mapping = {row['hostid']: row['name']
                             for row in self.zapi.host.get(output=['hostid', 'name'])} 
开发者ID:MyBook,项目名称:zabbix-exporter,代码行数:23,代码来源:core.py

示例3: __init__

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def __init__(self, server, user, password, verify=True):
        """
        Init zabbix class for further needs
        :param user: string
        :param password: string
        :return: pyzabbix object
        """
        self.server = server
        self.user = user
        self.password = password
        # Enable HTTP auth
        s = requests.Session()
        s.auth = (user, password)

        self.zapi = ZabbixAPI(server, s)
        self.zapi.session.verify = verify
        self.zapi.login(user, password)
        self.version = self.get_version() 
开发者ID:qk4l,项目名称:zabbix-cachet,代码行数:20,代码来源:zabbix-cachet.py

示例4: __init__

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def __init__(self, url, login, password):
        self.url = url
        self.login = login
        self.password = password
        self.zbx_api = ZabbixAPI(url=url, use_authenticate=False, user=login, password=password)
        log.debug('Object ZabbixAgent created')
        log.debug('API ver. %s', self.api_ver()) 
开发者ID:Prototype-X,项目名称:Zabbix-Network-Weathermap,代码行数:9,代码来源:zabbix.py

示例5: __init__

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def __init__(self):
        self.hosts_dump = list()
        self.hosts_dict = dict()
        self.projects = list()
        self.zapi = ZabbixAPI(os.getenv('ISOLATE_ZABBIX_URL'))
        self.zapi.login(os.getenv('ISOLATE_ZABBIX_USER'), os.getenv('ISOLATE_ZABBIX_PASS')) 
开发者ID:devopsprodigy,项目名称:isolate,代码行数:8,代码来源:helper.py

示例6: get

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def get(cls, graph):
        zabbix_client = ZabbixAPI(CONFIG.probes.zabbix.url)
        return cls(
            graph=graph,
            upstream_proxy=upstream.UpstreamProxy(zabbix_client),
            extractor=extractor.AlertExtractor.get(),
            synchronizer=utils.NodeSynchronizer(graph),
            resync_period=CONFIG.probes.zabbix.resync_period) 
开发者ID:openrca,项目名称:orca,代码行数:10,代码来源:probe.py

示例7: info_zabbix

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def info_zabbix(self, bot, update):
        if str(update.message.chat_id) == self.user_id_telegram and self.infozabbix.isChecked():
            try:
                self.zapi = ZabbixAPI(str(self.z_host))
                self.zapi.timeout = 4.0
                self.zapi.login(str(self.z_username), str(self.z_password))
                update.message.reply_text("Zabbix is running.")
            except:
                update.message.reply_text("Zabbix is not running.")
        else:
            update.message.reply_text("I can't give this information for you!") 
开发者ID:Warflop,项目名称:Telebix,代码行数:13,代码来源:jobs.py

示例8: login

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def login(self):
        zapi = ZabbixAPI(self.ZABBIX_URL)
        zapi.login(self.ZABBIX_USER, self.ZABBIX_PASSWORD)
        return zapi 
开发者ID:demisto,项目名称:content,代码行数:6,代码来源:Zabbix.py

示例9: __init__

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def __init__(self):
        self.zapi = ZabbixAPI(zabbix_url)
        self.zapi.session.auth = (zabbix_user, zabbix_pw)
        self.zapi.session.verify = False
        self.zapi.timeout = 5
        self.zapi.login(zabbix_user, zabbix_pw)
        self.val = 0.0 
开发者ID:wylok,项目名称:sparrow,代码行数:9,代码来源:tools.py

示例10: __init__

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def __init__(self, server, user, password):
        self.api = ZabbixAPI(server)
        self.user = user
        self.password = password 
开发者ID:ableev,项目名称:Zabbix-in-Telegram,代码行数:6,代码来源:ZbxTgDaemon.py

示例11: connect

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def connect(self):
        """
        Establishes a connection to the Zabbix server

        Raises:
            SystemExit

        """

        if self.auth == "webform":
            self.conn = ZabbixAPI(self.server)
        elif self.auth == "http":
            self.conn = ZabbixAPI(self.server, use_authenticate=False)
            self.conn.session.auth = (self.username, self.password)

        else:
            raise SystemExit('api auth method not implemented: %s' % self.conn.auth)

        if self.nocheckcertificate:
            self.conn.session.verify = False

        try:
            self.conn.login(self.username, self.password)
        except ZabbixAPIException as e:
            raise SystemExit('Cannot login to Zabbix server: %s' % e)

        self.logger.info("Connected to Zabbix API Version %s" % self.conn.api_version()) 
开发者ID:dnaeon,项目名称:zabbix-ldap-sync,代码行数:29,代码来源:zabbixconn.py

示例12: start_bot

# 需要导入模块: import pyzabbix [as 别名]
# 或者: from pyzabbix import ZabbixAPI [as 别名]
def start_bot(self):

        self.token, self.user_id_telegram, self.z_username, self.z_password, self.z_host = self.get_conf()
        self.zapi = ZabbixAPI(str(self.z_host))
        self.zapi.timeout = 4.0
        try:
            self.zapi.login(str(self.z_username), str(self.z_password))
        except:
            QtGui.QMessageBox.information(self, "Message", "Zabbix is not running! You need to fill in the connection details!")
            return

        self.updater = Updater(self.token)
        dp = self.updater.dispatcher
        dp.add_handler(CommandHandler("help", self.help))
        dp.add_handler(CommandHandler("hosts", self.info_hosts))
        dp.add_handler(CommandHandler("graphs", self.info_graphs, pass_args=True))
        dp.add_handler(CommandHandler("status", self.info_zabbix))
        dp.add_handler(CommandHandler("events", self.info_events))
        dp.add_handler(CommandHandler("webs", self.info_webs))
        dp.add_handler(CommandHandler("users", self.info_users))
        dp.add_handler(MessageHandler(Filters.text, self.echo))

        if self.infonotifications.isChecked():

            try:
                self.delete_script()
            except:
                pass

            try:
                self.create_script()
            except:
                QtGui.QMessageBox.information(self, "Message", "Check connection details!")
                return
        else:
            QtGui.QMessageBox.information(self, "Message", "You need to mark 'Realtime notification'!")
            return

        self.updater.start_polling()
        self.status.setStyleSheet("color: rgb(16, 172, 132)")
        self.status.setText("Running")      
        self.infohosts.setEnabled(False)
        self.infographs.setEnabled(False)
        self.infozabbix.setEnabled(False)
        self.infoevents.setEnabled(False)
        self.infowebs.setEnabled(False)
        self.infousers.setEnabled(False)
        self.infonotifications.setEnabled(False)
        self.start_button.setEnabled(False)
        self.stop_button.setEnabled(True) 
开发者ID:Warflop,项目名称:Telebix,代码行数:52,代码来源:jobs.py


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