Chapter 3. Djagios – a Nagios Clone in Django

In this chapter, we'll be creating a server status monitoring solution similar to Nagios. It is understandable if you have never heard of Nagios as it is not something that comes up in day-to-day conversations between web developers. In a nutshell, Nagios can tell you the status of your servers (which can be in the thousands) in one screen. You can configure alerts based on conditions, for example, if some critical server becomes unresponsive, so that you can be on top of problems before your users start to notice any service degradation. Nagios is an amazing piece of software that is used by millions of organizations around the world.

Our goal in this chapter is to create something similar, albeit very simple. Our Nagios clone, creatively named Djagios, will allow users to set up monitoring for simple stats from their servers. We will allow the monitoring of the following:

  • System load
  • Disk usage

We will also be developing a web page where this data will be shown to the user in a nice tabular format. The user will also see an overview of how their servers are doing, and if any alerts are active on those systems.

Here are some of the things that we will be looking at in this chapter:

  • What Django management commands are and how to create a custom one
  • Using the Django shell to test out small pieces of code quickly
  • Complicated validation of Django Model fields
  • Slightly more complicated uses of the built-in generic views
  • Creating an API endpoint to accept data from external sources
  • Securing these API endpoints with simple shared secret keys
  • Testing API endpoints using simple tools

Code pack

This chapter's code pack has a basic Django application setup with a SQLite database already configured. However, there isn't much code in the code pack because this chapter did not require user accounts or any other pre-existing setup. You can unzip the code pack, create a new virtual environment, activate it, and run the following commands from within the code folder to get up and running:

> pip install django
> python manage.py migrate
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.239.182