Skip to content

Commit

Permalink
MOD:修改读config静态获取target列表改成由数据库动态发现无需重启,并添加admin后台用于配置target列表并自动动态更新…
Browse files Browse the repository at this point in the history
….修改原版静态文件由cdn改到本地文件.
  • Loading branch information
calmkart committed Aug 9, 2019
1 parent 35b47fd commit 5eed97d
Show file tree
Hide file tree
Showing 73 changed files with 3,166 additions and 188 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "env/bin/python2.7"
}
43 changes: 43 additions & 0 deletions CentOS-Base.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
43 changes: 18 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
# Dockerfile for redispapa
FROM ubuntu:latest

MAINTAINER [email protected]

# Update apt
RUN cp /etc/apt/sources.list /etc/apt/sources.list.backup
COPY sources.list /etc/apt/sources.list
RUN apt-get update

# Install python lib
RUN apt-get install -y --upgrade python-setuptools python-dev build-essential \
&& apt-get install -y --upgrade wget \
&& apt-get install -y unzip \
&& wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py \
&& python get-pip.py \
&& rm -rf get-pip.py

# Download source file
RUN mkdir /root/redispapa
WORKDIR /root/redispapa
FROM centos:centos7.6.1810

ARG VERSION="v0.0.1"

LABEL Description="redispapa sqlite3 version by calmkart" Vendor="[email protected]" Version="${VERSION}"

COPY ./ /root/redispapa/
RUN mkdir /root/.pip

COPY pip.conf /root/.pip/pip.conf
COPY CentOS-Base.repo /etc/yum.repos.d/
COPY ./ /root/redispapa

WORKDIR /root/redispapa

# Install requirements
RUN pip install -r requirements.txt
RUN yum makecache \
&& yum install epel-release -y \
&& yum install -y python2-pip.noarch \
&& yum install -y python-devel gcc \
&& pip install -r /root/redispapa/requirements.txt

EXPOSE 5000

