Esempio n. 1
0
    def daily_audit_report(self, audit_date):

        logger.info("PlanAuditor: Generating %s audit report for '%s'" %
                    (TYPE_PLAN_AUDIT,  datetime_to_string(audit_date)))

        audit_end_date = date_plus_seconds(audit_date, 3600 * 24)
        all_plans_report = AuditReport()
        all_plans_report.audit_date = audit_date
        all_plans_report.audit_type = TYPE_PLAN_AUDIT

        total_plans = 0
        failed_plan_reports = []
        all_warned_audits = []
        total_warnings = 0
        for plan in get_mbs().plan_collection.find():
            # skip recently added plans whose created date is after audit date
            # and their next occurrence is not in auditing range
            if (plan.created_date > audit_date and plan.next_occurrence and
                plan.next_occurrence > audit_end_date) :
                logger.info("PlanAuditor: Skipping auditing plan '%s' since"
                            " its created date '%s' is later than audit date "
                            "'%s'" % (plan.id,
                                      datetime_to_string(plan.created_date),
                                      datetime_to_string(audit_date)))
                continue

            plan_report = self._create_plan_audit_report(plan, audit_date)

            if plan_report.has_failures():
                failed_plan_reports.append(plan_report)
            if plan_report.has_warnings():
                # only append to warned audits if report doesn't have failures
                if not plan_report.has_failures():
                    all_warned_audits.extend(plan_report.warned_audits)

                total_warnings += 1

            total_plans += 1

        total_failures = len(failed_plan_reports)

        if failed_plan_reports:
            all_plans_report.failed_audits = failed_plan_reports
        if all_warned_audits:
            all_plans_report.warned_audits = all_warned_audits

        all_plans_report.total_audits = total_plans
        all_plans_report.total_failures = total_failures
        all_plans_report.total_success = total_plans - total_failures
        all_plans_report.total_warnings = total_warnings

        logger.info("PlanAuditor: Generated report:\n%s " % all_plans_report)

        return all_plans_report
Esempio n. 2
0
    def _send_audit_report(self, auditor, report):
        subject = ("%s Audit Report for %s" %
                   (auditor.name, datetime_to_string(report.audit_date)))

        message = report.summary()
        get_mbs().notifications.send_notification(subject, message,
                                                  notification_type="audit")
Esempio n. 3
0
    def _send_audit_report(self, auditor, report):
        subject = ("%s Audit Report for %s" %
                   (auditor.name, datetime_to_string(report.audit_date)))

        message = report.summary()
        get_mbs().notifications.send_notification(subject,
                                                  message,
                                                  notification_type="audit")
Esempio n. 4
0
    def daily_audit_report(self, audit_date):

        logger.info("PlanScheduleAuditor: Generating %s audit report for '%s'"
                    % (TYPE_PLAN_AUDIT,  datetime_to_string(audit_date)))

        audit_end_date = date_plus_seconds(audit_date, 3600 * 24)
        all_plans_report = PlanScheduleAuditReport()
        all_plans_report.audit_date = audit_date
        all_plans_report.audit_type = TYPE_PLAN_AUDIT

        total_plans = 0
        failed_plan_reports = []
        all_warned_audits = []
        total_warnings = 0
        for plan in get_mbs().plan_collection.find_iter(no_cursor_timeout=True):
            logger.info("PlanScheduleAuditor: Processing plan %s" % plan.id)
            plan_report = self._create_plan_audit_report(plan, audit_date)

            if plan_report.has_failures():
                failed_plan_reports.append(plan_report)
            if plan_report.has_warnings():
                # only append to warned audits if report doesn't have failures
                if not plan_report.has_failures():
                    all_warned_audits.extend(plan_report.warned_audits)

                total_warnings += 1

            total_plans += 1

        total_failures = len(failed_plan_reports)

        if failed_plan_reports:
            all_plans_report.failed_audits = failed_plan_reports
        if all_warned_audits:
            all_plans_report.warned_audits = all_warned_audits

        all_plans_report.total_audits = total_plans
        all_plans_report.total_failures = total_failures
        all_plans_report.total_success = total_plans - total_failures
        all_plans_report.total_warnings = total_warnings

        logger.info("PlanScheduleAuditor: Generated report:\n%s " %
                    all_plans_report)

        # alert if failed audits are >= max allowed percent of total
        if float(total_failures) / total_plans > self.max_allowed_failures_percentage:
            subject = "%s Auditor Failure: Too many failures!!!" % self.name
            msg = "There are %s failures out of %s which is > %s%%" % (total_failures, total_plans,
                                                                       self.max_allowed_failures_percentage * 100)
            logger.error(subject)
            logger.error(msg)
            get_mbs().notifications.send_event_notification(subject, msg, priority=NotificationPriority.CRITICAL)
        else:
            logger.info("NO ALERT for %s Auditor: There are %s failures out of %s which is < %s%%" %
                        (self.name,total_failures, total_plans, self.max_allowed_failures_percentage * 100))

        return all_plans_report
