tag:github.com,2008:https://github.com/ArtCC/linux-server-admin-bot/releases
Release notes from linux-server-admin-bot
2026-02-04T17:01:13Z
tag:github.com,2008:Repository/1132849812/0.0.7
2026-02-04T17:01:42Z
v0.0.7 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.7/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.7/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Root partition space usage</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ณ Docker Management</h3>
<ul>
<li>Paginated container list (10 per page)</li>
<li>Container detail view with CPU, memory, IP, ports</li>
<li><strong>Start, Stop, Restart</strong> containers directly from Telegram</li>
<li>Container status with health indicators</li>
<li>Graceful detection when Docker is not available</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
<li>Host PID namespace with restricted capabilities (read-only process access)</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
<li><code>/temp</code> - System temperature sensors</li>
<li><code>/uptime</code> - System uptime and logged users</li>
<li><code>/services</code> - Systemd services status</li>
</ul>
<h4>Docker</h4>
<ul>
<li><code>/docker</code> - Docker container management menu</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h4>Info</h4>
<ul>
<li><code>/author</code> - Bot author information</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ docker.py # Docker management commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โ โโโ docker_manager.py # Docker container management
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ docker.py # Docker management commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โ โโโ docker_manager.py # Docker container management
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information
- /var/run/docker.sock:/var/run/docker.sock:ro # Docker management (optional)"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span>
- <span class="pl-s">/var/run/docker.sock:/var/run/docker.sock:ro </span><span class="pl-c"><span class="pl-c">#</span> Docker management (optional)</span></pre></div>
<blockquote>
<p><strong>Note</strong>: The Docker socket mount is optional. If not mounted, the Docker menu will show that Docker is not available.</p>
</blockquote>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://github.com/docker/docker-py">docker-py</a> - Docker SDK for Python</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.7/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC
tag:github.com,2008:Repository/1132849812/0.0.6
2026-01-18T18:55:12Z
v0.0.6 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.6/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.6/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Root partition space usage</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ณ Docker Management</h3>
<ul>
<li>Paginated container list (10 per page)</li>
<li>Container detail view with CPU, memory, IP, ports</li>
<li><strong>Start, Stop, Restart</strong> containers directly from Telegram</li>
<li>Container status with health indicators</li>
<li>Graceful detection when Docker is not available</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
<li>Host PID namespace with restricted capabilities (read-only process access)</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
<li><code>/temp</code> - System temperature sensors</li>
<li><code>/uptime</code> - System uptime and logged users</li>
<li><code>/services</code> - Systemd services status</li>
</ul>
<h4>Docker</h4>
<ul>
<li><code>/docker</code> - Docker container management menu</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h4>Info</h4>
<ul>
<li><code>/author</code> - Bot author information</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ docker.py # Docker management commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โ โโโ docker_manager.py # Docker container management
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ docker.py # Docker management commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โ โโโ docker_manager.py # Docker container management
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information
- /var/run/docker.sock:/var/run/docker.sock:ro # Docker management (optional)"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span>
- <span class="pl-s">/var/run/docker.sock:/var/run/docker.sock:ro </span><span class="pl-c"><span class="pl-c">#</span> Docker management (optional)</span></pre></div>
<blockquote>
<p><strong>Note</strong>: The Docker socket mount is optional. If not mounted, the Docker menu will show that Docker is not available.</p>
</blockquote>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://github.com/docker/docker-py">docker-py</a> - Docker SDK for Python</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.6/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC
tag:github.com,2008:Repository/1132849812/0.0.5
2026-01-18T18:11:17Z
v0.0.5 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.5/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.5/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Space usage across mount points</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ณ Docker Management</h3>
<ul>
<li>Paginated container list (10 per page)</li>
<li>Container detail view with CPU, memory, IP, ports</li>
<li><strong>Start, Stop, Restart</strong> containers directly from Telegram</li>
<li>Container status with health indicators</li>
<li>Graceful detection when Docker is not available</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
<li>Host PID namespace with restricted capabilities (read-only process access)</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
<li><code>/temp</code> - System temperature sensors</li>
<li><code>/uptime</code> - System uptime and logged users</li>
<li><code>/services</code> - Systemd services status</li>
</ul>
<h4>Docker</h4>
<ul>
<li><code>/docker</code> - Docker container management menu</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h4>Info</h4>
<ul>
<li><code>/author</code> - Bot author information</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ docker.py # Docker management commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โ โโโ docker_manager.py # Docker container management
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ docker.py # Docker management commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โ โโโ docker_manager.py # Docker container management
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information
- /var/run/docker.sock:/var/run/docker.sock:ro # Docker management (optional)"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span>
- <span class="pl-s">/var/run/docker.sock:/var/run/docker.sock:ro </span><span class="pl-c"><span class="pl-c">#</span> Docker management (optional)</span></pre></div>
<blockquote>
<p><strong>Note</strong>: The Docker socket mount is optional. If not mounted, the Docker menu will show that Docker is not available.</p>
</blockquote>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://github.com/docker/docker-py">docker-py</a> - Docker SDK for Python</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.5/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC
tag:github.com,2008:Repository/1132849812/0.0.4
2026-01-18T07:28:16Z
v0.0.4 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.4/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.4/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Space usage across mount points</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
<li>Host PID namespace with restricted capabilities (read-only process access)</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
<li><code>/temp</code> - System temperature sensors</li>
<li><code>/uptime</code> - System uptime and logged users</li>
<li><code>/services</code> - Systemd services status</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h4>Info</h4>
<ul>
<li><code>/author</code> - Bot author information</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span></pre></div>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.4/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC
tag:github.com,2008:Repository/1132849812/0.0.3
2026-01-17T20:07:12Z
v0.0.3 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.3/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.3/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Space usage across mount points</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
<li>Host PID namespace with restricted capabilities (read-only process access)</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
<li><code>/temp</code> - System temperature sensors</li>
<li><code>/uptime</code> - System uptime and logged users</li>
<li><code>/services</code> - Systemd services status</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h4>Info</h4>
<ul>
<li><code>/author</code> - Bot author information</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span></pre></div>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.3/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC
tag:github.com,2008:Repository/1132849812/0.0.2
2026-01-17T19:09:15Z
v0.0.2 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.2/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.2/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Space usage across mount points</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
<li>Host PID namespace with restricted capabilities (read-only process access)</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
<li><code>/temp</code> - System temperature sensors</li>
<li><code>/uptime</code> - System uptime and logged users</li>
<li><code>/services</code> - Systemd services status</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h4>Info</h4>
<ul>
<li><code>/author</code> - Bot author information</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span></pre></div>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.2/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC
tag:github.com,2008:Repository/1132849812/0.0.1
2026-01-12T19:25:10Z
v0.0.1 Pre launch
<h1>๐ค Linux Server Admin Bot</h1>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Linux Server Admin Bot" width="175" style="max-width: 100%;"></a>
</p>
<p><a href="https://www.python.org/downloads/" rel="nofollow"><img src="https://camo.githubusercontent.com/36cf3d0f7992a33a063d3833577d62204f8934d82b69874c086390608db4947c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31312b2d626c75652e737667" alt="Python Version" data-canonical-src="https://img.shields.io/badge/python-3.11+-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.1/LICENSE"><img src="https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width: 100%;"></a><br>
<a href="/ArtCC/linux-server-admin-bot/blob/0.0.1/Dockerfile"><img src="https://camo.githubusercontent.com/9b20b6131e402a89533d97d464e35a6948e0b0ab798b91b1c31a119c6cfbc7e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f636b65722d72656164792d627269676874677265656e2e737667" alt="Docker" data-canonical-src="https://img.shields.io/badge/docker-ready-brightgreen.svg" style="max-width: 100%;"></a></p>
<p>Telegram bot for monitoring Ubuntu servers. Monitor system resources and receive automated alerts - all from Telegram.</p>
<h2>โจ Features</h2>
<h3>๐ System Monitoring</h3>
<ul>
<li><strong>CPU</strong>: Real-time usage, per-core breakdown, frequency, load average</li>
<li><strong>Memory</strong>: RAM and swap usage with detailed breakdown</li>
<li><strong>Disk</strong>: Space usage across mount points</li>
<li><strong>Network</strong>: Interface statistics, traffic monitoring</li>
<li><strong>Processes</strong>: Top CPU-consuming processes</li>
</ul>
<h3>๐ Visualizations</h3>
<ul>
<li>Beautiful matplotlib charts for all metrics</li>
<li>CPU usage per core</li>
<li>Memory distribution pie charts</li>
<li>Disk usage visualization</li>
<li>Process resource graphs</li>
</ul>
<h3>๐ Automated Alerts</h3>
<ul>
<li>Configurable thresholds for CPU, RAM, and disk</li>
<li>Automatic notifications when limits exceeded</li>
<li>Smart cooldown to prevent spam</li>
<li>Alert severity levels (info, warning, critical)</li>
</ul>
<h3>๐ Security</h3>
<ul>
<li>User whitelist authentication</li>
<li>Rate limiting per user</li>
<li>Comprehensive logging</li>
</ul>
<h2>๐ Quick Start</h2>
<h3>Prerequisites</h3>
<ul>
<li>Ubuntu server (18.04+)</li>
<li>Docker and Docker Compose</li>
<li>Telegram Bot Token (<a href="https://t.me/botfather" rel="nofollow">create one</a>)</li>
<li>Your Telegram User ID (<a href="https://t.me/userinfobot" rel="nofollow">get it</a>)</li>
</ul>
<h3>Installation</h3>
<ol>
<li><strong>Clone the repository</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/artcc/linux-server-admin-bot.git
cd linux-server-admin-bot"><pre>git clone https://github.com/artcc/linux-server-admin-bot.git
<span class="pl-c1">cd</span> linux-server-admin-bot</pre></div>
<ol start="2">
<li><strong>Configure environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cp .env.example .env
nano .env"><pre>cp .env.example .env
nano .env</pre></div>
<p>Edit <code>.env</code> with your values:</p>
<div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USER_IDS=123456789,987654321
CPU_ALERT_THRESHOLD=80
MEMORY_ALERT_THRESHOLD=80
DISK_ALERT_THRESHOLD=90"><pre><span class="pl-v">TELEGRAM_BOT_TOKEN</span><span class="pl-k">=</span><span class="pl-s">your_bot_token_here</span>
<span class="pl-v">TELEGRAM_ALLOWED_USER_IDS</span><span class="pl-k">=</span><span class="pl-s">123456789,987654321</span>
<span class="pl-v">CPU_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">MEMORY_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">80</span>
<span class="pl-v">DISK_ALERT_THRESHOLD</span><span class="pl-k">=</span><span class="pl-s">90</span></pre></div>
<ol start="3">
<li><strong>Create logs directory with correct permissions</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs"><pre>mkdir -p logs
sudo chown -R 1000:1000 logs
sudo chmod -R 775 logs</pre></div>
<ol start="4">
<li><strong>Build and run with Docker Compose</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose up -d"><pre>docker-compose up -d</pre></div>
<ol start="5">
<li><strong>Check logs</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker-compose logs -f"><pre>docker-compose logs -f</pre></div>
<ol start="6">
<li><strong>Start chatting with your bot on Telegram!</strong></li>
</ol>
<h2>๐ Usage</h2>
<h3>๐จ Interactive Menu</h3>
<p>The bot features a <strong>beautiful interactive menu</strong> with inline keyboard buttons for easy navigation:</p>
<ul>
<li><strong>Main Menu</strong>: Access all features with a single tap</li>
<li><strong>System Monitoring</strong>: CPU, Memory, Disk, Network, Processes</li>
<li><strong>Quick Navigation</strong>: Back buttons and menu shortcuts</li>
</ul>
<p>Just type <code>/start</code> to see the interactive menu!</p>
<h3>Available Commands</h3>
<h4>Basic</h4>
<ul>
<li><code>/start</code> - Welcome message with interactive menu</li>
<li><code>/help</code> - Show all available commands</li>
<li><code>/status</code> - Overall system status summary</li>
</ul>
<h4>System Monitoring</h4>
<ul>
<li><code>/cpu</code> - Detailed CPU information with chart</li>
<li><code>/memory</code> - Memory usage with visualization</li>
<li><code>/disk</code> - Disk space usage</li>
<li><code>/top</code> - Top processes by CPU usage</li>
<li><code>/network</code> - Network interface statistics</li>
</ul>
<h4>Alerts</h4>
<ul>
<li><code>/alerts</code> - View alert configuration and active alerts</li>
</ul>
<h2>๐๏ธ Architecture</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies"><pre class="notranslate"><code>linux-server-admin-bot/
โโโ bot/
โ โโโ handlers/ # Command handlers
โ โ โโโ basic.py # Start, help, alerts
โ โ โโโ system.py # System monitoring commands
โ โ โโโ callbacks.py # Inline keyboard callbacks
โ โโโ services/ # Business logic
โ โ โโโ system_monitor.py # psutil wrapper
โ โ โโโ alert_manager.py # Alert system
โ โโโ monitors/ # Background tasks
โ โ โโโ health_monitor.py # Periodic health checks
โ โโโ models/ # Data models
โ โ โโโ metrics.py # Dataclasses for metrics
โ โโโ utils/ # Utilities
โ โโโ decorators.py # Auth, rate limiting, logging
โ โโโ formatters.py # Message formatting
โ โโโ keyboards.py # Inline keyboard layouts
โ โโโ charts.py # Chart generation
โโโ config/ # Configuration
โ โโโ settings.py # Pydantic settings
โ โโโ constants.py # Constants and enums
โ โโโ logger.py # Logging setup
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ main.py # Application entry point
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
</code></pre></div>
<h3>Design Principles</h3>
<ul>
<li><strong>Separation of Concerns</strong>: Clear separation between handlers, services, and utilities</li>
<li><strong>Type Safety</strong>: Full type hints and Pydantic validation</li>
<li><strong>Testability</strong>: Dependency injection and comprehensive tests</li>
<li><strong>Security</strong>: Authorization, rate limiting, and audit logging</li>
<li><strong>Observability</strong>: Structured logging and error handling</li>
<li><strong>Scalability</strong>: Async/await patterns for concurrent operations</li>
</ul>
<h2>๐ง Configuration</h2>
<h3>Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TELEGRAM_BOT_TOKEN</code></td>
<td>Telegram Bot API token</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>TELEGRAM_ALLOWED_USER_IDS</code></td>
<td>Comma-separated user IDs</td>
<td>โ
Yes</td>
<td>-</td>
</tr>
<tr>
<td><code>CPU_ALERT_THRESHOLD</code></td>
<td>CPU usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>MEMORY_ALERT_THRESHOLD</code></td>
<td>Memory usage alert threshold (%)</td>
<td>โ No</td>
<td>80</td>
</tr>
<tr>
<td><code>DISK_ALERT_THRESHOLD</code></td>
<td>Disk usage alert threshold (%)</td>
<td>โ No</td>
<td>90</td>
</tr>
<tr>
<td><code>ALERT_CHECK_INTERVAL</code></td>
<td>Alert check interval (seconds)</td>
<td>โ No</td>
<td>300</td>
</tr>
<tr>
<td><code>ALERT_COOLDOWN</code></td>
<td>Alert cooldown period (seconds)</td>
<td>โ No</td>
<td>600</td>
</tr>
<tr>
<td><code>RATE_LIMIT_CALLS</code></td>
<td>Max calls per period</td>
<td>โ No</td>
<td>10</td>
</tr>
<tr>
<td><code>RATE_LIMIT_PERIOD</code></td>
<td>Rate limit period (seconds)</td>
<td>โ No</td>
<td>60</td>
</tr>
<tr>
<td><code>LOG_LEVEL</code></td>
<td>Logging level</td>
<td>โ No</td>
<td>INFO</td>
</tr>
</tbody>
</table>
<h3>Docker Volumes</h3>
<p>The bot requires access to host system resources:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="volumes:
- /proc:/host/proc:ro # System metrics
- /sys:/host/sys:ro # System information"><pre><span class="pl-ent">volumes</span>:
- <span class="pl-s">/proc:/host/proc:ro </span><span class="pl-c"><span class="pl-c">#</span> System metrics</span>
- <span class="pl-s">/sys:/host/sys:ro </span><span class="pl-c"><span class="pl-c">#</span> System information</span></pre></div>
<h2>๐จ Bot Avatar</h2>
<p>You can use the official bot avatar for your own instance:</p>
<p align="left">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png"><img src="https://github.com/ArtCC/linux-server-admin-bot/raw/main/assets/linux-server-admin-bot.png" alt="Bot Avatar" width="200" style="max-width: 100%;"></a>
</p>
<p><strong>Download</strong>: <a href="https://github.com/ArtCC/linux-server-admin-bot/blob/main/assets/linux-server-admin-bot.png">linux-server-admin-bot.png</a></p>
<p>To set this image as your bot's profile picture:</p>
<ol>
<li>Download the image from the link above</li>
<li>Open <a href="https://t.me/botfather" rel="nofollow">@BotFather</a> on Telegram</li>
<li>Send <code>/setuserpic</code></li>
<li>Select your bot</li>
<li>Upload the downloaded image</li>
</ol>
<h2>๐งช Development</h2>
<h3>Local Setup</h3>
<ol>
<li><strong>Create virtual environment</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows"><pre>python -m venv venv
<span class="pl-c1">source</span> venv/bin/activate <span class="pl-c"><span class="pl-c">#</span> Linux/Mac</span>
<span class="pl-c"><span class="pl-c">#</span> or</span>
venv<span class="pl-cce">\S</span>cripts<span class="pl-cce">\a</span>ctivate <span class="pl-c"><span class="pl-c">#</span> Windows</span></pre></div>
<ol start="2">
<li><strong>Install dependencies</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip install -r requirements.txt"><pre>pip install -r requirements.txt</pre></div>
<ol start="3">
<li><strong>Run locally</strong></li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python main.py"><pre>python main.py</pre></div>
<h3>Running Tests</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Run all tests
pytest
# Run with coverage
pytest --cov=bot --cov-report=html
# Run specific test file
pytest tests/test_system_monitor.py"><pre><span class="pl-c"><span class="pl-c">#</span> Run all tests</span>
pytest
<span class="pl-c"><span class="pl-c">#</span> Run with coverage</span>
pytest --cov=bot --cov-report=html
<span class="pl-c"><span class="pl-c">#</span> Run specific test file</span>
pytest tests/test_system_monitor.py</pre></div>
<h3>Code Quality</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Format code
black .
# Lint code
ruff check .
# Type checking
mypy bot/ config/"><pre><span class="pl-c"><span class="pl-c">#</span> Format code</span>
black <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Lint code</span>
ruff check <span class="pl-c1">.</span>
<span class="pl-c"><span class="pl-c">#</span> Type checking</span>
mypy bot/ config/</pre></div>
<h2>๐ Troubleshooting</h2>
<h3>Bot doesn't respond</h3>
<ul>
<li>Check logs: <code>docker-compose logs -f</code></li>
<li>Verify bot token is correct</li>
<li>Ensure your user ID is in <code>TELEGRAM_ALLOWED_USER_IDS</code></li>
</ul>
<h3>High memory usage</h3>
<ul>
<li>Adjust resource limits in <code>docker-compose.yml</code></li>
<li>Increase alert check interval</li>
<li>Reduce chart DPI in settings</li>
</ul>
<h3>Temperature sensors not working</h3>
<ul>
<li>Install <code>lm-sensors</code>: <code>sudo apt install lm-sensors</code></li>
<li>Run sensor detection: <code>sudo sensors-detect</code></li>
</ul>
<h2>๐ค Contributing</h2>
<p>Contributions are welcome! Please feel free to submit a Pull Request.</p>
<ol>
<li>Fork the repository</li>
<li>Create your feature branch (<code>git checkout -b feature/AmazingFeature</code>)</li>
<li>Commit your changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li>
<li>Push to the branch (<code>git push origin feature/AmazingFeature</code>)</li>
<li>Open a Pull Request</li>
</ol>
<h2>๐ Acknowledgments</h2>
<ul>
<li><a href="https://github.com/python-telegram-bot/python-telegram-bot">python-telegram-bot</a> - Telegram Bot framework</li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a> - System monitoring</li>
<li><a href="https://matplotlib.org/" rel="nofollow">matplotlib</a> - Visualization library</li>
</ul>
<h2>๐ง Support</h2>
<p>For support, open an issue on GitHub.</p>
<h2>๐ License</h2>
<p>This project is licensed under the Apache License 2.0 - see the <a href="/ArtCC/linux-server-admin-bot/blob/0.0.1/LICENSE">LICENSE</a> file for details.</p>
<hr>
<p>Made with โค๏ธ for system administrators</p>
<p align="left">
<sub>100% built with GitHub Copilot (Claude Opus 4.5)</sub><br>
<sub>Arturo Carretero Calvo โ 2026</sub>
</p>
ArtCC