CMD ["python2.7", "/root/redispapa/run.py"]
CMD sh -c "python run.py"
134 changes: 82 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,112 @@
# RedisPAPA
we use `redis info` to monitor the redis usage. PAPA means a father who is monitoring the redis.
> accoding to the [redis doc](http://redis.io/commands/info), it is be recommanded to use `info` other than `monitor`.
> 利用redis的`info`信息对redis的使用情况进行监控。用到的技术:angular flask socket.io. PAPA是Dad的意思。
官方文档推荐使用info,而不是monitor(因为其会大大降低redis的负载)。

================

[![repo](http://ohmyrepo.ml/static/ohmyrepo.png)](http://ohmyrepo.ml/show?u=no13bus&r=redispapa)
## 相较原系统改动
- > 从原系统的读config文件获取监控target列表(静态,需手动修改并重启服务器)切换到sqlite动态发现(通过管理后台变更数据,无需重启)
- > 添加了flask admin管理后台用于动态变更监控target列表
[中文文档](https://github.com/no13bus/redispapa/blob/master/README_CN.md)
### 大致原理
通过定时任务定期查询数据库字段并更新线程列表.数据库动态发现target刷新时间设置为20秒一次,所以添加新target之后前端数据可能会有1-20s的延迟才会刷新.

## Let's start
### 部署方式

- 普通部署:
```shell
pip install -r requirements.txt

python run.py
```

- docker部署:
```shell
docker run -d -p 5000:5000 calmkart/redispapa-sqlite:v0.0.1
```

### 使用方式

监控页面

`http://0.0.0.0:5000/`

后台配置页面

`http://0.0.0.0:5000/admin/redisobj/`

================
# 以下为原系统readme

## 开始使用
- `pip install -r requirements.txt`
- check out the file `config.py` and make your own configure accoding to your redis servers.
- the REDIS_SERVER should be formated like this `['ip:port:password', 'ip:port', .....]`
- type this command `python run.py`, then you can watch it in `http://127.0.0.1:5000`
- we recommand use this command to deploy: `gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker run:app -b 0.0.0.0:5000`

## The tech we use
- [Angular](https://github.com/angular/angular)
- [Flask](https://github.com/mitsuhiko/flask)
- [Socket.io](http://socket.io/)
- [Highchart](http://www.highcharts.com/)

## Demo website
- 配置好config.py内的需要监控的redis服务器的相关信息.
- REDIS_SERVER服务器的类型这样 `['ip:port:pawword', 'ip:port', .....]`
- `python run.py` 即可进行redis服务监控
- 如果线上部署的话,推荐使用gunicorn部署. `gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker run:app -b 0.0.0.0:5000`

## 使用到的技术
- angular
- flask
- socket.io
- highchart

## demo website
http://redispapa.no13bus.com


## Project Details
- we do not use any database to store the redis information, we store the data in the memory.
- we use flask to start serveral threads which is equal to your redis server amount,and then send infomation to the front-end at regular time by socket.io.
- we use angular to render the front-end。angular will get the data from socket.io and then render the templates with highchart-ng and ngSocketIO.
- the good part of angular is two way bindings, when you change the redis server ip in the front-end select element, you will get a new front-end immediately.
## 说明
- 该项目没有使用任何数据库对监控信息进行存储,只是将监控到的前几个数据点保存到了内存中供前台调用。
- flask的后台会开启多个监控redis的线程,定时通过socket.io向前台发送info信息。flask在这个项目里面的主要作用就是socket.io的后台,不会对前台的模板进行渲染。
- angular 承担了主要的前端模板渲染工作。angular会将socket.io接受到的数据利用highchart-ng和ng-socket-io这2个库对前端的图表进行渲染。
- angular 的优点就是双向绑定,在前端切换不同的redis服务器的时候,只需要点选不同的选项,模型随之改变,前端页面就会随之改变。开发过程非常顺畅。

## 截图

## Project Screen
![1](https://raw.githubusercontent.com/no13bus/redispapa/master/screen/1.png)
![2](https://raw.githubusercontent.com/no13bus/redispapa/master/screen/2.png)
![3](https://raw.githubusercontent.com/no13bus/redispapa/master/screen/3.png)
![version 0.2](https://raw.githubusercontent.com/no13bus/redispapa/master/screen/4.png)
![version 0.2](https://raw.githubusercontent.com/no13bus/redispapa/master/screen/5.png)

## Version 0.3
- docker support: you can pull the [docker image of redispapa](https://registry.hub.docker.com/u/sinchb/redispapa/) from docker hub
## version 0.3
- 支持docker: 现在可以直接从docker hub下载最新的[redispapa的镜像](https://registry.hub.docker.com/u/sinchb/redispapa/):

```
docker pull sinchb/redispapa
```
```
docker pull sinchb/redispapa
```

to start a redispapa instance with default settings:
用默认配置启动一个redispapa实例:

```
docker run -p 5000:5000 sinchb/redispapa
```
```
docker run -p 5000:5000 sinchb/redispapa
```

If you want to use your own config.py:
用自己的config.py配置启动一个redispapa实例:

```
docker run -p 5000:5000 -v /path/to/config.py:/root/redispapa/config.py sinchb/redispapa
```
```
docker run -p 5000:5000 -v /path/to/config.py:/root/redispapa/config.py sinchb/redispapa
```

If you want to build your own docker image, please clone this repo, and run:
如果要build自己的redispapa 镜像,请先克隆本项目,然后运行:

```
cd /path/to/your/redispapa/
docker build -t=your-redispapa-tag .
```
```
cd /path/to/your/redispapa/
docker build -t=your-redispapa-tag .
```

## Version 0.2
- new feature: exectute redis commands in the website.
- In the website, you can type `set` in `command input box`, and type `a, papapa` in `args input box`
or you can type `get` in `command input box`, and type `a` in `args input box. Then you can get the result
from the redis server.
## version 0.2
- 加入新特性: 在前端执行redis命令, 返回执行结果。
- 执行方法如下: 网页上的command内写redis命令, args写命令的各个参数.
比如command内写 `set`, args内写 `a, papapa`
再比如command内写 `get`, args内写 `a`

## Version 0.1
supply kinds of information of redis server
## version 0.1
提供了redis-server的info的监控信息

## The links
## 相关项目连接
- [redis stat](https://github.com/junegunn/redis-stat)
- [highchart-ng](https://github.com/pablojim/highcharts-ng)
- [ng-socket-io](https://github.com/mbenford/ngSocketIO)
- [Angular](https://github.com/angular/angular)
- [Flask](https://github.com/mitsuhiko/flask)

- [angular](https://github.com/angular/angular)
- [flask](https://github.com/mitsuhiko/flask)
78 changes: 0 additions & 78 deletions README_CN.md

This file was deleted.

Loading

0 comments on commit 5eed97d

Please sign in to comment.