vitals-vps 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vitals_vps-0.2.0/LICENSE +21 -0
- vitals_vps-0.2.0/PKG-INFO +191 -0
- vitals_vps-0.2.0/README.md +153 -0
- vitals_vps-0.2.0/setup.cfg +4 -0
- vitals_vps-0.2.0/setup.py +45 -0
- vitals_vps-0.2.0/tests/test_analyzers.py +111 -0
- vitals_vps-0.2.0/tests/test_failures.py +210 -0
- vitals_vps-0.2.0/tests/test_root_cause.py +467 -0
- vitals_vps-0.2.0/vitals/__init__.py +94 -0
- vitals_vps-0.2.0/vitals/analyzers/__init__.py +15 -0
- vitals_vps-0.2.0/vitals/analyzers/cpu.py +112 -0
- vitals_vps-0.2.0/vitals/analyzers/disk.py +72 -0
- vitals_vps-0.2.0/vitals/analyzers/memory.py +131 -0
- vitals_vps-0.2.0/vitals/analyzers/network.py +89 -0
- vitals_vps-0.2.0/vitals/analyzers/root_cause.py +349 -0
- vitals_vps-0.2.0/vitals/analyzers/security.py +156 -0
- vitals_vps-0.2.0/vitals/cli.py +166 -0
- vitals_vps-0.2.0/vitals/collectors/__init__.py +19 -0
- vitals_vps-0.2.0/vitals/collectors/cpu.py +57 -0
- vitals_vps-0.2.0/vitals/collectors/disk.py +42 -0
- vitals_vps-0.2.0/vitals/collectors/logs.py +45 -0
- vitals_vps-0.2.0/vitals/collectors/memory.py +65 -0
- vitals_vps-0.2.0/vitals/collectors/network.py +47 -0
- vitals_vps-0.2.0/vitals/collectors/processes.py +48 -0
- vitals_vps-0.2.0/vitals/collectors/security.py +86 -0
- vitals_vps-0.2.0/vitals/collectors/system.py +33 -0
- vitals_vps-0.2.0/vitals/models.py +25 -0
- vitals_vps-0.2.0/vitals/reporters/__init__.py +19 -0
- vitals_vps-0.2.0/vitals/reporters/rich_reporter.py +286 -0
- vitals_vps-0.2.0/vitals/scanner.py +135 -0
- vitals_vps-0.2.0/vitals/ssh.py +120 -0
- vitals_vps-0.2.0/vitals_vps.egg-info/PKG-INFO +191 -0
- vitals_vps-0.2.0/vitals_vps.egg-info/SOURCES.txt +35 -0
- vitals_vps-0.2.0/vitals_vps.egg-info/dependency_links.txt +1 -0
- vitals_vps-0.2.0/vitals_vps.egg-info/entry_points.txt +2 -0
- vitals_vps-0.2.0/vitals_vps.egg-info/requires.txt +2 -0
- vitals_vps-0.2.0/vitals_vps.egg-info/top_level.txt +1 -0
vitals_vps-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Suriya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vitals-vps
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: 🩺 VPS Vital Signs Monitor — read-only SSH diagnostics with root-cause analysis
|
|
5
|
+
Author: Suriya
|
|
6
|
+
Author-email: suriyakumar.vijayanayagam@gmail.com
|
|
7
|
+
Keywords: vps,ssh,diagnostics,devops,server,monitoring,cli
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: System Administrators
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: System :: Systems Administration
|
|
21
|
+
Classifier: Topic :: System :: Monitoring
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: paramiko>=3.0.0
|
|
27
|
+
Requires-Dist: rich>=13.0.0
|
|
28
|
+
Dynamic: author
|
|
29
|
+
Dynamic: author-email
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: keywords
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: requires-dist
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
# vitals-vps
|
|
40
|
+
|
|
41
|
+
**Read-only SSH server diagnostics with plain-English guidance.**
|
|
42
|
+
|
|
43
|
+
Connect to any Linux VPS with your root credentials, get a full colourised report on what's wrong — CPU spikes, brute-force attacks, memory pressure, disk full, zombie processes — and exact commands to fix each issue.
|
|
44
|
+
|
|
45
|
+
> ✅ **100% read-only.** No files are created, modified, or deleted. No services are restarted. You can share root credentials safely knowing the tool cannot cause harm.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install vitals-vps
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
**Requirements:** Python 3.8+, `paramiko`, `rich`
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### CLI
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Prompt for password (recommended)
|
|
66
|
+
vitals 192.168.1.10 --ask-pass
|
|
67
|
+
|
|
68
|
+
# Use SSH key
|
|
69
|
+
vitals 192.168.1.10 --key ~/.ssh/id_rsa
|
|
70
|
+
|
|
71
|
+
# Non-standard port or user
|
|
72
|
+
vitals 192.168.1.10 --port 2222 --user ubuntu --ask-pass
|
|
73
|
+
|
|
74
|
+
# Also show raw process lists, log excerpts, port table
|
|
75
|
+
vitals 192.168.1.10 --ask-pass --verbose
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Python API (works in scripts, Jupyter, and Google Colab)
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import vitals
|
|
82
|
+
|
|
83
|
+
# Full styled report printed to screen
|
|
84
|
+
vitals.info("your.server.ip", password="mypass")
|
|
85
|
+
|
|
86
|
+
# Key-based auth
|
|
87
|
+
vitals.info("your.server.ip", user="ubuntu", key="~/.ssh/id_rsa")
|
|
88
|
+
|
|
89
|
+
# Silent — returns Finding objects for scripting
|
|
90
|
+
findings = vitals.scan("your.server.ip", password="mypass")
|
|
91
|
+
critical = [f for f in findings if f.severity.value == "critical"]
|
|
92
|
+
for f in critical:
|
|
93
|
+
print(f.title)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Google Colab
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
!pip install vitals-vps
|
|
100
|
+
|
|
101
|
+
import vitals
|
|
102
|
+
vitals.info("your.server.ip", password="mypass")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## What It Checks
|
|
108
|
+
|
|
109
|
+
| Category | What it looks for |
|
|
110
|
+
|-----------|-------------------|
|
|
111
|
+
| **CPU** | Load average vs core count, CPU %, I/O wait (iowait), runaway processes |
|
|
112
|
+
| **Memory**| RAM %, available memory, swap usage, OOM killer events |
|
|
113
|
+
| **Disk** | Partitions > 80% full, inode exhaustion, largest directories, I/O stats |
|
|
114
|
+
| **Network**| Connection floods, top remote IPs, TIME_WAIT buildup, open ports |
|
|
115
|
+
| **Security** | SSH brute-force attack count, top attacking IPs, fail2ban status, firewall presence, extra UID-0 accounts, active sessions |
|
|
116
|
+
| **Processes** | Zombie processes, D-state (I/O-blocked) processes, failed systemd services |
|
|
117
|
+
| **Logs** | dmesg kernel errors, systemd journal errors, web server errors, MySQL errors |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Sample Output
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
╭─────────────────────────────────────────────╮
|
|
125
|
+
│ System Identity │
|
|
126
|
+
│ Host my-server.example.com │
|
|
127
|
+
│ OS Ubuntu 22.04.3 LTS │
|
|
128
|
+
│ Kernel 5.15.0-89-generic │
|
|
129
|
+
│ Uptime up 12 days, 4 hours │
|
|
130
|
+
│ CPU Intel Xeon E5-2670 v2 │
|
|
131
|
+
│ Cores 4 │
|
|
132
|
+
╰─────────────────────────────────────────────╯
|
|
133
|
+
|
|
134
|
+
┌──────────────────────────────────────────────┐
|
|
135
|
+
│ Diagnostic Scorecard │
|
|
136
|
+
│ Category Status Findings │
|
|
137
|
+
│ CPU ● CRITICAL 1 issue(s) │
|
|
138
|
+
│ Memory ● CRITICAL 2 issue(s) │
|
|
139
|
+
│ Disk ✅ OK All clear │
|
|
140
|
+
│ Network ⚠ WARNING 1 issue(s) │
|
|
141
|
+
│ Security ● CRITICAL 2 issue(s) │
|
|
142
|
+
└──────────────────────────────────────────────┘
|
|
143
|
+
|
|
144
|
+
── CPU ──────────────────────────────────────────
|
|
145
|
+
🔴 Extreme load average: 8.4 on 4 core(s)
|
|
146
|
+
📋 1-min load=8.4, 5-min=6.2, 15-min=4.1. With 4 cores,
|
|
147
|
+
the system has ~2x more runnable work than it can handle.
|
|
148
|
+
💡 What to do: Identify the runaway process(es)…
|
|
149
|
+
📌 Commands:
|
|
150
|
+
ps aux --sort=-%cpu | head -15
|
|
151
|
+
top -b -n1 | head -20
|
|
152
|
+
|
|
153
|
+
── Security ─────────────────────────────────────
|
|
154
|
+
🔴 Active brute-force attack: 47,312 SSH login failures
|
|
155
|
+
📋 47,312 failed SSH login attempts found in auth log.
|
|
156
|
+
💡 What to do:
|
|
157
|
+
1. Install fail2ban immediately to auto-ban attackers.
|
|
158
|
+
2. Change SSH to a non-standard port (e.g. 2222).
|
|
159
|
+
3. Disable password login — use SSH keys only.
|
|
160
|
+
📌 Commands:
|
|
161
|
+
apt install fail2ban -y
|
|
162
|
+
systemctl enable --now fail2ban
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Safety Guarantees
|
|
170
|
+
|
|
171
|
+
- Every SSH command runs through a blocklist filter. If the command string contains anything resembling a write, delete, kill, or install operation, it raises a `ValueError` before sending it.
|
|
172
|
+
- The SSH client uses `AutoAddPolicy` for convenience but logs the host key. In a production hardened setup, you can supply `known_hosts`.
|
|
173
|
+
- No data is stored. The tool runs, prints, and exits.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Roadmap
|
|
180
|
+
|
|
181
|
+
- [ ] `--output json` flag for piping into alerting pipelines
|
|
182
|
+
- [ ] `--watch` mode: re-scan every N seconds
|
|
183
|
+
- [ ] HTML report export
|
|
184
|
+
- [ ] Docker container support (scan via `docker exec`)
|
|
185
|
+
- [ ] Comparison mode: scan baseline vs current and diff the findings
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# vitals-vps
|
|
2
|
+
|
|
3
|
+
**Read-only SSH server diagnostics with plain-English guidance.**
|
|
4
|
+
|
|
5
|
+
Connect to any Linux VPS with your root credentials, get a full colourised report on what's wrong — CPU spikes, brute-force attacks, memory pressure, disk full, zombie processes — and exact commands to fix each issue.
|
|
6
|
+
|
|
7
|
+
> ✅ **100% read-only.** No files are created, modified, or deleted. No services are restarted. You can share root credentials safely knowing the tool cannot cause harm.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install vitals-vps
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
**Requirements:** Python 3.8+, `paramiko`, `rich`
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### CLI
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Prompt for password (recommended)
|
|
28
|
+
vitals 192.168.1.10 --ask-pass
|
|
29
|
+
|
|
30
|
+
# Use SSH key
|
|
31
|
+
vitals 192.168.1.10 --key ~/.ssh/id_rsa
|
|
32
|
+
|
|
33
|
+
# Non-standard port or user
|
|
34
|
+
vitals 192.168.1.10 --port 2222 --user ubuntu --ask-pass
|
|
35
|
+
|
|
36
|
+
# Also show raw process lists, log excerpts, port table
|
|
37
|
+
vitals 192.168.1.10 --ask-pass --verbose
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Python API (works in scripts, Jupyter, and Google Colab)
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import vitals
|
|
44
|
+
|
|
45
|
+
# Full styled report printed to screen
|
|
46
|
+
vitals.info("your.server.ip", password="mypass")
|
|
47
|
+
|
|
48
|
+
# Key-based auth
|
|
49
|
+
vitals.info("your.server.ip", user="ubuntu", key="~/.ssh/id_rsa")
|
|
50
|
+
|
|
51
|
+
# Silent — returns Finding objects for scripting
|
|
52
|
+
findings = vitals.scan("your.server.ip", password="mypass")
|
|
53
|
+
critical = [f for f in findings if f.severity.value == "critical"]
|
|
54
|
+
for f in critical:
|
|
55
|
+
print(f.title)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Google Colab
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
!pip install vitals-vps
|
|
62
|
+
|
|
63
|
+
import vitals
|
|
64
|
+
vitals.info("your.server.ip", password="mypass")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## What It Checks
|
|
70
|
+
|
|
71
|
+
| Category | What it looks for |
|
|
72
|
+
|-----------|-------------------|
|
|
73
|
+
| **CPU** | Load average vs core count, CPU %, I/O wait (iowait), runaway processes |
|
|
74
|
+
| **Memory**| RAM %, available memory, swap usage, OOM killer events |
|
|
75
|
+
| **Disk** | Partitions > 80% full, inode exhaustion, largest directories, I/O stats |
|
|
76
|
+
| **Network**| Connection floods, top remote IPs, TIME_WAIT buildup, open ports |
|
|
77
|
+
| **Security** | SSH brute-force attack count, top attacking IPs, fail2ban status, firewall presence, extra UID-0 accounts, active sessions |
|
|
78
|
+
| **Processes** | Zombie processes, D-state (I/O-blocked) processes, failed systemd services |
|
|
79
|
+
| **Logs** | dmesg kernel errors, systemd journal errors, web server errors, MySQL errors |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Sample Output
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
╭─────────────────────────────────────────────╮
|
|
87
|
+
│ System Identity │
|
|
88
|
+
│ Host my-server.example.com │
|
|
89
|
+
│ OS Ubuntu 22.04.3 LTS │
|
|
90
|
+
│ Kernel 5.15.0-89-generic │
|
|
91
|
+
│ Uptime up 12 days, 4 hours │
|
|
92
|
+
│ CPU Intel Xeon E5-2670 v2 │
|
|
93
|
+
│ Cores 4 │
|
|
94
|
+
╰─────────────────────────────────────────────╯
|
|
95
|
+
|
|
96
|
+
┌──────────────────────────────────────────────┐
|
|
97
|
+
│ Diagnostic Scorecard │
|
|
98
|
+
│ Category Status Findings │
|
|
99
|
+
│ CPU ● CRITICAL 1 issue(s) │
|
|
100
|
+
│ Memory ● CRITICAL 2 issue(s) │
|
|
101
|
+
│ Disk ✅ OK All clear │
|
|
102
|
+
│ Network ⚠ WARNING 1 issue(s) │
|
|
103
|
+
│ Security ● CRITICAL 2 issue(s) │
|
|
104
|
+
└──────────────────────────────────────────────┘
|
|
105
|
+
|
|
106
|
+
── CPU ──────────────────────────────────────────
|
|
107
|
+
🔴 Extreme load average: 8.4 on 4 core(s)
|
|
108
|
+
📋 1-min load=8.4, 5-min=6.2, 15-min=4.1. With 4 cores,
|
|
109
|
+
the system has ~2x more runnable work than it can handle.
|
|
110
|
+
💡 What to do: Identify the runaway process(es)…
|
|
111
|
+
📌 Commands:
|
|
112
|
+
ps aux --sort=-%cpu | head -15
|
|
113
|
+
top -b -n1 | head -20
|
|
114
|
+
|
|
115
|
+
── Security ─────────────────────────────────────
|
|
116
|
+
🔴 Active brute-force attack: 47,312 SSH login failures
|
|
117
|
+
📋 47,312 failed SSH login attempts found in auth log.
|
|
118
|
+
💡 What to do:
|
|
119
|
+
1. Install fail2ban immediately to auto-ban attackers.
|
|
120
|
+
2. Change SSH to a non-standard port (e.g. 2222).
|
|
121
|
+
3. Disable password login — use SSH keys only.
|
|
122
|
+
📌 Commands:
|
|
123
|
+
apt install fail2ban -y
|
|
124
|
+
systemctl enable --now fail2ban
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Safety Guarantees
|
|
132
|
+
|
|
133
|
+
- Every SSH command runs through a blocklist filter. If the command string contains anything resembling a write, delete, kill, or install operation, it raises a `ValueError` before sending it.
|
|
134
|
+
- The SSH client uses `AutoAddPolicy` for convenience but logs the host key. In a production hardened setup, you can supply `known_hosts`.
|
|
135
|
+
- No data is stored. The tool runs, prints, and exits.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Roadmap
|
|
142
|
+
|
|
143
|
+
- [ ] `--output json` flag for piping into alerting pipelines
|
|
144
|
+
- [ ] `--watch` mode: re-scan every N seconds
|
|
145
|
+
- [ ] HTML report export
|
|
146
|
+
- [ ] Docker container support (scan via `docker exec`)
|
|
147
|
+
- [ ] Comparison mode: scan baseline vs current and diff the findings
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
long_description = (Path(__file__).parent / "README.md").read_text(encoding="utf-8")
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="vitals-vps", # <-- change if you prefer another name
|
|
8
|
+
version="0.2.0",
|
|
9
|
+
description="🩺 VPS Vital Signs Monitor — read-only SSH diagnostics with root-cause analysis",
|
|
10
|
+
long_description=long_description,
|
|
11
|
+
long_description_content_type="text/markdown",
|
|
12
|
+
|
|
13
|
+
author="Suriya",
|
|
14
|
+
author_email="suriyakumar.vijayanayagam@gmail.com",
|
|
15
|
+
python_requires=">=3.8",
|
|
16
|
+
packages=find_packages(exclude=["tests*"]),
|
|
17
|
+
install_requires=[
|
|
18
|
+
"paramiko>=3.0.0",
|
|
19
|
+
"rich>=13.0.0",
|
|
20
|
+
],
|
|
21
|
+
entry_points={
|
|
22
|
+
"console_scripts": [
|
|
23
|
+
"vitals=vitals.cli:main",
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
keywords=["vps", "ssh", "diagnostics", "devops", "server", "monitoring", "cli"],
|
|
28
|
+
classifiers=[
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Environment :: Console",
|
|
31
|
+
"Intended Audience :: Developers",
|
|
32
|
+
"Intended Audience :: System Administrators",
|
|
33
|
+
"License :: OSI Approved :: MIT License",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.8",
|
|
36
|
+
"Programming Language :: Python :: 3.9",
|
|
37
|
+
"Programming Language :: Python :: 3.10",
|
|
38
|
+
"Programming Language :: Python :: 3.11",
|
|
39
|
+
"Programming Language :: Python :: 3.12",
|
|
40
|
+
"Operating System :: OS Independent",
|
|
41
|
+
"Topic :: System :: Systems Administration",
|
|
42
|
+
"Topic :: System :: Monitoring",
|
|
43
|
+
"Topic :: Utilities",
|
|
44
|
+
],
|
|
45
|
+
)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Tests for analyzers using mock data — no real SSH connection needed."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from vitals.analyzers.cpu import analyze_cpu
|
|
5
|
+
from vitals.analyzers.memory import analyze_memory
|
|
6
|
+
from vitals.analyzers.disk import analyze_disk
|
|
7
|
+
from vitals.analyzers.security import analyze_security
|
|
8
|
+
from vitals.models import Severity
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# ── CPU ──────────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
def test_cpu_ok():
|
|
14
|
+
findings = analyze_cpu({"load_1": 0.5, "load_5": 0.4, "load_15": 0.3, "cores": 4}, {})
|
|
15
|
+
assert any(f.severity == Severity.OK for f in findings)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_cpu_critical_load():
|
|
19
|
+
findings = analyze_cpu({"load_1": 16.0, "load_5": 14.0, "load_15": 10.0, "cores": 4}, {})
|
|
20
|
+
assert any(f.severity == Severity.CRITICAL for f in findings)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_cpu_high_iowait():
|
|
24
|
+
findings = analyze_cpu({
|
|
25
|
+
"load_1": 1.0, "load_5": 1.0, "load_15": 1.0, "cores": 4,
|
|
26
|
+
"vmstat": "0 0 0 100000 1000 200000 0 0 0 0 100 200 5 2 57 36 0",
|
|
27
|
+
}, {})
|
|
28
|
+
assert any("I/O wait" in f.title for f in findings)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# ── Memory ───────────────────────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
def test_memory_ok():
|
|
34
|
+
findings = analyze_memory({
|
|
35
|
+
"ram_pct": 40, "ram_total_mb": 4096, "ram_avail_mb": 2400,
|
|
36
|
+
"swap_pct": 0, "swap_used_mb": 0, "swap_total_mb": 2048,
|
|
37
|
+
"oom_events": "",
|
|
38
|
+
})
|
|
39
|
+
assert any(f.severity == Severity.OK for f in findings)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_memory_critical():
|
|
43
|
+
findings = analyze_memory({
|
|
44
|
+
"ram_pct": 95, "ram_total_mb": 1024, "ram_avail_mb": 50,
|
|
45
|
+
"swap_pct": 90, "swap_used_mb": 1800, "swap_total_mb": 2048,
|
|
46
|
+
"oom_events": "oom-killer invoked",
|
|
47
|
+
})
|
|
48
|
+
severities = [f.severity for f in findings]
|
|
49
|
+
assert Severity.CRITICAL in severities
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_no_swap_warning():
|
|
53
|
+
findings = analyze_memory({
|
|
54
|
+
"ram_pct": 40, "ram_total_mb": 4096, "ram_avail_mb": 2400,
|
|
55
|
+
"swap_pct": 0, "swap_used_mb": 0, "swap_total_mb": 0,
|
|
56
|
+
"oom_events": "",
|
|
57
|
+
})
|
|
58
|
+
assert any("swap" in f.title.lower() or "swap" in f.recommendation.lower() for f in findings)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ── Disk ─────────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
def test_disk_ok():
|
|
64
|
+
findings = analyze_disk({"critical_mounts": [], "df_inodes": ""})
|
|
65
|
+
assert any(f.severity == Severity.OK for f in findings)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_disk_critical():
|
|
69
|
+
findings = analyze_disk({
|
|
70
|
+
"critical_mounts": [{"mount": "/", "pct": 97, "avail": "500M"}],
|
|
71
|
+
"df_inodes": "",
|
|
72
|
+
})
|
|
73
|
+
assert any(f.severity == Severity.CRITICAL for f in findings)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# ── Security ─────────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
def test_security_brute_force():
|
|
79
|
+
findings = analyze_security({
|
|
80
|
+
"total_auth_failures": 50000,
|
|
81
|
+
"top_attacking_ips": " 500 1.2.3.4\n 300 5.6.7.8",
|
|
82
|
+
"uid0_users": "root",
|
|
83
|
+
"fail2ban_status": "active",
|
|
84
|
+
"firewall_rules": "Chain INPUT (policy DROP)",
|
|
85
|
+
"logged_in_users": "root pts/0",
|
|
86
|
+
})
|
|
87
|
+
assert any(f.severity == Severity.CRITICAL and "brute" in f.title.lower() for f in findings)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_security_extra_uid0():
|
|
91
|
+
findings = analyze_security({
|
|
92
|
+
"total_auth_failures": 0,
|
|
93
|
+
"top_attacking_ips": "",
|
|
94
|
+
"uid0_users": "root\nhacker",
|
|
95
|
+
"fail2ban_status": "active",
|
|
96
|
+
"firewall_rules": "iptables rules here",
|
|
97
|
+
"logged_in_users": "",
|
|
98
|
+
})
|
|
99
|
+
assert any("UID 0" in f.title for f in findings)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_no_fail2ban():
|
|
103
|
+
findings = analyze_security({
|
|
104
|
+
"total_auth_failures": 0,
|
|
105
|
+
"top_attacking_ips": "",
|
|
106
|
+
"uid0_users": "root",
|
|
107
|
+
"fail2ban_status": "not found",
|
|
108
|
+
"firewall_rules": "iptables rules here",
|
|
109
|
+
"logged_in_users": "",
|
|
110
|
+
})
|
|
111
|
+
assert any("fail2ban" in f.title.lower() for f in findings)
|