Skip to content

[Snyk] Security upgrade urllib3 from 2.0.7 to 2.2.2 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 70 commits into from
Closed
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
80a3f64
更新linux脚本
LittleJake Aug 14, 2020
2c91a07
update using psutil.
LittleJake Mar 1, 2021
55c4640
1. add gitignore
LittleJake Apr 8, 2021
907dbe3
update disk partition support.
LittleJake Apr 14, 2021
1a5055d
update
LittleJake Sep 16, 2021
ebef363
Update report.py
LittleJake Dec 17, 2021
991e255
Update report.py
LittleJake Dec 17, 2021
15a26a7
Update report.py
LittleJake Dec 17, 2021
78c2ca5
Update
LittleJake Dec 8, 2023
63852c7
Update
LittleJake Dec 8, 2023
bd6790a
Update
LittleJake Dec 11, 2023
7fc6edf
Update
LittleJake Dec 11, 2023
4e0bcaf
Update
LittleJake Dec 11, 2023
4792904
Update
LittleJake Dec 11, 2023
e6b1852
Update
LittleJake Dec 11, 2023
27fdc89
Update
LittleJake Dec 11, 2023
25bc2ac
Update
LittleJake Dec 11, 2023
0102b26
Update
LittleJake Dec 11, 2023
b9599f4
Update
LittleJake Dec 11, 2023
039489f
Update
LittleJake Dec 11, 2023
3db5452
Update
LittleJake Dec 11, 2023
8ef1f33
Update
LittleJake Dec 11, 2023
9df652d
Update
LittleJake Dec 11, 2023
fb3052c
Update
LittleJake Dec 11, 2023
9c1be2f
Update
LittleJake Dec 11, 2023
76bb456
adding service install shell
LittleJake Jan 18, 2024
bf0256e
fix import
LittleJake Jan 18, 2024
66964c7
fix
LittleJake Jan 18, 2024
cb83cdb
fix env
LittleJake Jan 18, 2024
a8214bd
Update
LittleJake Jan 19, 2024
3e9c85d
Update README.md
LittleJake Jan 22, 2024
32184fe
Update README.md
LittleJake Jan 22, 2024
90bd439
Update README.md
LittleJake Jan 22, 2024
ffba9a0
Update report.py
LittleJake Jan 23, 2024
ed2e83b
Update SSL & fix bug
LittleJake Jan 23, 2024
d08392d
fix shell
LittleJake Jan 23, 2024
9b7bf9d
amend country
LittleJake Jan 23, 2024
e50946a
amend uptime
LittleJake Jan 23, 2024
362e093
Fixing termux (root mode)
LittleJake Jan 24, 2024
7effcd2
adding opts exclude
LittleJake Jan 24, 2024
8a934a3
Update
LittleJake Jan 24, 2024
eeed718
Update action
LittleJake Jan 24, 2024
8d9add1
Update report.py
LittleJake Jan 24, 2024
ee1c77d
fix ↑↓
LittleJake Jan 24, 2024
48e8f75
Update report.py
LittleJake Feb 4, 2024
97bf648
implement http api.
LittleJake Feb 7, 2024
7a4ffc3
Update exception
LittleJake Feb 7, 2024
905a190
adding timeout
LittleJake Feb 7, 2024
86c86bd
update log
LittleJake Feb 8, 2024
1f01c99
Update ip address fetch
LittleJake Apr 9, 2024
d98473f
Update
LittleJake Apr 18, 2024
5075ed0
Update
LittleJake Apr 18, 2024
a277049
Update report.py
LittleJake Apr 18, 2024
82576e2
Fix no IO data
LittleJake May 5, 2024
aa142cc
Create Dockerfile
LittleJake May 13, 2024
d1b59af
Update Dockerfile
LittleJake May 13, 2024
183a9a6
Update README.md
LittleJake May 13, 2024
374de58
Update report.py
LittleJake May 13, 2024
566e08b
fix: requirements.txt to reduce vulnerabilities
snyk-bot Jun 18, 2024
6b33939
Update for docker
LittleJake Jun 24, 2024
7b7d868
Merge pull request #1 from LittleJake/snyk-fix-550535aed439ac8b6d7e02…
LittleJake Jun 24, 2024
3cb090a
Update
LittleJake Jun 24, 2024
74c645c
Merge branch 'master' of github.com:LittleJake/server-monitor-script
LittleJake Jun 24, 2024
412eb54
changed to ipify api
LittleJake Jul 15, 2024
a3533e4
Update
LittleJake Jul 26, 2024
ca13e96
update dependencies
LittleJake Jul 26, 2024
26df79e
Update
LittleJake Jul 26, 2024
c33cc8f
Update
LittleJake Jul 26, 2024
62e78ad
remove urlib3 dependency
LittleJake Jul 26, 2024
75f46c5
fix: requirements.txt to reduce vulnerabilities
snyk-bot Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
REPORT_MODE=redis #http,redis
SOCKET_TIMEOUT=10

