sosmonitor 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sosmonitor
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Simple server monitor: CPU, memory, disk and load alerts by webhook or email. One file, no root, no dependencies.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/diemsouza/sosmonitor
|
|
7
|
+
Project-URL: Repository, https://github.com/diemsouza/sosmonitor
|
|
8
|
+
Project-URL: Changelog, https://github.com/diemsouza/sosmonitor/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/diemsouza/sosmonitor/issues
|
|
10
|
+
Keywords: monitoring,server,alerts,webhook,cron,n8n
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Topic :: System :: Monitoring
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: psutil
|
|
26
|
+
Requires-Dist: psutil>=5.9; extra == "psutil"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# SOSMonitor
|
|
30
|
+
|
|
31
|
+
> Sometimes simple is more than enough.
|
|
32
|
+
|
|
33
|
+
A tiny server monitor that watches **CPU, memory, disk and load average** and tells you when something crosses a limit, by **webhook** (n8n, Make, Zapier, your own endpoint...) and/or **email**.
|
|
34
|
+
|
|
35
|
+
No agent to install, no paid monitoring service, no dashboard to maintain, no root. One Python file run by cron. It fits any server that just needs a simple "hey, the disk is at 90%" alert, and it was born on locked-down hosts (Cloudways and similar) where you can't install anything else.
|
|
36
|
+
|
|
37
|
+
- **One file:** `sosmonitor.py`. Python 3.8+ standard library only (`psutil` is optional). Install it with a single `curl`, or from PyPI with `pipx`.
|
|
38
|
+
- **No root:** it is scheduled in your own user's crontab.
|
|
39
|
+
- **Self-contained:** it only writes next to its config file (log, state, lock).
|
|
40
|
+
- **No alert spam:** you get one alert per level change, with a margin so a value hovering around a threshold doesn't flood your inbox.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
### Single file (main way)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
mkdir ~/sosmonitor && cd ~/sosmonitor
|
|
48
|
+
curl -fsSLO https://github.com/diemsouza/sosmonitor/raw/main/sosmonitor.py
|
|
49
|
+
|
|
50
|
+
python3 sosmonitor.py install # 1. creates the config in ~/.config/sosmonitor/, schedules cron
|
|
51
|
+
# and creates the `sosmonitor` command
|
|
52
|
+
python3 sosmonitor.py config # 2. opens the config: set server_name, webhook and/or email
|
|
53
|
+
python3 sosmonitor.py test # 3. prints a test alert and sends it to the enabled channels
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Three steps: `install`, then `config` to edit, then `test` to validate the channels. Only `install` and `config` create a config file; `run` and `test` never do (without one they tell you to run `install`).
|
|
57
|
+
|
|
58
|
+
`install` can be run as many times as you like: it never duplicates the cron line, recreates the link or rewrites an existing config. It finishes with a summary showing the state of each step (`created`, `ok`, `already`, `manual` or `failed`), for example:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Config created /Users/me/.config/sosmonitor/config.json
|
|
62
|
+
Command ok sosmonitor (~/.local/bin/sosmonitor)
|
|
63
|
+
Schedule ok every 5 minute(s)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A step that fails does not stop the others. `install` exits with a non-zero code only when a step failed; a step that needs a manual action (for example a host without `crontab`, where it prints the line to paste in your panel) is marked `manual` and still exits 0.
|
|
67
|
+
|
|
68
|
+
**macOS:** `crontab` is blocked until your terminal has Full Disk Access. If `install` shows `Schedule failed crontab: Operation not permitted`, open System Settings > Privacy & Security > Full Disk Access, enable your terminal, restart it and run `install` again. The config and the command are already in place, so it only schedules cron.
|
|
69
|
+
|
|
70
|
+
`curl -fsSLO` downloads the file under its own name. The `-L` follows GitHub's redirect from `/raw/` to the raw file. You can also `git clone https://github.com/diemsouza/sosmonitor` and use the script from the clone.
|
|
71
|
+
|
|
72
|
+
### Python package (pipx, uv or pip)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pipx install sosmonitor # or: uv tool install sosmonitor
|
|
76
|
+
# or: pip install --user sosmonitor
|
|
77
|
+
|
|
78
|
+
sosmonitor install # 1. creates the config, schedules it in cron
|
|
79
|
+
sosmonitor config # 2. opens the config in your editor
|
|
80
|
+
sosmonitor test # 3. validates the channels
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Same three steps and the same `install` summary as above (including the macOS note). `install` is safe to run repeatedly, and `run` and `test` never create a config.
|
|
84
|
+
|
|
85
|
+
The `sosmonitor` command is created automatically by pip, pipx or uv, so `install` does not touch `~/.local/bin` or your shell startup files. On macOS and Windows, CPU and memory need `psutil`, so install it as an extra: `pipx install "sosmonitor[psutil]"` or `pip install "sosmonitor[psutil]"`. On Linux nothing else is needed.
|
|
86
|
+
|
|
87
|
+
The examples below use `python3 sosmonitor.py ...`. With the package, run `sosmonitor ...` instead.
|
|
88
|
+
|
|
89
|
+
## Commands
|
|
90
|
+
|
|
91
|
+
| Command | What it does |
|
|
92
|
+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `python3 sosmonitor.py` (or `run`) | Runs one check. This is what cron calls, and the default with no command. Without a config file it says so, points to `install` and exits non-zero (it never creates one) |
|
|
94
|
+
| `python3 sosmonitor.py test` | Prints a test alert on screen (title and body, as in the email), sends it to every enabled channel and shows the result. Never creates a config (without one it points to `install`) |
|
|
95
|
+
| `python3 sosmonitor.py config` | Creates the config if missing and opens it in `$VISUAL`, `$EDITOR`, `nano` or `vi` (`notepad` on Windows). Checks the JSON when the editor closes and offers to reopen it once. Without a terminal or an editor, prints the path and a command to copy |
|
|
96
|
+
| `python3 sosmonitor.py install` | Creates the config if missing, adds a crontab entry that runs every `check_interval_minutes` and creates the `sosmonitor` command (Linux/macOS), unless a package install already provides it. Safe to run again. Runs every step even if one fails and prints a summary of each; exits non-zero only if a step `failed`. `--no-shortcut` skips the command |
|
|
97
|
+
| `python3 sosmonitor.py uninstall` | Removes that crontab entry, the `sosmonitor` command and its PATH lines, and prints a summary of each step (non-zero exit only if a step `failed`) |
|
|
98
|
+
| `python3 sosmonitor.py --version` | Prints the installed version. See the [CHANGELOG](CHANGELOG.md) for what changed in each version |
|
|
99
|
+
|
|
100
|
+
### Where the config lives
|
|
101
|
+
|
|
102
|
+
| Install | Config file |
|
|
103
|
+
| ---------------------------- | ------------------------------------------------------------------------------------ |
|
|
104
|
+
| New install (`curl` or package) | `~/.config/sosmonitor/config.json` (or `$XDG_CONFIG_HOME/sosmonitor/`), `%APPDATA%\SOSMonitor\config.json` on Windows |
|
|
105
|
+
| Existing single-file install | `config.json` next to `sosmonitor.py`, if it is already there |
|
|
106
|
+
| Any, with `-c /path/to.json` | That file. `-c` overrides everything |
|
|
107
|
+
|
|
108
|
+
The order is: `-c`, then a `config.json` next to the script if it already exists (so every existing install keeps working as is), otherwise the user config folder. `install` (or `config`) creates the file there and tells you where. `run` and `test` never create a config: without one they say so and point to `install`. SOSMonitor never moves or copies an existing file. The user folder survives upgrades, which pip and pipx would otherwise wipe from the script's folder.
|
|
109
|
+
|
|
110
|
+
**The log, state and lock files always live next to the config file in use**, wherever that is. It doesn't matter which directory you run the command from.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python3 sosmonitor.py -c /path/to/other.json # run with that config
|
|
114
|
+
python3 sosmonitor.py -c /path/to/other.json test
|
|
115
|
+
python3 sosmonitor.py -c /path/to/other.json install # creates it if missing; the cron line keeps the -c path
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### The `sosmonitor` command
|
|
119
|
+
|
|
120
|
+
With the single-file install on Linux and macOS, `install` also creates the `sosmonitor` command (a link at `~/.local/bin/sosmonitor`) and adds that folder to your `PATH` in your shell startup files, so you never edit `.bashrc` yourself. Open a new terminal session to use it, or run the `export` line it prints. If your host's shell doesn't load startup files, `install` says so in its summary, and the full path it prints (`~/.local/bin/sosmonitor`) always works. The link is followed, so `config.json`, the log and the state stay next to the real file. Use `install --no-shortcut` to only schedule cron. If a package install (pip, pipx, uv) already put `sosmonitor` on your `PATH`, `install` marks the command `already`: it creates no link and touches no startup file, and the cron line runs that executable. `uninstall` only removes what `install` created.
|
|
121
|
+
|
|
122
|
+
On Windows, create `sosmonitor.cmd` in a folder on your `PATH` with this single line:
|
|
123
|
+
|
|
124
|
+
```bat
|
|
125
|
+
@py "C:\path\to\sosmonitor.py" %*
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## config.json
|
|
129
|
+
|
|
130
|
+
Created by `install` or `config` (with `chmod 600`, since it holds passwords and tokens). Shown here with the email fields filled in:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"server_name": "MY-SERVER",
|
|
135
|
+
"check_interval_minutes": 1,
|
|
136
|
+
"disk_path": "/",
|
|
137
|
+
"send_every_check": true,
|
|
138
|
+
"sustain_checks": 1,
|
|
139
|
+
"thresholds": {
|
|
140
|
+
"70": "{metric} at {value}%",
|
|
141
|
+
"80": "{metric} at {value}% (WARNING)",
|
|
142
|
+
"90": "{metric} at {value}% (CRITICAL)",
|
|
143
|
+
"100": "{metric} at {value}% (AT LIMIT)"
|
|
144
|
+
},
|
|
145
|
+
"recovery_message": "{metric} at {value}% (BACK TO NORMAL)",
|
|
146
|
+
"top_processes": {
|
|
147
|
+
"enabled": true,
|
|
148
|
+
"count": 3
|
|
149
|
+
},
|
|
150
|
+
"webhook": {
|
|
151
|
+
"enabled": false,
|
|
152
|
+
"url": "",
|
|
153
|
+
"token": "",
|
|
154
|
+
"token_header": "X-Monitor-Token"
|
|
155
|
+
},
|
|
156
|
+
"email": {
|
|
157
|
+
"enabled": false,
|
|
158
|
+
"smtp_host": "smtp.gmail.com",
|
|
159
|
+
"smtp_port": 587,
|
|
160
|
+
"username": "",
|
|
161
|
+
"password": "",
|
|
162
|
+
"from": "",
|
|
163
|
+
"to": ["you@example.com"]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
| Key | What it does |
|
|
169
|
+
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
170
|
+
| `server_name` | Name shown in alerts and in the email subject |
|
|
171
|
+
| `check_interval_minutes` | How often cron runs the check (used by `install`, 1 to 59) |
|
|
172
|
+
| `disk_path` | Partition to measure (`/`, `/home`, `C:\` ...) |
|
|
173
|
+
| `send_every_check` | `true`: the webhook receives the metrics on every check. `false`: only when there is an alert. Email is only ever sent for alerts |
|
|
174
|
+
| `sustain_checks` | How many consecutive checks a metric must stay at or above a level before the alert is sent. `1` (default) alerts on the first check. Raise it (e.g. `3`) on noisy servers. Recovery is never delayed |
|
|
175
|
+
| `thresholds` | Levels in % and the message for each one. They apply to CPU, memory and disk. Your object **replaces** the default list, so include every level you want (e.g. add `"50"` and keep `"70"`, `"80"`...) |
|
|
176
|
+
| `recovery_message` | Sent when a metric goes back below the lowest level |
|
|
177
|
+
| `top_processes` | `enabled` (default `true`) and `count` (default `3`): list the top CPU or memory consumers in the alert, only when that metric alerts |
|
|
178
|
+
| `webhook` | `url` receives a JSON `POST`; `token`, if set, goes in the header named by `token_header` (default `X-Monitor-Token`; change it to e.g. `X-Token` or `Authorization` if your service requires) |
|
|
179
|
+
| `email` | SMTP settings. Port 465 uses SSL; other ports use STARTTLS when the server offers it. For Gmail, use an [app password](https://myaccount.google.com/apppasswords). `to` is a list |
|
|
180
|
+
|
|
181
|
+
In messages, `{metric}` (CPU, Memory, Disk), `{value}` (rounded %) and `{server}` are replaced. Messages can be in any language. Set `"enabled": false` to turn a channel off without deleting its settings.
|
|
182
|
+
|
|
183
|
+
## How alerts work
|
|
184
|
+
|
|
185
|
+
SOSMonitor remembers the last level of each metric (in `sosmonitor_state.json`) and **only sends an alert when that level changes**:
|
|
186
|
+
|
|
187
|
+
- **Going up is immediate.** A value of 72% puts you at level 70, and a value of 85% at level 80.
|
|
188
|
+
- **Going down needs a 5-point margin.** A level is kept until the value falls 5 points below it. This keeps a value that hovers around a threshold from sending an alert/recovery pair on every check.
|
|
189
|
+
- **No repeats.** Staying at the same level for hours sends nothing.
|
|
190
|
+
- **CPU is an average, not a snapshot.** Each check reports the average CPU use since the previous check (SOSMonitor keeps the CPU counters in the state file). That is why it matches the graph in your host's panel, and why a short burst of another job at the moment cron fires doesn't trigger a false alert. The first check after install, or after a reboot, takes a 1-second sample instead.
|
|
191
|
+
- **Optionally, alert only when it persists.** With `"sustain_checks": 3`, a metric has to be at or above a level for 3 checks in a row before the alert goes out. The default is `1`, because the interval average already removes the spikes; use it as a knob for noisy servers.
|
|
192
|
+
|
|
193
|
+
Example with levels 70 and 80:
|
|
194
|
+
|
|
195
|
+
| Check | Value | Level | Alert |
|
|
196
|
+
| ----- | ----- | ----- | --------------------------------- |
|
|
197
|
+
| 1 | 65% | 0 | – |
|
|
198
|
+
| 2 | 71% | 70 | **"CPU at 71%"** |
|
|
199
|
+
| 3 | 69% | 70 | – (still within 70 − 5) |
|
|
200
|
+
| 4 | 72% | 70 | – |
|
|
201
|
+
| 5 | 83% | 80 | **"CPU at 83% (WARNING)"** |
|
|
202
|
+
| 6 | 77% | 80 | – (still within 80 − 5) |
|
|
203
|
+
| 7 | 74% | 70 | **"CPU at 74%"** |
|
|
204
|
+
| 8 | 64% | 0 | **"CPU at 64% (BACK TO NORMAL)"** |
|
|
205
|
+
|
|
206
|
+
### The alert message
|
|
207
|
+
|
|
208
|
+
The title shows **only the most severe alert** (highest level, ties broken by the highest value), plus a counter if there are others. With CPU at 75% and memory at 85%:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
[SOSMonitor] MY-SERVER: Memory at 85% (WARNING) (+1 more)
|
|
212
|
+
|
|
213
|
+
Server: MY-SERVER
|
|
214
|
+
Time: 2026-11-20T18:05:03+00:00
|
|
215
|
+
|
|
216
|
+
Alerts:
|
|
217
|
+
- Memory at 85% (WARNING)
|
|
218
|
+
- CPU at 75%
|
|
219
|
+
|
|
220
|
+
Top processes by memory:
|
|
221
|
+
1. php-fpm 8.2% (1.3 GB)
|
|
222
|
+
2. mysqld 6.1% (1.0 GB)
|
|
223
|
+
3. node 2.4% (395 MB)
|
|
224
|
+
|
|
225
|
+
Current metrics:
|
|
226
|
+
CPU 75% | MEMORY 85% | DISK 54%
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The top processes are looked up only when a CPU or memory alert goes out (never on quiet checks, never for disk). Memory ranks by current RSS; CPU is measured over one second. Only the command name is shown, never its arguments, since they can contain passwords. On hosts that hide other users' processes the list may be short or missing, and the alert is sent anyway.
|
|
230
|
+
|
|
231
|
+
Also:
|
|
232
|
+
|
|
233
|
+
- Every alert goes to every enabled channel.
|
|
234
|
+
- If every channel fails, the alert is not marked as sent, and the next check tries again.
|
|
235
|
+
- Load average is collected and sent, but has no thresholds (it isn't a percentage).
|
|
236
|
+
|
|
237
|
+
### Webhook payload
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"server": "MY-SERVER",
|
|
242
|
+
"hostname": "web-01",
|
|
243
|
+
"platform": "Linux-5.15.0-x86_64-with-glibc2.35",
|
|
244
|
+
"timestamp": "2026-11-19T20:15:00-03:00",
|
|
245
|
+
"metrics": {
|
|
246
|
+
"cpu": { "percent": 83.0 },
|
|
247
|
+
"memory": {
|
|
248
|
+
"percent": 61.2,
|
|
249
|
+
"total_bytes": 4100000000,
|
|
250
|
+
"available_bytes": 1590000000,
|
|
251
|
+
"used_bytes": 2510000000
|
|
252
|
+
},
|
|
253
|
+
"disk": {
|
|
254
|
+
"percent": 47.9,
|
|
255
|
+
"total_bytes": 80000000000,
|
|
256
|
+
"used_bytes": 38300000000,
|
|
257
|
+
"free_bytes": 41700000000,
|
|
258
|
+
"path": "/"
|
|
259
|
+
},
|
|
260
|
+
"load": {
|
|
261
|
+
"1m": 1.2,
|
|
262
|
+
"5m": 0.9,
|
|
263
|
+
"15m": 0.7,
|
|
264
|
+
"cpu_count": 2,
|
|
265
|
+
"1m_per_cpu": 0.6
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"alerts": [
|
|
269
|
+
{
|
|
270
|
+
"metric": "cpu",
|
|
271
|
+
"value": 83.0,
|
|
272
|
+
"threshold": 80,
|
|
273
|
+
"previous_threshold": 70,
|
|
274
|
+
"message": "CPU at 83% (WARNING)"
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
"top_processes": {
|
|
278
|
+
"cpu": [
|
|
279
|
+
{ "name": "php-fpm", "percent": 62.5 },
|
|
280
|
+
{ "name": "mysqld", "percent": 14.0 }
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
"message_title": "[SOSMonitor] MY-SERVER: CPU at 83% (WARNING)",
|
|
284
|
+
"message_body": "Server: MY-SERVER\nTime: 2026-11-19T20:15:00-03:00\n\nAlerts:\n - CPU at 83% (WARNING)\n\nTop processes by CPU:\n 1. php-fpm 62.5%\n 2. mysqld 14.0%\n\nCurrent metrics:\n CPU 83% | MEMORY 61% | DISK 48% | LOAD 1m=1.2 5m=0.9 15m=0.7 CPUs=2\n"
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
`message_title` and `message_body` are the same text as the email subject and body, ready to forward unchanged to WhatsApp, Telegram, Slack or any chat tool. On checks without alerts (sent only when `send_every_check` is `true`), `alerts` is an empty list and both message fields are empty strings, so in n8n you can filter on `message_title != ""`. `top_processes` (`cpu` and/or `memory` lists; memory entries also have `rss_bytes`) is present only when there is something to report. The `test` command fills the message fields and adds `"test": true`.
|
|
289
|
+
|
|
290
|
+
## Platforms
|
|
291
|
+
|
|
292
|
+
| | CPU / memory | Disk / load | Scheduling | Dependencies |
|
|
293
|
+
| ----------- | ---------------------- | ------------------------------ | -------------------------------------------------------------- | ------------------------------------------------- |
|
|
294
|
+
| **Linux** | Native (reads `/proc`) | Native | User crontab | None |
|
|
295
|
+
| **macOS** | Needs `psutil` | Native | User crontab | `pip install "sosmonitor[psutil]"` or `pip3 install psutil` |
|
|
296
|
+
| **Windows** | Needs `psutil` | Disk native, load via `psutil` | Task Scheduler: `install` prints the `schtasks` command to run | `pip install "sosmonitor[psutil]"` or `pip install psutil` |
|
|
297
|
+
|
|
298
|
+
When `psutil` is installed, SOSMonitor uses it on every platform. Without it, missing metrics are simply skipped.
|
|
299
|
+
|
|
300
|
+
Alpine and other musl or busybox hosts work with no dependency at all: everything, including the top processes list, is read straight from `/proc`, without needing `ps`.
|
|
301
|
+
|
|
302
|
+
**Docker:** SOSMonitor is not meant to run inside a container yet. There `/proc` reports the CPU, memory and load of the host, not the container's cgroup limits, so the numbers would describe the host and not your container. Run it on the host instead.
|
|
303
|
+
|
|
304
|
+
**Windows has not been tested.** It should work (locking uses `msvcrt`, and `install`/`uninstall` print the `schtasks` commands instead of editing crontab). Reports and fixes are welcome.
|
|
305
|
+
|
|
306
|
+
If your host has no `crontab` command but has a cron panel (common on managed hosting), `install` marks the schedule `manual`, prints the exact command to paste there and still exits 0.
|
|
307
|
+
|
|
308
|
+
On macOS, `crontab` also needs Full Disk Access for your terminal (see [Install](#install)).
|
|
309
|
+
|
|
310
|
+
## Files created (always next to the config in use)
|
|
311
|
+
|
|
312
|
+
| File | Content |
|
|
313
|
+
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
314
|
+
| `sosmonitor.log` | One JSON line per check (metrics, alerts, delivery result). Rotates to `.log.1` at 5 MB, keeping one old file (about 10 MB at most) |
|
|
315
|
+
| `sosmonitor_state.json` | Last level of each metric, the `sustain_checks` counters and the CPU counters used for the next average |
|
|
316
|
+
| `.sosmonitor.lock` | Prevents two checks from running at the same time |
|
|
317
|
+
|
|
318
|
+
## Updating
|
|
319
|
+
|
|
320
|
+
**Package install:** `pipx upgrade sosmonitor` (or `uv tool upgrade sosmonitor`, or `pip install --user -U sosmonitor`), then `sosmonitor --version` and `sosmonitor test`. Your config, log and state live in the user config folder, so the upgrade doesn't touch them. Cron keeps working because it points to the `sosmonitor` executable.
|
|
321
|
+
|
|
322
|
+
**Single file:** SOSMonitor is a single file, so updating is just downloading it again:
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
cd ~/sosmonitor # the folder where sosmonitor.py lives
|
|
326
|
+
cp sosmonitor.py sosmonitor.py.bak
|
|
327
|
+
curl -fsSLO https://github.com/diemsouza/sosmonitor/raw/main/sosmonitor.py
|
|
328
|
+
python3 sosmonitor.py --version
|
|
329
|
+
python3 sosmonitor.py test
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
To get a specific version instead of the latest, download `sosmonitor.py` from that version on the [Releases](https://github.com/diemsouza/sosmonitor/releases) page (or `pipx install sosmonitor==VERSION`), where each release also lists its changes.
|
|
333
|
+
|
|
334
|
+
**What is not touched:** `config.json`, the log, the state file and the lock. They are separate files. Cron and the `sosmonitor` command keep working because they point to the same `sosmonitor.py` (or to the package executable).
|
|
335
|
+
|
|
336
|
+
**What to check after updating:**
|
|
337
|
+
|
|
338
|
+
1. Read the [CHANGELOG](CHANGELOG.md) for the versions between yours and the new one. Each entry has a "Config changes" line (renamed, removed or new keys).
|
|
339
|
+
2. Keys missing from your `config.json` use the default value, so a new option never breaks an old config. To use a new option, add it by hand using `config.example.json` as reference (`sosmonitor config` opens the file).
|
|
340
|
+
3. Run `python3 sosmonitor.py test` to confirm the channels still work.
|
|
341
|
+
4. Run `python3 sosmonitor.py install` again only if the CHANGELOG says the cron entry or the command changed. It is safe to run and never overwrites `config.json`.
|
|
342
|
+
|
|
343
|
+
**Rolling back (single file):** `mv sosmonitor.py.bak sosmonitor.py`. For a package, install the previous version: `pipx install --force sosmonitor==VERSION`.
|
|
344
|
+
|
|
345
|
+
## Development
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
python3 -m unittest discover tests
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
The tests use only the standard library and never touch your real `config.json`.
|
|
352
|
+
|
|
353
|
+
## License
|
|
354
|
+
|
|
355
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
sosmonitor.py,sha256=E0dJowwRFEwo4lxdBnHCyeTxmDaSqG9VFxFVc-3NCTc,50633
|
|
2
|
+
sosmonitor-0.3.1.dist-info/licenses/LICENSE,sha256=A2GrrfWXyahVtB9GrLWRoBNlyjYGlnxv2vBD4QNF17U,1068
|
|
3
|
+
sosmonitor-0.3.1.dist-info/METADATA,sha256=5zrIJpp3y9MzvtaiSWzG9TPBity_KUCYERMmR7kbNY4,23390
|
|
4
|
+
sosmonitor-0.3.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
sosmonitor-0.3.1.dist-info/entry_points.txt,sha256=ymdU1w3ZG-8XRkt-2Z86VfH0eQm9dQQIiweKHDbvmi8,47
|
|
6
|
+
sosmonitor-0.3.1.dist-info/top_level.txt,sha256=wKDnMbwEZeZbGxtGrrG3BjLfaRmf-AHZ-Gs1lfk30zQ,11
|
|
7
|
+
sosmonitor-0.3.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Diego Souza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sosmonitor
|