Esempio n. 5
0
    def audit_report(self, audit_date):

        logger.info(
            "PlanRetentionAuditor: Generating %s audit report for "
            "'%s'" %
            (TYPE_PLAN_RETENTION_AUDIT, datetime_to_string(audit_date)))

        all_plans_report = PlanScheduleAuditReport()
        all_plans_report.audit_date = audit_date
        all_plans_report.audit_type = TYPE_PLAN_RETENTION_AUDIT

        total_plans = 0
        failed_plan_reports = []
        all_warned_audits = []
        total_warnings = 0

        for plan in get_mbs().plan_collection.find_iter(
                no_cursor_timeout=True):
            logger.info("=== Processing Plan '%s'..." % plan.id)
            if not plan.retention_policy:
                logger.warning("Plan '%s' has not retention policy! "
                               "Skipping..." % plan.id)
                continue

            plan_report = self._create_plan_audit_report(plan, audit_date)

            if plan_report.has_failures():
                failed_plan_reports.append(plan_report)
            if plan_report.has_warnings():
                # only append to warned audits if report doesn't have failures
                if not plan_report.has_failures():
                    all_warned_audits.extend(plan_report.warned_audits)

                total_warnings += 1

            total_plans += 1

        total_failures = len(failed_plan_reports)

        if failed_plan_reports:
            all_plans_report.failed_audits = failed_plan_reports
        if all_warned_audits:
            all_plans_report.warned_audits = all_warned_audits

        all_plans_report.total_audits = total_plans
        all_plans_report.total_failures = total_failures
        all_plans_report.total_success = total_plans - total_failures
        all_plans_report.total_warnings = total_warnings

        logger.info("PlanRetentionAuditor: Generated report:\n%s " %
                    all_plans_report)

        return all_plans_report
Esempio n. 6
0
    def audit_report(self, audit_date):

        logger.info("PlanRetentionAuditor: Generating %s audit report for "
                    "'%s'" % (TYPE_PLAN_RETENTION_AUDIT,
                              datetime_to_string(audit_date)))

        all_plans_report = PlanScheduleAuditReport()
        all_plans_report.audit_date = audit_date
        all_plans_report.audit_type = TYPE_PLAN_RETENTION_AUDIT

        total_plans = 0
        failed_plan_reports = []
        all_warned_audits = []
        total_warnings = 0

        for plan in get_mbs().plan_collection.find_iter(no_cursor_timeout=True):
            logger.info("=== Processing Plan '%s'..." % plan.id)
            if not plan.retention_policy:
                logger.warning("Plan '%s' has not retention policy! "
                               "Skipping..." % plan.id)
                continue

            plan_report = self._create_plan_audit_report(plan, audit_date)

            if plan_report.has_failures():
                failed_plan_reports.append(plan_report)
            if plan_report.has_warnings():
                # only append to warned audits if report doesn't have failures
                if not plan_report.has_failures():
                    all_warned_audits.extend(plan_report.warned_audits)

                total_warnings += 1

            total_plans += 1

        total_failures = len(failed_plan_reports)

        if failed_plan_reports:
            all_plans_report.failed_audits = failed_plan_reports
        if all_warned_audits:
            all_plans_report.warned_audits = all_warned_audits

        all_plans_report.total_audits = total_plans
        all_plans_report.total_failures = total_failures
        all_plans_report.total_success = total_plans - total_failures
        all_plans_report.total_warnings = total_warnings

        logger.info("PlanRetentionAuditor: Generated report:\n%s " %
                    all_plans_report)

        return all_plans_report
Esempio n. 7
0
 def _send_notification(self, date, reports):
     subject = "Backup Audit Reports for %s" % datetime_to_string(date)
     reports_str = map(str, reports)
     message = "\n\n\n".join(reports_str)
     self._notification_handler.send_notification(subject, message)
Esempio n. 8
0
    def daily_audit_report(self, audit_date):

        logger.info(
            "PlanScheduleAuditor: Generating %s audit report for '%s'" %
            (TYPE_PLAN_AUDIT, datetime_to_string(audit_date)))

        audit_end_date = date_plus_seconds(audit_date, 3600 * 24)
        all_plans_report = PlanScheduleAuditReport()
        all_plans_report.audit_date = audit_date
        all_plans_report.audit_type = TYPE_PLAN_AUDIT

        total_plans = 0
        failed_plan_reports = []
        all_warned_audits = []
        total_warnings = 0
        for plan in get_mbs().plan_collection.find_iter(
                no_cursor_timeout=True):
            plan_report = self._create_plan_audit_report(plan, audit_date)

            if plan_report.has_failures():
                failed_plan_reports.append(plan_report)
            if plan_report.has_warnings():
                # only append to warned audits if report doesn't have failures
                if not plan_report.has_failures():
                    all_warned_audits.extend(plan_report.warned_audits)

                total_warnings += 1

            total_plans += 1

        total_failures = len(failed_plan_reports)

        if failed_plan_reports:
            all_plans_report.failed_audits = failed_plan_reports
        if all_warned_audits:
            all_plans_report.warned_audits = all_warned_audits

        all_plans_report.total_audits = total_plans
        all_plans_report.total_failures = total_failures
        all_plans_report.total_success = total_plans - total_failures
        all_plans_report.total_warnings = total_warnings

        logger.info("PlanScheduleAuditor: Generated report:\n%s " %
                    all_plans_report)

        # alert if failed audits are >= max allowed percent of total
        if float(total_failures
                 ) / total_plans > self.max_allowed_failures_percentage:
            subject = "%s Auditor Failure: Too many failures!!!" % self.name
            msg = "There are %s failures out of %s which is > %s%%" % (
                total_failures, total_plans,
                self.max_allowed_failures_percentage * 100)
            logger.error(subject)
            logger.error(msg)
            get_mbs().notifications.send_event_notification(
                subject, msg, priority=NotificationPriority.CRITICAL)
        else:
            logger.info(
                "NO ALERT for %s Auditor: There are %s failures out of %s which is < %s%%"
                % (self.name, total_failures, total_plans,
                   self.max_allowed_failures_percentage * 100))

        return all_plans_report