HOST=127.0.0.1
PORT=6379
PASSWORD=""
SSL=False

REPORT_TIME=60
TIMEOUT=259200
RETENTION_TIME=86400

SERVER_TOKEN=""
SERVER_URL="http://127.0.0.1"

IPV4_API="https://api.ipify.org"
IPV6_API="https://api6.ipify.org"
IP_API="http://ip-api.com/json?fields=country,countryCode"


DISK_EXCLUDE=/run,/sys,/boot,/dev,/proc,/gdrive,/var/lib
DISK_FS_EXCLUDE=tmpfs,overlay
DISK_OPTS_EXCLUDE=ro

#PROCFS_PATH=/rootfs/proc # mount for docker.

PING_CONCURRENT=10
292 changes: 292 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
name: GitHub CI
on:
workflow_dispatch:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
linux32_build:
name: Linux x86 Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/ubuntu-core:i386-bionic /bin/sh -c "apt update && apt install -y bash zlib1g zlib1g-dev make cmake git python3 python3-pip && cd /root/workdir && chmod +x build-script/build.release.sh && bash build-script/build.release.sh"

- name: Package Release
run: tar czf server_monitor_linux32.tar.gz monitor

- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
server_monitor_*.tar.gz
- name: Draft Release
uses: softprops/action-gh-release@v1
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
with:
files: server_monitor_linux32.tar.gz
draft: true
tag_name: Alpha

linux64_build:
name: Linux x86_64 Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: docker run -v $GITHUB_WORKSPACE:/root/workdir multiarch/ubuntu-core:amd64-focal /bin/sh -c "apt update && apt install -y bash git python3 python3-pip && cd /root/workdir && chmod +x build-script/build.release.sh && bash build-script/build.release.sh"

- name: Package Release
run: tar czf server_monitor_linux64.tar.gz monitor

- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
server_monitor_*.tar.gz
- name: Draft Release
uses: softprops/action-gh-release@v1
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
with:
files: server_monitor_linux64.tar.gz
draft: true
tag_name: Alpha

# armv7_build:
# name: Linux armv7 Build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Build
# run: |
# docker run --rm --privileged multiarch/qemu-user-static:register --reset
# docker run -v $GITHUB_WORKSPACE:/root/workdir multiarch/ubuntu-core:armv7-focal /bin/sh -c "apt update && apt install -y bash git python3 python3-pip && cd /root/workdir && chmod +x build-script/build.release.sh && bash build-script/build.release.sh"
# - name: Package Release
# run: tar czf server_monitor_armv7.tar.gz monitor

# - name: Upload
# uses: actions/upload-artifact@v3
# with:
# path: |
# server_monitor_*.tar.gz

# - name: Draft Release
# uses: softprops/action-gh-release@v1
# if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
# with:
# files: server_monitor_armv7.tar.gz
# draft: true
# tag_name: Alpha

arm64_build:
name: Linux arm64 Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run -v $GITHUB_WORKSPACE:/root/workdir multiarch/ubuntu-core:arm64-focal /bin/sh -c "apt update && apt install -y bash git python3 python3-pip && cd /root/workdir && chmod +x build-script/build.release.sh && bash build-script/build.release.sh"
- name: Package Release
run: tar czf server_monitor_arm64.tar.gz monitor

- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
server_monitor_*.tar.gz
- name: Draft Release
uses: softprops/action-gh-release@v1
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
with:
files: server_monitor_arm64.tar.gz
draft: true
tag_name: Alpha

armhf_build:
name: Linux armhf Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run -v $GITHUB_WORKSPACE:/root/workdir multiarch/ubuntu-core:armhf-focal /bin/sh -c "apt update && apt install -y bash git python3 python3-pip && cd /root/workdir && chmod +x build-script/build.release.sh && bash build-script/build.release.sh"
- name: Package Release
run: tar czf server_monitor_armhf.tar.gz monitor

- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
server_monitor_*.tar.gz
- name: Draft Release
uses: softprops/action-gh-release@v1
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
with:
files: server_monitor_armhf.tar.gz
draft: true
tag_name: Alpha

# macos_build:
# name: macOS Build
# runs-on: macos-latest
# steps:
# - uses: actions/checkout@v3
# - name: Add commit id into version
# if: ${{ !startsWith(github.ref, 'refs/tags/') }}
# run: SHA=$(git rev-parse --short HEAD) && sed -i -e 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
# - name: Build
# run: bash build-script/build.macos.release.sh

# - name: Package Release
# run: tar czf server_monitor_darwin64.tar.gz monitor

# - name: Upload
# uses: actions/upload-artifact@v3
# with:
# path: |
# server_monitor_*.tar.gz

# - name: Draft Release
# uses: softprops/action-gh-release@v1
# if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
# with:
# files: server_monitor_darwin64.tar.gz
# draft: true
# tag_name: Alpha

# windows64_build:
# name: Windows x86_64 Build
# runs-on: windows-latest
# defaults:
# run:
# shell: msys2 {0}
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: "16"
# - uses: msys2/setup-msys2@v2
# with:
# update: true
# install: base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-libevent mingw-w64-x86_64-pcre2 patch
# msystem: MINGW64
# path-type: inherit
# - name: Add commit id into version
# if: ${{ !startsWith(github.ref, 'refs/tags/') }}
# run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
# - name: Build
# run: bash build-script/build.windows.release.sh

# - name: Package Release
# run: 7z a server_monitor_win64.7z monitor/

# - name: Upload
# uses: actions/upload-artifact@v3
# with:
# path: |
# server_monitor_*.7z

# - name: Draft Release
# uses: softprops/action-gh-release@v1
# if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
# with:
# files: server_monitor_win64.7z
# draft: true
# tag_name: Alpha

# windows32_build:
# name: Windows x86 Build
# runs-on: windows-latest
# defaults:
# run:
# shell: msys2 {0}
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: "16"
# - uses: msys2/setup-msys2@v2
# with:
# update: true
# install: base-devel git mingw-w64-i686-gcc mingw-w64-i686-cmake mingw-w64-i686-libevent mingw-w64-i686-pcre2 patch
# msystem: MINGW32
# path-type: inherit
# - name: Add commit id into version
# if: ${{ !startsWith(github.ref, 'refs/tags/') }}
# run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
# - name: Build
# run: bash build-script/build.windows.release.sh

# - name: Package Release
# run: 7z a server_monitor_win32.7z monitor/

# - name: Upload
# uses: actions/upload-artifact@v3
# with:
# path: |
# server_monitor_*.7z

# - name: Draft Release
# uses: softprops/action-gh-release@v1
# if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
# with:
# files: server_monitor_win32.7z
# draft: true
# tag_name: Alpha

Upload-Release:
permissions: write-all
if: ${{ github.ref_type=='branch' }}
needs:
[
linux64_build,
linux32_build,
# armv7_build,
armhf_build,
arm64_build,
# macos_build,
# windows64_build,
# windows32_build,
]
runs-on: ubuntu-latest
steps:
- name: Delete current release assets
uses: andreaswilli/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: Alpha
deleteOnlyFromDrafts: false

- uses: actions/download-artifact@v3
with:
name: artifact
path: bin/

- name: Display structure of downloaded files
run: ls -R
working-directory: bin

