def propagate_status(sender, **kwargs): if not settings.PROPAGATE_STATUS_TO_NAGIOS: return if kwargs['raw']: return status = kwargs['instance'] task = status.task_check.task if hasattr(task, 'backuptask'): nsca = NSCA() status_code = HUMAN_TO_NAGIOS[status.status] nsca.add_custom_status(task.backuptask.machine.fqdn, nagios_safe(task.description), status_code, status.comment) nsca.send()
def refresh_nagios_status(request): logger.debug("Refreshing nagios status") nsca = NSCA() for bt in BackupTask.objects.filter(active=True, machine__up=True): try: tch = TaskCheck.objects.filter(task=bt).order_by("-task_time")[0] except IndexError: logger.debug("There is no TaskCheck for %s", bt) continue status = tch.get_status() if isinstance(status, TaskStatus): logger.debug("Last status for %s: %s is %s (%s)", bt, bt.description, status, status.check_time) nsca.add_custom_status( bt.machine.fqdn, nagios_safe(bt.description), HUMAN_TO_NAGIOS[status.status], status.comment ) nsca.send() logger.debug("Nagios status updated for %s", bt) return HttpResponse("Nagios up to date")
def refresh_nagios_status(request): logger.debug('Refreshing nagios status') nsca = NSCA() for bt in BackupTask.objects.filter(active=True, machine__up=True): try: tch = TaskCheck.objects.filter(task=bt).order_by('-task_time')[0] except IndexError: logger.debug('There is no TaskCheck for %s', bt) continue status = tch.get_status() if isinstance(status, TaskStatus): logger.debug('Last status for %s: %s is %s (%s)', bt, bt.description, status, status.check_time) nsca.add_custom_status(bt.machine.fqdn, nagios_safe(bt.description), HUMAN_TO_NAGIOS[status.status], status.comment) nsca.send() logger.debug('Nagios status updated for %s', bt) return HttpResponse("Nagios up to date")