telert 0.2.1__tar.gz → 0.2.3__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.
- {telert-0.2.1/telert.egg-info → telert-0.2.3}/PKG-INFO +115 -51
- {telert-0.2.1 → telert-0.2.3}/README.md +114 -50
- {telert-0.2.1 → telert-0.2.3}/pyproject.toml +1 -1
- {telert-0.2.1 → telert-0.2.3}/telert/__init__.py +1 -1
- {telert-0.2.1 → telert-0.2.3}/telert/messaging.py +91 -17
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/base.py +1 -1
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/cli.py +3 -3
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/cli_logs.py +1 -1
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/network.py +1 -1
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/process.py +80 -69
- {telert-0.2.1 → telert-0.2.3/telert.egg-info}/PKG-INFO +115 -51
- {telert-0.2.1 → telert-0.2.3}/telert.egg-info/SOURCES.txt +2 -4
- telert-0.2.1/telert/monitoring/logs.py +0 -267
- {telert-0.2.1 → telert-0.2.3}/LICENSE +0 -0
- {telert-0.2.1 → telert-0.2.3}/MANIFEST.in +0 -0
- {telert-0.2.1 → telert-0.2.3}/setup.cfg +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/api.py +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/cli.py +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/data/notification-icon.png +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/data/notification.mp3 +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/__init__.py +0 -0
- /telert-0.2.1/telert/monitoring/fixed_logs.py → /telert-0.2.3/telert/monitoring/activity_logs.py +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/debug_logs.py +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert/monitoring/log.py +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert.egg-info/dependency_links.txt +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert.egg-info/entry_points.txt +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert.egg-info/requires.txt +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert.egg-info/top_level.txt +0 -0
- {telert-0.2.1 → telert-0.2.3}/telert.png +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: telert
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks.
|
|
5
5
|
Author-email: Mihir Khandekar <mihirkhandekar@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -54,11 +54,11 @@ Dynamic: license-file
|
|
|
54
54
|
<img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
|
-
**Version 0.2.
|
|
57
|
+
**Version 0.2.3**
|
|
58
58
|
|
|
59
|
+
[](https://pepy.tech/projects/telert)
|
|
59
60
|
[](https://github.com/navig-me/telert/stargazers)
|
|
60
61
|
[](https://pypi.org/project/telert/)
|
|
61
|
-
[](https://pepy.tech/project/telert)
|
|
62
62
|
[](https://github.com/navig-me/telert/blob/main/LICENSE)
|
|
63
63
|
[](https://github.com/marketplace/actions/telert-run)
|
|
64
64
|
[](https://marketplace.visualstudio.com/items?itemName=Navig.telert-vscode)
|
|
@@ -87,7 +87,7 @@ find . -name "*.log" | telert "Log files found!"
|
|
|
87
87
|
telert monitor log --name "postgres" --file "/var/log/postgresql/postgresql-15-main.log" --pattern "ERROR|FATAL"
|
|
88
88
|
|
|
89
89
|
# Monitor a process and notify on high memory usage
|
|
90
|
-
telert monitor process --
|
|
90
|
+
telert monitor process --command-pattern "ps aux | grep postgres" --memory-threshold 2G
|
|
91
91
|
|
|
92
92
|
# Monitor a network endpoint and notify on failure
|
|
93
93
|
telert monitor network --name "myapp-health" --host "myapp.com" --port 80 --type http --interval 60 --timeout 5 --expected-status 200 --expected-content "healthy"
|
|
@@ -102,10 +102,14 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
|
|
|
102
102
|
- As a cloud-hosted API on [Replit](https://replit.com/@mihir95/Telert-CLI-Notifier), [Railway](https://railway.com/template/A_kYXt?referralCode=vj4bEA), [Render](https://render.com/deploy?repo=https://github.com/navig-me/telert-notifier) or [Fly.io](https://github.com/navig-me/telert-notifier?tab=readme-ov-file#-deploy-manually-on-flyio) with one-click deployments.
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
<img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="
|
|
105
|
+
<img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="700">
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
## 📋 Table of Contents
|
|
109
|
+
|
|
110
|
+
<details>
|
|
111
|
+
<summary> <b>View Table of Contents</b> </summary>
|
|
112
|
+
|
|
109
113
|
- [Installation & Quick Start](#-installation--quick-start)
|
|
110
114
|
- [Notification Providers](#-notification-providers)
|
|
111
115
|
- [Telegram](#telegram-setup)
|
|
@@ -133,9 +137,13 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
|
|
|
133
137
|
- [Message Formatting](#-message-formatting)
|
|
134
138
|
- [Use Cases](#-use-cases-and-tips)
|
|
135
139
|
- [Contributing](#-contributing--license)
|
|
140
|
+
</details>
|
|
136
141
|
|
|
137
142
|
## Documentation
|
|
138
143
|
|
|
144
|
+
<details>
|
|
145
|
+
<summary> <b>View Documentation Directory</b></summary>
|
|
146
|
+
|
|
139
147
|
For more detailed information, please refer to the [docs](https://github.com/navig-me/telert/blob/main/docs/) directory:
|
|
140
148
|
|
|
141
149
|
- [Environment Variables](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
|
|
@@ -153,10 +161,13 @@ For more detailed information, please refer to the [docs](https://github.com/nav
|
|
|
153
161
|
- [Docker Usage](https://github.com/navig-me/telert/blob/main/docs/DOCKER.md)
|
|
154
162
|
- [CI/CD Integrations](https://github.com/navig-me/telert/blob/main/docs/CI-CD.md)
|
|
155
163
|
|
|
164
|
+
</details>
|
|
165
|
+
|
|
156
166
|
## 🚀 Installation & Quick Start
|
|
157
167
|
|
|
168
|
+
Install and configure in seconds:
|
|
169
|
+
|
|
158
170
|
```bash
|
|
159
|
-
# Install from PyPI (works on any OS with Python 3.8+)
|
|
160
171
|
pip install telert
|
|
161
172
|
|
|
162
173
|
# Interactive setup wizard - easiest way to get started
|
|
@@ -164,13 +175,45 @@ telert init
|
|
|
164
175
|
|
|
165
176
|
# Or configure a notification provider manually
|
|
166
177
|
telert config desktop --app-name "My App" --set-default
|
|
178
|
+
```
|
|
167
179
|
|
|
168
|
-
|
|
180
|
+
Use in your shell directly or wrap any command:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Pipe command output for notification
|
|
169
184
|
long_running_command | telert "Command finished!"
|
|
170
185
|
|
|
171
|
-
#
|
|
186
|
+
# Wrap a command to capture status and timing
|
|
172
187
|
telert run --label "Database Backup" pg_dump -U postgres mydb > backup.sql
|
|
173
188
|
|
|
189
|
+
# Get notified for any command taking longer than 30 seconds
|
|
190
|
+
eval "$(telert hook -l 30)"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Or use in your Python code:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
from telert import send, telert, notify
|
|
197
|
+
|
|
198
|
+
# Simple notification
|
|
199
|
+
send("Script completed successfully!")
|
|
200
|
+
|
|
201
|
+
# Using the context manager
|
|
202
|
+
def process():
|
|
203
|
+
with telert("Data processing", provider="telegram"):
|
|
204
|
+
# Your long-running code here
|
|
205
|
+
process_large_dataset()
|
|
206
|
+
|
|
207
|
+
# Using the function decorator
|
|
208
|
+
@notify("Database backup", provider="email")
|
|
209
|
+
def backup_database():
|
|
210
|
+
# Backup code here
|
|
211
|
+
return "Backup completed"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Or monitor processes, log files, and network endpoints:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
174
217
|
# Monitor a process
|
|
175
218
|
telert monitor process --name "postgres" --command "ps aux | grep postgres" --memory-threshold 2G
|
|
176
219
|
|
|
@@ -388,7 +431,7 @@ telert monitor process --name "nginx" --notify-on stop,high-cpu --provider slack
|
|
|
388
431
|
telert monitor process --name "postgres" --cpu-threshold 80 --memory-threshold 2G --provider telegram
|
|
389
432
|
|
|
390
433
|
# Monitor with custom action on state change
|
|
391
|
-
telert monitor process --command "python worker.py" --notify-on crash --action "systemctl restart worker"
|
|
434
|
+
telert monitor process --command-pattern "python worker.py" --notify-on crash --action "systemctl restart worker"
|
|
392
435
|
|
|
393
436
|
# List all monitored processes
|
|
394
437
|
telert monitor process --list
|
|
@@ -737,6 +780,21 @@ curl -X POST https://your-deployment-url.example.com/send \
|
|
|
737
780
|
|
|
738
781
|
For more details on deployment options and configuration, see the [telert-notifier repository](https://github.com/navig-me/telert-notifier).
|
|
739
782
|
|
|
783
|
+
---
|
|
784
|
+
## 🌿 Environment Variables
|
|
785
|
+
|
|
786
|
+
Telert can be configured using environment variables, which is especially useful in CI/CD pipelines or containerized environments. Key variables include:
|
|
787
|
+
|
|
788
|
+
- `TELERT_DEFAULT_PROVIDER` - Set default provider(s) to use
|
|
789
|
+
- Provider-specific variables for Telegram, Teams, Slack, Discord, Pushover, etc.
|
|
790
|
+
- Runtime variables like `TELERT_SILENT=1` for output control
|
|
791
|
+
|
|
792
|
+
Environment variables take precedence over the configuration file, making them perfect for temporary overrides.
|
|
793
|
+
|
|
794
|
+
[**See all environment variables**](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
|
|
795
|
+
|
|
796
|
+
---
|
|
797
|
+
|
|
740
798
|
## 🔧 Troubleshooting
|
|
741
799
|
|
|
742
800
|
### Desktop Notifications Issues
|
|
@@ -768,49 +826,55 @@ For more details on deployment options and configuration, see the [telert-notifi
|
|
|
768
826
|
- Install required audio players (macOS: built-in, Linux: mpg123/paplay/aplay, Windows: winsound/playsound)
|
|
769
827
|
- For MP3 support on Windows: `pip install telert[audio]`
|
|
770
828
|
|
|
829
|
+
### Notification Delivery Failures
|
|
830
|
+
- Verify your internet connection
|
|
831
|
+
- Check provider configuration with `telert status`
|
|
832
|
+
- For cloud services, verify API keys and webhook URLs
|
|
833
|
+
- Check rate limits for your notification provider
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
### Monitoring Installation Issues & Commands
|
|
837
|
+
|
|
838
|
+
Telert’s process monitoring depends on the `psutil` library. If you encounter errors related to psutil (such as ImportError, build failures, or missing wheels), follow these platform-specific tips:
|
|
839
|
+
|
|
840
|
+
**Apple Silicon (M1/M2):**
|
|
841
|
+
- Try installing psutil using the native ARM64 architecture:
|
|
842
|
+
```bash
|
|
843
|
+
arch -arm64 pip install --no-cache-dir psutil
|
|
844
|
+
```
|
|
845
|
+
- For Intel compatibility (Rosetta):
|
|
846
|
+
```bash
|
|
847
|
+
arch -x86_64 pip install --no-cache-dir psutil
|
|
848
|
+
```
|
|
849
|
+
- If you see compilation errors, ensure you have Xcode Command Line Tools installed:
|
|
850
|
+
```bash
|
|
851
|
+
xcode-select --install
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
**Linux:**
|
|
855
|
+
- Make sure you have Python development headers and a C compiler installed:
|
|
856
|
+
```bash
|
|
857
|
+
sudo apt-get install python3-dev gcc
|
|
858
|
+
pip install --upgrade --force-reinstall psutil
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
**Windows:**
|
|
862
|
+
- You may need to install Visual C++ Build Tools from:
|
|
863
|
+
https://visualstudio.microsoft.com/visual-cpp-build-tools/
|
|
864
|
+
- Then try:
|
|
865
|
+
```bash
|
|
866
|
+
pip install --upgrade --force-reinstall psutil
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
**General:**
|
|
870
|
+
- If you still have issues, try upgrading pip and setuptools:
|
|
871
|
+
```bash
|
|
872
|
+
pip install --upgrade pip setuptools wheel
|
|
873
|
+
```
|
|
874
|
+
- For more details, see the error message for platform-specific instructions.
|
|
875
|
+
|
|
876
|
+
> **Note:** psutil is required for all process monitoring features in Telert. If import fails, you’ll see a detailed error with platform-specific help.
|
|
771
877
|
|
|
772
|
-
---
|
|
773
|
-
## 🌿 Environment Variables
|
|
774
|
-
|
|
775
|
-
Telert can be configured using environment variables, which is especially useful in CI/CD pipelines or containerized environments. Key variables include:
|
|
776
|
-
|
|
777
|
-
- `TELERT_DEFAULT_PROVIDER` - Set default provider(s) to use
|
|
778
|
-
- Provider-specific variables for Telegram, Teams, Slack, Discord, Pushover, etc.
|
|
779
|
-
- Runtime variables like `TELERT_SILENT=1` for output control
|
|
780
|
-
|
|
781
|
-
Environment variables take precedence over the configuration file, making them perfect for temporary overrides.
|
|
782
|
-
|
|
783
|
-
[**See all environment variables**](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
|
|
784
|
-
|
|
785
|
-
---
|
|
786
|
-
|
|
787
|
-
## 🔍 Troubleshooting
|
|
788
|
-
|
|
789
|
-
### Common Issues and Solutions
|
|
790
|
-
|
|
791
|
-
#### Notification Delivery Failures
|
|
792
|
-
- **Symptom**: Notifications not being received
|
|
793
|
-
- Verify your internet connection
|
|
794
|
-
- Check provider configuration with `telert status`
|
|
795
|
-
- For cloud services, verify API keys and webhook URLs
|
|
796
|
-
- Check rate limits for your notification provider
|
|
797
|
-
|
|
798
|
-
#### Audio Notifications Not Working
|
|
799
|
-
- **Symptom**: No sound when using audio notifications
|
|
800
|
-
- Ensure audio package dependencies are installed: `pip install 'telert[audio]'`
|
|
801
|
-
- Check system volume and audio output device
|
|
802
|
-
- On Linux, ensure `libasound2` and `libasound2-dev` are installed
|
|
803
|
-
|
|
804
|
-
#### Apple Silicon (M1/M2) Installation
|
|
805
|
-
- **Symptom**: Installation fails on Apple Silicon Macs
|
|
806
|
-
- For Apple Silicon (M-series) users, try:
|
|
807
|
-
```bash
|
|
808
|
-
# Native ARM64 installation (recommended)
|
|
809
|
-
arch -arm64 pip install --no-cache-dir telert
|
|
810
|
-
|
|
811
|
-
# Or for Intel compatibility
|
|
812
|
-
arch -x86_64 pip install --no-cache-dir telert
|
|
813
|
-
```
|
|
814
878
|
|
|
815
879
|
---
|
|
816
880
|
## 📝 Message Formatting
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
**Version 0.2.
|
|
9
|
+
**Version 0.2.3**
|
|
10
10
|
|
|
11
|
+
[](https://pepy.tech/projects/telert)
|
|
11
12
|
[](https://github.com/navig-me/telert/stargazers)
|
|
12
13
|
[](https://pypi.org/project/telert/)
|
|
13
|
-
[](https://pepy.tech/project/telert)
|
|
14
14
|
[](https://github.com/navig-me/telert/blob/main/LICENSE)
|
|
15
15
|
[](https://github.com/marketplace/actions/telert-run)
|
|
16
16
|
[](https://marketplace.visualstudio.com/items?itemName=Navig.telert-vscode)
|
|
@@ -39,7 +39,7 @@ find . -name "*.log" | telert "Log files found!"
|
|
|
39
39
|
telert monitor log --name "postgres" --file "/var/log/postgresql/postgresql-15-main.log" --pattern "ERROR|FATAL"
|
|
40
40
|
|
|
41
41
|
# Monitor a process and notify on high memory usage
|
|
42
|
-
telert monitor process --
|
|
42
|
+
telert monitor process --command-pattern "ps aux | grep postgres" --memory-threshold 2G
|
|
43
43
|
|
|
44
44
|
# Monitor a network endpoint and notify on failure
|
|
45
45
|
telert monitor network --name "myapp-health" --host "myapp.com" --port 80 --type http --interval 60 --timeout 5 --expected-status 200 --expected-content "healthy"
|
|
@@ -54,10 +54,14 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
|
|
|
54
54
|
- As a cloud-hosted API on [Replit](https://replit.com/@mihir95/Telert-CLI-Notifier), [Railway](https://railway.com/template/A_kYXt?referralCode=vj4bEA), [Render](https://render.com/deploy?repo=https://github.com/navig-me/telert-notifier) or [Fly.io](https://github.com/navig-me/telert-notifier?tab=readme-ov-file#-deploy-manually-on-flyio) with one-click deployments.
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
<img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="
|
|
57
|
+
<img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="700">
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
## 📋 Table of Contents
|
|
61
|
+
|
|
62
|
+
<details>
|
|
63
|
+
<summary> <b>View Table of Contents</b> </summary>
|
|
64
|
+
|
|
61
65
|
- [Installation & Quick Start](#-installation--quick-start)
|
|
62
66
|
- [Notification Providers](#-notification-providers)
|
|
63
67
|
- [Telegram](#telegram-setup)
|
|
@@ -85,9 +89,13 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
|
|
|
85
89
|
- [Message Formatting](#-message-formatting)
|
|
86
90
|
- [Use Cases](#-use-cases-and-tips)
|
|
87
91
|
- [Contributing](#-contributing--license)
|
|
92
|
+
</details>
|
|
88
93
|
|
|
89
94
|
## Documentation
|
|
90
95
|
|
|
96
|
+
<details>
|
|
97
|
+
<summary> <b>View Documentation Directory</b></summary>
|
|
98
|
+
|
|
91
99
|
For more detailed information, please refer to the [docs](https://github.com/navig-me/telert/blob/main/docs/) directory:
|
|
92
100
|
|
|
93
101
|
- [Environment Variables](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
|
|
@@ -105,10 +113,13 @@ For more detailed information, please refer to the [docs](https://github.com/nav
|
|
|
105
113
|
- [Docker Usage](https://github.com/navig-me/telert/blob/main/docs/DOCKER.md)
|
|
106
114
|
- [CI/CD Integrations](https://github.com/navig-me/telert/blob/main/docs/CI-CD.md)
|
|
107
115
|
|
|
116
|
+
</details>
|
|
117
|
+
|
|
108
118
|
## 🚀 Installation & Quick Start
|
|
109
119
|
|
|
120
|
+
Install and configure in seconds:
|
|
121
|
+
|
|
110
122
|
```bash
|
|
111
|
-
# Install from PyPI (works on any OS with Python 3.8+)
|
|
112
123
|
pip install telert
|
|
113
124
|
|
|
114
125
|
# Interactive setup wizard - easiest way to get started
|
|
@@ -116,13 +127,45 @@ telert init
|
|
|
116
127
|
|
|
117
128
|
# Or configure a notification provider manually
|
|
118
129
|
telert config desktop --app-name "My App" --set-default
|
|
130
|
+
```
|
|
119
131
|
|
|
120
|
-
|
|
132
|
+
Use in your shell directly or wrap any command:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Pipe command output for notification
|
|
121
136
|
long_running_command | telert "Command finished!"
|
|
122
137
|
|
|
123
|
-
#
|
|
138
|
+
# Wrap a command to capture status and timing
|
|
124
139
|
telert run --label "Database Backup" pg_dump -U postgres mydb > backup.sql
|
|
125
140
|
|
|
141
|
+
# Get notified for any command taking longer than 30 seconds
|
|
142
|
+
eval "$(telert hook -l 30)"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Or use in your Python code:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from telert import send, telert, notify
|
|
149
|
+
|
|
150
|
+
# Simple notification
|
|
151
|
+
send("Script completed successfully!")
|
|
152
|
+
|
|
153
|
+
# Using the context manager
|
|
154
|
+
def process():
|
|
155
|
+
with telert("Data processing", provider="telegram"):
|
|
156
|
+
# Your long-running code here
|
|
157
|
+
process_large_dataset()
|
|
158
|
+
|
|
159
|
+
# Using the function decorator
|
|
160
|
+
@notify("Database backup", provider="email")
|
|
161
|
+
def backup_database():
|
|
162
|
+
# Backup code here
|
|
163
|
+
return "Backup completed"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Or monitor processes, log files, and network endpoints:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
126
169
|
# Monitor a process
|
|
127
170
|
telert monitor process --name "postgres" --command "ps aux | grep postgres" --memory-threshold 2G
|
|
128
171
|
|
|
@@ -340,7 +383,7 @@ telert monitor process --name "nginx" --notify-on stop,high-cpu --provider slack
|
|
|
340
383
|
telert monitor process --name "postgres" --cpu-threshold 80 --memory-threshold 2G --provider telegram
|
|
341
384
|
|
|
342
385
|
# Monitor with custom action on state change
|
|
343
|
-
telert monitor process --command "python worker.py" --notify-on crash --action "systemctl restart worker"
|
|
386
|
+
telert monitor process --command-pattern "python worker.py" --notify-on crash --action "systemctl restart worker"
|
|
344
387
|
|
|
345
388
|
# List all monitored processes
|
|
346
389
|
telert monitor process --list
|
|
@@ -689,6 +732,21 @@ curl -X POST https://your-deployment-url.example.com/send \
|
|
|
689
732
|
|
|
690
733
|
For more details on deployment options and configuration, see the [telert-notifier repository](https://github.com/navig-me/telert-notifier).
|
|
691
734
|
|
|
735
|
+
---
|
|
736
|
+
## 🌿 Environment Variables
|
|
737
|
+
|
|
738
|
+
Telert can be configured using environment variables, which is especially useful in CI/CD pipelines or containerized environments. Key variables include:
|
|
739
|
+
|
|
740
|
+
- `TELERT_DEFAULT_PROVIDER` - Set default provider(s) to use
|
|
741
|
+
- Provider-specific variables for Telegram, Teams, Slack, Discord, Pushover, etc.
|
|
742
|
+
- Runtime variables like `TELERT_SILENT=1` for output control
|
|
743
|
+
|
|
744
|
+
Environment variables take precedence over the configuration file, making them perfect for temporary overrides.
|
|
745
|
+
|
|
746
|
+
[**See all environment variables**](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
|
|
747
|
+
|
|
748
|
+
---
|
|
749
|
+
|
|
692
750
|
## 🔧 Troubleshooting
|
|
693
751
|
|
|
694
752
|
### Desktop Notifications Issues
|
|
@@ -720,49 +778,55 @@ For more details on deployment options and configuration, see the [telert-notifi
|
|
|
720
778
|
- Install required audio players (macOS: built-in, Linux: mpg123/paplay/aplay, Windows: winsound/playsound)
|
|
721
779
|
- For MP3 support on Windows: `pip install telert[audio]`
|
|
722
780
|
|
|
781
|
+
### Notification Delivery Failures
|
|
782
|
+
- Verify your internet connection
|
|
783
|
+
- Check provider configuration with `telert status`
|
|
784
|
+
- For cloud services, verify API keys and webhook URLs
|
|
785
|
+
- Check rate limits for your notification provider
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
### Monitoring Installation Issues & Commands
|
|
789
|
+
|
|
790
|
+
Telert’s process monitoring depends on the `psutil` library. If you encounter errors related to psutil (such as ImportError, build failures, or missing wheels), follow these platform-specific tips:
|
|
791
|
+
|
|
792
|
+
**Apple Silicon (M1/M2):**
|
|
793
|
+
- Try installing psutil using the native ARM64 architecture:
|
|
794
|
+
```bash
|
|
795
|
+
arch -arm64 pip install --no-cache-dir psutil
|
|
796
|
+
```
|
|
797
|
+
- For Intel compatibility (Rosetta):
|
|
798
|
+
```bash
|
|
799
|
+
arch -x86_64 pip install --no-cache-dir psutil
|
|
800
|
+
```
|
|
801
|
+
- If you see compilation errors, ensure you have Xcode Command Line Tools installed:
|
|
802
|
+
```bash
|
|
803
|
+
xcode-select --install
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
**Linux:**
|
|
807
|
+
- Make sure you have Python development headers and a C compiler installed:
|
|
808
|
+
```bash
|
|
809
|
+
sudo apt-get install python3-dev gcc
|
|
810
|
+
pip install --upgrade --force-reinstall psutil
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
**Windows:**
|
|
814
|
+
- You may need to install Visual C++ Build Tools from:
|
|
815
|
+
https://visualstudio.microsoft.com/visual-cpp-build-tools/
|
|
816
|
+
- Then try:
|
|
817
|
+
```bash
|
|
818
|
+
pip install --upgrade --force-reinstall psutil
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
**General:**
|
|
822
|
+
- If you still have issues, try upgrading pip and setuptools:
|
|
823
|
+
```bash
|
|
824
|
+
pip install --upgrade pip setuptools wheel
|
|
825
|
+
```
|
|
826
|
+
- For more details, see the error message for platform-specific instructions.
|
|
827
|
+
|
|
828
|
+
> **Note:** psutil is required for all process monitoring features in Telert. If import fails, you’ll see a detailed error with platform-specific help.
|
|
723
829
|
|
|
724
|
-
---
|
|
725
|
-
## 🌿 Environment Variables
|
|
726
|
-
|
|
727
|
-
Telert can be configured using environment variables, which is especially useful in CI/CD pipelines or containerized environments. Key variables include:
|
|
728
|
-
|
|
729
|
-
- `TELERT_DEFAULT_PROVIDER` - Set default provider(s) to use
|
|
730
|
-
- Provider-specific variables for Telegram, Teams, Slack, Discord, Pushover, etc.
|
|
731
|
-
- Runtime variables like `TELERT_SILENT=1` for output control
|
|
732
|
-
|
|
733
|
-
Environment variables take precedence over the configuration file, making them perfect for temporary overrides.
|
|
734
|
-
|
|
735
|
-
[**See all environment variables**](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
|
|
736
|
-
|
|
737
|
-
---
|
|
738
|
-
|
|
739
|
-
## 🔍 Troubleshooting
|
|
740
|
-
|
|
741
|
-
### Common Issues and Solutions
|
|
742
|
-
|
|
743
|
-
#### Notification Delivery Failures
|
|
744
|
-
- **Symptom**: Notifications not being received
|
|
745
|
-
- Verify your internet connection
|
|
746
|
-
- Check provider configuration with `telert status`
|
|
747
|
-
- For cloud services, verify API keys and webhook URLs
|
|
748
|
-
- Check rate limits for your notification provider
|
|
749
|
-
|
|
750
|
-
#### Audio Notifications Not Working
|
|
751
|
-
- **Symptom**: No sound when using audio notifications
|
|
752
|
-
- Ensure audio package dependencies are installed: `pip install 'telert[audio]'`
|
|
753
|
-
- Check system volume and audio output device
|
|
754
|
-
- On Linux, ensure `libasound2` and `libasound2-dev` are installed
|
|
755
|
-
|
|
756
|
-
#### Apple Silicon (M1/M2) Installation
|
|
757
|
-
- **Symptom**: Installation fails on Apple Silicon Macs
|
|
758
|
-
- For Apple Silicon (M-series) users, try:
|
|
759
|
-
```bash
|
|
760
|
-
# Native ARM64 installation (recommended)
|
|
761
|
-
arch -arm64 pip install --no-cache-dir telert
|
|
762
|
-
|
|
763
|
-
# Or for Intel compatibility
|
|
764
|
-
arch -x86_64 pip install --no-cache-dir telert
|
|
765
|
-
```
|
|
766
830
|
|
|
767
831
|
---
|
|
768
832
|
## 📝 Message Formatting
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "telert"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.3"
|
|
4
4
|
description = "Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks."
|
|
5
5
|
authors = [{name = "Mihir Khandekar", email = "mihirkhandekar@gmail.com"}]
|
|
6
6
|
license = "MIT"
|
|
@@ -337,7 +337,11 @@ def prepare_telegram_html(message: str) -> str:
|
|
|
337
337
|
# Process all elements recursively
|
|
338
338
|
def process_node(node):
|
|
339
339
|
if node.name is None: # Text node
|
|
340
|
-
|
|
340
|
+
# Escape HTML special characters in text content
|
|
341
|
+
text = node.string or ""
|
|
342
|
+
# HTML mode requires escaping of <, >, & characters
|
|
343
|
+
text = text.replace('&', '&').replace('<', '<').replace('>', '>')
|
|
344
|
+
return text
|
|
341
345
|
|
|
342
346
|
# Only include supported tags, strip others but keep their content
|
|
343
347
|
supported_tags = ['b', 'i', 'u', 's', 'code', 'pre', 'a']
|
|
@@ -361,6 +365,37 @@ def prepare_telegram_html(message: str) -> str:
|
|
|
361
365
|
return result
|
|
362
366
|
|
|
363
367
|
|
|
368
|
+
def prepare_telegram_plain_text(message: str) -> str:
|
|
369
|
+
"""
|
|
370
|
+
Prepare plain text messages for Telegram by escaping special characters.
|
|
371
|
+
|
|
372
|
+
When sending plain text (no HTML or Markdown), certain characters still need
|
|
373
|
+
to be escaped to prevent Telegram API errors. This function handles the
|
|
374
|
+
escaping of characters that have special meaning in Telegram messages.
|
|
375
|
+
|
|
376
|
+
Args:
|
|
377
|
+
message: Message text that contains special characters
|
|
378
|
+
|
|
379
|
+
Returns:
|
|
380
|
+
Message with special characters properly escaped for plain text mode
|
|
381
|
+
"""
|
|
382
|
+
if not message:
|
|
383
|
+
return message
|
|
384
|
+
|
|
385
|
+
# Characters that need to be escaped in plain text to prevent API errors
|
|
386
|
+
# Based on Telegram Bot API documentation and common error patterns
|
|
387
|
+
special_chars = ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']
|
|
388
|
+
|
|
389
|
+
result = ""
|
|
390
|
+
for char in message:
|
|
391
|
+
if char in special_chars:
|
|
392
|
+
result += '\\' + char
|
|
393
|
+
else:
|
|
394
|
+
result += char
|
|
395
|
+
|
|
396
|
+
return result
|
|
397
|
+
|
|
398
|
+
|
|
364
399
|
def prepare_telegram_markdown(message: str) -> str:
|
|
365
400
|
"""
|
|
366
401
|
Prepare Markdown-formatted messages for Telegram.
|
|
@@ -380,29 +415,65 @@ def prepare_telegram_markdown(message: str) -> str:
|
|
|
380
415
|
# Characters that need to be escaped in MarkdownV2
|
|
381
416
|
special_chars = ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']
|
|
382
417
|
|
|
383
|
-
#
|
|
418
|
+
# For MarkdownV2, we need to escape special characters but preserve markdown syntax
|
|
419
|
+
# This is a simplified approach - for complex markdown, consider using a proper parser
|
|
384
420
|
result = ""
|
|
385
|
-
in_tag = False
|
|
386
421
|
i = 0
|
|
387
422
|
|
|
388
423
|
while i < len(message):
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
424
|
+
char = message[i]
|
|
425
|
+
|
|
426
|
+
# Handle code blocks (``` or single `)
|
|
427
|
+
if char == '`':
|
|
428
|
+
# Find the matching closing backtick(s)
|
|
429
|
+
if i + 2 < len(message) and message[i:i+3] == '```':
|
|
430
|
+
# Code block - find closing ```
|
|
431
|
+
end = message.find('```', i + 3)
|
|
432
|
+
if end != -1:
|
|
433
|
+
# Include the entire code block without escaping
|
|
434
|
+
result += message[i:end+3]
|
|
435
|
+
i = end + 3
|
|
436
|
+
continue
|
|
437
|
+
else:
|
|
438
|
+
# Inline code - find closing `
|
|
439
|
+
end = message.find('`', i + 1)
|
|
440
|
+
if end != -1:
|
|
441
|
+
# Include the entire inline code without escaping
|
|
442
|
+
result += message[i:end+1]
|
|
443
|
+
i = end + 1
|
|
444
|
+
continue
|
|
445
|
+
|
|
446
|
+
# Handle other markdown formatting characters
|
|
447
|
+
if char in ['*', '_', '~'] and i + 1 < len(message):
|
|
448
|
+
# Check for double characters (**, __, etc.)
|
|
394
449
|
if message[i:i+2] in ['**', '__']:
|
|
395
|
-
|
|
396
|
-
|
|
450
|
+
# Find matching closing tag
|
|
451
|
+
tag = message[i:i+2]
|
|
452
|
+
end = message.find(tag, i + 2)
|
|
453
|
+
if end != -1:
|
|
454
|
+
# Include the formatted text, escaping content inside
|
|
455
|
+
content = message[i+2:end]
|
|
456
|
+
escaped_content = ''.join('\\' + c if c in special_chars and c not in ['*', '_'] else c for c in content)
|
|
457
|
+
result += tag + escaped_content + tag
|
|
458
|
+
i = end + 2
|
|
459
|
+
continue
|
|
397
460
|
else:
|
|
398
|
-
|
|
461
|
+
# Single character formatting
|
|
462
|
+
end = message.find(char, i + 1)
|
|
463
|
+
if end != -1:
|
|
464
|
+
# Include the formatted text, escaping content inside
|
|
465
|
+
content = message[i+1:end]
|
|
466
|
+
escaped_content = ''.join('\\' + c if c in special_chars and c != char else c for c in content)
|
|
467
|
+
result += char + escaped_content + char
|
|
468
|
+
i = end + 1
|
|
469
|
+
continue
|
|
470
|
+
|
|
471
|
+
# Regular character - escape if it's a special character
|
|
472
|
+
if char in special_chars:
|
|
473
|
+
result += '\\' + char
|
|
399
474
|
else:
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
result += '\\' + message[i]
|
|
403
|
-
else:
|
|
404
|
-
result += message[i]
|
|
405
|
-
i += 1
|
|
475
|
+
result += char
|
|
476
|
+
i += 1
|
|
406
477
|
|
|
407
478
|
return result
|
|
408
479
|
|
|
@@ -486,6 +557,9 @@ class TelegramProvider:
|
|
|
486
557
|
elif has_markdown:
|
|
487
558
|
payload["parse_mode"] = "MarkdownV2"
|
|
488
559
|
payload["text"] = prepare_telegram_markdown(message)
|
|
560
|
+
else:
|
|
561
|
+
# Plain text - escape special characters to prevent API errors
|
|
562
|
+
payload["text"] = prepare_telegram_plain_text(message)
|
|
489
563
|
|
|
490
564
|
try:
|
|
491
565
|
response = requests.post(
|
|
@@ -10,7 +10,7 @@ from datetime import datetime
|
|
|
10
10
|
from typing import Any, Dict, List, Optional, Union, TypeVar, Generic
|
|
11
11
|
|
|
12
12
|
from telert.messaging import Provider, send_message
|
|
13
|
-
from telert.monitoring.
|
|
13
|
+
from telert.monitoring.activity_logs import MonitorLogger, LogLevel
|
|
14
14
|
|
|
15
15
|
# Type definitions
|
|
16
16
|
MonitorID = str
|