- name: Tag Repo
uses: richardsimko/[email protected]
with:
tag_name: Alpha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release
uses: softprops/action-gh-release@v1
if: ${{ success() }}
with:
tag: Alpha
tag_name: Alpha
files: bin/*
generate_release_notes: true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea
.env
.uuid
ip.json
dist/
build/
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3-slim
MAINTAINER LittleJake https://github.com/LittleJake/

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./report.py" ]
78 changes: 77 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
# server-monitor-script
server-monitor-script
=======

<img alt="Apache 2.0" src="https://img.shields.io/github/license/LittleJake/server-monitor-script?style=for-the-badge"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/LittleJake/server-monitor-script?style=for-the-badge">

<img src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white"> <img src="https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black"> <img src="https://img.shields.io/badge/python3-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54">

[Server Monitor](https://github.com/LittleJake/server-monitor/)的探针节点脚本,支持多种系统。

数据上报至Redis服务器,Linux、Windows已通过测试。

可注册使用免费Redis服务器:[redislab](https://redis.com/)[aiven.io](https://console.aiven.io/)

### 安装


#### Docker

```bash
git clone https://github.com/LittleJake/server-monitor-script/

# 编辑.env.example文件保存为.env文件
cp .env.example .env
vim .env

docker build -t server-monitor-script:latest ./
docker run -v /:/rootfs:ro --name monitor -d server-monitor-script:latest

```

#### Linux

```bash
git clone https://github.com/LittleJake/server-monitor-script/

pip3 install -r requirements.txt

# 编辑.env.example文件保存为.env文件
cp .env.example .env
vim .env

# 安装服务CentOS/Debian/Ubuntu
bash install_service_linux.sh

```

#### Windows

```cmd
git clone https://github.com/LittleJake/server-monitor-script/
pip3 install -r requirements.txt
# 编辑.env.example文件保存为.env文件
copy .env.example .env
notepad .env
# 运行服务
python3 report.py
```


### Sponsors

Thanks for the amazing VM server provided by [DartNode](https://dartnode.com?via=1).

<a href="https://dartnode.com?via=1"><img src="https://raw.githubusercontent.com/LittleJake/LittleJake/master/images/dartnode.png" width="150"></a>

Thanks for the open source project license provided by [JetBrains](https://www.jetbrains.com/).

<a href="https://www.jetbrains.com/"><img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" width="150" alt="JetBrains Logo (Main) logo."></a>


### Credit

[四网(三网)TCPping域名生成](https://mjjbb.com/p/ping)

[ipify API](https://ipify.org/)
17 changes: 17 additions & 0 deletions build-script/build.release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -xe

apt install -y gcc python3-dev python3-psutil python3-dotenv python3-wheel g++ python3-setuptools

pip3 install -r requirements.txt

pip3 install pyinstaller

pyinstaller --onefile report.py

cd dist
chmod +rx report
chmod +r ./*
cd ..
mv .env.example dist/
mv dist monitor
57 changes: 57 additions & 0 deletions install_service_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

case `uname` in
Linux )
LINUX=1
which apk && {
echo "Alpine"
mkdir -p /usr/local/monitor
\cp -f .env /usr/local/monitor
\cp -f report.py /usr/local/monitor
\cp -f ip.json /usr/local/monitor

cat > /etc/local.d/monitor.start << EOF
cd /usr/local/monitor/
nohup /usr/bin/python3 /usr/local/monitor/report.py &
EOF

chmod +x /etc/local.d/monitor.start
rc-update add local
rc-service local start
}
(which yum || which apt-get) && {
echo "CentOS or Debian"
mkdir -p /usr/local/monitor
\cp -f report.py /usr/local/monitor
\cp -f .env /usr/local/monitor
\cp -f ip.json /usr/local/monitor

cat > /lib/systemd/system/monitor.service << EOF
[Unit]
Description=server monitor
After=network.target
[Service]
User=root
ExecStart=/usr/bin/python3 /usr/local/monitor/report.py
WorkingDirectory=/usr/local/monitor/
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start monitor
systemctl enable monitor
}
;;
Darwin )
DARWIN=1
;;
* )
# Handle AmigaOS, CPM, and modified cable modems.
;;
esac

14 changes: 14 additions & 0 deletions ip.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"CN-BJ-CT": "v4.bj-ct.cn.tcpping.top",
"CN-BJ-CU": "v4.bj-cu.cn.tcpping.top",
"CN-BJ-CM": "v4.bj-cm.cn.tcpping.top",
"CN-BJ-EDU": "v4.bj-edu.cn.tcpping.top",
"CN-SH-CT": "v4.sh-ct.cn.tcpping.top",
"CN-SH-CU": "v4.sh-cu.cn.tcpping.top",
"CN-SH-CM": "v4.sh-cm.cn.tcpping.top",
"CN-SH-EDU": "v4.sh-edu.cn.tcpping.top",
"CN-GD-CT": "v4.gd-ct.cn.tcpping.top",
"CN-GD-CU": "v4.gd-cu.cn.tcpping.top",
"CN-GD-CM": "v4.gd-cm.cn.tcpping.top",
"CN-GD-EDU": "v4.gd-edu.cn.tcpping.top"
}
432 changes: 432 additions & 0 deletions report.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
py-cpuinfo
distro
psutil
requests
redis
python-dotenv
ping3
urllib3>=2.2.2 # not directly required, pinned by Snyk to avoid a vulnerability