From a967f50d7f3fab344c1df3122d32c9bd7fc495b8 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 9 Jul 2022 00:47:36 +0800 Subject: [PATCH] up --- plugins/mongodb/index.html | 58 +++++------------------------------ plugins/mongodb/index.py | 7 +++++ plugins/mongodb/install.sh | 12 +++++--- plugins/mongodb/js/mongodb.js | 47 ++++++++++++++++++++++++++++ plugins/mysql/conf/my.cnf | 2 -- plugins/mysql/index.py | 4 +-- 6 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 plugins/mongodb/js/mongodb.js diff --git a/plugins/mongodb/index.html b/plugins/mongodb/index.html index ebe9c50cf..dcb713bef 100755 --- a/plugins/mongodb/index.html +++ b/plugins/mongodb/index.html @@ -4,7 +4,7 @@

服务

自启动

配置修改

-

负载状态

+

负载状态

日志

@@ -13,55 +13,11 @@
\ No newline at end of file diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index 26fc280c7..1029104ab 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -226,6 +226,11 @@ def runLog(): if __name__ == "__main__": func = sys.argv[1] + + version = "4.4" + if (len(sys.argv) > 2): + version = sys.argv[2] + if func == 'status': print(status()) elif func == 'start': @@ -236,6 +241,8 @@ if __name__ == "__main__": print(restart()) elif func == 'reload': print(reload()) + elif func == 'install_pre_inspection': + print(installPreInspection(version)) elif func == 'initd_status': print(initdStatus()) elif func == 'initd_install': diff --git a/plugins/mongodb/install.sh b/plugins/mongodb/install.sh index e62a3ef84..dcbaf030e 100755 --- a/plugins/mongodb/install.sh +++ b/plugins/mongodb/install.sh @@ -227,12 +227,14 @@ Install_app() Install_app_linux fi - echo "${VERSION}" > $serverPath/mongodb/version.pl - echo '安装完成' > $install_tmp + if [ "$?" == "0" ];then + echo "${VERSION}" > $serverPath/mongodb/version.pl + echo '安装完成' > $install_tmp - #初始化 - cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py start - cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py initd_install + #初始化 + cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py initd_install + fi } diff --git a/plugins/mongodb/js/mongodb.js b/plugins/mongodb/js/mongodb.js new file mode 100644 index 000000000..bff45b955 --- /dev/null +++ b/plugins/mongodb/js/mongodb.js @@ -0,0 +1,47 @@ +function mongoStatus() { + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'mongodb', func:'run_info'}, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + var rdata = $.parseJSON(data.data); + hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2); + var Con = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
字段当前值说明
version' + rdata.version + '版本
db_path' + rdata.db_path + '数据路径
uptime' + rdata.uptime + '已运行秒
connections' + rdata.connections + '当前链接数
collections' + rdata.collections + '文档数

'; + + var t = ''; + for(var i=0; i'; + t += ''+toSize(rdata.dbs[i]["totalSize"])+''; + t += ''+toSize(rdata.dbs[i]["storageSize"])+''; + t += ''+toSize(rdata.dbs[i]["dataSize"])+''; + t += ''+toSize(rdata.dbs[i]["indexSize"])+''; + t += ''+rdata.dbs[i]["indexes"]+''; + t += ''+rdata.dbs[i]["objects"]+''; + t += ''; + } + // console.log(t); + + Con += '
\ + \ + \ + '+t+'\ +
库名大小存储大小数据索引文档数据对象
'; + // console.log(rdata.dbs); + + $(".soft-man-con").html(Con); + },'json'); +} \ No newline at end of file diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my.cnf index 2e404d89e..b20e5b744 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my.cnf @@ -6,8 +6,6 @@ socket = {$SERVER_APP_PATH}/mysql.sock [mysqld] pid-file = {$SERVER_APP_PATH}/data/mysql.pid -# 5.6 -#default-authentication-plugin=sha256_password user = mysql port = 3306 socket = {$SERVER_APP_PATH}/mysql.sock diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index a25eab6c8..526cd976f 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -307,9 +307,9 @@ def initMysqlData(): datadir = getDataDir() if not os.path.exists(datadir + '/mysql'): serverdir = getServerDir() + myconf = serverdir + "/etc/my.cnf" user = pGetDbUser() - cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --user=' + \ - user + ' --basedir=' + serverdir + ' --ldata=' + datadir + cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --defaults-file=' + myconf mw.execShell(cmd) return False return True