# Path: mongodb_consistent_backup/Errors.py
# class NotifyError(Error):
#     """Raised when an notify operation failed in an expected but unrecoverable way"""
#     pass
# 
# class OperationError(Error):
#     """Raised when an operation failed in an expected but unrecoverable way"""
#     pass


import logging
import sys
from pyzabbix import ZabbixMetric, ZabbixSender
from mongodb_consistent_backup.Errors import NotifyError, OperationError
from mongodb_consistent_backup.Pipeline import Task
        except Exception, e:
            logging.error("Error initiating ZabbixSender! Error: %s" % e)
            raise OperationError(e)

    def _use_config(self):
        if isinstance(self.use_config, bool):
            return self.use_config
        elif isinstance(self.use_config, str) and self.use_config.strip().lower() != 'false':
            return True
        return False

    def close(self):
        pass

    def run(self, ret_code, message):
        if self.notifier:
            logging.info("Sending Zabbix metric to item '%s:%s' to Zabbix Server" % (
                self.nodename,
                self.key,
            ))
            logging.debug("Zabbix metric return code: '%s', item key: '%s', node name: '%s'" % (ret_code, self.key, self.nodename))

            try:
                metrics = [ZabbixMetric(self.nodename, self.key, ret_code)]
                response = self.notifier.send(metrics)

                if response.failed > 0:
                    raise NotifyError("%s metric(s) failed out of %s" % (response.failed, response.total))
            except Exception, e:
                logging.error("Failed to send Zabbix metric to host" % (sys.exc_info()[1]))

# Path: mongodb_consistent_backup/Errors.py
# class NotifyError(Error):
#     """Raised when an notify operation failed in an expected but unrecoverable way"""
#     pass
# 
# class OperationError(Error):
#     """Raised when an operation failed in an expected but unrecoverable way"""
#     pass


# Path: mongodb_consistent_backup/Notify/Zabbix/Zabbix.py
import logging
import sys
from pyzabbix import ZabbixMetric, ZabbixSender
from mongodb_consistent_backup.Errors import NotifyError, OperationError
from mongodb_consistent_backup.Pipeline import Task

        except Exception, e:
            logging.error("Error initiating ZabbixSender! Error: %s" % e)
            raise OperationError(e)

    def _use_config(self):
        if isinstance(self.use_config, bool):
            return self.use_config
        elif isinstance(self.use_config, str) and self.use_config.strip().lower() != 'false':
            return True
        return False

    def close(self):
        pass

    def run(self, ret_code, message):
        if self.notifier:
            logging.info("Sending Zabbix metric to item '%s:%s' to Zabbix Server" % (
                self.nodename,
                self.key,
            ))
            logging.debug("Zabbix metric return code: '%s', item key: '%s', node name: '%s'" % (ret_code, self.key, self.nodename))

            try:
                metrics = [ZabbixMetric(self.nodename, self.key, ret_code)]
                response = self.notifier.send(metrics)

                if response.failed > 0:
                    raise NotifyError("%s metric(s) failed out of %s" % (response.failed, response.total))
            except Exception, e:
                logging.error("Failed to send Zabbix metric to host" % (sys.exc_info()[1]))

                raise NotifyError(e)