LinuxMonitor 1.5.5__tar.gz → 1.5.6__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.
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6/LinuxMonitor.egg-info}/PKG-INFO +1 -1
- {linuxmonitor-1.5.5/LinuxMonitor.egg-info → linuxmonitor-1.5.6}/PKG-INFO +1 -1
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/linuxmonitor/__main__.py +4 -4
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/linuxmonitor/linuxmonitor.py +23 -19
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/setup.py +1 -1
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/LICENSE.md +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/LinuxMonitor.egg-info/SOURCES.txt +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/LinuxMonitor.egg-info/dependency_links.txt +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/LinuxMonitor.egg-info/requires.txt +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/LinuxMonitor.egg-info/top_level.txt +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/README.md +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/linuxmonitor/__init__.py +0 -0
- {linuxmonitor-1.5.5 → linuxmonitor-1.5.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: LinuxMonitor
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.6
|
|
4
4
|
Summary: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)
|
|
5
5
|
Home-page: https://github.com/QuentinCG/Linux-Monitor-Python-Library
|
|
6
6
|
Author: Quentin Comte-Gaz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: LinuxMonitor
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.6
|
|
4
4
|
Summary: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)
|
|
5
5
|
Home-page: https://github.com/QuentinCG/Linux-Monitor-Python-Library
|
|
6
6
|
Author: Quentin Comte-Gaz
|
|
@@ -71,10 +71,10 @@ def main() -> None:
|
|
|
71
71
|
out_msg += msg
|
|
72
72
|
|
|
73
73
|
out_msg += "\n"
|
|
74
|
-
out_msg += monitoring.check_load_average(display_only_if_critical=False) + "\n"
|
|
75
|
-
out_msg += monitoring.check_cpu_usage(display_only_if_critical=False) + "\n"
|
|
76
|
-
out_msg += monitoring.check_ram_usage(display_only_if_critical=False) + "\n"
|
|
77
|
-
out_msg += monitoring.check_swap_usage(display_only_if_critical=False) + "\n"
|
|
74
|
+
out_msg += asyncio.run(monitoring.check_load_average(display_only_if_critical=False)) + "\n"
|
|
75
|
+
out_msg += asyncio.run(monitoring.check_cpu_usage(display_only_if_critical=False)) + "\n"
|
|
76
|
+
out_msg += asyncio.run(monitoring.check_ram_usage(display_only_if_critical=False)) + "\n"
|
|
77
|
+
out_msg += asyncio.run(monitoring.check_swap_usage(display_only_if_critical=False)) + "\n"
|
|
78
78
|
out_msg += monitoring.check_cpu_temperature(display_only_if_critical=False) + "\n"
|
|
79
79
|
out_msg += monitoring.get_network_info()
|
|
80
80
|
print(out_msg)
|
|
@@ -33,7 +33,7 @@ __email__ = "quentin@comte-gaz.com"
|
|
|
33
33
|
__license__ = "MIT License"
|
|
34
34
|
__copyright__ = "Copyright Quentin Comte-Gaz (2024)"
|
|
35
35
|
__python_version__ = "3.+"
|
|
36
|
-
__version__ = "1.5.
|
|
36
|
+
__version__ = "1.5.6 (2024/11/03)"
|
|
37
37
|
__status__ = "Usable for any Linux project"
|
|
38
38
|
|
|
39
39
|
import json
|
|
@@ -587,7 +587,7 @@ class LinuxMonitor:
|
|
|
587
587
|
logging.exception(msg=f"Error getting CPU name:\n{e}")
|
|
588
588
|
return ""
|
|
589
589
|
|
|
590
|
-
def check_cpu_usage(self, display_only_if_critical: bool=False) -> str:
|
|
590
|
+
async def check_cpu_usage(self, display_only_if_critical: bool=False) -> str:
|
|
591
591
|
"""
|
|
592
592
|
Check the CPU usage.
|
|
593
593
|
|
|
@@ -613,9 +613,9 @@ class LinuxMonitor:
|
|
|
613
613
|
out_msg = f"- 🚨 **Critical CPU usage**:\n- **{cpu_percent:.2f}%** used on {cpu_cores} core of {cpu_info:.2f}GHz ({cpu_name})\n⚠️ **Check what is using so much CPU power** ⚠️"
|
|
614
614
|
|
|
615
615
|
# If there is a critical CPU usage, we also display the top 10 processes consuming the most CPU
|
|
616
|
-
out_msg += "\n" +
|
|
616
|
+
out_msg += "\n" + await self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False, max_processes=10)
|
|
617
617
|
|
|
618
|
-
logging.warning(msg=out_msg)
|
|
618
|
+
logging.warning(msg=out_msg)
|
|
619
619
|
elif not display_only_if_critical:
|
|
620
620
|
if cpu_percent >= self.warning_cpu_percent:
|
|
621
621
|
icon = "⚠️"
|
|
@@ -632,7 +632,7 @@ class LinuxMonitor:
|
|
|
632
632
|
|
|
633
633
|
return out_msg
|
|
634
634
|
|
|
635
|
-
def check_ram_usage(self, display_only_if_critical: bool=False) -> str:
|
|
635
|
+
async def check_ram_usage(self, display_only_if_critical: bool=False) -> str:
|
|
636
636
|
"""
|
|
637
637
|
Check the RAM usage.
|
|
638
638
|
|
|
@@ -656,9 +656,9 @@ class LinuxMonitor:
|
|
|
656
656
|
out_msg = f"- 🚨 **Critical RAM usage**:\n- Total: {total_ram:.2f}GB\n- Used: {used_ram:.2f}GB ({percent_ram:.2f}%)\n- Free: {free_ram:.2f}GB\n⚠️ **Check what is using so much RAM** ⚠️"
|
|
657
657
|
|
|
658
658
|
# If there is a critical RAM usage, we also display the top 10 processes consuming the most RAM
|
|
659
|
-
out_msg += "\n" +
|
|
659
|
+
out_msg += "\n" + await self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=True, max_processes=10)
|
|
660
660
|
|
|
661
|
-
logging.warning(msg=out_msg)
|
|
661
|
+
logging.warning(msg=out_msg)
|
|
662
662
|
elif not display_only_if_critical:
|
|
663
663
|
if percent_ram >= self.warning_ram_percent:
|
|
664
664
|
icon = "⚠️"
|
|
@@ -675,7 +675,7 @@ class LinuxMonitor:
|
|
|
675
675
|
|
|
676
676
|
return out_msg
|
|
677
677
|
|
|
678
|
-
def check_load_average(self, display_only_if_critical: bool=False) -> str:
|
|
678
|
+
async def check_load_average(self, display_only_if_critical: bool=False) -> str:
|
|
679
679
|
"""
|
|
680
680
|
Check the load average.
|
|
681
681
|
|
|
@@ -702,9 +702,9 @@ class LinuxMonitor:
|
|
|
702
702
|
out_msg = f"- 🚨 **High load average**: **{avg_load_avg:.2f}%**\n⚠️ **Check what is causing the high load average** ⚠️"
|
|
703
703
|
|
|
704
704
|
# If there is a critical load average, we also display the top 10 processes consuming the most CPU
|
|
705
|
-
out_msg += "\n" +
|
|
705
|
+
out_msg += "\n" + await self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False, max_processes=10)
|
|
706
706
|
|
|
707
|
-
logging.warning(msg=out_msg)
|
|
707
|
+
logging.warning(msg=out_msg)
|
|
708
708
|
elif not display_only_if_critical:
|
|
709
709
|
if avg_load_avg >= self.warning_load_average_percent:
|
|
710
710
|
icon = "⚠️"
|
|
@@ -721,7 +721,7 @@ class LinuxMonitor:
|
|
|
721
721
|
|
|
722
722
|
return out_msg
|
|
723
723
|
|
|
724
|
-
def check_swap_usage(self, display_only_if_critical: bool=False) -> str:
|
|
724
|
+
async def check_swap_usage(self, display_only_if_critical: bool=False) -> str:
|
|
725
725
|
"""
|
|
726
726
|
Check the SWAP usage.
|
|
727
727
|
|
|
@@ -743,6 +743,10 @@ class LinuxMonitor:
|
|
|
743
743
|
percent_swap: float = swap.percent
|
|
744
744
|
if percent_swap >= self.critical_swap_percent:
|
|
745
745
|
out_msg = f"- 🚨 **Critical SWAP usage**\n- Total: {total_swap:.2f}GB\n- Used: {used_swap:.2f}GB ({percent_swap:.2f}%)\n- Free: {free_swap:.2f}GB\n⚠️ **Check what is using so much SWAP** ⚠️"
|
|
746
|
+
|
|
747
|
+
# If there is a critical SWAP/RAM usage, we also display the top 10 processes consuming the most RAM
|
|
748
|
+
out_msg += "\n" + await self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=True, max_processes=10)
|
|
749
|
+
|
|
746
750
|
logging.warning(msg=out_msg)
|
|
747
751
|
elif not display_only_if_critical:
|
|
748
752
|
if percent_swap >= self.warning_swap_percent:
|
|
@@ -2150,7 +2154,7 @@ class LinuxMonitor:
|
|
|
2150
2154
|
try:
|
|
2151
2155
|
# Load average
|
|
2152
2156
|
if is_private:
|
|
2153
|
-
msg = self.check_load_average(display_only_if_critical=True)
|
|
2157
|
+
msg = await self.check_load_average(display_only_if_critical=True)
|
|
2154
2158
|
if msg != "":
|
|
2155
2159
|
logging.warning(msg=msg)
|
|
2156
2160
|
if datetime_last_load_average_error_displayed is None or ((datetime.now() - datetime_last_load_average_error_displayed).total_seconds() > self.max_duration_seconds_showing_same_error_again_in_scheduled_tasks):
|
|
@@ -2172,7 +2176,7 @@ class LinuxMonitor:
|
|
|
2172
2176
|
|
|
2173
2177
|
# CPU
|
|
2174
2178
|
if is_private:
|
|
2175
|
-
msg = self.check_cpu_usage(display_only_if_critical=True)
|
|
2179
|
+
msg = await self.check_cpu_usage(display_only_if_critical=True)
|
|
2176
2180
|
if msg != "":
|
|
2177
2181
|
logging.warning(msg=msg)
|
|
2178
2182
|
if datetime_last_cpu_usage_error_displayed is None or ((datetime.now() - datetime_last_cpu_usage_error_displayed).total_seconds() > self.max_duration_seconds_showing_same_error_again_in_scheduled_tasks):
|
|
@@ -2194,7 +2198,7 @@ class LinuxMonitor:
|
|
|
2194
2198
|
|
|
2195
2199
|
# RAM
|
|
2196
2200
|
if is_private:
|
|
2197
|
-
msg = self.check_ram_usage(display_only_if_critical=True)
|
|
2201
|
+
msg = await self.check_ram_usage(display_only_if_critical=True)
|
|
2198
2202
|
if msg != "":
|
|
2199
2203
|
logging.warning(msg=msg)
|
|
2200
2204
|
if datetime_last_ram_usage_error_displayed is None or ((datetime.now() - datetime_last_ram_usage_error_displayed).total_seconds() > self.max_duration_seconds_showing_same_error_again_in_scheduled_tasks):
|
|
@@ -2216,7 +2220,7 @@ class LinuxMonitor:
|
|
|
2216
2220
|
|
|
2217
2221
|
# Swap
|
|
2218
2222
|
if is_private:
|
|
2219
|
-
msg = self.check_swap_usage(display_only_if_critical=True)
|
|
2223
|
+
msg = await self.check_swap_usage(display_only_if_critical=True)
|
|
2220
2224
|
if msg != "":
|
|
2221
2225
|
logging.warning(msg=msg)
|
|
2222
2226
|
if datetime_last_swap_usage_error_displayed is None or ((datetime.now() - datetime_last_swap_usage_error_displayed).total_seconds() > self.max_duration_seconds_showing_same_error_again_in_scheduled_tasks):
|
|
@@ -2565,7 +2569,7 @@ class LinuxMonitor:
|
|
|
2565
2569
|
|
|
2566
2570
|
# Load average
|
|
2567
2571
|
if is_private:
|
|
2568
|
-
msg = self.check_load_average(display_only_if_critical=False)
|
|
2572
|
+
msg = await self.check_load_average(display_only_if_critical=False)
|
|
2569
2573
|
if msg != "":
|
|
2570
2574
|
if out_msg != "":
|
|
2571
2575
|
out_msg += "\n"
|
|
@@ -2573,7 +2577,7 @@ class LinuxMonitor:
|
|
|
2573
2577
|
|
|
2574
2578
|
# CPU
|
|
2575
2579
|
if is_private:
|
|
2576
|
-
msg = self.check_cpu_usage(display_only_if_critical=False)
|
|
2580
|
+
msg = await self.check_cpu_usage(display_only_if_critical=False)
|
|
2577
2581
|
if msg != "":
|
|
2578
2582
|
if out_msg != "":
|
|
2579
2583
|
out_msg += "\n"
|
|
@@ -2581,7 +2585,7 @@ class LinuxMonitor:
|
|
|
2581
2585
|
|
|
2582
2586
|
# RAM
|
|
2583
2587
|
if is_private:
|
|
2584
|
-
msg = self.check_ram_usage(display_only_if_critical=False)
|
|
2588
|
+
msg = await self.check_ram_usage(display_only_if_critical=False)
|
|
2585
2589
|
if msg != "":
|
|
2586
2590
|
if out_msg != "":
|
|
2587
2591
|
out_msg += "\n"
|
|
@@ -2589,7 +2593,7 @@ class LinuxMonitor:
|
|
|
2589
2593
|
|
|
2590
2594
|
# Swap
|
|
2591
2595
|
if is_private:
|
|
2592
|
-
msg = self.check_swap_usage(display_only_if_critical=False)
|
|
2596
|
+
msg = await self.check_swap_usage(display_only_if_critical=False)
|
|
2593
2597
|
if msg != "":
|
|
2594
2598
|
if out_msg != "":
|
|
2595
2599
|
out_msg += "\n"
|
|
@@ -6,7 +6,7 @@ with io.open(file='README.md', mode='r', encoding='utf-8') as readme_file:
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="LinuxMonitor",
|
|
9
|
-
version="1.5.
|
|
9
|
+
version="1.5.6",
|
|
10
10
|
description="Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)",
|
|
11
11
|
long_description=readme,
|
|
12
12
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|