def pure_disk_monitoring(): try: '''Get the argument from Zabbix''' ip = str(sys.argv[2]) #IP of the Pure Storage Array token = str(sys.argv[3]) #API Token host = str(sys.argv[4]) #Host name (for the sender) zabbixIP = str( sys.argv[5]) #Zabbix Proxy or Server IP (for the sender) '''Get data''' arrayConnect = purestorage.FlashArray(ip, api_token=token, verify_https=False) diskList = arrayConnect.list_drives() metrics = [] for i in diskList: disk = i["name"] diskMonitoring = arrayConnect.get_drive(drive=disk) '''Sending data''' if "status" in diskMonitoring: diskStatus = str(diskMonitoring["status"]) m = ZabbixMetric(host, "pure.disk.status[" + disk + "]", diskStatus) metrics.append(m) if "capacity" in diskMonitoring: diskCapacity = str(diskMonitoring["capacity"]) m = ZabbixMetric(host, "pure.disk.capacity[" + disk + "]", diskCapacity) metrics.append(m) if "protocol" in diskMonitoring: diskProtocol = str(diskMonitoring["protocol"]) m = ZabbixMetric(host, "pure.disk.protocol[" + disk + "]", diskProtocol) metrics.append(m) if "type" in diskMonitoring: diskType = str(diskMonitoring["type"]) m = ZabbixMetric(host, "pure.disk.type[" + disk + "]", diskType) metrics.append(m) if "last_failure" in diskMonitoring: diskLastFailure = str(diskMonitoring["last_failure"]) m = ZabbixMetric(host, "pure.disk.last.failure[" + disk + "]", diskLastFailure) metrics.append(m) data = ZabbixSender(zabbixIP) data.send(metrics) '''Send 1 to give a result to Zabbix''' print(1) except Exception as e: ''' Sending 0 to Zabbix instead of a Python error. Like that the items won't be considered as "unsupported" ''' metrics = [ ZabbixMetric(host, "pure.disk.monitoring.launcher.error", str(e)) ] data = ZabbixSender(zabbixIP) data.send(metrics) print(0)
def send_zabbix(self, log): if self.conf['zabbix_enable']: msg = self.verbose_format(log) impact = int(log['owasp']['impact']) allowed_range = range(1, 8) if self.conf['zabbix_advantage_keys']: metrics = [ ZabbixMetric( self.conf['server_name'], 'artlas_check{}'.format('_0{}'.format(impact) if impact in allowed_range else ''), msg) ] else: metrics = [ ZabbixMetric(self.conf['server_name'], 'artlas_check', msg) ] ZabbixSender(use_config=self.conf['agentd_config']).send(metrics) if self.conf['notifications']: if self.conf['zabbix_advantage_keys']: metrics = [ ZabbixMetric( self.conf['server_name'], 'artlas_check{}'.format('_0{}'.format( impact) if impact in allowed_range else ''), "OK") ] else: metrics = [ ZabbixMetric(self.conf['server_name'], 'artlas_check', "OK") ] ZabbixSender( use_config=self.conf['agentd_config']).send(metrics)
def main(): drive_list = [] json_string = [] smartctl_check = 'smartctl -f hex,id -A -i -H -lerror -d ' metric = [] zabbix_server = 'zabbix.saber3d.ru' if os.name == 'nt': hostname = os.environ['COMPUTERNAME'].lower( ) + '.' + os.environ['USERDNSDOMAIN'].lower() codepg = 'cp1251' smartctl_scan = r'c:\"Program Files"\smartmontools\bin\smartctl --scan' smartctl_check = 'c:\\"Program Files"\\smartmontools\\bin\\' + smartctl_check elif os.popen('uname').read().strip().lower() == 'vmkernel': hostname = os.uname()[1] codepg = 'utf8' smartctl_scan = "/usr/bin/esxcli storage core device list | /bin/grep -v -E '^ ' | /bin/grep -i ata | /usr/bin/awk '{print \"/dev/disks/\"$0}'" smartctl_check = r'/opt/smartmontools/' + smartctl_check else: hostname = os.uname()[1] codepg = 'utf8' smartctl_scan = "/usr/sbin/smartctl --scan | /bin/grep -i megaraid | /usr/bin/awk '{print $3}'" drive_type = cmd_line(smartctl_scan, codepg) for i in range(len(drive_type)): if drive_type[i] != '': drive_list.append(('/dev/bus/0 ' + drive_type[i]).split(' ')) json_string.append( {'{#DEVNAME}': drive_type[i].replace(',', '')}) smartctl_scan = "/usr/bin/sg_map -i | /bin/grep -i -E 'ata|seagate' | awk '{print $1 (\" sat\")}'" smartctl_check = r'/usr/sbin/' + smartctl_check devices = cmd_line(smartctl_scan, codepg) # json for zabbix template for i in range(len(devices)): if devices[i] != '': drive_list.append((devices[i].split()[0] + ' sat').split(' ')) json_string.append({'{#DEVNAME}': devices[i].split()[0]}) json_dumps = json.dumps({"data": json_string}) ZabbixSender(zabbix_server).send( [ZabbixMetric(hostname, "HDD.discovery[{#DEVNAME}]", json_dumps)]) # getting smart data for disk in drive_list: smart_out = cmd_line(smartctl_check + disk[1] + ' ' + disk[0], codepg) if 'megaraid' in disk[1]: metric += smart_parser(smart_out, disk[1].replace(',', ''), hostname) else: metric += smart_parser(smart_out, disk[0], hostname) #print(metric) # send data to zabbix ZabbixSender(zabbix_server).send(metric)
def test_create_messages(self): m = [ZabbixMetric('host1', 'key1', 1), ZabbixMetric('host2', 'key2', 2)] zs = ZabbixSender() result = zs._create_messages(m) self.assertIsInstance(result, list) self.assertEqual(len(result), 2)
def __init__(self,worker_id): self.time_end = timeutils.isotime(datetime.datetime.utcnow()) self.time_start = timeutils.isotime(datetime.datetime.utcnow() - datetime.timedelta(days=1)) self.user = cfg.CONF.zabbix.username self.password = cfg.CONF.zabbix.keystone_pwd self.sender = ZabbixSender(cfg.CONF.zabbix.agent_server) super(ZabbixSenderService, self).__init__(worker_id)
def __init__(self, manager, config, timer, base_dir, backup_dir, **kwargs): super(Zabbix, self).__init__(self.__class__.__name__, manager, config, timer, base_dir, backup_dir, **kwargs) self.server = self.config.notify.zabbix.server self.port = self.config.notify.zabbix.port self.use_config = self.config.notify.zabbix.use_config self.key = self.config.notify.zabbix.key self.nodename = self.config.notify.zabbix.node self.success = 0 self.failed = 2 req_attrs = ['key'] for attr in req_attrs: if not getattr(self, attr): raise OperationError( 'Zabbix notifier module requires attribute: %s!' % attr) try: self.notifier = ZabbixSender( use_config=self._use_config(), zabbix_server=self.server, zabbix_port=self.port, ) except Exception, e: logging.error("Error initiating ZabbixSender! Error: %s" % e) raise OperationError(e)
def send(self): """Отправляет статистику работы майнеров на серввер""" for name, metrics in self.__metrics.items(): server = ZabbixSender( self.server, self.port, chunk_size=len(metrics), ) try: self.log.info( "metrics sended to {server}:{port} " "for {miner} ({result})".format( server=self.server, port=self.port, miner=name, result=server.send(metrics), ), ) except socket.error as e: self.log.error( "error on sending metrics to {server}:{port} " "for {miner} ({message})".format( server=self.server, port=self.port, miner=name, message=e, ), ) break
def test_get_response_fail_s_close(self, mock_socket): mock_socket.recv.side_effect = (b'IDDQD', self.resp_body) mock_socket.close.side_effect = socket.error zs = ZabbixSender() result = zs._get_response(mock_socket) self.assertFalse(result)
def __init__(self, zabbix_server='127.0.0.1', zabbix_port=10051, use_config=None, items=None): """ Parameters ---------- zabbix_server : str Zabbix server ip address (default is '127.0.0.1') zabbix_port : int Zabbix server port (default is 10051) use_config : str or bool Path to zabbix_agentd.conf file to load settings from. If value is 'True' then default config path will used: /etc/zabbix/zabbix_agentd.conf items: dict List of sender items. (Prerequisite keys: host pv interval, Optional: item_key func) """ self._monitor_items = [] self._interval_item_q = PriorityPeekQueue() self.zbx_sender = ZabbixSender(zabbix_server, zabbix_port, use_config) self.__is_stop = threading.Event() self.__stop_request = False self._is_running = False if items: for item in items: self.add_item(item)
def _zabbix(args: Namespace): host = args.host sender = ZabbixSender(args.zabbix_server) meter = CO2Meter(args.device) n = args.n logger.info('zabbix-server:{}\thost:{}\tn:{}'.format( args.zabbix_server, host, n )) def send(data): packet = [] for key in ['co2', 'temperature']: if key in data: packet.append(ZabbixMetric(host, 'co2monitor[{}]'.format(key), data[key])) r = sender.send(packet) logger.info(r) if n: for i in range(n): data = meter.get_data() send(data) if i < n - 1: time.sleep(10) else: while True: data = meter.get_data() send(data) time.sleep(10)
def send_to_zabbix(self, data: dict) -> None: """ Send results (evaluated with rules) to zabbix Args: data (dict): results dict """ zabbix_name = self.config['settings']['zabbix'].get('name', self.name) zabbix_url = self.config['settings']['zabbix']['url'] zabbix_port = int(self.config['settings']['zabbix']['port']) zabbix_key = self.config['settings']['zabbix']['key'] fixed_data = data[next(iter(data))] if 'error' in fixed_data or not fixed_data or not data: return payload = [] for topic, consumers in fixed_data.items(): for consumer, lag_data in consumers.items(): level = lag_data['zabbix']['level'] epoch = lag_data['epoch'] metric = ZabbixMetric( zabbix_name, f'{zabbix_key}[{topic},{consumer}]', level.value, clock=epoch ) payload.append(metric) try: with timeout(): zabbix_sender = ZabbixSender(zabbix_url, zabbix_port) zabbix_sender.send(payload) except Exception as e: self.log.error('zabbix_send_error', payload=payload, exc_info=e)
def on_message(self, client: mqtt.Client, userdata, msg: mqtt.MQTTMessage): if msg.topic not in self._cfg["topics"]: logging.warning(f"Ignoring unrequested topic: {msg.topic}") return else: items = self._cfg["topics"][msg.topic] metrics = [] for item in items: payload = msg.payload.decode() if "jq" in item: try: payload = apply_jq(payload, item["jq"]) except Exception as e: logging.error("Failed to apply JQ to payload, skipping", e) continue metrics.append(ZabbixMetric(item["host"], item["item"], payload)) logging.debug( f"{msg.topic} -> {item['item']}@{item['host']}{{{payload}}}") try: # noinspection PyTypeChecker result = ZabbixSender(use_config=True).send(metrics) except Exception as e: logging.error("Failed to send metrics to Zabbix agent", e)
def main(): print(sys.version) # check python version print(serial.__version__) # check pyserial version alreadySend = False arduino = serial.Serial('/dev/ttyUSB0', 57600, timeout=2) time.sleep(1) # give the connection a second to settle while True: data = arduino.read(2000) if data: print(data) # strip out the new lines for now print("size recu= " + str(len(data))) if checkDataIntegrity(data): print("check ok!") obj = json.loads(extractStruct(data)) print(json.dumps(obj, indent=4)) print(obj['payload']['vbatt']) # Send metrics to zabbix trapper xbeeid = obj['payload']['xbeeid'] freemem = obj['payload']['freemem'] vbatt = obj['payload']['vbatt'] packet = [ ZabbixMetric(hostId, 'xbeeid', xbeeid) # multiple metrics can be sent in same call for effeciency , ZabbixMetric(hostId, 'freemem', freemem), ZabbixMetric(hostId, 'vbatt', vbatt) ] ZabbixResponse = ZabbixSender(zserver, port, use_config=None).send(packet) print(ZabbixResponse) else: print("bad message!")
def send_information_to_zabbix(ZABBIX_SERVER, information): try: send = ZabbixSender(ZABBIX_SERVER).send(information) except: print "An error occurred in sending the data" sys.exit() print "Succesful={} Failed={} Total={} Elapsed Time={}".format(send.processed, send.failed, send.total, send.time)
def send(monitor=None): monitor = monitor if monitor else ZBX_PASSIVE_MONITOR if not ZBX_PASSIVE_SERVER or not ZBX_PASSIVE_PORT or not monitor: LOGGER.error('Settings insufficient to passive monitoring') return zabbix_server = ZabbixSender(zabbix_server=ZBX_PASSIVE_SERVER, zabbix_port=int(ZBX_PASSIVE_PORT), chunk_size=2) time_now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') # Creates the message passive_message_status = ZabbixMetric(ZBX_PASSIVE_MONITOR, 'passive_message', 'Working - {0}'.format(time_now)) # Creates the status (0 - OK; 1 - Warning; 2 - Critical) passive_monitor_status = ZabbixMetric(ZBX_PASSIVE_MONITOR, 'passive_check', 0) metrics = [passive_message_status, passive_monitor_status] result = zabbix_server.send(metrics) try: if result.failed == 0: LOGGER.info('Passive monitoring sent with success.') LOGGER.debug(result) else: LOGGER.error('Fail to sent Passive monitoring.') except AttributeError: LOGGER.error('Fail to verify return of Passive monitoring.')
def test_get_response(self, mock_socket): mock_socket.recv.side_effect = (self.resp_header, self.resp_body) zs = ZabbixSender() result = zs._get_response(mock_socket) mock_socket.recv.assert_has_calls([call(92)]) self.assertEqual(result['response'], 'success')
def send_zabbix_script_monitoring(status_code, config_options): metrics = [] m = ZabbixMetric(config_options['APP']['SERVER_NAME'], "cron.domain_expiry_checker", status_code) metrics.append(m) zbx = ZabbixSender(use_config=config_options['APP']['ZABBIX_CONFIG_FILE']) zbx.send(metrics)
def main(argv=None): if argv is None: argv = sys.argv fileHostCheck='./myhosts.json' if not os.path.exists(fileHostCheck): return -1 else: with open(fileHostCheck, 'rb') as json_data: try: myHostDict = json.load(json_data) except Exception as e: print "failed when loading current host json file or parsing the json" + traceback.format_exc() zabbixPacket=[] for host in list(myHostDict): if len(myHostDict[host]['units'])>0 : myUser=myHostDict[host]['user'] myPass=myHostDict[host]['password'] myHostId=myHostDict[host]['hostId'] myHostIp=host reqArray=[] for unit in list(myHostDict[host]['units']): reqArray.append(DaikinStructReqPntState(type=0,id=int(unit))) pLogin=DaikinApi()/DaikinHeader()/DaikinReqSetLogin(username=myUser, password=myPass) respLogin=DaikinHeader(sendP(myHostIp,pLogin)) if int(respLogin.arg1)!=1: print "Login Failure",myHostIp continue myUserId=respLogin.arg2 pPntReq=DaikinApi()/DaikinHeader(id=myUserId)/DaikinReqGetPntState(reqIds=reqArray) respPnt=DaikinHeader(sendP(myHostIp,pPntReq)) pLogout=DaikinApi()/DaikinHeader(id=myUserId)/DaikinReqSetLogout() DaikinHeader(sendP(myHostIp,pLogout)) for pnt in respPnt.payload.pntStateArray: tempPacket=[ ZabbixMetric(myHostId,'daikin.pnt[enumDriveMode,{0}]'.format(pnt.id),pnt.enumDriveMode), ZabbixMetric(myHostId,'daikin.pnt[tempAmbient,{0}]'.format(pnt.id),pnt.tempAmbient), ZabbixMetric(myHostId,'daikin.pnt[tempSetPoint,{0}]'.format(pnt.id),pnt.tempSetPoint), ZabbixMetric(myHostId,'daikin.pnt[enumVentMode,{0}]'.format(pnt.id),pnt.enumVentMode), ZabbixMetric(myHostId,'daikin.pnt[enumVentVol,{0}]'.format(pnt.id),pnt.enumVentVol), ZabbixMetric(myHostId,'daikin.pnt[pntState,{0}]'.format(pnt.id),pnt.pntState), ZabbixMetric(myHostId,'daikin.pnt[errorString,{0}]'.format(pnt.id),pnt.errorString), ZabbixMetric(myHostId,'daikin.pnt[iconMode,{0}]'.format(pnt.id),pnt.iconMode), ZabbixMetric(myHostId,'daikin.pnt[iconAppend,{0}]'.format(pnt.id),pnt.iconAppend), ZabbixMetric(myHostId,'daikin.pnt[filterLed,{0}]'.format(pnt.id), 1 if (pnt.iconAppend & 0x08) else 0 ) ] zabbixPacket.extend(tempPacket) zbx=ZabbixSender('192.168.128.7') zbxResp=zbx.send(zabbixPacket) print zbxResp
def sendLLD(url_hosts, item_key): print('Sending LLD to ' + item_key) json_lld = [] for mongohost in url_hosts: json_lld.append({"host": mongohost.split('.')[0]}) packet = [ZabbixMetric(zbhost, item_key, json.dumps(json_lld))] t = ZabbixSender(zabbix_port=zbport, zabbix_server=zbserver).send(packet) print(t)
async def send_metric(zserver, port, packet_item): """ send metric to zserver :param packet_item: list :return: dict """ result = ZabbixSender(zserver, port).send(packet_item) return result
def send_zabbix(self, localhost, item, data): packet = [ ZabbixMetric(localhost, item, data), ] result = ZabbixSender(zabbix_server='10.210.2.41', zabbix_port=10051, use_config=None).send(packet) print result
def test_init_config(self): folder = os.path.dirname(__file__) filename = os.path.join(folder, 'data/zabbix_agentd.conf') zs = ZabbixSender(use_config=filename) self.assertEqual(zs.__class__.__name__, 'ZabbixSender') self.assertEqual(isinstance(zs.zabbix_uri[0], tuple), True) self.assertEqual(zs.zabbix_uri[0][0], '192.168.1.2') self.assertEqual(zs.zabbix_uri[0][1], 10051)
def test_send_sendall_exception(self, mock_socket): mock_socket.return_value = mock_socket mock_socket.sendall.side_effect = socket.error zm = ZabbixMetric('host1', 'key1', 100500, 1457358608) zs = ZabbixSender() with self.assertRaises(socket.error): zs.send([zm])
def characteristic_value_updated(self, characteristic, value): flags_b_value = bytes(value)[0:1] dose_accumulated_b_value = bytes(value)[1:5] dose_power_b_value = bytes(value)[5:9] impulses_b_value = bytes(value)[9:11] charge_b_value = bytes(value)[11:12] temperature_b_value = bytes(value)[12:13] flags = struct.unpack('b', flags_b_value)[0] dose_accumulated = struct.unpack('f', dose_accumulated_b_value)[0] dose_power = struct.unpack('f', dose_power_b_value)[0] impulses = struct.unpack('H', impulses_b_value)[0] charge = struct.unpack('b', charge_b_value)[0] temperature = struct.unpack('B', temperature_b_value)[0] dose_exceed_flag = flags >> 0 & 1 dose_power_exceed_flag = flags >> 1 & 1 count_speed_inc_flag = flags >> 2 & 1 current_exceed_flag = flags >> 4 & 1 detector_overload_flag = flags >> 5 & 1 charger_connected_flag = flags >> 6 & 1 emergency_shutdown_flag = flags >> 7 & 1 date_now = datetime.datetime.now().timestamp() if settings['piface'] == 'yes': cad.lcd.set_cursor(0, 0) cad.lcd.write(str(str(round(dose_power, 3)) + " uSv/h").ljust(16)) cad.lcd.set_cursor(0, 1) cad.lcd.write( str(str(round(dose_accumulated, 3)) + " uSv").ljust(16)) info = { 'timestamp': date_now, 'dose_accumulated': dose_accumulated, 'dose_power': dose_power, 'impulses': impulses, 'charge': charge, 'temperature': temperature, 'flags': { 'dose_exceed': dose_exceed_flag, 'dose_power_exceed': dose_power_exceed_flag, 'count_speed_inc': count_speed_inc_flag, 'current_exceed': current_exceed_flag, 'detector_overload': detector_overload_flag, 'charger_connected': charger_connected_flag, 'emergency_shutdown': emergency_shutdown_flag } } print(info) metrics = [] m = ZabbixMetric(settings['metric_host'], settings['metric_name'], dose_power, date_now) metrics.append(m) z = ZabbixSender(settings['zabbix_host'], int(settings['zabbix_port'])).send(metrics) print(z)
def on_message(client, userdata, msg): print(msg.topic+" - "+str(msg.payload.decode('utf-8'))) packet = [ ZabbixMetric(str(msg.topic).split('.')[0], str(msg.topic).split('.')[1], str(msg.payload.decode('utf-8'))), ] result = ZabbixSender(zabbix_server=ZabbixServer, zabbix_port=ZabbixPort, use_config=None, chunk_size=250).send(packet) print(result)
def test_init_config_default(self): folder = os.path.dirname(__file__) filename = os.path.join(folder, 'data/zabbix_agentd.conf') file = open(filename, 'r') f = file.read() with patch('pyzabbix.sender.open', mock_open(read_data=f)): zs = ZabbixSender(use_config=True) self.assertEqual(zs.zabbix_uri, [('192.168.1.2', 10051)]) file.close()
def __init__(self, config, config_name, resources, resources_excluded, resources_excluded_web, resources_excluded_zabbix, discovery_interval, data_resend_interval): self.manage_threads = [] self.logger = logging.getLogger(self.__class__.__name__) self.config_name = config_name self.discovery_interval = int(discovery_interval) self.data_resend_interval = int(data_resend_interval) self.api_zabbix_interval = 60 self.rate_limit_seconds = 30 self.api_configuration = client.Configuration() self.api_configuration.host = config.k8s_api_host self.api_configuration.verify_ssl = str2bool(config.verify_ssl) self.api_configuration.api_key = { "authorization": "Bearer " + config.k8s_api_token } # K8S API self.debug_k8s_events = False self.api_client = client.ApiClient(self.api_configuration) self.core_v1 = KubernetesApi(self.api_client).core_v1 self.apps_v1 = KubernetesApi(self.api_client).apps_v1 self.extensions_v1 = KubernetesApi(self.api_client).extensions_v1 self.zabbix_sender = ZabbixSender(zabbix_server=config.zabbix_server) self.zabbix_resources = CheckKubernetesDaemon.exclude_resources( resources, resources_excluded_zabbix) self.zabbix_host = config.zabbix_host self.zabbix_debug = str2bool(config.zabbix_debug) self.zabbix_single_debug = str2bool(config.zabbix_single_debug) self.zabbix_dry_run = str2bool(config.zabbix_dry_run) self.web_api_enable = str2bool(config.web_api_enable) self.web_api_resources = CheckKubernetesDaemon.exclude_resources( resources, resources_excluded_web) self.web_api_host = config.web_api_host self.web_api_token = config.web_api_token self.web_api_cluster = config.web_api_cluster self.web_api_verify_ssl = str2bool(config.web_api_verify_ssl) self.resources = CheckKubernetesDaemon.exclude_resources( resources, resources_excluded) init_msg = "INIT K8S-ZABBIX Watcher\n<===>\n" \ "K8S API Server: %s\n" \ "Zabbix Server: %s\n" \ "Zabbix Host: %s\n" \ "Resources watching: %s\n" \ "web_api_enable => %s (resources: %s)\n" \ "web_api_host => %s\n" \ "<===>" \ % (self.api_configuration.host, config.zabbix_server, self.zabbix_host, ",".join(self.resources), self.web_api_enable, ",".join(self.web_api_resources), self.web_api_host) self.logger.info(init_msg)
def main(): token = Token() client = OpenstackClient(session_auth=token.session_auth) packet_vms = check_vms(client) packet_volumes = check_volumes(client) packet.extend(packet_vms) packet.extend(packet_volumes) result = ZabbixSender(zserver, port, use_config=None).send(packet) return result
def test_recive(self, mock_socket): mock_data = b'\x01\\\x00\x00\x00\x00\x00\x00\x00' mock_socket.recv.side_effect = (False, b'ZBXD', mock_data) zs = ZabbixSender() result = zs._receive(mock_socket, 13) self.assertEqual(result, b'ZBXD' + mock_data) self.assertEqual(mock_socket.recv.call_count, 3) mock_socket.recv.assert_has_calls([call(13), call(13), call(9)])
def send_metric(self, hostname, key, data): zm = ZabbixMetric(hostname, key, data) if self.send_aggregated_metrics: self.aggregated_metrics.append(zm) if len(self.aggregated_metrics) > self.metrics_chunk_size: self.logger.info("Sending: %s metrics" % (len(self.aggregated_metrics))) try: ZabbixSender(zabbix_server=self.sender_host, zabbix_port=self.sender_port).send(self.aggregated_metrics) self.aggregated_metrics = [] except Exception as e: self.logger.exception(e) pass else: try: ZabbixSender(zabbix_server=self.sender_host, zabbix_port=self.sender_port).send(zm) except Exception as e: self.logger.exception(e) pass