Compare commits

..
45 Commits
Author SHA1 Message Date
Mr Chen 1517d8d2d7 Merge pull request #181 from midoks/dev
0.9.7
2022-08-29 13:15:36 +08:00
midoks ba55477492 up 2022-08-29 13:14:41 +08:00
midoks e363833437 Update install.sh 2022-08-29 13:12:37 +08:00
midoks 6ec51baedb Update install.sh 2022-08-29 12:48:28 +08:00
midoks 0fdf62499b Update index.py 2022-08-29 12:22:59 +08:00
midoks 1498e23b48 Update haproxy.js 2022-08-29 12:14:13 +08:00
midoks 106ce839d8 Update index.html 2022-08-29 12:13:40 +08:00
midoks eed561dadc Update haproxy.conf 2022-08-29 12:09:13 +08:00
midoks c97ec1cbba up 2022-08-29 12:08:02 +08:00
midoks 29802d8066 up 2022-08-29 11:32:29 +08:00
midoks 9a51bc4b4e Update index.py 2022-08-29 00:35:46 +08:00
midoks 082f697706 Update index.py 2022-08-29 00:34:58 +08:00
midoks 6e026f2998 Update install.sh 2022-08-28 23:35:31 +08:00
midoks c647f0c02d Update haproxy.tpl 2022-08-28 23:26:02 +08:00
midoks da99297253 Update haproxy.service.tpl 2022-08-28 23:25:31 +08:00
midoks 4ab982827e 优化 2022-08-28 23:02:37 +08:00
midoks d3a4db511a haproxy init 2022-08-28 22:50:17 +08:00
midoks fa9e4e3b06 Update index.py 2022-08-24 15:31:44 +08:00
midoks e7cd941f0f Update index.py 2022-08-24 15:16:59 +08:00
midoks c641606ecd #175
统计流量区分类型
2022-08-23 11:13:44 +08:00
Mr Chen 021a360462 Merge pull request #177 from midoks/dev
优化getLocalIp方法
2022-08-23 07:37:59 +08:00
midoks 9104280ff1 不再全部测试 2022-08-23 07:37:11 +08:00
midoks 0ea0f2d13d 优化getLocalIp方法 2022-08-23 07:35:34 +08:00
Mr Chen 289e251480 Merge pull request #176 from midoks/dev
php74版本退回
2022-08-23 07:03:14 +08:00
midoks ce421cfb89 Update install.sh 2022-08-23 06:52:54 +08:00
Mr Chen bec41f2c63 Merge pull request #174 from midoks/dev
代码改变版本号
2022-08-22 13:28:50 +08:00
midoks 3a34974ec9 Update config_api.py 2022-08-22 13:26:48 +08:00
midoks a7c9fff283 up 2022-08-22 11:55:30 +08:00
midoks c36cca61a1 Update centos.sh 2022-08-22 11:52:05 +08:00
Mr Chen 42edf12d01 Merge pull request #172 from midoks/dev
0.9.6
2022-08-22 11:44:39 +08:00
midoks d6799e89c4 0.9.6 2022-08-22 11:43:11 +08:00
midoks 4b4006c9da Update index.html 2022-08-21 12:23:39 +08:00
midoks 33bb042b41 up 2022-08-17 19:16:51 +08:00
midoks be2e91b9ce mariadb up 2022-08-17 19:14:36 +08:00
midoks db424f8912 mariadb up 2022-08-17 19:12:12 +08:00
midoks bfca2e313a Update rsyncd.js 2022-08-17 12:01:28 +08:00
midoks 1de51747e6 Update supervisor.js 2022-08-17 09:28:25 +08:00
midoks 8a623b490b supervisor增加错误查看 2022-08-17 09:25:08 +08:00
midoks b5b8ef7e46 Update .gitignore 2022-08-16 22:08:07 +08:00
midoks daa561b6c4 Update README.md 2022-08-16 18:42:03 +08:00
midoks 9bc30db1ad Update README.md 2022-08-16 18:38:35 +08:00
midoks 1a9d506d61 Update README.md 2022-08-16 18:35:29 +08:00
midoks 62b5d812e2 Update install.sh 2022-08-16 17:29:10 +08:00
midoks 433c9ab5ea Update files_api.py 2022-08-16 11:51:46 +08:00
midoks a7a6976204 增加插件[备份]功能。
1. json: "hook":["backup"]   -- 备份钩子开启
2.crontab的执行周期添加优化。
2022-08-16 04:45:21 +08:00
41 changed files with 952 additions and 154 deletions
+2 -2
View File
@@ -5,9 +5,9 @@ name: MW APP MySQL55
on:
push:
branches: [ "master" ]
branches: [ "run_test" ]
pull_request:
branches: [ "master" ]
branches: [ "run_test" ]
permissions:
contents: read
+2 -2
View File
@@ -5,9 +5,9 @@ name: MW APP MySQL56
on:
push:
branches: [ "master" ]
branches: [ "run_test" ]
pull_request:
branches: [ "master" ]
branches: [ "run_test" ]
permissions:
contents: read
+2 -2
View File
@@ -5,9 +5,9 @@ name: MW APP MySQL57
on:
push:
branches: [ "master" ]
branches: [ "run_test" ]
pull_request:
branches: [ "master" ]
branches: [ "run_test" ]
permissions:
contents: read
+2 -2
View File
@@ -5,9 +5,9 @@ name: MW APP MySQL80
on:
push:
branches: [ "master" ]
branches: [ "run_test" ]
pull_request:
branches: [ "master" ]
branches: [ "run_test" ]
permissions:
contents: read
+2 -2
View File
@@ -5,9 +5,9 @@ name: MW APP PHP
on:
push:
branches: [ "master" ]
branches: [ "run_test" ]
pull_request:
branches: [ "master" ]
branches: [ "run_test" ]
permissions:
contents: read
+4 -2
View File
@@ -128,6 +128,7 @@ lib/python*
bin
pyvenv.cfg
include
share
pip-selfcheck.json
scripts/mdserver-web
@@ -140,16 +141,17 @@ data/restart.pl
data/ssl.pl
data/edate.pl
data/osname.pl
data/only_netio_counters.pl
data/system.db-journal
data/hook_*.json
plugins/l2tp
plugins/openlitespeed
plugins/gdrive
plugins/mtproxy
plugins/zimg
plugins/bk_demo
debug.out
+6 -11
View File
@@ -1,4 +1,4 @@
### mdserver-web 0.9.5
### mdserver-web 0.9.7
简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。
复制了后台管理界面,按照自己想要的方式写了一版。
@@ -71,14 +71,10 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```
### 版本更新 0.9.5
* 页面更新优化[2].
* 修复maridb的用户管理[2].
* Gogs初始化提示更人性.
* MySQL&&MariaDB修改密码修复.
* MySQL&&MariaDB导入修复.
### 版本更新 0.9.7
* haproxy插件添加.
* 细节优化.
### JSDelivr安装地址
@@ -127,13 +123,12 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/up
```
### 微信赞助
[![截图](/route/static/img/weixin_zz.jpg)](/route/static/img/weixin_zz.jpg)
[![截图](https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/route/static/img/weixin_zz.jpg)](https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/route/static/img/weixin_zz.jpg)
### 无图不真相
[![截图](/route/static/mdw.jpg)](/route/static/mdw.jpg)
[![截图](https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/route/static/mdw.jpg)](https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/route/static/mdw.jpg)
### Stargazers over time
+1 -1
View File
@@ -15,7 +15,7 @@ from flask import request
class config_api:
__version = '0.9.5'
__version = '0.9.7'
def __init__(self):
pass
+18 -11
View File
@@ -295,9 +295,18 @@ class crontab_api:
# 取数据列表
def getDataListApi(self):
stype = request.form.get('type', '')
bak_data = []
if stype == 'sites' or stype == 'databases':
hookPath = mw.getPanelDataDir() + "/hook_backup.json"
if os.path.exists(hookPath):
t = mw.readFile(hookPath)
bak_data = json.loads(t)
if stype == 'databases':
db_list = {}
db_list['orderOpt'] = []
db_list['orderOpt'] = bak_data
path = mw.getServerDir() + '/mysql'
if not os.path.exists(path + '/mysql.db'):
db_list['data'] = []
@@ -307,8 +316,9 @@ class crontab_api:
return mw.getJson(db_list)
data = {}
data['orderOpt'] = bak_data
data['data'] = mw.M(stype).field('name,ps').select()
data['orderOpt'] = []
return mw.getJson(data)
##### ----- start ----- ###
@@ -411,16 +421,13 @@ class crontab_api:
'rememory': head + "/bin/bash " + script_dir + '/rememory.sh'
}
if param['backup_to'] != 'localhost':
cfile = mw.getServerDir() + "/mdserver-web/plugin/" + \
param['backup_to'] + "/" + param['backup_to'] + "_main.py"
if not os.path.exists(cfile):
cfile = script_dir + "/backup_" + \
param['backup_to'] + ".py"
cfile = mw.getPluginDir() + "/" + \
param['backup_to'] + "/index.py"
wheres = {
'path': head + "python " + cfile + " path " + param['sname'] + " " + str(param['save']),
'site': head + "python " + cfile + " site " + param['sname'] + " " + str(param['save']),
'database': head + "python " + cfile + " database " + param['sname'] + " " + str(param['save']),
'logs': head + "python " + script_dir + "/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
'path': head + "python3 " + cfile + " path " + param['sname'] + " " + str(param['save']),
'site': head + "python3 " + cfile + " site " + param['sname'] + " " + str(param['save']),
'database': head + "python3 " + cfile + " database " + param['sname'] + " " + str(param['save']),
'logs': head + "python3 " + script_dir + "/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
'rememory': head + "/bin/bash " + script_dir + '/rememory.sh'
}
try:
+1 -2
View File
@@ -676,8 +676,7 @@ class files_api:
data['encoding'] = 'utf-8'
if char['encoding'] == 'Big5':
data['encoding'] = 'BIG5'
if not char['encoding'] in ['GBK', 'utf-8',
'BIG5']:
if not char['encoding'] in ['GBK', 'utf-8', 'BIG5']:
data['encoding'] = 'utf-8'
try:
if sys.version_info[0] == 2:
+21 -17
View File
@@ -57,10 +57,22 @@ def getPluginDir():
return getRunDir() + '/plugins'
def getPanelDataDir():
return getRunDir() + '/data'
def getServerDir():
return getRootDir() + '/server'
def getLogsDir():
return getRootDir() + '/wwwlogs'
def getBackupDir():
return getRootDir() + '/backup'
def getWwwDir():
file = getRunDir() + '/data/site.pl'
if os.path.exists(file):
@@ -73,14 +85,6 @@ def setWwwDir(wdir):
return writeFile(file, wdir)
def getLogsDir():
return getRootDir() + '/wwwlogs'
def getBackupDir():
return getRootDir() + '/backup'
def setBackupDir(bdir):
file = getRunDir() + '/data/backup.pl'
return writeFile(file, bdir)
@@ -646,16 +650,14 @@ def getLocalIp():
try:
ipaddress = readFile(filename)
if not ipaddress or ipaddress == '127.0.0.1':
raise Exception("ip is empty!")
cmd = "curl -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
ip = execShell(cmd)
result = ip[0].strip()
if result == '':
raise Exception("ipv4 is empty!")
writeFile(filename, result)
return result
return ipaddress
except Exception as e:
cmd = "curl -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
ip = execShell(cmd)
result = ip[0].strip()
if result == '':
raise e
writeFile(filename, result)
return result
except Exception as e:
cmd = "curl -6 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
ip = execShell(cmd)
@@ -664,6 +666,8 @@ def getLocalIp():
return '127.0.0.1'
writeFile(filename, result)
return result
finally:
pass
return '127.0.0.1'
+53 -4
View File
@@ -114,6 +114,7 @@ class plugins_api:
return mw.returnJson(False, '配置文件不存在!', ())
pluginInfo = json.loads(mw.readFile(infoJsonPos))
self.hookInstall(pluginInfo)
execstr = "cd " + os.getcwd() + "/plugins/" + \
name + " && /bin/bash " + pluginInfo["shell"] \
@@ -131,6 +132,55 @@ class plugins_api:
mw.triggerTask()
return mw.returnJson(True, '已将安装任务添加到队列!')
def hookInstallFile(self, hook_name, info):
hookPath = mw.getPanelDataDir() + "/hook_" + hook_name + ".json"
data = []
if os.path.exists(hookPath):
t = mw.readFile(hookPath)
data = json.loads(t)
isNeedAdd = True
for x in range(len(data)):
if data[x]['title'] == info['title'] and data[x]['name'] == info['name']:
isNeedAdd = False
if isNeedAdd:
tmp = {}
tmp['title'] = info['title']
tmp['name'] = info['name']
data.append(tmp)
mw.writeFile(hookPath, json.dumps(data))
def hookUninstallFile(self, hook_name, info):
hookPath = mw.getPanelDataDir() + "/hook_" + hook_name + ".json"
data = []
if os.path.exists(hookPath):
t = mw.readFile(hookPath)
data = json.loads(t)
for idx in range(len(data)):
if data[idx]['title'] == info['title'] and data[idx]['name'] == info['name']:
data.remove(data[idx])
mw.writeFile(hookPath, json.dumps(data))
def hookInstall(self, info):
if 'hook' in info:
hooks = info['hook']
for x in hooks:
if x in ['backup']:
self.hookInstallFile(x, info)
return True
return False
def hookUninstall(self, info):
if 'hook' in info:
hooks = info['hook']
for x in hooks:
if x in ['backup']:
self.hookUninstallFile(x, info)
return True
return False
def uninstallOldApi(self):
rundir = mw.getRunDir()
name = request.form.get('name', '')
@@ -147,7 +197,6 @@ class plugins_api:
return mw.returnJson(False, "配置文件不存在!", ())
pluginInfo = json.loads(mw.readFile(infoJsonPos))
execstr = "cd " + os.getcwd() + "/plugins/" + \
name + " && /bin/bash " + pluginInfo["shell"] \
+ " uninstall " + version
@@ -175,13 +224,13 @@ class plugins_api:
return mw.returnJson(False, "配置文件不存在!", ())
pluginInfo = json.loads(mw.readFile(infoJsonPos))
self.hookUninstall(pluginInfo)
execstr = "cd " + os.getcwd() + "/plugins/" + \
name + " && /bin/bash " + pluginInfo["shell"] \
+ " uninstall " + version
data = mw.execShell(execstr)
if mw.isAppleSystem():
if mw.isDebugMode():
print(execstr)
print(data[0], data[1])
self.removeIndex(name, version)
@@ -793,7 +842,7 @@ class plugins_api:
print('getIndexList:', e)
# 使用gevent模式时,无法使用多进程
#plist = self.checkStatusMProcess(plist)
# plist = self.checkStatusMProcess(plist)
plist = self.checkStatusMThreads(plist)
return plist
+38 -35
View File
@@ -437,12 +437,35 @@ class system_api:
os.system('echo > /tmp/panelBoot.pl')
return total, count
def psutilNetIoCounters(self):
'''
统计网卡流量
'''
stat_pl = 'data/only_netio_counters.pl'
if os.path.exists(stat_pl):
local_lo = (0, 0, 0, 0)
ioName = psutil.net_io_counters(pernic=True).keys()
for x in ioName:
if x.find("lo") > -1:
local_lo = psutil.net_io_counters(
pernic=True).get(x)[:4]
all_io = psutil.net_io_counters()[:4]
result_io = tuple([all_io[i] - local_lo[i]
for i in range(0, len(all_io))])
# print(local_lo)
# print(all_io)
# print(result_io)
return result_io
return psutil.net_io_counters()[:4]
def getNetWork(self):
# return self.GetNetWorkApi(get);
# 取网络流量信息
try:
# 取网络流量信息
networkIo = psutil.net_io_counters()[:4]
networkIo = self.psutilNetIoCounters()
if not "otime" in session:
session['up'] = networkIo[0]
session['down'] = networkIo[1]
@@ -470,38 +493,7 @@ class system_api:
return networkInfo
except Exception as e:
# print(e)
return None
def getNetWorkApi(self):
# 取网络流量信息
try:
tmpfile = 'data/network.temp'
networkIo = psutil.net_io_counters()[:4]
if not os.path.exists(tmpfile):
mw.writeFile(tmpfile, str(
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
lastValue = mw.readFile(tmpfile).split('|')
ntime = time.time()
networkInfo = {}
networkInfo['upTotal'] = networkIo[0]
networkInfo['downTotal'] = networkIo[1]
networkInfo['up'] = round(
float(networkIo[0] - int(lastValue[0])) / 1024 / (ntime - int(lastValue[2])), 2)
networkInfo['down'] = round(
float(networkIo[1] - int(lastValue[1])) / 1024 / (ntime - int(lastValue[2])), 2)
networkInfo['downPackets'] = networkIo[3]
networkInfo['upPackets'] = networkIo[2]
mw.writeFile(tmpfile, str(
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
# networkInfo['cpu'] = self.GetCpuInfo(0.1)
return networkInfo
except:
print("getNetWork error:", e)
return None
def getNetWorkIoData(self, start, end):
@@ -567,14 +559,19 @@ class system_api:
def setControl(self, stype, day):
filename = 'data/control.conf'
stat_pl = 'data/only_netio_counters.pl'
if stype == '0':
mw.execShell("rm -f " + filename)
mw.execShell("rm -rf " + filename)
elif stype == '1':
_day = int(day)
if _day < 1:
return mw.returnJson(False, "设置失败!")
mw.writeFile(filename, day)
elif stype == '2':
mw.execShell("rm -rf " + stat_pl)
elif stype == '3':
mw.execShell("echo 'True' > " + stat_pl)
elif stype == 'del':
if not mw.isRestart():
return mw.returnJson(False, '请等待所有安装任务完成再执行')
@@ -597,6 +594,12 @@ class system_api:
else:
data['day'] = 30
data['status'] = False
if os.path.exists(stat_pl):
data['stat_all_status'] = True
else:
data['stat_all_status'] = False
return mw.getJson(data)
return mw.returnJson(True, "设置成功!")
+37
View File
@@ -0,0 +1,37 @@
global
daemon
log 127.0.0.1 local0
pidfile /tmp/haproxy.pid
maxconn 4000
user haproxy
group haproxy
defaults
mode http
log global
option httplog
timeout connect 10s
timeout client 15s
timeout server 15s
listen stats
mode http
bind *:10800
stats enable
stats uri /haproxy
stats realm Haproxy\ Statistics
stats auth admin:admin
frontend http-in
bind *:1080
default_backend servers
option forwardfor
option httpclose
backend servers
balance roundrobin
server web1 0.0.0.0:9090 check
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

+18
View File
@@ -0,0 +1,18 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('haproxy');">服务</p>
<p onclick="pluginInitD('haproxy');">自启动</p>
<p onclick="pluginConfigTpl('haproxy');">配置修改</p>
<p onclick="pluginLogs('haproxy','','run_log',30);">运行日志</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=haproxy&f=js/haproxy.js", function(){
pluginService('haproxy');
});
</script>
+253
View File
@@ -0,0 +1,253 @@
# coding:utf-8
import sys
import io
import os
import time
import re
import string
import subprocess
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'haproxy'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getConfTpl():
path = getPluginDir() + "/conf/haproxy.conf"
return path
def getConf():
path = getServerDir() + "/haproxy.conf"
return path
def getInitDTpl():
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
return path
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def configTpl():
path = getPluginDir() + '/tpl'
pathFile = os.listdir(path)
tmp = []
for one in pathFile:
file = path + '/' + one
tmp.append(file)
return mw.getJson(tmp)
def readConfigTpl():
args = getArgs()
data = checkArgs(args, ['file'])
if not data[0]:
return data[1]
content = mw.readFile(args['file'])
content = contentReplace(content)
return mw.returnJson(True, 'ok', content)
def contentReplace(content):
service_path = mw.getServerDir()
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$SERVER_APP}', service_path + '/haproxy')
return content
def status():
data = mw.execShell(
"ps -ef|grep haproxy |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
# initd replace
if not os.path.exists(file_bin):
content = mw.readFile(file_tpl)
content = contentReplace(content)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
# config replace
conf_bin = getConf()
if not os.path.exists(conf_bin):
conf_content = mw.readFile(getConfTpl())
conf_content = contentReplace(conf_content)
mw.writeFile(getServerDir() + '/haproxy.conf', conf_content)
# systemd
systemDir = mw.systemdCfgDir()
systemService = systemDir + '/haproxy.service'
systemServiceTpl = getPluginDir() + '/init.d/haproxy.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
service_path = mw.getServerDir()
se_content = mw.readFile(systemServiceTpl)
se_content = se_content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(systemService, se_content)
mw.execShell('systemctl daemon-reload')
return file_bin
def haOp(method):
file = initDreplace()
if not mw.isAppleSystem():
data = mw.execShell('systemctl ' + method + ' haproxy')
if data[1] == '':
return 'ok'
return 'fail'
data = mw.execShell(file + ' ' + method)
if data[1] == '':
return 'ok'
return data[1]
def start():
return haOp('start')
def stop():
return haOp('stop')
def restart():
return haOp('restart')
def reload():
return haOp('reload')
def initdStatus():
if mw.isAppleSystem():
return "Apple Computer does not support"
shell_cmd = 'systemctl status haproxy | grep loaded | grep "enabled;"'
data = mw.execShell(shell_cmd)
if data[0] == '':
return 'fail'
return 'ok'
def initdInstall():
if mw.isAppleSystem():
return "Apple Computer does not support"
mw.execShell('systemctl enable haproxy')
return 'ok'
def initdUinstall():
if mw.isAppleSystem():
return "Apple Computer does not support"
mw.execShell('systemctl disable haproxy')
return 'ok'
def runLog():
path = getConf()
content = mw.readFile(path)
rep = 'log\s*=\s*(.*)'
tmp = re.search(rep, content)
return tmp.groups()[0]
def getPort():
path = getConf()
content = mw.readFile(path)
rep = 'listen\s*=\s*(.*)'
tmp = re.search(rep, content)
return tmp.groups()[0]
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print(status())
elif func == 'start':
print(start())
elif func == 'stop':
print(stop())
elif func == 'restart':
print(restart())
elif func == 'reload':
print(reload())
elif func == 'initd_status':
print(initdStatus())
elif func == 'initd_install':
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'conf':
print(getConf())
elif func == 'config_tpl':
print(configTpl())
elif func == 'read_config_tpl':
print(readConfigTpl())
elif func == 'run_log':
print(runLog())
elif func == 'query_log':
print(queryLog())
else:
print('error')
+19
View File
@@ -0,0 +1,19 @@
{
"sort": 7,
"ps": "可靠、高性能的TCP/HTTP负载平衡器",
"name": "haproxy",
"title": "haproxy",
"shell": "install.sh",
"versions":["2.6"],
"updates":["2.6"],
"tip": "soft",
"checks": "server/haproxy",
"path": "server/haproxy",
"display": 1,
"author": "midoks",
"date": "2022-08-26",
"home": "https://www.haproxy.org/",
"doc1": "https://www.haproxy.org/",
"type": 0,
"pid": "4"
}
@@ -0,0 +1,13 @@
[Unit]
Description=he Reliable, High Performance TCP/HTTP Load Balancer
After=network.target
[Service]
Type=forking
ExecStartPre={$SERVER_PATH}/haproxy/sbin/haproxy -c -f {$SERVER_PATH}/haproxy/haproxy.conf
ExecStart={$SERVER_PATH}/haproxy/sbin/haproxy -D -f {$SERVER_PATH}/haproxy/haproxy.conf
ExecReload={$SERVER_PATH}/haproxy/sbin/haproxy -f {$SERVER_PATH}/haproxy/haproxy.conf -c -q
Restart=on-failure
[Install]
WantedBy=multi-user.target
+119
View File
@@ -0,0 +1,119 @@
#!/bin/sh
#
# chkconfig: - 85 15
# description: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited \
# for high availability environments.
# processname: haproxy
# config: /etc/haproxy/haproxy.cfg
# pidfile: /var/run/haproxy.pid
# Script Author: Simon Matter <simon.matter@invoca.ch>
# Version: 2004060600
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
echo ".."
fi
# Source networking configuration.
if [ -f /etc/sysconfig/network ];then
. /etc/sysconfig/network
fi
# Check that networking is up.
# [ ${NETWORKING} = "no" ] && exit 0
HAPROXYDIR={$SERVER_PATH}/haproxy
BASENAME=haproxy
# This is our service name
#BASENAME=`basename $0`
#if [ -L $0 ]; then
# BASENAME=`find $0 -name $BASENAME -printf %l`
# BASENAME=`basename $BASENAME`
#fi
[ -f $HAPROXYDIR/etc/$BASENAME.conf ] || exit 1
RETVAL=0
start() {
$HAPROXYDIR/sbin/$BASENAME -c -q -f $HAPROXYDIR/etc/$BASENAME.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
fi
echo -n "Starting $BASENAME: "
daemon $HAPROXYDIR/sbin/$BASENAME -D -f $HAPROXYDIR/etc/$BASENAME.conf
RETVAL=$?
# echo
# [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
return $RETVAL
}
stop() {
echo -n "Shutting down $BASENAME: "
killproc $BASENAME -USR1
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASENAME
[ $RETVAL -eq 0 ] && rm -f /var/run/$BASENAME.pid
return $RETVAL
}
restart() {
$HAPROXYDIR/sbin/$BASENAME -c -q -f $HAPROXYDIR/etc/$BASENAME.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
fi
stop
start
}
reload() {
$HAPROXYDIR/sbin/$BASENAME -c -q -f $HAPROXYDIR/etc/$BASENAME.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
fi
$HAPROXYDIR/sbin/$BASENAME -D -f $HAPROXYDIR/$BASENAME.conf -p /var/run/$BASENAME.pid -sf $(cat /var/run/$BASENAME.pid)
}
check() {
$HAPROXYDIR/sbin/$BASENAME -c -q -V -f $HAPROXYDIR/etc/$BASENAME.conf
}
rhstatus() {
status $BASENAME
}
condrestart() {
[ -e /var/lock/subsys/$BASENAME ] && restart || :
}
# See how we were called.
case "$1" in
start) start ;;
stop) stop ;;
restart) restart;;
reload) reload;;
condrestart) condrestart ;;
status) rhstatus ;;
check) check ;;
*)
echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|check}"
exit 1
esac
exit $?
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
action=$1
type=$2
echo $action $type
if id haproxy &> /dev/null ;then
echo "haproxy UID is `id -u haproxy`"
echo "haproxy Shell is `grep "^haproxy:" /etc/passwd |cut -d':' -f7 `"
else
groupadd haproxy
useradd -g haproxy haproxy
fi
if [ "${2}" == "" ];then
echo '缺少安装脚本...' > $install_tmp
exit 0
fi
if [ ! -d $curPath/versions/$2 ];then
echo '缺少安装脚本2...' > $install_tmp
exit 0
fi
if [ "${action}" == "uninstall" ];then
if [ -f /usr/lib/systemd/system/haproxy.service ] || [ -f /lib/systemd/system/haproxy.service ];then
systemctl stop haproxy
systemctl disable haproxy
rm -rf /usr/lib/systemd/system/haproxy.service
rm -rf /lib/systemd/system/haproxy.service
systemctl daemon-reload
fi
fi
sh -x $curPath/versions/$2/install.sh $1
if [ "${action}" == "install" ] && [ -d $serverPath/haproxy ];then
#初始化
cd ${rootPath} && python3 ${rootPath}/plugins/haproxy/index.py start ${type}
cd ${rootPath} && python3 ${rootPath}/plugins/haproxy/index.py initd_install ${type}
fi
+53
View File
@@ -0,0 +1,53 @@
function spPostMin(method, args, callback){
var req_data = {};
req_data['name'] = 'haproxy';
req_data['func'] = method;
if (typeof(args) != 'undefined' && args!=''){
req_data['args'] = JSON.stringify(args);
}
$.post('/plugins/run', req_data, function(data) {
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function spPost(method, args, callback){
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
spPostMin(method,args,function(data){
layer.close(loadT);
if(typeof(callback) == 'function'){
callback(data);
}
});
}
function secToTime(s) {
var t;
if(s > -1){
var hour = Math.floor(s/3600);
var min = Math.floor(s/60) % 60;
var sec = s % 60;
if(hour < 10) {
t = '0'+ hour + ":";
} else {
t = hour + ":";
}
if(min < 10){t += "0";}
t += min + ":";
if(sec < 10){t += "0";}
t += sec.toFixed(2);
}
return t;
}
+70
View File
@@ -0,0 +1,70 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
VERSION=2.6.4
MIN_VERSION=2.6
Install_App()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/haproxy
APP_DIR=${serverPath}/source/haproxy
mkdir -p $APP_DIR
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then
if [ $sysName == 'Darwin' ]; then
wget -O ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz
else
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz
fi
fi
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz
fi
cd ${APP_DIR} && tar -zxvf haproxy-${VERSION}.tar.gz
if [ "$OSNAME" == "macos" ];then
cd ${APP_DIR}/haproxy-${VERSION} && make TARGET=osx && make install PREFIX=$serverPath/haproxy
else
cd ${APP_DIR}/haproxy-${VERSION} && make TARGET=linux-glibc && make install PREFIX=$serverPath/haproxy
fi
echo $MIN_VERSION > $serverPath/haproxy/version.pl
echo 'Install_HA' > $install_tmp
}
Uninstall_App()
{
if [ -f $serverPath/haproxy/initd/haproxy ];then
$serverPath/haproxy/initd/haproxy stop
fi
rm -rf $serverPath/haproxy
echo "Uninstall_HA" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_App
else
Uninstall_App
fi
+9 -4
View File
@@ -14,7 +14,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb
MY_VER=10.6.8
MY_VER=10.6.9
Install_app()
{
@@ -57,10 +57,15 @@ Install_app()
fi
# ----- cpu end ------
# https://mirrors.aliyun.com/mariadb/mariadb-10.8.3/source/mariadb-10.8.3.tar.gz
if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
# https://mirrors.aliyun.com/mariadb/mariadb-10.8.3/source/mariadb-10.8.3.tar.gz
wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
# wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
fi
# https://downloads.mariadb.org/interstitial/mariadb-10.6.8/source/mariadb-10.6.8.tar.gz
if [ "$?" != "0" ];then
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
fi
if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then
+6 -4
View File
@@ -14,7 +14,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb
MY_VER=10.7.4
MY_VER=10.7.5
Install_app()
{
@@ -58,14 +58,16 @@ Install_app()
# ----- cpu end ------
if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
# wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
fi
if [ "$?" != "0" ];then
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
fi
if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then
cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz
fi
if [ ! -d $serverPath/mariadb ];then
cd ${mariadbDir}/mariadb-${MY_VER} && cmake \
+6 -3
View File
@@ -14,7 +14,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb
MY_VER=10.8.3
MY_VER=10.8.4
Install_app()
{
@@ -58,8 +58,11 @@ Install_app()
# ----- cpu end ------
if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
# wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
fi
if [ "$?" != "0" ];then
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
fi
if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then
+16 -4
View File
@@ -21,14 +21,26 @@ OSNAME=`cat ${rootPath}/data/osname.pl`
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
Install_app_mac()
{
if [ ! -f $serverPath/source/mongodb-macos-x86_64-${VERSION}.tgz ];then
wget -O $serverPath/source/mongodb-macos-x86_64-${VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${VERSION}.tgz
mkdir -p $serverPath/mongodb
if [ "$VERSION" == "5.0" ];then
G_VERSION="5.0.11"
elif [[ "$VERSION" == "4.4" ]]; then
G_VERSION="4.4.11"
fi
cd $serverPath/source && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
cd mongodb-macos-x86_64-${VERSION} && mv ./* $serverPath/mongodb
if [ ! -f $serverPath/source/mongodb-macos-x86_64-${G_VERSION}.tgz ];then
wget -O $serverPath/source/mongodb-macos-x86_64-${G_VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${G_VERSION}.tgz
fi
cd $serverPath/source && tar -zxvf mongodb-macos-x86_64-${G_VERSION}.tgz
cd mongodb-macos-x86_64-${G_VERSION} && mv ./* $serverPath/mongodb
}
+1 -1
View File
@@ -53,7 +53,7 @@
.conf_p span {
display: inline-block;
margin-right: 10px;
width: 95px;
width: 135px;
text-align: right;
}
</style>
+5 -1
View File
@@ -39,7 +39,11 @@ if [ ! -d $sourcePath/php/php${PHP_VER} ];then
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
fi
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
rm -rf $sourcePath/php/php-${version}.tar.xz
echo "reinstall php${version}"
exit 1
fi
cd $sourcePath/php/php${PHP_VER}
+1 -1
View File
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
version=8.0.21
version=8.0.22
PHP_VER=80
Install_php()
{
+1 -1
View File
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
version=8.1.8
version=8.1.9
PHP_VER=81
Install_php()
{
+1 -1
View File
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
version=8.2.0alpha2
version=8.2.0beta3
PHP_VER=82
Install_php()
{
+5 -2
View File
@@ -135,11 +135,12 @@ def initDReceive():
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
lock_file = getServerDir() + "/installed_rsyncd.pl"
# systemd
systemDir = mw.systemdCfgDir()
systemService = systemDir + '/rsyncd.service'
systemServiceTpl = getPluginDir() + '/init.d/rsyncd.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
if not os.path.exists(lock_file):
rsync_bin = mw.execShell('which rsync')[0].strip()
if rsync_bin == '':
print('rsync missing!')
@@ -152,6 +153,8 @@ def initDReceive():
mw.writeFile(systemService, se)
mw.execShell('systemctl daemon-reload')
mw.writeFile(lock_file, "ok")
rlog = getLog()
if os.path.exists(rlog):
mw.writeFile(rlog, '')
@@ -199,7 +202,7 @@ def initDSend():
mw.writeFile(systemService, content)
mw.execShell('systemctl daemon-reload')
mw.writeFile(lock_file, "ok")
mw.writeFile(lock_file, "ok")
lslog = getLsyncdLog()
if os.path.exists(lslog):
+4 -1
View File
@@ -339,7 +339,10 @@ function createSendTask(name = ''){
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
if (rdata.status){
setTimeout(function(){layer.close(index);},2000);
setTimeout(function(){
layer.close(index);
lsyncdSend();
},2000);
return;
}
});
+24
View File
@@ -477,6 +477,28 @@ def readConfigLogTpl():
return mw.returnJson(False, 'OK', '')
def readConfigLogErrorTpl():
args = getArgs()
data = checkArgs(args, ['file'])
if not data[0]:
return data[1]
file_log = args['file']
line_log = args['line']
with open(file_log, "r") as fr:
infos = fr.readlines()
stderr_logfile = ''
for line in infos:
if "stderr_logfile=" in line.strip():
stderr_logfile = line.strip().split('=')[1]
if stderr_logfile != '':
data = mw.getNumLines(stderr_logfile, int(line_log))
return mw.returnJson(True, 'OK', data)
return mw.returnJson(False, 'OK', '')
def supClearLog():
args = getArgs()
data = checkArgs(args, ['file'])
@@ -529,6 +551,8 @@ if __name__ == "__main__":
print(readConfigTpl())
elif func == 'read_config_log_tpl':
print(readConfigLogTpl())
elif func == 'read_config_log_error_tpl':
print(readConfigLogErrorTpl())
elif func == 'sup_clear_log':
print(supClearLog())
elif func == 'conf':
+20 -3
View File
@@ -405,7 +405,7 @@ function supConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_fun
return;
}
$("#textBody").empty().text(rdata.data);
$("#textBody").empty().html(rdata.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
@@ -424,7 +424,7 @@ function supConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_fun
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#onlineEditFileBtn").unbind('click');
$("#onlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
$("#textBody").html(editor.getValue());
pluginConfigSave(fileName);
});
},'json');
@@ -474,6 +474,7 @@ function supLogs(_name, config_tpl_func, read_config_tpl_func,line){
var con = '<div><select id="config_tpl" class="bt-input-text mr20" style="width:30%;margin-bottom: 3px;"><option value="0">请选择</option></select>\
<button id="sup_clear_log" class="btn btn-success btn-sm clear_logs mr5">清理日志</button>\
<button id="sup_error_log" class="btn btn-success btn-sm clear_logs mr5">查看错误日志</button>\
</div>';
con += '<textarea readonly="" style="margin: 0px;width: 100%;height: 520px;background-color: #333;color:#fff; padding:0 5px" id="info_log"></textarea>';
$(".soft-man-con").html(con);
@@ -489,6 +490,21 @@ function supLogs(_name, config_tpl_func, read_config_tpl_func,line){
});
}
function errorLog(file,file_line){
$('#sup_error_log').click(function(){
var _args = JSON.stringify({file:file,line:file_line});
$.post('/plugins/run', {name:_name, func:'read_config_log_error_tpl',args:_args}, function(data){
var rdata = $.parseJSON(data.data);
if (!rdata.status){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$("#info_log").empty().html(rdata.data);
},'json');
});
}
var loadT = layer.msg('日志路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/plugins/run', {name:_name, func:_config_tpl_func},function (data) {
layer.close(loadT);
@@ -517,10 +533,11 @@ function supLogs(_name, config_tpl_func, read_config_tpl_func,line){
return;
}
$("#info_log").empty().text(rdata.data);
$("#info_log").empty().html(rdata.data);
},'json');
clearLog(selected);
errorLog(selected,file_line);
///
});
+38 -17
View File
@@ -77,7 +77,7 @@ $(".networkbtn").click(function(){
function Wday(day,name){
var now = (new Date().getTime())/1000;
if(day==0){
var b = (new Date(GetToday() + " 00:00:01").getTime())/1000;
var b = (new Date(getToday() + " 00:00:01").getTime())/1000;
b = Math.round(b);
var e = Math.round(now);
}
@@ -111,7 +111,7 @@ function Wday(day,name){
}
}
function GetToday(){
function getToday(){
var mydate = new Date();
var str = "" + mydate.getFullYear() + "/";
str += (mydate.getMonth()+1) + "/";
@@ -123,30 +123,51 @@ function GetToday(){
function getStatus(){
loadT = layer.msg('正在读取,请稍候...',{icon:16,time:0})
$.post('/system/set_control','type=-1',function(rdata){
// console.log(rdata);
layer.close(loadT);
if(rdata.status){
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox' checked><label class='btswitch-btn' for='ctswitch' onclick='setControl()'></label>")
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox' checked><label class='btswitch-btn' for='ctswitch' onclick='setControl(\"openjk\", true)'></label>");
} else {
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox'><label class='btswitch-btn' for='ctswitch' onclick='setControl(\"openjk\",false)'></label>");
}
else{
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox'><label class='btswitch-btn' for='ctswitch' onclick='setControl()'></label>")
if(rdata.stat_all_status){
$("#statAll").html("<input class='btswitch btswitch-ios' id='stat_witch' type='checkbox' checked><label class='btswitch-btn' for='stat_witch' onclick='setControl(\"stat\",true)'></label>");
} else{
$("#statAll").html("<input class='btswitch btswitch-ios' id='stat_witch' type='checkbox'><label class='btswitch-btn' for='stat_witch' onclick='setControl(\"stat\",false)'></label>");
}
$("#saveDay").val(rdata.day)
$("#save_day").val(rdata.day);
},'json');
}
getStatus();
//设置监控状态
function setControl(act){
var day = $("#saveDay").val()
if(day < 1){
layer.msg('保存天数不合法!',{icon:2});
return;
}
if(act){
var type = $("#ctswitch").prop('checked')?'1':'0';
}else{
function setControl(act, value=false){
if (act == 'openjk'){
var type = $("#ctswitch").prop('checked')?'0':'1';
var day = $("#save_day").val();
if(day < 1){
layer.msg('保存天数不合法!',{icon:2});
return;
}
} else if (act == 'stat'){
var type = $("#stat_witch").prop('checked')?'2':'3';
} else if (act == 'save_day'){
var type = $("#ctswitch").prop('checked')?'1':'0';
var day = $("#save_day").val();
if(type == 0){
layer.msg('先开启监控!',{icon:2});
return;
}
if(day < 1){
layer.msg('保存天数不合法!',{icon:2});
return;
}
}
loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0})
@@ -156,13 +177,13 @@ function setControl(act){
},'json');
}
//清理记录
function closeControl(){
layer.confirm('您真的清空所有监控记录吗?',{title:'清空记录',icon:3,closeBtn:2}, function() {
loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0})
$.post('/system/set_control','type=del',function(rdata){
layer.close(loadT);
// $.get('/system?action=ReWeb',function(){});
layer.msg(rdata.msg,{icon:rdata.status?1:2});
},'json');
});
+16 -11
View File
@@ -203,6 +203,7 @@ function planAdd(){
$("#set-Config input[name='type']").val(type);
var where1 = $("#ptime input[name='where1']").val();
var is1;
var is2 = 1;
switch(type){
@@ -226,6 +227,7 @@ function planAdd(){
return;
}
where1 = $('#excode_week b').attr('val');
$("#set-Config input[name='where1']").val(where1);
var hour = $("#ptime input[name='hour']").val();
@@ -305,7 +307,9 @@ function planAdd(){
$("#set-Config input[name='sName']").val(sName);
layer.msg('正在添加,请稍候...!',{icon:16,time:0,shade: [0.3, '#000']});
var data= $("#set-Config").serialize() + '&sBody='+sBody + '&urladdress=' + urladdress;
var data = $("#set-Config").serialize() + '&sBody='+sBody + '&urladdress=' + urladdress;
console.log(data);
$.post('/crontab/add',data,function(rdata){
if(!rdata.status) {
layer.msg(rdata.msg,{icon:2, time:2000});
@@ -469,9 +473,9 @@ function toBackup(type){
sOpt += '<li><a role="menuitem" tabindex="-1" href="javascript:;" value="'+rdata.data[i].name+'">'+rdata.data[i].name+'['+rdata.data[i].ps+']</a></li>';
}
var orderOpt = ''
var orderOpt = '';
for (var i=0;i<rdata.orderOpt.length;i++){
orderOpt += '<li><a role="menuitem" tabindex="-1" href="javascript:;" value="'+rdata.orderOpt[i].value+'">'+rdata.orderOpt[i].name+'</a></li>'
orderOpt += '<li><a role="menuitem" tabindex="-1" href="javascript:;" value="'+rdata.orderOpt[i].name+'">'+rdata.orderOpt[i].title+'</a></li>'
}
@@ -514,7 +518,7 @@ function editTaskInfo(id){
layer.msg('正在获取,请稍候...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/crontab/get_crond_find',{id:id},function(rdata){
layer.closeAll();
// console.log('init:', rdata);
// console.log('get_crond_find:', rdata);
var sTypeName = '',sTypeDom = '',cycleName = '',cycleDom = '',weekName = '',weekDom = '',sNameName ='',sNameDom = '',backupsName = '',backupsDom ='';
obj = {
from:{
@@ -557,10 +561,11 @@ function editTaskInfo(id){
if(obj.from.stype == 'site' || obj.from.stype == 'database' || obj.from.stype == 'path' || obj.from.stype == 'logs'){
$.post('/crontab/get_data_list',{type:obj.from.stype == 'databases'?'database':'sites'},function(rdata){
// console.log(rdata);
obj.sNameArray = rdata.data;
obj.sNameArray.unshift({name:'ALL',ps:'所有'});
obj.backupsArray = rdata.orderOpt;
obj.backupsArray.unshift({name:'服务器磁盘',value:'localhost'});
obj.backupsArray.unshift({title:'服务器磁盘',name:'localhost'});
for(var i = 0; i <obj['sNameArray'].length; i++){
if(obj.from['sname'] == obj['sNameArray'][i]['name']){
sNameName = obj['sNameArray'][i]['ps'];
@@ -568,10 +573,10 @@ function editTaskInfo(id){
sNameDom += '<li><a role="menuitem" href="javascript:;" value="'+ obj['sNameArray'][i]['name'] +'">'+ obj['sNameArray'][i]['ps'] +'</a></li>';
}
for(var i = 0; i <obj['backupsArray'].length; i++){
if(obj.from['backup_to'] == obj['backupsArray'][i]['value']) {
backupsName = obj['backupsArray'][i]['name'];
if(obj.from['backup_to'] == obj['backupsArray'][i]['name']) {
backupsName = obj['backupsArray'][i]['title'];
}
backupsDom += '<li><a role="menuitem" href="javascript:;" value="'+ obj['backupsArray'][i]['value'] +'">'+ obj['backupsArray'][i]['name'] +'</a></li>';
backupsDom += '<li><a role="menuitem" href="javascript:;" value="'+ obj['backupsArray'][i]['name'] +'">'+ obj['backupsArray'][i]['title'] +'</a></li>';
}
callback();
},'json');
@@ -629,7 +634,7 @@ function editTaskInfo(id){
<span class="typename controls c4 pull-left f14 text-right mr20">'+ sTypeName +'</span>\
<div style="line-height:34px"><div class="dropdown pull-left mr20 sName_btn" style="display:'+ (obj.from.sType != "path"?'block;':'none') +'">\
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="width:auto" disabled="disabled">\
<b id="sName" val="'+ obj.from.sname +'">'+ sNameName +'</b>\
<b id="sName" val="'+ obj.from.sname +'">'+ obj.from.sname +'</b>\
<span class="caret"></span>\
</button>\
<ul class="dropdown-menu" role="menu" aria-labelledby="sName">'+ sNameDom +'</ul>\
@@ -835,10 +840,10 @@ function closeOpt(){
//星期
function toWeek(){
var mBody = '<div class="dropdown planweek pull-left mr20">\
<button class="btn btn-default dropdown-toggle" type="button" id="excode" data-toggle="dropdown">\
<button class="btn btn-default dropdown-toggle" type="button" id="excode_week" data-toggle="dropdown">\
<b val="1">周一</b> <span class="caret"></span>\
</button>\
<ul class="dropdown-menu" role="menu" aria-labelledby="excode">\
<ul class="dropdown-menu" role="menu" aria-labelledby="excode_week">\
<li><a role="menuitem" tabindex="-1" href="javascript:;" value="1">周一</a></li>\
<li><a role="menuitem" tabindex="-1" href="javascript:;" value="2">周二</a></li>\
<li><a role="menuitem" tabindex="-1" href="javascript:;" value="3">周三</a></li>\
+11 -5
View File
@@ -13,20 +13,26 @@
<div class="mr50 pull-left">
<div class="ss-text pull-left">
<em>开启监控</em>
<div class='ssh-item' id="openJK">
</div>
<div class='ssh-item' id="openJK"></div>
</div>
</div>
<div class="mr50 pull-left">
<div class="ss-text pull-left">
<em>保存天数:</em>
<input class="bt-input-text" id="saveDay" value="" type="number">
<input class="bt-input-text" id="save_day" value="" type="number">
</div>
<div class="ss-text pull-left" style="margin-left:10px">
<button class="btn btn-default btn-sm" type="button" onclick="setControl(true);">更改</button>
<button class="btn btn-default btn-sm" type="button" onclick="setControl('save_day',true);">更改</button>
</div>
</div>
<div class="mr50 pull-left" style="padding-left:50px; border-left:#ccc 1px solid; margin-right:0">
<div class="mr50 pull-left" style="padding-left:10px; border-left:#ccc 1px solid; margin-right:0">
<div class="mr50 pull-left">
<div class="ss-text pull-left">
<em>仅统计外网</em>
<div class='ssh-item' id="statAll"></div>
</div>
</div>
<button class="btn btn-default btn-sm" type="button" onclick="closeControl()">清空记录</button>
</div>
</div>
+1 -1
View File
@@ -109,7 +109,7 @@ yum install -y ImageMagick ImageMagick-devel
yum install -y libzstd-devel
yum install -y libevent libevent-devel unzip zip
yum install -y python-imaging libicu-devel bzip2-devel gcc pcre pcre-devel
yum install -y python-imaging libicu-devel bzip2-devel pcre pcre-devel
yum install -y gd gd-devel
yum install -y libjpeg-devel libpng-devel libwebp libwebp-devel
+1 -1
View File
@@ -250,7 +250,7 @@ def systemTask():
cpuInfo = tmp
# 取当前网络Io
networkIo = psutil.net_io_counters()[:4]
networkIo = sm.psutilNetIoCounters()
if not network_up:
network_up = networkIo[0]
network_down = networkIo[1]