function spPostMin(method, args, callback){
var req_data = {};
req_data['name'] = 'sphinx';
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 rebuild(){
var con = '';
$(".soft-man-con").html(con);
}
function rebuildIndex(){
spPost('rebuild', '', function(data){
if (data.data == 'ok'){
layer.msg('在重建中..',{icon:1,time:2000,shade: [0.3, '#000']});
} else {
layer.msg(data.data,{icon:2,time:2000,shade: [0.3, '#000']});
}
});
}
function runStatus(){
spPost('run_status', '', function(data){
var rdata = $.parseJSON(data.data);
if (!rdata['status']){
layer.msg(rdata['msg'],{icon:2,time:2000,shade: [0.3, '#000']});
return;
}
var idata = rdata.data;
console.log(idata);
var Con = '
\
\
运行时间 | ' + idata.uptime + 's | 每秒查询 | ' + parseInt(parseInt(idata.queries) / parseInt(idata.uptime)) + ' |
\
总连接次数 | ' + idata.connections + ' | work_queue_length | ' +idata.work_queue_length + ' |
\
agent_connect | ' + idata.agent_connect+ ' | workers_active | ' + idata.workers_active + ' |
\
agent_retry | ' + idata.agent_retry + ' | workers_total | ' + idata.workers_total + ' |
\
\
\
\
| | | | \
\
command_delete | ' + idata.command_delete + ' | command_delete |
\
command_excerpt | ' + idata.command_excerpt + ' | command_excerpt |
\
command_flushattrs | ' + idata.command_flushattrs + ' | command_flushattrs |
\
command_keywords | ' + idata.command_keywords + ' | command_keywords |
\
command_persist | ' + idata.command_persist + ' | command_persist |
\
command_search | ' + idata.command_search + ' | command_search |
\
command_status | ' + idata.command_status + ' | command_status |
\
command_update | ' + idata.command_update + ' | command_update |
\
\
';
$(".soft-man-con").html(Con);
});
}