mirror of
https://github.com//cppla/ServerStatus
synced 2025-06-05 07:09:49 +08:00
dev: add month traffic , no completed
This commit is contained in:
parent
55ee9ca6fb
commit
7cf9d969bc
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
# The Dockerfile for build localhost source, not git repo
|
||||
FROM debian:buster as builder
|
||||
|
||||
MAINTAINER cppla https://cpp.la
|
||||
|
||||
RUN apt-get update -y && apt-get -y install gcc g++ make
|
||||
|
||||
COPY . .
|
||||
|
||||
WORKDIR /server
|
||||
|
||||
RUN make
|
||||
RUN pwd && ls -a
|
||||
|
||||
# glibc env run
|
||||
FROM nginx:latest
|
||||
|
||||
RUN mkdir -p /ServerStatus/server/
|
||||
|
||||
COPY --from=builder server /ServerStatus/server/
|
||||
COPY --from=builder web /usr/share/nginx/html/
|
||||
|
||||
EXPOSE 80 35601
|
||||
|
||||
CMD nohup sh -c '/etc/init.d/nginx start && /ServerStatus/server/sergate --config=/ServerStatus/server/config.json --web-dir=/usr/share/nginx/html'
|
@ -1,4 +1,5 @@
|
||||
FROM debian:latest as builder
|
||||
# the Dockerfile is for build git repo
|
||||
FROM debian:buster as builder
|
||||
|
||||
MAINTAINER cppla https://cpp.la
|
||||
|
||||
|
20
autodeploy/config.json
Executable file → Normal file
20
autodeploy/config.json
Executable file → Normal file
@ -6,7 +6,8 @@
|
||||
"type": "xen",
|
||||
"host": "host1",
|
||||
"location": "🇨🇳",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
},
|
||||
{
|
||||
"username": "s02",
|
||||
@ -14,7 +15,8 @@
|
||||
"type": "vmware",
|
||||
"host": "host2",
|
||||
"location": "🇯🇵",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
},
|
||||
{
|
||||
"disabled": true,
|
||||
@ -23,15 +25,17 @@
|
||||
"type": "Nothing",
|
||||
"host": "host3",
|
||||
"location": "🇫🇷",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
},
|
||||
{
|
||||
"username": "s04",
|
||||
"name": "ssss",
|
||||
"type": "ssss",
|
||||
"host": "ssss",
|
||||
"location": "🇺🇸",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"name": "node4",
|
||||
"type": "kvm",
|
||||
"host": "host4",
|
||||
"location": "🇰🇷",
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
"type": "xen",
|
||||
"host": "host1",
|
||||
"location": "🇨🇳",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
},
|
||||
{
|
||||
"username": "s02",
|
||||
@ -14,7 +15,8 @@
|
||||
"type": "vmware",
|
||||
"host": "host2",
|
||||
"location": "🇯🇵",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
},
|
||||
{
|
||||
"disabled": true,
|
||||
@ -23,7 +25,8 @@
|
||||
"type": "Nothing",
|
||||
"host": "host3",
|
||||
"location": "🇫🇷",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
},
|
||||
{
|
||||
"username": "s04",
|
||||
@ -31,7 +34,8 @@
|
||||
"type": "kvm",
|
||||
"host": "host4",
|
||||
"location": "🇰🇷",
|
||||
"password": "USER_DEFAULT_PASSWORD"
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -269,11 +269,23 @@ void CMain::JSONUpdateThread(void *pUser)
|
||||
else
|
||||
str_format(aUptime, sizeof(aUptime), "%02d:%02d:%02d", (int)(pClients[i].m_Stats.m_Uptime/60.0/60.0), (int)((pClients[i].m_Stats.m_Uptime/60)%60), (int)((pClients[i].m_Stats.m_Uptime)%60));
|
||||
|
||||
// track month network traffic, diff: 2021-10-01 00:10
|
||||
time_t currentStamp = (long long)time(/*ago*/0);
|
||||
if(0 == pClients[i].m_LastNetworkIN || (localtime(¤tStamp)->tm_mday == pClients[i].m_aMonthStart && localtime(¤tStamp)->tm_hour == 0 && localtime(¤tStamp)->tm_min < 10))
|
||||
{
|
||||
pClients[i].m_LastNetworkIN = pClients[i].m_Stats.m_NetworkIN;
|
||||
pClients[i].m_LastNetworkOUT = pClients[i].m_Stats.m_NetworkOUT;
|
||||
}
|
||||
|
||||
str_format(pBuf, sizeof(aFileBuf) - (pBuf - aFileBuf),
|
||||
"{ \"name\": \"%s\",\"type\": \"%s\",\"host\": \"%s\",\"location\": \"%s\",\"online4\": %s, \"online6\": %s,\"ip_status\": %s,\"uptime\": \"%s\",\"load_1\": %.2f, \"load_5\": %.2f, \"load_15\": %.2f,\"ping_10010\": %.2f, \"ping_189\": %.2f, \"ping_10086\": %.2f,\"time_10010\": %" PRId64 ", \"time_189\": %" PRId64 ", \"time_10086\": %" PRId64 ", \"tcp_count\": %" PRId64 ", \"udp_count\": %" PRId64 ", \"process_count\": %" PRId64 ", \"thread_count\": %" PRId64 ", \"network_rx\": %" PRId64 ", \"network_tx\": %" PRId64 ", \"network_in\": %" PRId64 ", \"network_out\": %" PRId64 ", \"cpu\": %d, \"memory_total\": %" PRId64 ", \"memory_used\": %" PRId64 ", \"swap_total\": %" PRId64 ", \"swap_used\": %" PRId64 ", \"hdd_total\": %" PRId64 ", \"hdd_used\": %" PRId64 ", \"custom\": \"%s\" },\n",
|
||||
"{ \"name\": \"%s\",\"type\": \"%s\",\"host\": \"%s\",\"location\": \"%s\",\"online4\": %s, \"online6\": %s,\"ip_status\": %s,\"uptime\": \"%s\",\"load_1\": %.2f, \"load_5\": %.2f, \"load_15\": %.2f,\"ping_10010\": %.2f, \"ping_189\": %.2f, \"ping_10086\": %.2f,\"time_10010\": %" PRId64 ", \"time_189\": %" PRId64 ", \"time_10086\": %" PRId64 ", \"tcp_count\": %" PRId64 ", \"udp_count\": %" PRId64 ", \"process_count\": %" PRId64 ", \"thread_count\": %" PRId64 ", \"network_rx\": %" PRId64 ", \"network_tx\": %" PRId64 ", \"network_in\": %" PRId64 ", \"network_out\": %" PRId64 ", \"cpu\": %d, \"memory_total\": %" PRId64 ", \"memory_used\": %" PRId64 ", \"swap_total\": %" PRId64 ", \"swap_used\": %" PRId64 ", \"hdd_total\": %" PRId64 ", \"hdd_used\": %" PRId64 ", \"last_network_in\": %" PRId64 ", \"last_network_out\": %" PRId64 ",\"custom\": \"%s\" },\n",
|
||||
pClients[i].m_aName,pClients[i].m_aType,pClients[i].m_aHost,pClients[i].m_aLocation,
|
||||
pClients[i].m_Stats.m_Online4 ? "true" : "false",pClients[i].m_Stats.m_Online6 ? "true" : "false",pClients[i].m_Stats.m_IpStatus ? "true": "false",
|
||||
aUptime, pClients[i].m_Stats.m_Load_1, pClients[i].m_Stats.m_Load_5, pClients[i].m_Stats.m_Load_15, pClients[i].m_Stats.m_ping_10010, pClients[i].m_Stats.m_ping_189, pClients[i].m_Stats.m_ping_10086, pClients[i].m_Stats.m_time_10010, pClients[i].m_Stats.m_time_189, pClients[i].m_Stats.m_time_10086,pClients[i].m_Stats.m_tcpCount,pClients[i].m_Stats.m_udpCount,pClients[i].m_Stats.m_processCount,pClients[i].m_Stats.m_threadCount,pClients[i].m_Stats.m_NetworkRx, pClients[i].m_Stats.m_NetworkTx, pClients[i].m_Stats.m_NetworkIN, pClients[i].m_Stats.m_NetworkOUT, (int)pClients[i].m_Stats.m_CPU, pClients[i].m_Stats.m_MemTotal, pClients[i].m_Stats.m_MemUsed, pClients[i].m_Stats.m_SwapTotal, pClients[i].m_Stats.m_SwapUsed, pClients[i].m_Stats.m_HDDTotal, pClients[i].m_Stats.m_HDDUsed, pClients[i].m_Stats.m_aCustom);
|
||||
aUptime, pClients[i].m_Stats.m_Load_1, pClients[i].m_Stats.m_Load_5, pClients[i].m_Stats.m_Load_15, pClients[i].m_Stats.m_ping_10010, pClients[i].m_Stats.m_ping_189, pClients[i].m_Stats.m_ping_10086,
|
||||
pClients[i].m_Stats.m_time_10010, pClients[i].m_Stats.m_time_189, pClients[i].m_Stats.m_time_10086,pClients[i].m_Stats.m_tcpCount,pClients[i].m_Stats.m_udpCount,pClients[i].m_Stats.m_processCount,pClients[i].m_Stats.m_threadCount,
|
||||
pClients[i].m_Stats.m_NetworkRx, pClients[i].m_Stats.m_NetworkTx, pClients[i].m_Stats.m_NetworkIN, pClients[i].m_Stats.m_NetworkOUT, (int)pClients[i].m_Stats.m_CPU, pClients[i].m_Stats.m_MemTotal, pClients[i].m_Stats.m_MemUsed,
|
||||
pClients[i].m_Stats.m_SwapTotal, pClients[i].m_Stats.m_SwapUsed, pClients[i].m_Stats.m_HDDTotal, pClients[i].m_Stats.m_HDDUsed,
|
||||
pClients[i].m_Stats.m_NetworkIN - pClients[i].m_LastNetworkIN, pClients[i].m_Stats.m_NetworkOUT - pClients[i].m_LastNetworkOUT, pClients[i].m_Stats.m_aCustom);
|
||||
pBuf += strlen(pBuf);
|
||||
}
|
||||
else
|
||||
@ -367,15 +379,23 @@ int CMain::ReadConfig()
|
||||
str_copy(Client(ID)->m_aHost, rStart[i]["host"].u.string.ptr, sizeof(Client(ID)->m_aHost));
|
||||
str_copy(Client(ID)->m_aLocation, rStart[i]["location"].u.string.ptr, sizeof(Client(ID)->m_aLocation));
|
||||
str_copy(Client(ID)->m_aPassword, rStart[i]["password"].u.string.ptr, sizeof(Client(ID)->m_aPassword));
|
||||
//if month start day > 28, diff: 3days(29,30,31)
|
||||
Client(ID)->m_aMonthStart = rStart[i]["monthstart"].u.integer;
|
||||
if(Client(ID)->m_aMonthStart > 28)
|
||||
{
|
||||
Client(ID)->m_aMonthStart = 28;
|
||||
}
|
||||
Client(ID)->m_LastNetworkIN = 0;
|
||||
Client(ID)->m_LastNetworkOUT = 0;
|
||||
|
||||
if(m_Config.m_Verbose)
|
||||
{
|
||||
if(Client(ID)->m_Disabled)
|
||||
dbg_msg("main", "[#%d: Name: \"%s\", Username: \"%s\", Type: \"%s\", Host: \"%s\", Location: \"%s\", Password: \"%s\"]",
|
||||
ID, Client(ID)->m_aName, Client(ID)->m_aUsername, Client(ID)->m_aType, Client(ID)->m_aHost, Client(ID)->m_aLocation, Client(ID)->m_aPassword);
|
||||
dbg_msg("main", "[#%d: Name: \"%s\", Username: \"%s\", Type: \"%s\", Host: \"%s\", Location: \"%s\", Password: \"%s\", MonthStart: %\" PRId64 \"]",
|
||||
ID, Client(ID)->m_aName, Client(ID)->m_aUsername, Client(ID)->m_aType, Client(ID)->m_aHost, Client(ID)->m_aLocation, Client(ID)->m_aPassword, Client(ID)->m_aMonthStart);
|
||||
else
|
||||
dbg_msg("main", "#%d: Name: \"%s\", Username: \"%s\", Type: \"%s\", Host: \"%s\", Location: \"%s\", Password: \"%s\"",
|
||||
ID, Client(ID)->m_aName, Client(ID)->m_aUsername, Client(ID)->m_aType, Client(ID)->m_aHost, Client(ID)->m_aLocation, Client(ID)->m_aPassword);
|
||||
dbg_msg("main", "#%d: Name: \"%s\", Username: \"%s\", Type: \"%s\", Host: \"%s\", Location: \"%s\", Password: \"%s\", MonthStart: %\" PRId64 \"",
|
||||
ID, Client(ID)->m_aName, Client(ID)->m_aUsername, Client(ID)->m_aType, Client(ID)->m_aHost, Client(ID)->m_aLocation, Client(ID)->m_aPassword, Client(ID)->m_aMonthStart);
|
||||
|
||||
}
|
||||
ID++;
|
||||
|
@ -36,6 +36,10 @@ class CMain
|
||||
char m_aHost[128];
|
||||
char m_aLocation[128];
|
||||
char m_aPassword[128];
|
||||
int m_aMonthStart; //track month network traffic. by: https://cpp.la
|
||||
|
||||
int64_t m_LastNetworkIN; //last network traffic in record.
|
||||
int64_t m_LastNetworkOUT; //last network traffic out record.
|
||||
|
||||
int64 m_TimeConnected;
|
||||
int64 m_LastUpdate;
|
||||
|
@ -1,13 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
json字段保持完整, 后期更新会向下兼容
|
||||
可以自定义前端展示
|
||||
json字段保持完整, 自行自定义前端展示
|
||||
ლ(•̀ _ •́ ლ)
|
||||
ლ(•̀ _ •́ ლ)ლ(•̀ _ •́ ლ)
|
||||
ლ(•̀ _ •́ ლ)ლ(•̀ _ •́ ლ)ლ(•̀ _ •́ ლ)
|
||||
ლ(•̀ _ •́ ლ)ლ(•̀ _ •́ ლ)
|
||||
ლ(•̀ _ •́ ლ)
|
||||
by:https://www.cpp.la
|
||||
by:https://cpp.la
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@ -77,14 +76,14 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="status4" style="text-align: center;">协议</th>
|
||||
<th id="ipstatus" style="text-align: center;">Flight</th>
|
||||
<th id="ipstatus" style="text-align: center;">月流量</th>
|
||||
<th id="name">节点名</th>
|
||||
<th id="type">虚拟化</th>
|
||||
<th id="location">位置</th>
|
||||
<th id="uptime">在线时间</th>
|
||||
<th id="load">负载</th>
|
||||
<th id="network">网络 ↓|↑</th>
|
||||
<th id="traffic">流量 ↓|↑</th>
|
||||
<th id="traffic">总流量 ↓|↑</th>
|
||||
<th id="cpu">处理器</th>
|
||||
<th id="ram">内存</th>
|
||||
<th id="hdd">硬盘</th>
|
||||
|
@ -75,7 +75,7 @@ function uptime() {
|
||||
$.getJSON("json/stats.json", function(result) {
|
||||
$("#loading-notice").remove();
|
||||
if(result.reload)
|
||||
setTimeout(function() { location.reload(true) }, 1000);
|
||||
setTimeout(function() { location.reload() }, 1000);
|
||||
|
||||
for (var i = 0, rlen=result.servers.length; i < rlen; i++) {
|
||||
var TableRow = $("#servers tr#r" + i);
|
||||
@ -145,10 +145,10 @@ function uptime() {
|
||||
// Ipstatus
|
||||
// mh361 or mh370, mourn mh370, 2014-03-08 01:20 lost from all over the world.
|
||||
if (result.servers[i].ip_status) {
|
||||
TableRow.children["ip_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||
TableRow.children["ip_status"].children[0].children[0].className = "progress-bar";
|
||||
TableRow.children["ip_status"].children[0].children[0].innerHTML = "<small>MH361</small>";
|
||||
} else {
|
||||
TableRow.children["ip_status"].children[0].children[0].className = "progress-bar progress-bar-danger";
|
||||
TableRow.children["ip_status"].children[0].children[0].className = "progress-bar";
|
||||
TableRow.children["ip_status"].children[0].children[0].innerHTML = "<small>MH370</small>";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user