You can get python web crawler, data analysis, machine learning, big data and other learning materials. Looking forward to your joining us! If you have any suggestions, please leave a message

Today, I had an idea to check the load of each hardware of the server. However, using Linux commands such as free and top, I could see a pile of data intelligently and could not visually display the network, memory and memory usage

So, after researching, I found a useful tool: PyDash

Pydash is a Performance monitoring tool based on Python and Django. It can run on mainstream Linux distributions such as centos and Ubuntu to collect statistics on server resources and monitor server performance

Results show

Without further ado, here are some pictures to see the effect:




Honestly, the effect is ok

The installation process

Recommended initial installation, please try to achieve on the test machine

1. Clone PyDash locally using Git

You are assumed to have Git and Python installed (either python2.x or python3.x)

Clone PyDash to local

git clone https://gitlab.com/k3oni/pydash.git

cd pydash

Copy the code

Display result:

Is cloning to'pydash'.

remote: Enumerating objects: 1230, done.

remote: Counting objects: 100% (1230/1230), done.

remote: Compressing objects: 100% (588/588), done.

remote: Total 1230 (delta 625), reused 1230 (delta 625)

Receiving object: 100% (1230/1230), 1.25 MiB | 683.00 KiB/s,done.

Processing delta: 100% (625/625),done.

Copy the code

2. Create a virtual environment

To avoid conflicts with the existing environment on the server, create a virtual environment. All operations are performed in the virtual environment

pip install virtualenv

virtualenv pydashtest

Copy the code

To create a python2.7 virtual environment, run the following command:

virtualenv pydashtest --python=python2.7

Copy the code

At this point, the virtual environment PyDashTest is created

Using base prefix '/usr/local'

New python executable in /home/jh/pydash/pydashtest/bin/python36.

Also creating executable in /home/jh/pydash/pydashtest/bin/python

Installing setuptools, pip, wheel...

done.

Copy the code

3. Activate the virtual environment

source pydashtest/bin/activate

Copy the code

You’ll notice that the shell interface has changed:

(pydashtest) [jh@localhost pydash]$

You have entered the virtual environment. To exit the virtual environment, run the following command

deactivate

Copy the code

You can quit

4. Install django

Since PyDash is based on Python and Django, django needs to be installed

There are two ways to install pyDash directly using the requirements. TXT file under PyDash

pip install -r requirements.txt

Copy the code

Django 1.6.8 is installed. If Python is later than 3.5, youll get the following error when using django commands to create projects:

Traceback (most recent call last) :

  File "manage.py", line 10.in <module>

    execute_from_command_line(sys.argv)

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/core/management/set p y", line 399.in execute_from_command_line

    utility.execute()

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/core/management/set p y", line 392.in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/core/management/set p y", line 261.in fetch_command

    commands = get_commands()

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/core/management/set p y", line 107.in get_commands

    apps = settings.INSTALLED_APPS

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/conf/set p y", line 54.in __getattr__

    self._setup(name)

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/conf/set p y", line 50.in _setup

    self._configure_logging()

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/conf/set p y", line 72.in _configure_logging

    from django.utils.log import DEFAULT_LOGGING

  File "/ home/jh pydash/pydashtest/lib/python3.6 / site - packages/django/utils/the py." ", line 7.in <module>

    from django.views.debug import ExceptionReporter, get_exception_reporter_filter

  File "/ home/jh pydash/pydashtest/lib/python3.6 / site - packages/django/views/debug. Py." ", line 12.in <module>

    from django.template import Template.Context, TemplateDoesNotExist

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django template/set p y", line 53.in <module>

    from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,

  File "/ home/jh pydash/pydashtest/lib/python3.6 / site - packages/django template/base. Py." ", line 19.in <module>

    from django.utils.html import escape

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/utils/HTML py." ", line 14.in <module>

    from .html_parser import HTMLParser, HTMLParseError

  File "/ home/jh/pydash/pydashtest/lib/python3.6 / site - packages/django/utils/html_parser py." ", line 12.in <module>

    HTMLParseError = _html_parser.HTMLParseError

AttributeError: module 'html.parser' has no attribute 'HTMLParseError'

Copy the code

The reason:

HTMLParseError is deprecated from Python 3.3 and removed in Python 3.5.

Solutions:

  1. Reduce the python version
  2. Upgrade your Django version

Using the second option, installing a later version of Django is the quickest and most convenient way

pip install django==1.8

Copy the code

5. Create the project database and install Django authentication

python manage.py syncdb

Copy the code

Enter user information:

Operations to perform:

  Synchronize unmigrated apps: staticfiles, messages

  Apply all migrations: contenttypes, sessions, auth

Synchronizing apps without migrations:

  Creating tables...

    Running deferred SQL...

  Installing custom SQL...

Running migrations:

  Rendering model states... DONE

  Applying contenttypes.0001_initial... OK

  Applying contenttypes.0002_remove_content_type_name... OK

  Applying auth.0001_initial... OK

  Applying auth.0002_alter_permission_name_max_length... OK

  Applying auth.0003_alter_user_email_max_length... OK

  Applying auth.0004_alter_user_username_opts... OK

  Applying auth.0005_alter_user_last_login_null... OK

  Applying auth.0006_require_contenttypes_0002... OK

  Applying sessions.0001_initial... OK



You have installed Django's auth system, and don't have any superusers defined.

Would you like to create one now? (yes/no): yes

Username (leave blank to use 'jh') :

Email address: linupy@163.com

Password:

Password (again):

Superuser created successfully.

Copy the code

Username and Password are the Username and Password for logging in to the monitoring system

6. Start the service (background)

After the above steps are correct, you can start the service, which is run in the background

nohup python ./manage.py runserver 192.168.0.3:8000 &

Copy the code

Results:

Performing system checks...



System check identified no issues (0 silenced).

April 03.2019 - 00:58:37

Django version 1.8.using settings 'pydash.settings'

Starting development server at http: / /192.168. 03.:8000/

Quit the server with CONTROL-C.

Copy the code

Enter 192.168.0.3:8000 in the browser to enter the user login page


Enter the user name and password set in step 5 to log in to the system

Focus on me and don’t get lost

The following is the qr code picture of my official account, welcome to follow.