The python programming language is very useful to system administrators as it offers rapid development and one can easily write scripts in a very short time to automate daily tasks. There are many python tools for linux system admins out there, one of them is pyDash which is a small web-based monitoring dashboard for linux in python and django.
I really like using pyDash as it gives me information about my linux system such as cpu usage, memory usage, internet traffic, ip addresses, disk usage, processes currently running, users and general info like the name and version of Operating System being used. In the general info tab you can also learn about the CPUs and uptime.
In short words the pyDash app helps the linux user to monitor servers. According to the official author on his github page the app supports the following OSes:
- Arch Linux
A very cool feature pyDash has is the ability to retrieve data remotely in JSON format which can be easily retrieved as long as the user agent has been authenticated by the web application.
How to install pyDash using django development server
What is django
Django is a free opensource web application development framework built in Python programming language by some developers during their work at a local newspaper. It focuses on rapid development, pragmatic design and follows the DRY(Do not repeat yourself philosophy).
I am not going to explain how django works in this tutorial but only teach you how to install it for running pyDash on your local linux machine.
Note: Make sure if you have installed git on your system. You can read some tutorial on google on how to install it for your linux distro.
Now open your terminal and run the following command to clone the pyDash repository from github on your local machine.
git clone of pydash
Now that you have finished cloning the repo we need to install the following tools:
What is pip
pip is a commandline tool which is used to easily install and manage python packages in your machine.
Ubuntu and Debian users can install pip using the following command.
sudo apt-get install pip
RHEL, CentOS and Fedora users can install pip on their machine using the following command.
sudo yum -y install python-pip
What is virtualenv
virtualenv is the perfect tool when it comes to solving dependecy problems in your python projects. This tool creates virtual environments on your machine allowing the user to keep the dependencies required by different projects in separate places.
For example project x uses django 1.6.x but your boss is asking you to work on project y where django 1.7.x needs to be used. What is your solution to this problem? Which version of django are you going to keep?
virtualenv is the solution. Now that you have pip installed on your machine you can easily install it by typing the following command on your terminal.
pip install virtualenv
I get the following output when running the above command on my machine because I have already installed virtualenv on my machine.
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages
Finally you have finished with installing new tools on your system.
Change directory to pydash using the cd command.
My pydash is located on my Desktop folder so I type the following command to cd there.
The next step consists in creating a virtual environment for our project with the help of the virtualenv.
Use the following command to do this. You can name the virtual environment you are creating anything you want but I personally like to name it pydashvenv.
Then we need to activate our virtual environment using the following command.
If after running the above command the output on your console looks like the following it means the virtual environment is activated and it is ready for you to work on it.
Now install the requirements of your project by using the following command. It look for a file called requirements.txt in your project. This is the file where the developer defines the packages which are required to run the project.
Install requirements for the project
pip install -r requirements.txt
If you do cat requirements.txt you will see the following output.
So it is very easy to understand that pip installed django 1.6.8 on the virtual environment you created with virtualenv. Yes you can install other packages but we don't need them for this project.
If you want to verify that django 1.6.8 is installed on your machine then fire up a python interpreter and run the following commands.
Everything should be ok if the following is displayed on your console.
Configure and run this django project
On your pydash directory do cd pydash and open settings.py file and look for a string called SECRET_KEY like shown in the following screenshot.
Make sure you change the secret key and please keep it secret as it should be.
Run the following django command.
python manage.py syncdb
Make sure to select yes when it asks you if you want to create a superuser or no. Then run the app with the following command.
python manage.py runserver
Got and visit
Type the username and password that you created with the superuser.
Then the following will appear.