From 7c602b7634de2997573525154c7a0273d6dc3edf Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年8月15日 17:39:19 +0800 Subject: [PATCH 01/12] add install.sh --- service/install.sh | 14 ++++++++++++++ service/status-client.service | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 service/install.sh diff --git a/service/install.sh b/service/install.sh new file mode 100755 index 00000000..37df0552 --- /dev/null +++ b/service/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +curl -s https://raw.githubusercontent.com/MelvinTo/ServerStatus/master/clients/client-linux.py -o /tmp/client-linux.py +curl -s https://raw.githubusercontent.com/MelvinTo/ServerStatus/master/service/status-client.service -o /tmp/status-client.service + +sudo mkdir -p /usr/local/ServerStatus/clients/ +sudo mv /tmp/client-linux.py /usr/local/ServerStatus/clients/ +sudo mv /tmp/status-client.service /etc/systemd/system/ +sudo systemctl daemon-reload # optional if new +sudo systemctl enable status-client + +echo Modify key configurations in /usr/local/ServerStatus/clients/client-linux.py, then run "sudo systemctl start status-client" diff --git a/service/status-client.service b/service/status-client.service index 350a96ec..645862d8 100644 --- a/service/status-client.service +++ b/service/status-client.service @@ -2,7 +2,7 @@ Description=ServerStatus-Client After=network.target [Service] -ExecStart=/usr/bin/python3 /usr/local/ServerStatus/clients/client-linux.py +ExecStart=/usr/bin/python3 /usr/local/bin/ss-client-linux.py ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure [Install] From 18a76d2375416ef7713eb8e3b4a9b2a40ca2f858 Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年8月15日 18:02:48 +0800 Subject: [PATCH 02/12] add firewalla services --- service/firewalla-status-client.service | 9 +++++++++ service/firewalla_install.sh | 20 ++++++++++++++++++++ service/status-client.service | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 service/firewalla-status-client.service create mode 100755 service/firewalla_install.sh diff --git a/service/firewalla-status-client.service b/service/firewalla-status-client.service new file mode 100644 index 00000000..f7f361d3 --- /dev/null +++ b/service/firewalla-status-client.service @@ -0,0 +1,9 @@ +[Unit] +Description=ServerStatus-Client +After=network.target +[Service] +ExecStart=/usr/bin/python3 /home/pi/ss/client-linux.py +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +[Install] +WantedBy=multi-user.target diff --git a/service/firewalla_install.sh b/service/firewalla_install.sh new file mode 100755 index 00000000..ddb4962b --- /dev/null +++ b/service/firewalla_install.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +curl -s https://raw.githubusercontent.com/MelvinTo/ServerStatus/master/clients/client-linux.py -o /tmp/client-linux.py +curl -s https://raw.githubusercontent.com/MelvinTo/ServerStatus/master/service/firewalla-status-client.service -o /tmp/status-client.service + +ROOT_RO=/media/root-ro + +sudo mkdir -p /home/pi/ss/ +sudo mv /tmp/client-linux.py /home/pi/ss/client-linux.py +sudo cp /tmp/status-client.service /etc/systemd/system/status-client.service +sudo cp /tmp/status-client.service ${ROOT_RO}/etc/systemd/system/status-client.service +sudo ln -sf /etc/systemd/system/status-client.service ${ROOT_RO}/etc/systemd/system/multi-user.target.wants/status-client.service +sudo systemctl daemon-reload # optional if new +sudo systemctl enable status-client + +echo Modify key configurations in /home/pi/ss/client-linux.py, then run "sudo systemctl start status-client" + +rm /tmp/client-linux.py diff --git a/service/status-client.service b/service/status-client.service index 645862d8..350a96ec 100644 --- a/service/status-client.service +++ b/service/status-client.service @@ -2,7 +2,7 @@ Description=ServerStatus-Client After=network.target [Service] -ExecStart=/usr/bin/python3 /usr/local/bin/ss-client-linux.py +ExecStart=/usr/bin/python3 /usr/local/ServerStatus/clients/client-linux.py ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure [Install] From 8010a5e9967cf079510f0e2b3c66ecfe8487a0cb Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年8月15日 18:04:03 +0800 Subject: [PATCH 03/12] bugfix --- service/firewalla_install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/service/firewalla_install.sh b/service/firewalla_install.sh index ddb4962b..7cbd21ef 100755 --- a/service/firewalla_install.sh +++ b/service/firewalla_install.sh @@ -16,5 +16,3 @@ sudo systemctl daemon-reload # optional if new sudo systemctl enable status-client echo Modify key configurations in /home/pi/ss/client-linux.py, then run "sudo systemctl start status-client" - -rm /tmp/client-linux.py From 8e11bcbabfb2d5840aeb1f0197f7f0c8302966ef Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年8月15日 18:09:14 +0800 Subject: [PATCH 04/12] bugfix --- service/firewalla_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/firewalla_install.sh b/service/firewalla_install.sh index 7cbd21ef..3ea6e684 100755 --- a/service/firewalla_install.sh +++ b/service/firewalla_install.sh @@ -15,4 +15,4 @@ sudo ln -sf /etc/systemd/system/status-client.service ${ROOT_RO}/etc/systemd/sys sudo systemctl daemon-reload # optional if new sudo systemctl enable status-client -echo Modify key configurations in /home/pi/ss/client-linux.py, then run "sudo systemctl start status-client" +echo Modify key configurations in /home/pi/ss/client-linux.py then run "sudo systemctl start status-client" From f44034408c15cf2bc9dfa1fd6d20ed8347af59f7 Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年8月15日 18:45:40 +0800 Subject: [PATCH 05/12] comment refine --- service/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/install.sh b/service/install.sh index 37df0552..4d1ac25b 100755 --- a/service/install.sh +++ b/service/install.sh @@ -11,4 +11,4 @@ sudo mv /tmp/status-client.service /etc/systemd/system/ sudo systemctl daemon-reload # optional if new sudo systemctl enable status-client -echo Modify key configurations in /usr/local/ServerStatus/clients/client-linux.py, then run "sudo systemctl start status-client" +echo Modify key configurations in /usr/local/ServerStatus/clients/client-linux.py then run "sudo systemctl start status-client" From 536622dbf4f51c445036ee39e0ca57a0fb1e732f Mon Sep 17 00:00:00 2001 From: Jian Yang Date: 2022年10月25日 21:46:22 -0700 Subject: [PATCH 06/12] add ip_address --- clients/client-linux.py | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/client-linux.py b/clients/client-linux.py index cfac848a..c84dca1b 100755 --- a/clients/client-linux.py +++ b/clients/client-linux.py @@ -411,6 +411,7 @@ def byte_str(object): array['tcp'], array['udp'], array['process'], array['thread'] = tupd() array['io_read'] = diskIO.get("read") array['io_write'] = diskIO.get("write") + array['ip_address'] = subprocess.check_output("ip -4 --br a show $(ip r | head -n 1 | awk '{print 5ドル}') | awk '{print 3ドル}'|awk -F/ '{print 1ドル}'",shell=True).strip() s.send(byte_str("update " + json.dumps(array) + "\n")) except KeyboardInterrupt: From 9dbc949e8b2b3b52f55b13f675d39f13eb78e3b4 Mon Sep 17 00:00:00 2001 From: Melvin <108800+melvinto@users.noreply.github.com> Date: 2022年10月28日 18:51:13 +0800 Subject: [PATCH 07/12] Update client-linux.py --- clients/client-linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/client-linux.py b/clients/client-linux.py index c84dca1b..88861ad4 100755 --- a/clients/client-linux.py +++ b/clients/client-linux.py @@ -411,7 +411,7 @@ def byte_str(object): array['tcp'], array['udp'], array['process'], array['thread'] = tupd() array['io_read'] = diskIO.get("read") array['io_write'] = diskIO.get("write") - array['ip_address'] = subprocess.check_output("ip -4 --br a show $(ip r | head -n 1 | awk '{print 5ドル}') | awk '{print 3ドル}'|awk -F/ '{print 1ドル}'",shell=True).strip() + array['ip_address'] = subprocess.check_output("ip -4 --br a show $(ip r | head -n 1 | awk '{print 5ドル}') | awk '{print 3ドル}'|awk -F/ '{print 1ドル}'",shell=True).strip().decode("utf-8") s.send(byte_str("update " + json.dumps(array) + "\n")) except KeyboardInterrupt: From af2ebd702aef8c4cb715538649a25fe28240a3e4 Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年10月31日 14:41:33 +0800 Subject: [PATCH 08/12] add ip address --- server/src/main.cpp | 5 ++++- server/src/main.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/main.cpp b/server/src/main.cpp index 46d4ac16..7d263e7a 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -197,6 +197,8 @@ int CMain::HandleMessage(int ClientNetID, char *pMessage) pClient->m_Stats.m_Online4 = rStart["online4"].u.boolean; if(rStart["online6"].type && pClient->m_ClientNetType == NETTYPE_IPV4) pClient->m_Stats.m_Online6 = rStart["online6"].u.boolean; + if(rStart["ip_address"].type) + pClient->m_Stats.m_HDDUsed = rStart["ip_address"].u.string.ptr; if(rStart["custom"].type == json_string) str_copy(pClient->m_Stats.m_aCustom, rStart["custom"].u.string.ptr, sizeof(pClient->m_Stats.m_aCustom)); @@ -405,7 +407,7 @@ void CMain::JSONUpdateThread(void *pUser) } str_format(pBuf, sizeof(aFileBuf) - (pBuf - aFileBuf), - "{ \"name\": \"%s\",\"type\": \"%s\",\"host\": \"%s\",\"location\": \"%s\",\"online4\": %s, \"online6\": %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 ",\"io_read\": %" PRId64 ", \"io_write\": %" PRId64 ",\"custom\": \"%s\" },\n", + "{ \"name\": \"%s\",\"type\": \"%s\",\"host\": \"%s\",\"location\": \"%s\",\"online4\": %s, \"online6\": %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 ",\"io_read\": %" PRId64 ", \"io_write\": %" PRId64 ",\"ip_address\": \"%s\",\"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", 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, @@ -415,6 +417,7 @@ void CMain::JSONUpdateThread(void *pUser) pClients[i].m_Stats.m_NetworkIN == 0 || pClients[i].m_LastNetworkIN == 0 ? pClients[i].m_Stats.m_NetworkIN : pClients[i].m_LastNetworkIN, pClients[i].m_Stats.m_NetworkOUT == 0 || pClients[i].m_LastNetworkOUT == 0 ? pClients[i].m_Stats.m_NetworkOUT : pClients[i].m_LastNetworkOUT, pClients[i].m_Stats.m_IORead, pClients[i].m_Stats.m_IOWrite, + pClients[i].m_Stats.m_IPAddress, pClients[i].m_Stats.m_aCustom); pBuf += strlen(pBuf); } diff --git a/server/src/main.h b/server/src/main.h index 5070743e..4fcb1ca6 100644 --- a/server/src/main.h +++ b/server/src/main.h @@ -77,6 +77,7 @@ class CMain int64_t m_IORead; int64_t m_IOWrite; double m_CPU; + char m_IPAddress[512]; char m_aCustom[512]; // Options bool m_Pong; From 15eedc8956eb6fe5a99dd2df1e8f455323c8b0a3 Mon Sep 17 00:00:00 2001 From: Melvin Tu Date: 2022年10月31日 15:03:43 +0800 Subject: [PATCH 09/12] add ip_address --- server/src/main.cpp | 2 +- web/index.html | 1 + web/js/serverstatus.js | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/main.cpp b/server/src/main.cpp index 7d263e7a..675e7c84 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -198,7 +198,7 @@ int CMain::HandleMessage(int ClientNetID, char *pMessage) if(rStart["online6"].type && pClient->m_ClientNetType == NETTYPE_IPV4) pClient->m_Stats.m_Online6 = rStart["online6"].u.boolean; if(rStart["ip_address"].type) - pClient->m_Stats.m_HDDUsed = rStart["ip_address"].u.string.ptr; + str_copy(pClient->m_Stats.m_IPAddress, rStart["ip_address"].u.string.ptr, sizeof(pClient->m_Stats.m_IPAddress)); if(rStart["custom"].type == json_string) str_copy(pClient->m_Stats.m_aCustom, rStart["custom"].u.string.ptr, sizeof(pClient->m_Stats.m_aCustom)); diff --git a/web/index.html b/web/index.html index 7c175dde..efff205d 100644 --- a/web/index.html +++ b/web/index.html @@ -78,6 +78,7 @@ 🔗协议 📊月流量↓|↑ 📌节点 + 📌IP 🗂️虚拟化 🌍位置 ⏱️在线 diff --git a/web/js/serverstatus.js b/web/js/serverstatus.js index 9b34d962..1cc95dc1 100644 --- a/web/js/serverstatus.js +++ b/web/js/serverstatus.js @@ -66,6 +66,7 @@ function uptime() { "
加载中
" + "
加载中
" + " 加载中" + + " 加载中" + " 加载中" + " 加载中" + " 加载中" + @@ -114,6 +115,9 @@ function uptime() { // Name TableRow.children["name"].innerHTML = result.servers[i].name; + // IP + TableRow.children["ip"].innerHTML = result.servers[i].ip_address; + // Type TableRow.children["type"].innerHTML = result.servers[i].type; From 979c0046403b6756ac4ec1405ce5af0d15dec17d Mon Sep 17 00:00:00 2001 From: Melvin <108800+melvinto@users.noreply.github.com> Date: 2022年10月31日 15:05:45 +0800 Subject: [PATCH 10/12] Create main.yml --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..cf786579 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: Build Docker Images +on: + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: set lower case owner name + run: | + echo "OWNER_LC=${OWNER,,}">>${GITHUB_ENV} + env: + OWNER: '${{ github.repository_owner }}' + - name: Build and release Docker images + uses: docker/build-push-action@v2 + with: + platforms: linux/amd64 + tags: ghcr.io/${{ env.OWNER_LC }}/serverstatus_server:latest + push: true From b7c011a477dfb467f642fa9efa7b8498f37c62a8 Mon Sep 17 00:00:00 2001 From: Melvin <108800+melvinto@users.noreply.github.com> Date: 2022年10月31日 15:06:17 +0800 Subject: [PATCH 11/12] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cf786579..38e5cd3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ name: Build Docker Images on: push: - branches: [ main ] + branches: [ master ] jobs: build: From e8299c61f7484bdcf2298b700622637dabad93a2 Mon Sep 17 00:00:00 2001 From: melvin <108800+melvinto@users.noreply.github.com> Date: 2022年10月31日 15:13:04 +0800 Subject: [PATCH 12/12] add default value for ip --- web/js/serverstatus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/serverstatus.js b/web/js/serverstatus.js index 1cc95dc1..2a876c73 100644 --- a/web/js/serverstatus.js +++ b/web/js/serverstatus.js @@ -116,7 +116,7 @@ function uptime() { TableRow.children["name"].innerHTML = result.servers[i].name; // IP - TableRow.children["ip"].innerHTML = result.servers[i].ip_address; + TableRow.children["ip"].innerHTML = result.servers[i].ip_address || "-"; // Type TableRow.children["type"].innerHTML = result.servers[i].type;

AltStyle によって変換されたページ (->オリジナル) /