Package: django-kitsune
Author:Raul Garreta - Tryolabs <raul@tryolabs.com>Project Website:https://github.com/tryolabs/django-kitsuneDescriptionA Django Admin app to perform host server monitoring. A control panel will be added to the Admin in order to configure hosts, checks and monitor check results.
Notification rules can be defined to notify administrator users by mail.
All host shall have access to a common database in order to get information about scheduled jobs and check jobs to run.ScreenshotsFeaturesHostsAdd hosts to monitorChecksAdd jobs with checks to be performedScheduleCheck to be performedHost to checkSelect users or groups to be notifiedConfigure notification rulesSelect how to render resultsSet amount of log history to keepCustom ChecksYou can implement your own checks by implementing a subclass ofkitsune.base.BaseKitsuneCheckNagios ChecksA builtin check is provided that wrapps any Nagios check.You can use any existing Nagios check within django-kitsuneLogsLog and list check resultsResult RenderersCan implement renderers by implementing a subclass ofkitsune.renderers.KitsuneJobRendererReturns a html with the corresponding result that will be rendered within result listings.List ChecksHost name, last time performed, last result, next scheduled run.Notification RulesNotifications through e-mail.Configure who to notify: Groups or Users.Configure when to trigger a notification.Configure the frequency of notifications to avoid spam emails :)All configurations are made through a graphic UI within admin panel.RequirementsPython 2.6 and higher.Nagios plugins:sudoapt-getinstallnagios-plugins(if you want to use Nagios checks).InstallationTo install Kitsune:easy_installdjango-kitsuneor download package and executepython setup.py installAdd'kitsune'to theINSTALLED_APPSin your project’ssettings.pyConfigurecronin every host to run a kitsune management command by runningcrontabcommand:* * * * * /path/to/your/project/manage.py kitsune_cronEvery minute cron will run a management command to check pending jobs.
Note that both, django-kitsune and your project must be installed in each host, and each host must have access to the common database (where kitsune tables shall be stored).ConfigurationKitsune can be configured via the following parameters, to be defined in your project settings file:KITSUNE_RENDERERS: List of modules that contain renderer classes, eg::KITSUNE_RENDERERS = ['myproject.myapp.renderers'].Kitsune comes with a default rendererkitsune.renderers.KitsuneJobRenderer.UsageAdd a new HostAdd a Nagios checkFor example, to add a check_disk, do the following steps:Within Admin go to Kitsune -> Jobs -> Add jobFill the necessary fields, eg:Name: check_diskHost: select a job from the comboboxCommand: select nagios wrapper:kitsune_nagios_checkArgs: you must provide a special parametercheckwith the name of the nagios check eg: check=check_disk.Then provide the necessary nagios check arguments, in this case: -u=GB -w=5 -c=2 -p=/
To sum up, the string of arguments will be:check=check_disk-u=GB-w=5-c=2-p=/Select the result Renderer, eg: KitsuneJobRendererConfigure scheduling options, eg: Frequency: Hourly, Params:interval:1.Params are semicolon-separated list ofrruleparameters.This will schedule the check to be run every 1 hour.Configure log options, last logs to keep specifies the last N logs to keep.Configure Notification rules.Every check returns a status code of0=OK, 1=WARNING, 2=CRITICAL ERROR, 3=UNKNOWN ERRORwith its corresponding status message.
With notification rules you must set the:Threshold(the status code to be reached)Rule type:Last time: triggered when last result reached the threshold.N last times: triggered when last N results reached the threshold.M of N last times: triggered when M of the last N results reached the threshold.Rule NandRule Mparameters.Notification frequency:Interval unit,Interval valuesets the maximum frequency to receive email notifications. These are useful to avoid filling admin inbox with notification mails.User/Groupspecifies the users or group of users to be notified. These must be staff users and shall be created within admin.Add a custom checkIn order to implement a custom check, you must implement a class that is subclass ofkitsune.base.BaseKitsuneCheck.Within this class, you must implement the methodcheck(self, *args, **options). For example:from kitsune.renderers import STATUS_OK, STATUS_WARNING, STATUS_CRITICAL, STATUS_UNKNOWN
from kitsune.base import BaseKitsuneCheck

class Command(BaseKitsuneCheck):
    help = 'A simple test check.'

    def check(self, *args, **options):
        self.status_code = STATUS_OK

        if self.status_code == STATUS_OK:
            self.status_message = 'OK message'
        elif self.status_code == STATUS_WARNING:
            self.status_message = 'WARNING message'
        elif self.status_code == STATUS_CRITICAL:
            self.status_message = 'CRITICAL message'
        else:
            self.status_message = 'UNKNOWN message'With*args and **optionsyou will receive the arguments and options set from the Args string.
Modules that implement checks are Django management commands, and must live within management.commands package of an app within your project.Add a custom rendererRenderers are in charge to render the results within the admin panel. They will take the status code and status message and return a html.
If you want to implement your own renderer, you must implement a class that is sublcass ofkitsune.renderers.KitsuneJobRenderer.
You must implement to methods:get_html_status(self, log)that receives a log and and returns a html for status code.get_html_message(self, log)that recevies a log and returns a html for status message.
For example:from django.template.loader import render_to_string
from kitsune.renderers import KitsuneJobRenderer
from kitsune.base import STATUS_OK, STATUS_WARNING, STATUS_CRITICAL, STATUS_UNKNOWN

class MyJobRenderer(KitsuneJobRenderer):

    def get_html_status(self, log):
        return render_to_string('kitsune/status_code.html', dictionary={'status_code':int(log.stderr)})

    def get_html_message(self, log):
        return 'All OK!'Then you must specify where to get this renderer with theKITSUNE_RENDERERSat your project settings (see bellow).AcknowledgmentsKitsune scheduling system is based ondjango-chronograph.