pull/109/head
midoks 6 years ago
parent 6b18518961
commit 81e7ef1471
  1. 2
      plugins/redis/index.py
  2. 46
      plugins/simdht/index.py
  3. 2
      plugins/simdht/init.d/simdht.tpl
  4. 110
      plugins/simdht/js/simdht.js
  5. 4
      plugins/simdht/workers/db.cfg
  6. 17
      plugins/simdht/workers/simdht_worker.py

@ -9,7 +9,7 @@ sys.path.append(os.getcwd() + "/class/core")
import public
app_debug = False
if public.getOs() == 'darwin':
if public.isAppleSystem():
app_debug = True

@ -11,6 +11,11 @@ sys.path.append(os.getcwd() + "/class/core")
import public
app_debug = False
if public.isAppleSystem():
app_debug = True
def getPluginName():
return 'simdht'
@ -187,30 +192,37 @@ def isSqlError(mysqlMsg):
return None
def getMinData(conn, min):
def getMinData(conn, smin):
time_diff = 0
if public.isAppleSystem():
time_diff = 3 * 60
pre = time.strftime("%Y-%m-%d %H:%M:%S",
time.localtime(time.time() - min))
time.localtime(time.time() - smin - time_diff))
sql = "select count(*) from search_hash where create_time > '" + pre + "'"
data = conn.query(sql)
return data[0][0]
def getTrendData():
import time
args = getArgs()
data = checkArgs(args, ['interval'])
if not data[0]:
return data[1]
pdb = pMysqlDb()
interval = int(args['interval'])
result = pdb.execute("show tables")
isError = isSqlError(result)
if isError:
return isError
one = getMinData(pdb, interval)
two = getMinData(pdb, interval * 2)
three = getMinData(pdb, interval * 3)
return public.getJson([one, two, three])
try:
args = getArgs()
data = checkArgs(args, ['interval'])
if not data[0]:
return data[1]
pdb = pMysqlDb()
interval = int(args['interval'])
result = pdb.execute("show tables")
isError = isSqlError(result)
if isError:
return isError
one = getMinData(pdb, interval)
two = getMinData(pdb, interval * 2)
three = getMinData(pdb, interval * 3)
return public.getJson([one, two, three])
except Exception as e:
return public.getJson([0, 0, 0])
if __name__ == "__main__":
func = sys.argv[1]

