Psdash主机监控面板

简介

官方发布地址: https://github.com/wenguonideshou/psdash_HTTPBasicAuth

简介:在psdash的基础上添加httpbasicauth(也就是打开页面弹出提示框,要输入用户名密码),界面翻译为中文,增加展示所有节点基本状态的主界面,可以理解为psdash的中文版分支

功能:psdash是基于psutil、zerorpc的python语言开发的主机监控面板,本分支包含psdash的所有功能—支持多节点/集群部署,所有数据每3秒自动更新,无需手动刷新页面;

总览页:支持查看 cpu, disks, network, users, memory, swap , network
进程:进程列表,并展示每个进程详情,包括打开的文件数、打开的连接数、内存占用、子进程、资源限制
硬盘:所有硬盘和分区
网络:所有网络接口和使用的流量,以及当前的网络连接
日志:展现自定义的日志文件详情,并支持搜索文件内容

安装

Debian/Ubuntu:

apt-get install build-essential python-dev -y

apt-get install python-setuptools  -y

pip install psdash --allow-external argparse

如果上面的命令安装不成功则执行下面的命令

git clone https://github.com/Jahaja/psdash.git 

cd psdash 

pip install -U setuptools  若报错 先执行 apt-get install python-pip

python setup.py install

RHEL (Fedora, CentOS):

节点和agent节点都执行下面的命令(安装psdash)

yum groupinstall "Development Tools"  -y

yum install python-devel  -y

yum install python-setuptools  -y

git clone https://github.com/Jahaja/psdash.git

cd psdash

pip install -U setuptools 若报错 先执行 yum install -y python-pip

pip install -U setuptools

python setup.py install

主节点执行

pip install flask-httpauth
git clone https://github.com/wenguonideshou/psdash_HTTPBasicAuth.git
cd psdash_HTTPBasicAuth
python run.py -l '/var/log/**/*.log'

如何修改参数?

在run.py的app=Flask(name)下面添加如下语句:

app.config.xxx = yyy

xxx为下面的参数,yyy为值,比如:

app.config.PSDASH_ALLOWED_REMOTE_ADDRESSES = "10.0.0.2, 192.29.20.2"
app.config.PSDASH_URL_PREFIX = "/psdash"
app.config.PSDASH_LOG_LEVEL = logging.INFO
app.config.PSDASH_LOG_LEVEL = "%(levelname)s"
app.config.PSDASH_NODES = [{'name': 'mywebnode', 'host': '10.0.0.2', 'port': 5000}]
app.config.PSDASH_NET_IO_COUNTER_INTERVAL = 3
app.config.PSDASH_LOGS_INTERVAL = 60
app.config.PSDASH_REGISTER_INTERVAL = 60
app.config.PSDASH_LOGS    = ['/var/log/*.log']
app.config.PSDASH_REGISTER_TO = 'http://10.0.20.2:5000'
app.config.PSDASH_REGISTER_AS = 'myvps'
app.config.PSDASH_HTTPS_KEYFILE = '/home/user/private.key'
app.config.PSDASH_HTTPS_CERTFILE    = '/home/user/certificate.crt'
app.config.PSDASH_ENVIRON_WHITELIST = ['HOME']

本次主节点为192.168.2.3,添加内容如下

app.config.PSDASH_URL_PREFIX = "/psdash"
app.config.PSDASH_LOG_LEVEL = logging.INFO
app.config.PSDASH_LOG_LEVEL = "%(levelname)s"
app.config.PSDASH_NODES = [{'HOME': 'mywebnode', 'host': '192.168.2.3', 'port': 5000}]
app.config.PSDASH_NET_IO_COUNTER_INTERVAL = 3
app.config.PSDASH_LOGS_INTERVAL = 60
app.config.PSDASH_REGISTER_INTERVAL = 60
app.config.PSDASH_LOGS  = ['/var/log/*.log']
app.config.PSDASH_REGISTER_TO = 'http://192.168.2.3:5000'
app.config.PSDASH_REGISTER_AS = 'myvps'

详细参数详见:https://github.com/Jahaja/psdash#configuration

开机启动

#创建screen.sh 
#!/bin/bash
cd /root/psdash_HTTPBasicAuth
screen -dmS psdash python run.py -l '/var/log/**/*.log'
chmod +x screen.sh
#添加开机启动
vi /etc/rc.d/rc.local    
#在最后一行添加如下字段
sh /root/psdash/psdash_HTTPBasicAuth/screen.sh

#赋予可执行权限
chmod +x /etc/rc.d/rc.local
#然后重启
reboot

修改用户名密码

修改web.py里的users = {“admin”: “admin”,} 前面是用户名后面是密码,可以添加多个用户

agent节点执行

#在psdash目录下创建screen.sh

#!/bin/bash
cd /root/psdash
screen -dmS psdash psdash -a --register-as woniu -l '/var/log/**/*.log' --register-to http://192.168.2.3:5000

chmod +x screen.sh
#添加开机启动
vi /etc/rc.d/rc.local
在最后一行添加如下字段
sh /root/psdash/screen.sh
#赋予可执行权限
chmod +x /etc/rc.d/rc.local
#然后重启
reboot

内网穿透设置

frpc内网穿透设置(lede 后期会单出教程)

frp内网穿透设置