pull/121/head
midoks 3 years ago
parent 10ac5106c9
commit a967f50d7f
  1. 58
      plugins/mongodb/index.html
  2. 7
      plugins/mongodb/index.py
  3. 12
      plugins/mongodb/install.sh
  4. 47
      plugins/mongodb/js/mongodb.js
  5. 2
      plugins/mysql/conf/my.cnf
  6. 4
      plugins/mysql/index.py

@ -4,7 +4,7 @@
<p class="bgw" onclick="pluginService('mongodb');">服务</p>
<p onclick="pluginInitD('mongodb');">自启动</p>
<p onclick="pluginConfig('mongodb');">配置修改</p>
<p onclick="redisStatus();">负载状态</p>
<p onclick="mongoStatus();">负载状态</p>
<p onclick="pluginLogs('mongodb','','run_log');">日志</p>
</div>
<div class="bt-w-con pd15">
@ -13,55 +13,11 @@
</div>
</div>
<script type="text/javascript">
pluginService('mongodb');
//redis负载状态 start
function redisStatus() {
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 = '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>字段</th><th>当前值</th><th>说明</th></thead>\
<tbody>\
<tr><th>version</th><td>' + rdata.version + '</td><td>版本</td></tr>\
<tr><th>db_path</th><td>' + rdata.db_path + '</td><td>数据路径</td></tr>\
<tr><th>uptime</th><td>' + rdata.uptime + '</td><td>已运行秒</td></tr>\
<tr><th>connections</th><td>' + rdata.connections + '</td><td>当前链接数</td></tr>\
<tr><th>collections</th><td>' + rdata.collections + '</td><td>文档数</td></tr>\
<tbody>\
</table></div><hr/>';
var t = '';
for(var i=0; i<rdata.dbs.length;i++){
t += '<tr>';
t += '<th>'+rdata.dbs[i]["db"]+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["totalSize"])+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["storageSize"])+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["dataSize"])+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["indexSize"])+'</th>';
t += '<th>'+rdata.dbs[i]["indexes"]+'</th>';
t += '<th>'+rdata.dbs[i]["objects"]+'</th>';
t += '</tr>';
}
// console.log(t);
Con += '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>库名</th><th>大小</th><th>存储大小</th><th>数据</th><th>索引</th><th>文档数据</th><th>对象</th></thead>\
<tbody>'+t+'<tbody>\
</table></div>';
// console.log(rdata.dbs);
$(".soft-man-con").html(Con);
},'json');
}
//mongodb start
var loading = layer.msg("资源加载中...", { icon: 16, time: 0, shade: 0.3 });
$.getScript( "/plugins/file?name=mongodb&f=js/mongodb.js", function(){
layer.close(loading);
pluginService('mongodb')
});
//mongodb end
</script>

@ -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':

@ -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
}

@ -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 = '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>字段</th><th></th><th></th></thead>\
<tbody>\
<tr><th>version</th><td>' + rdata.version + '</td><td></td></tr>\
<tr><th>db_path</th><td>' + rdata.db_path + '</td><td></td></tr>\
<tr><th>uptime</th><td>' + rdata.uptime + '</td><td></td></tr>\
<tr><th>connections</th><td>' + rdata.connections + '</td><td></td></tr>\
<tr><th>collections</th><td>' + rdata.collections + '</td><td></td></tr>\
<tbody>\
</table></div><hr/>';
var t = '';
for(var i=0; i<rdata.dbs.length;i++){
t += '<tr>';
t += '<th>'+rdata.dbs[i]["db"]+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["totalSize"])+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["storageSize"])+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["dataSize"])+'</th>';
t += '<th>'+toSize(rdata.dbs[i]["indexSize"])+'</th>';
t += '<th>'+rdata.dbs[i]["indexes"]+'</th>';
t += '<th>'+rdata.dbs[i]["objects"]+'</th>';
t += '</tr>';
}
// console.log(t);
Con += '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>库名</th><th></th><th></th><th></th><th></th><th></th><th></th></thead>\
<tbody>'+t+'<tbody>\
</table></div>';
// console.log(rdata.dbs);
$(".soft-man-con").html(Con);
},'json');
}

@ -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

@ -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

Loading…
Cancel
Save