@ -15,7 +15,7 @@
dht_start(){
cd {$SERVER_PATH}/simdht/workers
nohup python simdht_worker.py >> {$SERVER_PATH}/simdht/logs.pl 2>&1 &
nohup python simdht_worker.py > {$SERVER_PATH}/simdht/logs.pl 2>&1 &
}
dht_stop(){
echo "Stopping ..."

@ -49,8 +49,9 @@ function dhtTrendData(callback){
function dhtTrendRender() {
var myChartNetwork = echarts.init(document.getElementById('dht_trend'));
var xData = [];
var yData = [];
var zData = [];
var oneData = [];
var twoData = [];
var threeData = [];
function getTime() {
var now = new Date();
@ -78,39 +79,40 @@ function dhtTrendRender() {
}
function addData(data) {
console.log(data);
// console.log(data);
var rdata = $.parseJSON(data.data);
xData.push(getTime());
yData.push(data[0]);
zData.push(data[1]);
// if (shift) {
// xData.shift();
// yData.shift();
// zData.shift();
// }
oneData.push(rdata[0]);
twoData.push(rdata[1]);
threeData.push(rdata[2]);
xData.shift();
oneData.shift();
twoData.shift();
threeData.shift();
}
for (var i = 8; i >= 0; i--) {
var time = (new Date()).getTime();
xData.push(format(time - (i * 3 * 1000)));
yData.push(0);
zData.push(0);
xData.push(format(time - (i * 5 * 1000)));
oneData.push(0);
twoData.push(0);
threeData.push(0);
}
// 指定图表的配置项和数据
var option = {
title: {
text: lan.index.interface_net,
text: '接口流量实时',
left: 'center',
textStyle: {
color: '#888888',
fontStyle: 'normal',
fontFamily: lan.index.net_font,
fontSize: 16,
color: '#888888',fontStyle: 'normal',
fontFamily: '宋体',fontSize: 16,
}
},
tooltip: {
trigger: 'axis'
},
legend: {
data: [lan.index.net_up, lan.index.net_down],
data: ['5s', '10s', '15s'],
bottom: '2%'
},
xAxis: {
@ -124,7 +126,7 @@ function dhtTrendRender() {
}
},
yAxis: {
name: lan.index.unit + 'KB/s',
name: '单位个数',
splitLine: {
lineStyle: {
color: "#eee"
@ -137,9 +139,30 @@ function dhtTrendRender() {
}
},
series: [{
name: lan.index.net_up,
name: '5s',
type: 'line',
data: yData,
data: oneData,
smooth: true,
showSymbol: false,
symbol: 'circle',
symbolSize: 6,
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1,
[{offset: 0,color: 'rgba(205, 51, 51,0.5)'},
{offset: 1,color: 'rgba(205, 51, 51,0.8)'}], false)
}
},
itemStyle: {
normal: {color: '#cd3333'}
},
lineStyle: {
normal: {width: 1}
}
}, {
name: '10s',
type: 'line',
data: twoData,
smooth: true,
showSymbol: false,
symbol: 'circle',
@ -148,27 +171,25 @@ function dhtTrendRender() {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(255, 140, 0,0.5)'
color: 'rgba(30, 144, 255,0.5)'
}, {
offset: 1,
color: 'rgba(255, 140, 0,0.8)'
color: 'rgba(30, 144, 255,0.8)'
}], false)
}
},
itemStyle: {
normal: {
color: '#f7b851'
}
normal: {color: '#52a9ff'}
},
lineStyle: {
normal: {
width: 1
}
}
}, {
name: lan.index.net_down,
},{
name: '15s',
type: 'line',
data: zData,
data: threeData,
smooth: true,
showSymbol: false,
symbol: 'circle',
@ -185,9 +206,7 @@ function dhtTrendRender() {
}
},
itemStyle: {
normal: {
color: '#52a9ff'
}
normal: {color: '#C6E2FF'}
},
lineStyle: {
normal: {
@ -196,23 +215,32 @@ function dhtTrendRender() {
}
}]
};
setInterval(function() {
// 使用刚指定的配置项和数据显示图表。
myChartNetwork.setOption(option);
window.addEventListener("resize", function() {
myChartNetwork.resize();
});
function render(){
dhtTrendData(function(data){
addData(data);
});
myChartNetwork.setOption({
xAxis: {data: xData},
series: [
{name: '5s',data: yData},
{name: '10s',data: zData}
{name: '5s',data: oneData},
{name: '10s',data: twoData},
{name: '15s',data: threeData}
]
});
}
render();
setInterval(function() {
render();
}, 5000);
// 使用刚指定的配置项和数据显示图表。
myChartNetwork.setOption(option);
window.addEventListener("resize", function() {
myChartNetwork.resize();
});
}

@ -4,3 +4,7 @@ DB_USER = ssbc
DB_PORT = 3306
DB_PASS = ssbc
DB_NAME = ssbc
[queue]
MAX_QUEUE_LT = 30
MAX_QUEUE_PT = 200

@ -49,12 +49,12 @@ from metadata import save_metadata
from configparser import ConfigParser
cp = ConfigParser()
cp.read("db.cfg")
section = cp.sections()[0]
DB_HOST = cp.get(section, "DB_HOST")
DB_USER = cp.get(section, "DB_USER")
DB_PORT = cp.getint(section, "DB_PORT")
DB_PASS = cp.get(section, "DB_PASS")
DB_NAME = cp.get(section, "DB_NAME")
section_db = cp.sections()[0]
DB_HOST = cp.get(section_db, "DB_HOST")
DB_USER = cp.get(section_db, "DB_USER")
DB_PORT = cp.getint(section_db, "DB_PORT")
DB_PASS = cp.get(section_db, "DB_PASS")
DB_NAME = cp.get(section_db, "DB_NAME")
BLACK_FILE = 'black_list.txt'
BOOTSTRAP_NODES = (
@ -66,8 +66,9 @@ TID_LENGTH = 2
RE_JOIN_DHT_INTERVAL = 3
TOKEN_LENGTH = 2
MAX_QUEUE_LT = 30
MAX_QUEUE_PT = 200
section_queue = cp.sections()[1]
MAX_QUEUE_LT = cp.getint(section_db, "MAX_QUEUE_LT")
MAX_QUEUE_PT = cp.getint(section_db, "MAX_QUEUE_PT")
geoip = pygeoip.GeoIP('GeoIP.dat')

Loading…
Cancel
Save