pulseping-lite 0.1.0__tar.gz

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alessio Auretto (PyForge)
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,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ include pulseping_lite.py
5
+ include test_pulseping_lite.py
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: pulseping-lite
3
+ Version: 0.1.0
4
+ Summary: Uptime monitor and TLS certificate expiry check in one stdlib-only Python CLI.
5
+ Author: Alessio Auretto
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/alessio1999xx-debug/pulseping-lite
8
+ Project-URL: Pro version, https://py-forge.com/products/pulseping-cli
9
+ Keywords: uptime,monitoring,tls,ssl,certificate,healthcheck,cli,stdlib
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: System :: Monitoring
22
+ Classifier: Topic :: System :: Networking :: Monitoring
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # pulseping-lite: uptime monitor and TLS certificate expiry check in one Python file
30
+
31
+ pulseping-lite helps with quick uptime and TLS certificate expiry checks for one URL or `host:port`, from cron or CI, without running a monitoring server. Python stdlib only (3.9+), plain text or `--json` output, and exit codes 0/1/2 so cron or CI can act on the result.
32
+
33
+
34
+ **Free · MIT · one file · stdlib only.** One target per run; no dashboard, history or built-in alerts.
35
+
36
+ Need multi-monitor workflows? **[PulsePing CLI](https://py-forge.com/products/pulseping-cli?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)** · **[PyForge All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)**
37
+
38
+ ## Demo
39
+
40
+ ![Real terminal demo: one command checks uptime and TLS expiry; a larger warning window fails with exit 1; a refused TCP connection also fails.](docs/demo.gif)
41
+
42
+ Recorded on November 10, 2026 with asciinema + agg; real commands and output, no simulated results. The file is already downloaded when the demo starts. Public endpoint latency and certificate lifetime will change.
43
+
44
+ ```console
45
+ $ python3 pulseping_lite.py https://example.com
46
+ UP https://example.com status=200 172.5 ms cert expires in 45 days
47
+ $ python3 pulseping_lite.py https://example.com --warn-days 365
48
+ DOWN https://example.com status=200 200.0 ms cert expires in 45 days
49
+ certificate expires in 45 days (warn at 365)
50
+ ```
51
+
52
+ The first check exits `0`; the deliberately larger warning window exits `1` even though HTTP is up. [Recording source](docs/demo.cast) · [Capture script](docs/record-demo.py).
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ pip install pulseping-lite
58
+ pulseping-lite https://example.com
59
+ ```
60
+
61
+ Or download the single file (Python 3.9+, stdlib only, no extra packages):
62
+
63
+ ```bash
64
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/pulseping-lite/main/pulseping_lite.py && python3 pulseping_lite.py https://example.com
65
+ ```
66
+
67
+ Requires Python 3.9+. No config file and no state. Flags: `--warn-days`, `--timeout`, `--tls`, `--insecure`, `--json`, `--version`. After `pip install`, use `pulseping-lite` in place of `python3 pulseping_lite.py`.
68
+
69
+ ## Usage
70
+
71
+ ### HTTP(S) health check for a URL
72
+
73
+ ```bash
74
+ python3 pulseping_lite.py https://example.com/health
75
+ python3 pulseping_lite.py http://127.0.0.1:8080/ready --timeout 3
76
+ ```
77
+
78
+ An HTTP status below 400 counts as up. `--timeout` is in seconds (default 5).
79
+
80
+ ### TCP check for host:port
81
+
82
+ ```bash
83
+ python3 pulseping_lite.py db.local:5432 --timeout 2
84
+ ```
85
+
86
+ Without `--tls`, a `host:port` target is only a TCP connect check (databases, SSH, …).
87
+
88
+ ### TLS certificate expiry (days left)
89
+
90
+ ```bash
91
+ python3 pulseping_lite.py https://example.com --warn-days 14
92
+ python3 pulseping_lite.py example.com:443 --tls --warn-days 14
93
+ ```
94
+
95
+ For `https://` URLs the certificate is read from the same connection; for `host:port` add `--tls`. The check fails when the certificate expires in fewer than `--warn-days` days (default 14).
96
+
97
+ `--insecure` skips certificate verification. Use it only for self-signed or internal certs you already trust; certificate expiry can be unavailable in this mode (`null` in JSON).
98
+
99
+ ### JSON output
100
+
101
+ Real output captured November 10, 2026 (network-dependent values vary):
102
+
103
+ ```console
104
+ $ python3 pulseping_lite.py https://example.com --json
105
+ {
106
+ "target": "https://example.com",
107
+ "up": true,
108
+ "status_code": 200,
109
+ "tls_days_left": 45,
110
+ "issuer": null,
111
+ "latency_ms": 172.1,
112
+ "error": null
113
+ }
114
+ ```
115
+
116
+ ## Exit codes
117
+
118
+ | Code | Meaning |
119
+ | --- | --- |
120
+ | `0` | Target is up, and the TLS certificate (if read) is not within `--warn-days` of expiry |
121
+ | `1` | Target is down (HTTP ≥ 400, connect failure, timeout, TLS error) **or** the certificate is expired / fewer than `--warn-days` days left |
122
+ | `2` | Bad arguments (e.g. a target that is neither a URL nor `host:port`) |
123
+
124
+ There is no separate "warning" code: an expiring certificate is a failure (`1`).
125
+
126
+ ## Cron example
127
+
128
+ ```cron
129
+ # every 5 minutes: mail me if the site is down or the cert expires within 14 days
130
+ */5 * * * * python3 /opt/pulseping_lite.py https://example.com/health --warn-days 14 || echo "example.com check failed" | mail -s "uptime" you@example.com
131
+ ```
132
+
133
+ pulseping-lite does not send alerts and checks one target per run: it exits non-zero and you decide what happens next (mail, a script, a failed CI job).
134
+
135
+ ## Measured footprint: lite CLI vs Blackbox Exporter
136
+
137
+ A one-shot check and a persistent monitoring exporter solve different jobs. This is a small, reproducible footprint check, **not a full monitoring-stack shootout**.
138
+
139
+ | Metric | pulseping-lite 0.1.0 | [Prometheus Blackbox Exporter 0.29.1](https://github.com/prometheus/blackbox_exporter/releases/tag/v0.29.1) |
140
+ | --- | ---: | ---: |
141
+ | Installed payload, excluding shared runtime | 6,511 bytes (one Python file) | 35,573,925 bytes (binary + minimal YAML) |
142
+ | Fresh-process start → first successful local HTTP result, median of 5 | 64.2 ms | 12.7 ms |
143
+ | Third-party code dependencies shipped/required | 0 Python modules | 40 Go modules embedded in binary |
144
+
145
+ **Method and machine.** Measured November 10, 2026, Europe/Rome, on this shared Linux box: kernel 6.12.113+, x86_64 KVM, 8 vCPUs (Intel Xeon), 16,002 MiB RAM, Python 3.13.5; exporter official linux-amd64 release built with Go 1.27.3. Five alternating fresh-process runs per tool, no warm-up, no filesystem-cache flush, no CPU/memory isolation. Both check the same local HTTP server returning 200 and `OK`; no DNS, public network or TLS in this benchmark.
146
+
147
+ Timing starts before process launch. For lite it ends after successful CLI exit. For the exporter it includes readiness polling (1 ms retry interval), one `/probe` request, and validation of `probe_success 1`, but excludes shutdown. It is **fresh-process**, not cold-disk timing or steady-state probe latency. Blackbox Exporter was faster in this test; lite's advantage here is its smaller payload and lack of third-party Python packages, not a blanket performance claim.
148
+
149
+ Payload uses exact file byte counts, not compressed downloads or filesystem blocks. Python, its stdlib, CA certificates and OS libraries are excluded; Go dependencies are compiled into the exporter, not packages the user installs. The dependency counts have different packaging meanings and do not estimate security or maintenance burden. No Prometheus server, dashboard, history or alerting stack was installed for either side.
150
+
151
+ **Not measured:** reliable peak RSS, TLS performance, Uptime Kuma, or the size/memory of a complete monitoring stack. No memory or Uptime Kuma numbers are claimed.
152
+
153
+ [Raw runs + release build metadata](docs/benchmark-results.json) · [Reproduction script](docs/benchmark.py) · [Setup and exact scope](docs/BENCHMARK.md).
154
+
155
+ ## What it does not do
156
+
157
+ - One target per invocation; no scheduler, persistent service, history or dashboard.
158
+ - No built-in alert delivery. Cron, CI or your wrapper decides what to do with exit codes.
159
+ - HTTP status / TCP connectivity and TLS expiry only; it is not a full replacement for Blackbox Exporter or Uptime Kuma.
160
+ - `--timeout` bounds individual network operations, not the entire process wall time; redirects are not followed.
161
+
162
+ ## Need more?
163
+
164
+ The full **[PulsePing CLI](https://py-forge.com/products/pulseping-cli?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)** helps with:
165
+
166
+ - many monitors in one config file (HTTP with expected status and keyword, TCP, DNS, certificate expiry, gRPC health)
167
+ - consecutive-failure thresholds, so a single blip does not become an alert
168
+ - alerts to Telegram, Discord, Slack, PagerDuty or a webhook, with recovery notices
169
+ - a static, zero-JavaScript status page
170
+
171
+ One-time payment, no subscription. Every PyForge tool is also in the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite).
172
+
173
+ ## Tests
174
+
175
+ ```bash
176
+ python3 test_pulseping_lite.py
177
+ ```
178
+
179
+ The tests use only a local server.
180
+
181
+ ## License
182
+
183
+ MIT (this lite version). The full PulsePing CLI is sold separately under its own license.
@@ -0,0 +1,155 @@
1
+ # pulseping-lite: uptime monitor and TLS certificate expiry check in one Python file
2
+
3
+ pulseping-lite helps with quick uptime and TLS certificate expiry checks for one URL or `host:port`, from cron or CI, without running a monitoring server. Python stdlib only (3.9+), plain text or `--json` output, and exit codes 0/1/2 so cron or CI can act on the result.
4
+
5
+
6
+ **Free · MIT · one file · stdlib only.** One target per run; no dashboard, history or built-in alerts.
7
+
8
+ Need multi-monitor workflows? **[PulsePing CLI](https://py-forge.com/products/pulseping-cli?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)** · **[PyForge All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)**
9
+
10
+ ## Demo
11
+
12
+ ![Real terminal demo: one command checks uptime and TLS expiry; a larger warning window fails with exit 1; a refused TCP connection also fails.](docs/demo.gif)
13
+
14
+ Recorded on November 10, 2026 with asciinema + agg; real commands and output, no simulated results. The file is already downloaded when the demo starts. Public endpoint latency and certificate lifetime will change.
15
+
16
+ ```console
17
+ $ python3 pulseping_lite.py https://example.com
18
+ UP https://example.com status=200 172.5 ms cert expires in 45 days
19
+ $ python3 pulseping_lite.py https://example.com --warn-days 365
20
+ DOWN https://example.com status=200 200.0 ms cert expires in 45 days
21
+ certificate expires in 45 days (warn at 365)
22
+ ```
23
+
24
+ The first check exits `0`; the deliberately larger warning window exits `1` even though HTTP is up. [Recording source](docs/demo.cast) · [Capture script](docs/record-demo.py).
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pip install pulseping-lite
30
+ pulseping-lite https://example.com
31
+ ```
32
+
33
+ Or download the single file (Python 3.9+, stdlib only, no extra packages):
34
+
35
+ ```bash
36
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/pulseping-lite/main/pulseping_lite.py && python3 pulseping_lite.py https://example.com
37
+ ```
38
+
39
+ Requires Python 3.9+. No config file and no state. Flags: `--warn-days`, `--timeout`, `--tls`, `--insecure`, `--json`, `--version`. After `pip install`, use `pulseping-lite` in place of `python3 pulseping_lite.py`.
40
+
41
+ ## Usage
42
+
43
+ ### HTTP(S) health check for a URL
44
+
45
+ ```bash
46
+ python3 pulseping_lite.py https://example.com/health
47
+ python3 pulseping_lite.py http://127.0.0.1:8080/ready --timeout 3
48
+ ```
49
+
50
+ An HTTP status below 400 counts as up. `--timeout` is in seconds (default 5).
51
+
52
+ ### TCP check for host:port
53
+
54
+ ```bash
55
+ python3 pulseping_lite.py db.local:5432 --timeout 2
56
+ ```
57
+
58
+ Without `--tls`, a `host:port` target is only a TCP connect check (databases, SSH, …).
59
+
60
+ ### TLS certificate expiry (days left)
61
+
62
+ ```bash
63
+ python3 pulseping_lite.py https://example.com --warn-days 14
64
+ python3 pulseping_lite.py example.com:443 --tls --warn-days 14
65
+ ```
66
+
67
+ For `https://` URLs the certificate is read from the same connection; for `host:port` add `--tls`. The check fails when the certificate expires in fewer than `--warn-days` days (default 14).
68
+
69
+ `--insecure` skips certificate verification. Use it only for self-signed or internal certs you already trust; certificate expiry can be unavailable in this mode (`null` in JSON).
70
+
71
+ ### JSON output
72
+
73
+ Real output captured November 10, 2026 (network-dependent values vary):
74
+
75
+ ```console
76
+ $ python3 pulseping_lite.py https://example.com --json
77
+ {
78
+ "target": "https://example.com",
79
+ "up": true,
80
+ "status_code": 200,
81
+ "tls_days_left": 45,
82
+ "issuer": null,
83
+ "latency_ms": 172.1,
84
+ "error": null
85
+ }
86
+ ```
87
+
88
+ ## Exit codes
89
+
90
+ | Code | Meaning |
91
+ | --- | --- |
92
+ | `0` | Target is up, and the TLS certificate (if read) is not within `--warn-days` of expiry |
93
+ | `1` | Target is down (HTTP ≥ 400, connect failure, timeout, TLS error) **or** the certificate is expired / fewer than `--warn-days` days left |
94
+ | `2` | Bad arguments (e.g. a target that is neither a URL nor `host:port`) |
95
+
96
+ There is no separate "warning" code: an expiring certificate is a failure (`1`).
97
+
98
+ ## Cron example
99
+
100
+ ```cron
101
+ # every 5 minutes: mail me if the site is down or the cert expires within 14 days
102
+ */5 * * * * python3 /opt/pulseping_lite.py https://example.com/health --warn-days 14 || echo "example.com check failed" | mail -s "uptime" you@example.com
103
+ ```
104
+
105
+ pulseping-lite does not send alerts and checks one target per run: it exits non-zero and you decide what happens next (mail, a script, a failed CI job).
106
+
107
+ ## Measured footprint: lite CLI vs Blackbox Exporter
108
+
109
+ A one-shot check and a persistent monitoring exporter solve different jobs. This is a small, reproducible footprint check, **not a full monitoring-stack shootout**.
110
+
111
+ | Metric | pulseping-lite 0.1.0 | [Prometheus Blackbox Exporter 0.29.1](https://github.com/prometheus/blackbox_exporter/releases/tag/v0.29.1) |
112
+ | --- | ---: | ---: |
113
+ | Installed payload, excluding shared runtime | 6,511 bytes (one Python file) | 35,573,925 bytes (binary + minimal YAML) |
114
+ | Fresh-process start → first successful local HTTP result, median of 5 | 64.2 ms | 12.7 ms |
115
+ | Third-party code dependencies shipped/required | 0 Python modules | 40 Go modules embedded in binary |
116
+
117
+ **Method and machine.** Measured November 10, 2026, Europe/Rome, on this shared Linux box: kernel 6.12.113+, x86_64 KVM, 8 vCPUs (Intel Xeon), 16,002 MiB RAM, Python 3.13.5; exporter official linux-amd64 release built with Go 1.27.3. Five alternating fresh-process runs per tool, no warm-up, no filesystem-cache flush, no CPU/memory isolation. Both check the same local HTTP server returning 200 and `OK`; no DNS, public network or TLS in this benchmark.
118
+
119
+ Timing starts before process launch. For lite it ends after successful CLI exit. For the exporter it includes readiness polling (1 ms retry interval), one `/probe` request, and validation of `probe_success 1`, but excludes shutdown. It is **fresh-process**, not cold-disk timing or steady-state probe latency. Blackbox Exporter was faster in this test; lite's advantage here is its smaller payload and lack of third-party Python packages, not a blanket performance claim.
120
+
121
+ Payload uses exact file byte counts, not compressed downloads or filesystem blocks. Python, its stdlib, CA certificates and OS libraries are excluded; Go dependencies are compiled into the exporter, not packages the user installs. The dependency counts have different packaging meanings and do not estimate security or maintenance burden. No Prometheus server, dashboard, history or alerting stack was installed for either side.
122
+
123
+ **Not measured:** reliable peak RSS, TLS performance, Uptime Kuma, or the size/memory of a complete monitoring stack. No memory or Uptime Kuma numbers are claimed.
124
+
125
+ [Raw runs + release build metadata](docs/benchmark-results.json) · [Reproduction script](docs/benchmark.py) · [Setup and exact scope](docs/BENCHMARK.md).
126
+
127
+ ## What it does not do
128
+
129
+ - One target per invocation; no scheduler, persistent service, history or dashboard.
130
+ - No built-in alert delivery. Cron, CI or your wrapper decides what to do with exit codes.
131
+ - HTTP status / TCP connectivity and TLS expiry only; it is not a full replacement for Blackbox Exporter or Uptime Kuma.
132
+ - `--timeout` bounds individual network operations, not the entire process wall time; redirects are not followed.
133
+
134
+ ## Need more?
135
+
136
+ The full **[PulsePing CLI](https://py-forge.com/products/pulseping-cli?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)** helps with:
137
+
138
+ - many monitors in one config file (HTTP with expected status and keyword, TCP, DNS, certificate expiry, gRPC health)
139
+ - consecutive-failure thresholds, so a single blip does not become an alert
140
+ - alerts to Telegram, Discord, Slack, PagerDuty or a webhook, with recovery notices
141
+ - a static, zero-JavaScript status page
142
+
143
+ One-time payment, no subscription. Every PyForge tool is also in the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite).
144
+
145
+ ## Tests
146
+
147
+ ```bash
148
+ python3 test_pulseping_lite.py
149
+ ```
150
+
151
+ The tests use only a local server.
152
+
153
+ ## License
154
+
155
+ MIT (this lite version). The full PulsePing CLI is sold separately under its own license.
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: pulseping-lite
3
+ Version: 0.1.0
4
+ Summary: Uptime monitor and TLS certificate expiry check in one stdlib-only Python CLI.
5
+ Author: Alessio Auretto
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/alessio1999xx-debug/pulseping-lite
8
+ Project-URL: Pro version, https://py-forge.com/products/pulseping-cli
9
+ Keywords: uptime,monitoring,tls,ssl,certificate,healthcheck,cli,stdlib
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: System :: Monitoring
22
+ Classifier: Topic :: System :: Networking :: Monitoring
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # pulseping-lite: uptime monitor and TLS certificate expiry check in one Python file
30
+
31
+ pulseping-lite helps with quick uptime and TLS certificate expiry checks for one URL or `host:port`, from cron or CI, without running a monitoring server. Python stdlib only (3.9+), plain text or `--json` output, and exit codes 0/1/2 so cron or CI can act on the result.
32
+
33
+
34
+ **Free · MIT · one file · stdlib only.** One target per run; no dashboard, history or built-in alerts.
35
+
36
+ Need multi-monitor workflows? **[PulsePing CLI](https://py-forge.com/products/pulseping-cli?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)** · **[PyForge All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)**
37
+
38
+ ## Demo
39
+
40
+ ![Real terminal demo: one command checks uptime and TLS expiry; a larger warning window fails with exit 1; a refused TCP connection also fails.](docs/demo.gif)
41
+
42
+ Recorded on November 10, 2026 with asciinema + agg; real commands and output, no simulated results. The file is already downloaded when the demo starts. Public endpoint latency and certificate lifetime will change.
43
+
44
+ ```console
45
+ $ python3 pulseping_lite.py https://example.com
46
+ UP https://example.com status=200 172.5 ms cert expires in 45 days
47
+ $ python3 pulseping_lite.py https://example.com --warn-days 365
48
+ DOWN https://example.com status=200 200.0 ms cert expires in 45 days
49
+ certificate expires in 45 days (warn at 365)
50
+ ```
51
+
52
+ The first check exits `0`; the deliberately larger warning window exits `1` even though HTTP is up. [Recording source](docs/demo.cast) · [Capture script](docs/record-demo.py).
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ pip install pulseping-lite
58
+ pulseping-lite https://example.com
59
+ ```
60
+
61
+ Or download the single file (Python 3.9+, stdlib only, no extra packages):
62
+
63
+ ```bash
64
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/pulseping-lite/main/pulseping_lite.py && python3 pulseping_lite.py https://example.com
65
+ ```
66
+
67
+ Requires Python 3.9+. No config file and no state. Flags: `--warn-days`, `--timeout`, `--tls`, `--insecure`, `--json`, `--version`. After `pip install`, use `pulseping-lite` in place of `python3 pulseping_lite.py`.
68
+
69
+ ## Usage
70
+
71
+ ### HTTP(S) health check for a URL
72
+
73
+ ```bash
74
+ python3 pulseping_lite.py https://example.com/health
75
+ python3 pulseping_lite.py http://127.0.0.1:8080/ready --timeout 3
76
+ ```
77
+
78
+ An HTTP status below 400 counts as up. `--timeout` is in seconds (default 5).
79
+
80
+ ### TCP check for host:port
81
+
82
+ ```bash
83
+ python3 pulseping_lite.py db.local:5432 --timeout 2
84
+ ```
85
+
86
+ Without `--tls`, a `host:port` target is only a TCP connect check (databases, SSH, …).
87
+
88
+ ### TLS certificate expiry (days left)
89
+
90
+ ```bash
91
+ python3 pulseping_lite.py https://example.com --warn-days 14
92
+ python3 pulseping_lite.py example.com:443 --tls --warn-days 14
93
+ ```
94
+
95
+ For `https://` URLs the certificate is read from the same connection; for `host:port` add `--tls`. The check fails when the certificate expires in fewer than `--warn-days` days (default 14).
96
+
97
+ `--insecure` skips certificate verification. Use it only for self-signed or internal certs you already trust; certificate expiry can be unavailable in this mode (`null` in JSON).
98
+
99
+ ### JSON output
100
+
101
+ Real output captured November 10, 2026 (network-dependent values vary):
102
+
103
+ ```console
104
+ $ python3 pulseping_lite.py https://example.com --json
105
+ {
106
+ "target": "https://example.com",
107
+ "up": true,
108
+ "status_code": 200,
109
+ "tls_days_left": 45,
110
+ "issuer": null,
111
+ "latency_ms": 172.1,
112
+ "error": null
113
+ }
114
+ ```
115
+
116
+ ## Exit codes
117
+
118
+ | Code | Meaning |
119
+ | --- | --- |
120
+ | `0` | Target is up, and the TLS certificate (if read) is not within `--warn-days` of expiry |
121
+ | `1` | Target is down (HTTP ≥ 400, connect failure, timeout, TLS error) **or** the certificate is expired / fewer than `--warn-days` days left |
122
+ | `2` | Bad arguments (e.g. a target that is neither a URL nor `host:port`) |
123
+
124
+ There is no separate "warning" code: an expiring certificate is a failure (`1`).
125
+
126
+ ## Cron example
127
+
128
+ ```cron
129
+ # every 5 minutes: mail me if the site is down or the cert expires within 14 days
130
+ */5 * * * * python3 /opt/pulseping_lite.py https://example.com/health --warn-days 14 || echo "example.com check failed" | mail -s "uptime" you@example.com
131
+ ```
132
+
133
+ pulseping-lite does not send alerts and checks one target per run: it exits non-zero and you decide what happens next (mail, a script, a failed CI job).
134
+
135
+ ## Measured footprint: lite CLI vs Blackbox Exporter
136
+
137
+ A one-shot check and a persistent monitoring exporter solve different jobs. This is a small, reproducible footprint check, **not a full monitoring-stack shootout**.
138
+
139
+ | Metric | pulseping-lite 0.1.0 | [Prometheus Blackbox Exporter 0.29.1](https://github.com/prometheus/blackbox_exporter/releases/tag/v0.29.1) |
140
+ | --- | ---: | ---: |
141
+ | Installed payload, excluding shared runtime | 6,511 bytes (one Python file) | 35,573,925 bytes (binary + minimal YAML) |
142
+ | Fresh-process start → first successful local HTTP result, median of 5 | 64.2 ms | 12.7 ms |
143
+ | Third-party code dependencies shipped/required | 0 Python modules | 40 Go modules embedded in binary |
144
+
145
+ **Method and machine.** Measured November 10, 2026, Europe/Rome, on this shared Linux box: kernel 6.12.113+, x86_64 KVM, 8 vCPUs (Intel Xeon), 16,002 MiB RAM, Python 3.13.5; exporter official linux-amd64 release built with Go 1.27.3. Five alternating fresh-process runs per tool, no warm-up, no filesystem-cache flush, no CPU/memory isolation. Both check the same local HTTP server returning 200 and `OK`; no DNS, public network or TLS in this benchmark.
146
+
147
+ Timing starts before process launch. For lite it ends after successful CLI exit. For the exporter it includes readiness polling (1 ms retry interval), one `/probe` request, and validation of `probe_success 1`, but excludes shutdown. It is **fresh-process**, not cold-disk timing or steady-state probe latency. Blackbox Exporter was faster in this test; lite's advantage here is its smaller payload and lack of third-party Python packages, not a blanket performance claim.
148
+
149
+ Payload uses exact file byte counts, not compressed downloads or filesystem blocks. Python, its stdlib, CA certificates and OS libraries are excluded; Go dependencies are compiled into the exporter, not packages the user installs. The dependency counts have different packaging meanings and do not estimate security or maintenance burden. No Prometheus server, dashboard, history or alerting stack was installed for either side.
150
+
151
+ **Not measured:** reliable peak RSS, TLS performance, Uptime Kuma, or the size/memory of a complete monitoring stack. No memory or Uptime Kuma numbers are claimed.
152
+
153
+ [Raw runs + release build metadata](docs/benchmark-results.json) · [Reproduction script](docs/benchmark.py) · [Setup and exact scope](docs/BENCHMARK.md).
154
+
155
+ ## What it does not do
156
+
157
+ - One target per invocation; no scheduler, persistent service, history or dashboard.
158
+ - No built-in alert delivery. Cron, CI or your wrapper decides what to do with exit codes.
159
+ - HTTP status / TCP connectivity and TLS expiry only; it is not a full replacement for Blackbox Exporter or Uptime Kuma.
160
+ - `--timeout` bounds individual network operations, not the entire process wall time; redirects are not followed.
161
+
162
+ ## Need more?
163
+
164
+ The full **[PulsePing CLI](https://py-forge.com/products/pulseping-cli?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite)** helps with:
165
+
166
+ - many monitors in one config file (HTTP with expected status and keyword, TCP, DNS, certificate expiry, gRPC health)
167
+ - consecutive-failure thresholds, so a single blip does not become an alert
168
+ - alerts to Telegram, Discord, Slack, PagerDuty or a webhook, with recovery notices
169
+ - a static, zero-JavaScript status page
170
+
171
+ One-time payment, no subscription. Every PyForge tool is also in the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=pulseping-lite).
172
+
173
+ ## Tests
174
+
175
+ ```bash
176
+ python3 test_pulseping_lite.py
177
+ ```
178
+
179
+ The tests use only a local server.
180
+
181
+ ## License
182
+
183
+ MIT (this lite version). The full PulsePing CLI is sold separately under its own license.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pulseping_lite.py
5
+ pyproject.toml
6
+ test_pulseping_lite.py
7
+ pulseping_lite.egg-info/PKG-INFO
8
+ pulseping_lite.egg-info/SOURCES.txt
9
+ pulseping_lite.egg-info/dependency_links.txt
10
+ pulseping_lite.egg-info/entry_points.txt
11
+ pulseping_lite.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pulseping-lite = pulseping_lite:main
@@ -0,0 +1 @@
1
+ pulseping_lite
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/env python3
2
+ """pulseping-lite: check one URL or host:port and its TLS certificate expiry.
3
+
4
+ Free, MIT-licensed, reduced version of PulsePing CLI (https://py-forge.com).
5
+ Standard library only. Python 3.9+.
6
+
7
+ Exit codes: 0 = up (and certificate not close to expiry), 1 = down or certificate
8
+ expired / expiring within --warn-days, 2 = bad arguments.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import argparse
14
+ import http.client
15
+ import json
16
+ import socket
17
+ import ssl
18
+ import sys
19
+ import time
20
+ import urllib.parse
21
+ from typing import Any, Dict, Optional, Tuple
22
+
23
+ VERSION = "0.1.0"
24
+ USER_AGENT = f"pulseping-lite/{VERSION}"
25
+
26
+
27
+ def parse_target(target: str) -> Tuple[str, str, int, str]:
28
+ """Return (kind, host, port, path). kind is 'http', 'https' or 'tcp'."""
29
+ target = target.strip()
30
+ if "://" in target:
31
+ parts = urllib.parse.urlsplit(target)
32
+ if parts.scheme not in ("http", "https") or not parts.hostname:
33
+ raise ValueError(f"unsupported target {target!r}: use http(s)://host or host:port")
34
+ port = parts.port or (443 if parts.scheme == "https" else 80)
35
+ path = parts.path or "/"
36
+ if parts.query:
37
+ path += "?" + parts.query
38
+ return parts.scheme, parts.hostname, port, path
39
+ if target.startswith("["): # [ipv6]:port
40
+ host, _, rest = target[1:].partition("]")
41
+ port_s = rest.lstrip(":")
42
+ elif target.count(":") == 1:
43
+ host, port_s = target.split(":")
44
+ else:
45
+ host, port_s = target, ""
46
+ if not host or not port_s:
47
+ raise ValueError(f"target {target!r} must be a URL or host:port")
48
+ return "tcp", host, int(port_s), "/"
49
+
50
+
51
+ def days_left(cert: Dict[str, Any]) -> Optional[int]:
52
+ not_after = cert.get("notAfter") if cert else None
53
+ if not not_after:
54
+ return None
55
+ return int((ssl.cert_time_to_seconds(not_after) - time.time()) // 86400)
56
+
57
+
58
+ def tls_days(host: str, port: int, timeout: float, verify: bool) -> Tuple[Optional[int], str]:
59
+ ctx = ssl.create_default_context()
60
+ if not verify:
61
+ ctx.check_hostname = False
62
+ ctx.verify_mode = ssl.CERT_NONE
63
+ with socket.create_connection((host, port), timeout=timeout) as sock:
64
+ with ctx.wrap_socket(sock, server_hostname=host) as tls:
65
+ cert = tls.getpeercert()
66
+ issuer = ", ".join(v for rdn in cert.get("issuer", ()) for k, v in rdn if k in ("organizationName", "commonName"))
67
+ return days_left(cert), issuer
68
+
69
+
70
+ def check(target: str, timeout: float = 5.0, warn_days: int = 14, verify: bool = True,
71
+ tls: bool = False) -> Dict[str, Any]:
72
+ """Run one check and return a result dict."""
73
+ started = time.perf_counter()
74
+ res: Dict[str, Any] = {"target": target, "up": False, "status_code": None,
75
+ "tls_days_left": None, "issuer": None, "latency_ms": None, "error": None}
76
+ try:
77
+ kind, host, port, path = parse_target(target)
78
+ if kind in ("http", "https"):
79
+ if kind == "https":
80
+ conn: http.client.HTTPConnection = http.client.HTTPSConnection(
81
+ host, port, timeout=timeout,
82
+ context=ssl._create_unverified_context() if not verify else ssl.create_default_context())
83
+ else:
84
+ conn = http.client.HTTPConnection(host, port, timeout=timeout)
85
+ try:
86
+ conn.request("GET", path, headers={"User-Agent": USER_AGENT, "Accept": "*/*"})
87
+ if kind == "https" and conn.sock is not None:
88
+ res["tls_days_left"] = days_left(conn.sock.getpeercert())
89
+ resp = conn.getresponse()
90
+ resp.read(1024)
91
+ res["status_code"] = resp.status
92
+ finally:
93
+ conn.close()
94
+ res["up"] = resp.status < 400
95
+ if not res["up"]:
96
+ res["error"] = f"HTTP status {resp.status}"
97
+ else:
98
+ with socket.create_connection((host, port), timeout=timeout):
99
+ pass
100
+ res["up"] = True
101
+ if tls:
102
+ res["tls_days_left"], res["issuer"] = tls_days(host, port, timeout, verify)
103
+ res["latency_ms"] = round((time.perf_counter() - started) * 1000.0, 1)
104
+ days = res["tls_days_left"]
105
+ if days is not None and days < warn_days:
106
+ res["up"] = False
107
+ res["error"] = "certificate expired" if days < 0 else f"certificate expires in {days} days (warn at {warn_days})"
108
+ except Exception as exc: # network errors, TLS errors, timeouts
109
+ res["latency_ms"] = round((time.perf_counter() - started) * 1000.0, 1)
110
+ res["error"] = f"{type(exc).__name__}: {exc}"
111
+ return res
112
+
113
+
114
+ def build_parser() -> argparse.ArgumentParser:
115
+ p = argparse.ArgumentParser(
116
+ prog="pulseping-lite",
117
+ description="Check one URL or host:port, and report days until its TLS certificate expires.")
118
+ p.add_argument("target", help="https://example.com/health, http://host:8080, or host:port")
119
+ p.add_argument("--warn-days", type=int, default=14, help="fail when the certificate expires sooner (default 14)")
120
+ p.add_argument("--timeout", type=float, default=5.0, help="seconds (default 5)")
121
+ p.add_argument("--tls", action="store_true", help="for a host:port target, also read the TLS certificate (e.g. host:443)")
122
+ p.add_argument("--insecure", action="store_true", help="do not verify the certificate chain")
123
+ p.add_argument("--json", action="store_true", help="print the result as JSON")
124
+ p.add_argument("--version", action="version", version=f"pulseping-lite {VERSION}")
125
+ return p
126
+
127
+
128
+ def main(argv: Optional[list] = None) -> int:
129
+ args = build_parser().parse_args(argv)
130
+ try:
131
+ parse_target(args.target)
132
+ except ValueError as exc:
133
+ print(f"error: {exc}", file=sys.stderr)
134
+ return 2
135
+ res = check(args.target, args.timeout, args.warn_days, not args.insecure, args.tls)
136
+ if args.json:
137
+ print(json.dumps(res, indent=2))
138
+ else:
139
+ state = "UP " if res["up"] else "DOWN"
140
+ line = f"{state} {res['target']}"
141
+ if res["status_code"] is not None:
142
+ line += f" status={res['status_code']}"
143
+ if res["latency_ms"] is not None:
144
+ line += f" {res['latency_ms']} ms"
145
+ if res["tls_days_left"] is not None:
146
+ line += f" cert expires in {res['tls_days_left']} days"
147
+ print(line)
148
+ if res["error"]:
149
+ print(f" {res['error']}")
150
+ return 0 if res["up"] else 1
151
+
152
+
153
+ if __name__ == "__main__":
154
+ sys.exit(main())
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pulseping-lite"
7
+ version = "0.1.0"
8
+ description = "Uptime monitor and TLS certificate expiry check in one stdlib-only Python CLI."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [{name = "Alessio Auretto"}]
14
+ keywords = [
15
+ "uptime",
16
+ "monitoring",
17
+ "tls",
18
+ "ssl",
19
+ "certificate",
20
+ "healthcheck",
21
+ "cli",
22
+ "stdlib",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Environment :: Console",
27
+ "Intended Audience :: Developers",
28
+ "Intended Audience :: System Administrators",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.9",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Topic :: System :: Monitoring",
37
+ "Topic :: System :: Networking :: Monitoring",
38
+ "Topic :: Utilities",
39
+ ]
40
+ [project.urls]
41
+ Homepage = "https://github.com/alessio1999xx-debug/pulseping-lite"
42
+ "Pro version" = "https://py-forge.com/products/pulseping-cli"
43
+
44
+ [project.scripts]
45
+ pulseping-lite = "pulseping_lite:main"
46
+
47
+ [tool.setuptools]
48
+ py-modules = ["pulseping_lite"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,92 @@
1
+ import contextlib
2
+ import datetime as dt
3
+ import http.server
4
+ import io
5
+ import json
6
+ import socket
7
+ import threading
8
+ import unittest
9
+
10
+ import pulseping_lite as pl
11
+
12
+
13
+ class H(http.server.BaseHTTPRequestHandler):
14
+ def do_GET(self):
15
+ code = 500 if self.path == "/fail" else 200
16
+ self.send_response(code)
17
+ self.end_headers()
18
+ self.wfile.write(b"ok")
19
+
20
+ def log_message(self, *a):
21
+ pass
22
+
23
+
24
+ def run(argv):
25
+ out = io.StringIO()
26
+ with contextlib.redirect_stdout(out):
27
+ code = pl.main(argv)
28
+ return code, out.getvalue()
29
+
30
+
31
+ class Tests(unittest.TestCase):
32
+ @classmethod
33
+ def setUpClass(cls):
34
+ cls.srv = http.server.HTTPServer(("127.0.0.1", 0), H)
35
+ cls.port = cls.srv.server_address[1]
36
+ threading.Thread(target=cls.srv.serve_forever, daemon=True).start()
37
+
38
+ @classmethod
39
+ def tearDownClass(cls):
40
+ cls.srv.shutdown()
41
+
42
+ def test_parse_target(self):
43
+ self.assertEqual(pl.parse_target("https://a.com/x?y=1"), ("https", "a.com", 443, "/x?y=1"))
44
+ self.assertEqual(pl.parse_target("http://a.com:8080"), ("http", "a.com", 8080, "/"))
45
+ self.assertEqual(pl.parse_target("db.local:5432"), ("tcp", "db.local", 5432, "/"))
46
+ self.assertEqual(pl.parse_target("[::1]:22"), ("tcp", "::1", 22, "/"))
47
+ with self.assertRaises(ValueError):
48
+ pl.parse_target("ftp://a.com")
49
+ with self.assertRaises(ValueError):
50
+ pl.parse_target("justahost")
51
+
52
+ def test_http_up(self):
53
+ code, out = run([f"http://127.0.0.1:{self.port}/"])
54
+ self.assertEqual(code, 0)
55
+ self.assertIn("UP", out)
56
+ self.assertIn("status=200", out)
57
+
58
+ def test_http_500_is_down(self):
59
+ code, out = run([f"http://127.0.0.1:{self.port}/fail"])
60
+ self.assertEqual(code, 1)
61
+ self.assertIn("DOWN", out)
62
+
63
+ def test_tcp_up_and_down(self):
64
+ self.assertEqual(run([f"127.0.0.1:{self.port}"])[0], 0)
65
+ s = socket.socket()
66
+ s.bind(("127.0.0.1", 0))
67
+ free = s.getsockname()[1]
68
+ s.close()
69
+ self.assertEqual(run([f"127.0.0.1:{free}", "--timeout", "1"])[0], 1)
70
+
71
+ def test_json_output(self):
72
+ code, out = run([f"http://127.0.0.1:{self.port}/", "--json"])
73
+ data = json.loads(out)
74
+ self.assertEqual(code, 0)
75
+ self.assertTrue(data["up"])
76
+ self.assertEqual(data["status_code"], 200)
77
+
78
+ def test_bad_target_exit_2(self):
79
+ err = io.StringIO()
80
+ with contextlib.redirect_stderr(err):
81
+ self.assertEqual(pl.main(["nonsense"]), 2)
82
+
83
+ def test_days_left(self):
84
+ future = (dt.datetime.now(dt.timezone.utc) + dt.timedelta(days=30, hours=1)).strftime("%b %d %H:%M:%S %Y GMT")
85
+ self.assertIn(pl.days_left({"notAfter": future}), (30,))
86
+ past = (dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=3)).strftime("%b %d %H:%M:%S %Y GMT")
87
+ self.assertLess(pl.days_left({"notAfter": past}), 0)
88
+ self.assertIsNone(pl.days_left({}))
89
+
90
+
91
+ if __name__ == "__main__":
92
+ unittest.main()