diff --git a/plugins/mongodb/check.sh b/plugins/mongodb/check.sh
new file mode 100644
index 000000000..e94441c2a
--- /dev/null
+++ b/plugins/mongodb/check.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# MongoDB 监控脚本
+# 功能:检查 MongoDB 是否运行,如果停止则自动重启
+
+# MongoDB 服务名称(根据你的系统配置调整)
+SERVICE_NAME="mongod"
+
+# 检查 MongoDB 状态函数
+check_mongodb() {
+ # 检查 MongoDB 进程是否在运行
+ if pgrep -x "$SERVICE_NAME" > /dev/null; then
+ echo "$(date): MongoDB 正在运行"
+ return 0
+ else
+ echo "$(date): MongoDB 已停止"
+ return 1
+ fi
+}
+
+# 重启 MongoDB 函数
+restart_mongodb() {
+ echo "$(date): 尝试重启 MongoDB..."
+
+ # 根据你的系统选择适当的命令
+ # 对于使用 systemd 的系统(如 Ubuntu 16.04+, CentOS 7+)
+ if systemctl restart "mongodb"; then
+ echo "$(date): MongoDB 重启成功"
+ return 0
+ else
+ echo "$(date): MongoDB 重启失败"
+ return 1
+ fi
+
+ # 对于使用 init.d 的系统
+ # service mongod restart
+}
+
+if ! check_mongodb; then
+ echo "$(date): 检测到 MongoDB 停止运行"
+ restart_mongodb
+fi
diff --git a/plugins/mongodb/index.html b/plugins/mongodb/index.html
index 46f25956f..3d930fab4 100755
--- a/plugins/mongodb/index.html
+++ b/plugins/mongodb/index.html
@@ -63,6 +63,7 @@
负载状态
复制状态
日志
+ 维护功能
相关说明
diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py
index 4480ba02b..c6b74c6f8 100755
--- a/plugins/mongodb/index.py
+++ b/plugins/mongodb/index.py
@@ -1524,6 +1524,22 @@ def runLog():
return f
return getServerDir() + '/logs.pl'
+def cronAddCheck():
+ try:
+ import tool_task
+ tool_task.createBgTask()
+ return mw.returnJson(True, '添加检查任务成功')
+ except Exception as e:
+ return mw.returnJson(False, '添加检查任务失败:'+str(e))
+
+def cronDelCheck():
+ try:
+ import tool_task
+ tool_task.removeBgTask()
+ return mw.returnJson(True, '删除检查任务成功')
+ except Exception as e:
+ return mw.returnJson(False, '删除检查任务失败:'+str(e))
+
def installPreInspectionDebainCheck(sysId,version):
if version == '8.0':
@@ -1666,5 +1682,9 @@ if __name__ == "__main__":
print(test())
elif func == 'test_data':
print(testData())
+ elif func == 'cron_add_check':
+ print(cronAddCheck())
+ elif func == 'cron_del_check':
+ print(cronDelCheck())
else:
print('error')
diff --git a/plugins/mongodb/js/mongodb.js b/plugins/mongodb/js/mongodb.js
index 8617d6d7a..526372bd4 100644
--- a/plugins/mongodb/js/mongodb.js
+++ b/plugins/mongodb/js/mongodb.js
@@ -1241,6 +1241,28 @@ function importDbExternal(file,name){
});
}
+function otherFunc(){
+ var con = '
\
+ \
+ \
+
';
+ $(".soft-man-con").html(con);
+}
+
+function cronAddCheck(){
+ mgPost('cron_add_check', '', {}, function(data){
+ var rdata = $.parseJSON(data.data);
+ layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
+ });
+}
+
+function cronDelCheck(){
+ mgPost('cron_del_check', '', {}, function(data){
+ var rdata = $.parseJSON(data.data);
+ layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
+ });
+}
+
function mgdbReadme(){
var readme = '
';
readme += '- 认证同步说明
';
diff --git a/plugins/mongodb/tool_task.py b/plugins/mongodb/tool_task.py
new file mode 100644
index 000000000..d7a769640
--- /dev/null
+++ b/plugins/mongodb/tool_task.py
@@ -0,0 +1,124 @@
+# coding:utf-8
+
+import sys
+import io
+import os
+import time
+import json
+
+web_dir = os.getcwd() + "/web"
+if os.path.exists(web_dir):
+ sys.path.append(web_dir)
+ os.chdir(web_dir)
+
+import core.mw as mw
+from utils.crontab import crontab as MwCrontab
+
+
+app_debug = False
+if mw.isAppleSystem():
+ app_debug = True
+
+
+def getPluginName():
+ return 'mongodb'
+
+
+def getPluginDir():
+ return mw.getPluginDir() + '/' + getPluginName()
+
+
+def getServerDir():
+ return mw.getServerDir() + '/' + getPluginName()
+
+
+def getTaskConf():
+ conf = getServerDir() + "/task_config.json"
+ return conf
+
+
+def getConfigData():
+ conf = getTaskConf()
+ if os.path.exists(conf):
+ return json.loads(mw.readFile(getTaskConf()))
+ return {
+ "task_id": -1,
+ "period": "minute-n",
+ "where1": "1",
+ "hour": "0",
+ "minute": "0",
+ }
+
+
+def createBgTask():
+ removeBgTask()
+ createBgTaskByName(getPluginName())
+
+
+def createBgTaskByName(name):
+ args = getConfigData()
+ _name = "[MongoDB]检查任务"
+ res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find()
+ if res:
+ return True
+
+ if "task_id" in args and args["task_id"] > 0:
+ res = mw.M("crontab").field("id, name").where(
+ "id=?", (args["task_id"],)).find()
+ if res and res["id"] == args["task_id"]:
+ print("计划任务已经存在!")
+ return True
+
+ mw_dir = mw.getPanelDir()
+ cmd = '''
+mw_dir=%s
+rname=%s
+plugin_path=%s
+script_path=%s
+''' % (mw_dir, name, getServerDir(), getPluginDir())
+ cmd += 'echo "bash $script_path/check.sh"' + "\n"
+ cmd += 'cd $mw_dir && bash $script_path/check.sh' + "\n"
+
+ params = {
+ 'name': _name,
+ 'type': args['period'],
+ 'week': "",
+ 'where1': args['where1'],
+ 'hour': args['hour'],
+ 'minute': args['minute'],
+ 'save': "",
+ 'backup_to': "",
+ 'stype': "toShell",
+ 'sname': '',
+ 'sbody': cmd,
+ 'url_address': '',
+ }
+
+ task_id = MwCrontab.instance().add(params)
+ if task_id > 0:
+ args["task_id"] = task_id
+ args["name"] = name
+ mw.writeFile(getTaskConf(), json.dumps(args))
+
+
+def removeBgTask():
+ cfg = getConfigData()
+ if "task_id" in cfg and cfg["task_id"] > 0:
+ res = mw.M("crontab").field("id, name").where(
+ "id=?", (cfg["task_id"],)).find()
+ if res and res["id"] == cfg["task_id"]:
+ data = MwCrontab.instance().delete(cfg["task_id"])
+ if data["status"]:
+ cfg["task_id"] = -1
+ mw.writeFile(getTaskConf(), json.dumps(cfg))
+ return True
+ return False
+
+
+if __name__ == "__main__":
+ if len(sys.argv) > 1:
+ action = sys.argv[1]
+ if action == "remove":
+ removeBgTask()
+ elif action == "add":
+ createBgTask()
diff --git a/plugins/openresty/index.html b/plugins/openresty/index.html
index ab2ec7ac1..8b7a409df 100755
--- a/plugins/openresty/index.html
+++ b/plugins/openresty/index.html
@@ -8,7 +8,7 @@
负载状态
性能调整
错误日志
- 其它功能
+ 维护功能
diff --git a/plugins/openresty/tool_task.py b/plugins/openresty/tool_task.py
index bc1cb3a85..6029ad9ee 100644
--- a/plugins/openresty/tool_task.py
+++ b/plugins/openresty/tool_task.py
@@ -76,7 +76,7 @@ rname=%s
plugin_path=%s
script_path=%s
''' % (mw_dir, name, getServerDir(), getPluginDir())
- cmd += 'echo "python3 $script_path/check.sh"' + "\n"
+ cmd += 'echo "bash $script_path/check.sh"' + "\n"
cmd += 'cd $mw_dir && bash $script_path/check.sh' + "\n"
params = {
diff --git a/web/utils/site.py b/web/utils/site.py
index 8c3de2240..954c0e2b9 100644
--- a/web/utils/site.py
+++ b/web/utils/site.py
@@ -1994,8 +1994,8 @@ location ^~ {from} {\n\
dnsapi_option = [
{"name":"none", "title":'手动解析', 'key':'', 'help':''},
{"name":"dns_ali", "title":'Aliyun', 'key':'Ali_Key:Ali_Secret', 'help':'阿里云控制台》用户头像》accesskeys按指引获取AccessKey/SecretKey'},
- {"name":"dns_huaweicloud", "title":'华为云', 'key':'HUAWEICLOUD_Username:HUAWEICLOUD_Password:HUAWEICLOUD_DomainName:HUAWEICLOUD_ProjectID:HUAWEICLOUD_AccessKey:HUAWEICLOUD_SecretKey'},
- {"name":"dns_cf", "title":'cloudflare', 'key':'CF_Key:CF_Email', 'help':'CloudFlare后台获取Global API Key'},
+ {"name":"dns_huaweicloud", "title":'华为云', 'key':'HUAWEICLOUD_Username:HUAWEICLOUD_Password:HUAWEICLOUD_DomainName'},
+ {"name":"dns_cf", "title":'cloudflare', 'key':'CF_Key:CF_Email:CF_Token:CF_Account_ID:CF_Zone_ID', 'help':'CloudFlare后台获取Global API Key'},
{"name":"dns_dp", "title":'dnspod/国内', 'key':'DP_Id:DP_Key','help':'DnsPod后台》用户中心》安全设置,开启API Token'},
{"name":"dns_dpi", "title":'dnspod/国际', 'key':'DPI_Id:DPI_Key','help':'DnsPod后台》用户中心》安全设置,开启API Token'},
{"name":"dns_tencent", "title":"腾讯云DNS", 'key':'Tencent_SecretId:Tencent_SecretKey', 'help':'腾讯云后台获取通行证'},