zoukankan      html  css  js  c++  java
  • Django开发Web监控工具-pyDash

      今天发现了一个比较有意思的监控工具,是基于Django开发的,开发大牛已经开放了源代码,向大牛致敬,同时研究研究,目前感觉这个监控比较直观,可以针对个人服务器使用,同时涉及的环境比较简单,部署起来很方便。

    安装pyDash

    安装python、pip、git

      首先工具是基于python开发的,所以我们需要python以及pip工具,简单的是,一般情况下我们的服务器在安装系统时就已经安装好python2.x环境了,python2.x已经完全可以支撑此监控工具的运行了,所以这点我们不需要担心太多,安装git是因为我们需要克隆源码。
    yum -y install epel-release python pip git

    克隆pyDash源码

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

    安装相应版本的Django

      不难理解,因为是基于Django开发,所以我们必须有相应的环境,才能支持软件的运行。
    cd pydash
    pip install -r requirements.txt

    需要相应的Django版本号,作者已经写入requirements.txt配置文件,我们只需要使用pip指定文件进行安装即可。

    修改加密文件

    vi pydash/settings.py

    """
    Django settings for pydash project.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/1.6/topics/settings/
    
    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/1.6/ref/settings/
    """
    
    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    import os
    
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
    # SITE_ID = 1
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '111aaa...'
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = False
    
    TEMPLATE_DEBUG = False
    
    ADMINS = (
    )
    
    MANAGERS = ADMINS
    
    #All refresh values are in miliseconds, 1 second = 1000 miliseconds
    #Adjust accordingly as you wish
    TIME_JS_REFRESH = 30000
    TIME_JS_REFRESH_LONG = 120000
    TIME_JS_REFRESH_NET = 2000
    
    VERSION = "1.4.6"
    
    ALLOWED_HOSTS = ['*']
    
    
    # Application definition
    
    INSTALLED_APPS = (
        #'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        #'django.contrib.sites',
        'django.contrib.staticfiles',
    )
    
    MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )
    
    ROOT_URLCONF = 'pydash.urls'
    
    WSGI_APPLICATION = 'pydash.wsgi.application'
    
    
    # Database
    # https://docs.djangoproject.com/en/1.6/ref/settings/#databases
    
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3')
        }
    }
    
    # Internationalization
    # https://docs.djangoproject.com/en/1.6/topics/i18n/
    
    LANGUAGE_CODE = 'en-us'
    
    TIME_ZONE = 'UTC'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    
    TEMPLATE_LOADERS = (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
        # 'django.template.loaders.eggs.Loader',
    )
    
    TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
    
    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/1.6/howto/static-files/
    
    STATIC_ROOT = os.path.join(os.path.dirname(__file__), '..', 'static')
    STATIC_URL = '/static/'
    
    STATICFILES_DIRS = (
    )
    
    STATICFILES_FINDERS = (
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        #'django.contrib.staticfiles.finders.DefaultStorageFinder',
    )
    
    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'filters': {
            'require_debug_false': {
                '()': 'django.utils.log.RequireDebugFalse'
            }
        },
        'handlers': {
            'mail_admins': {
                'level': 'ERROR',
                'filters': ['require_debug_false'],
                'class': 'django.utils.log.AdminEmailHandler'
            }
        },
        'loggers': {
            'django.request': {
                'handlers': ['mail_admins'],
                'level': 'ERROR',
                'propagate': True,
            },
        }
    }
    
    try:
        from local_settings import *
    except ImportError:
        pass
    

      修改配置文件中SECRET_KEY = '111aaa...'配置即可,修改后保存退出。

    创建管理员账户

    python manage.py syncdb

    Creating tables ...
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_groups
    Creating table auth_user_user_permissions
    Creating table auth_user
    Creating table django_content_type
    Creating table django_session
    
    You just installed Django's auth system, which means you don't have any superusers defined.
    Would you like to create one now? (yes/no): yes
    Username (leave blank to use 'root'): admin
    Email address: federicosun@163.com
    Password:
    Password (again):
    Superuser created successfully.
    Installing custom SQL ...
    Installing indexes ...
    Installed 0 object(s) from 0 fixture(s)
    

      根据相关提示设置即可。

    启动pyDash服务

    nohup python manage.py runserver 0.0.0.0:1234 &

    查看展示界面

      使用我们刚刚设置的账号密码进行登录。

      麻雀虽小五脏俱全,向大牛学习,争取自己早日可以自己编出实用程序。

  • 相关阅读:
    最少必要知识
    pythonGUI编程
    计算机网络基础
    .htaccess总结
    SSRF总结
    jsp学习笔记
    url任意跳转漏洞
    学期总结
    计科一班本学期作业成绩汇总表格
    C语言I博客作业08
  • 原文地址:https://www.cnblogs.com/Cherry-Linux/p/9555812.html
Copyright © 2011-2022 走看看