LinuxMonitor 1.5.4__tar.gz → 1.5.5__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.4 → linuxmonitor-1.5.5/LinuxMonitor.egg-info}/PKG-INFO +1 -1
- {linuxmonitor-1.5.4/LinuxMonitor.egg-info → linuxmonitor-1.5.5}/PKG-INFO +1 -1
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/linuxmonitor/linuxmonitor.py +33 -9
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/setup.py +1 -1
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/LICENSE.md +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/LinuxMonitor.egg-info/SOURCES.txt +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/LinuxMonitor.egg-info/dependency_links.txt +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/LinuxMonitor.egg-info/requires.txt +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/LinuxMonitor.egg-info/top_level.txt +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/README.md +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/linuxmonitor/__init__.py +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/linuxmonitor/__main__.py +0 -0
- {linuxmonitor-1.5.4 → linuxmonitor-1.5.5}/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.5
|
|
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.5
|
|
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
|
|
@@ -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.5 (2024/10/27)"
|
|
37
37
|
__status__ = "Usable for any Linux project"
|
|
38
38
|
|
|
39
39
|
import json
|
|
@@ -597,6 +597,10 @@ class LinuxMonitor:
|
|
|
597
597
|
"""
|
|
598
598
|
out_msg: str = ""
|
|
599
599
|
try:
|
|
600
|
+
if display_only_if_critical and self.critical_cpu_percent > 100:
|
|
601
|
+
# There is no need to check for showing msg only if critical and the critical percentage is greater than the max possible
|
|
602
|
+
return out_msg
|
|
603
|
+
|
|
600
604
|
# Getting average CPU usage for the last second
|
|
601
605
|
cpu_percent: float = psutil.cpu_percent(percpu=False)
|
|
602
606
|
|
|
@@ -609,9 +613,9 @@ class LinuxMonitor:
|
|
|
609
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** ⚠️"
|
|
610
614
|
|
|
611
615
|
# If there is a critical CPU usage, we also display the top 10 processes consuming the most CPU
|
|
612
|
-
out_msg += "\n" + self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False, max_processes=10)
|
|
616
|
+
out_msg += "\n" + asyncio.run(self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False, max_processes=10)) # type: ignore
|
|
613
617
|
|
|
614
|
-
logging.warning(msg=out_msg)
|
|
618
|
+
logging.warning(msg=out_msg) # type: ignore
|
|
615
619
|
elif not display_only_if_critical:
|
|
616
620
|
if cpu_percent >= self.warning_cpu_percent:
|
|
617
621
|
icon = "⚠️"
|
|
@@ -638,6 +642,10 @@ class LinuxMonitor:
|
|
|
638
642
|
"""
|
|
639
643
|
out_msg: str = ""
|
|
640
644
|
try:
|
|
645
|
+
if display_only_if_critical and self.critical_ram_percent > 100:
|
|
646
|
+
# There is no need to check for showing msg only if critical and the critical percentage is greater than the max possible
|
|
647
|
+
return out_msg
|
|
648
|
+
|
|
641
649
|
# Getting RAM usage
|
|
642
650
|
ram = psutil.virtual_memory()
|
|
643
651
|
total_ram: float = ram.total / (2**30)
|
|
@@ -648,9 +656,9 @@ class LinuxMonitor:
|
|
|
648
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** ⚠️"
|
|
649
657
|
|
|
650
658
|
# If there is a critical RAM usage, we also display the top 10 processes consuming the most RAM
|
|
651
|
-
out_msg += "\n" + self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=True, max_processes=10)
|
|
659
|
+
out_msg += "\n" + asyncio.run(self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=True, max_processes=10)) # type: ignore
|
|
652
660
|
|
|
653
|
-
logging.warning(msg=out_msg)
|
|
661
|
+
logging.warning(msg=out_msg) # type: ignore
|
|
654
662
|
elif not display_only_if_critical:
|
|
655
663
|
if percent_ram >= self.warning_ram_percent:
|
|
656
664
|
icon = "⚠️"
|
|
@@ -677,11 +685,15 @@ class LinuxMonitor:
|
|
|
677
685
|
"""
|
|
678
686
|
out_msg: str = ""
|
|
679
687
|
try:
|
|
688
|
+
if display_only_if_critical and self.critical_load_average_percent > 100:
|
|
689
|
+
# There is no need to check for showing msg only if critical and the critical percentage is greater than the max possible
|
|
690
|
+
return out_msg
|
|
691
|
+
|
|
680
692
|
# Number of CPU cores
|
|
681
693
|
num_cores: int = psutil.cpu_count()
|
|
682
694
|
|
|
683
695
|
# Getting load average
|
|
684
|
-
load_avg: Tuple[float] = psutil.getloadavg()
|
|
696
|
+
load_avg: Tuple[float] = psutil.getloadavg() # type: ignore
|
|
685
697
|
|
|
686
698
|
# Getting an average of all 3 values
|
|
687
699
|
avg_load_avg: float = 100 * sum(min(value, num_cores) for value in load_avg) / (len(load_avg) * num_cores)
|
|
@@ -690,9 +702,9 @@ class LinuxMonitor:
|
|
|
690
702
|
out_msg = f"- 🚨 **High load average**: **{avg_load_avg:.2f}%**\n⚠️ **Check what is causing the high load average** ⚠️"
|
|
691
703
|
|
|
692
704
|
# If there is a critical load average, we also display the top 10 processes consuming the most CPU
|
|
693
|
-
out_msg += "\n" + self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False, max_processes=10)
|
|
705
|
+
out_msg += "\n" + asyncio.run(self.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False, max_processes=10)) # type: ignore
|
|
694
706
|
|
|
695
|
-
logging.warning(msg=out_msg)
|
|
707
|
+
logging.warning(msg=out_msg) # type: ignore
|
|
696
708
|
elif not display_only_if_critical:
|
|
697
709
|
if avg_load_avg >= self.warning_load_average_percent:
|
|
698
710
|
icon = "⚠️"
|
|
@@ -719,6 +731,10 @@ class LinuxMonitor:
|
|
|
719
731
|
"""
|
|
720
732
|
out_msg: str = ""
|
|
721
733
|
try:
|
|
734
|
+
if display_only_if_critical and self.critical_swap_percent > 100:
|
|
735
|
+
# There is no need to check for showing msg only if critical and the critical percentage is greater than the max possible
|
|
736
|
+
return out_msg
|
|
737
|
+
|
|
722
738
|
# Getting Swap usage
|
|
723
739
|
swap = psutil.swap_memory()
|
|
724
740
|
total_swap: float = swap.total / (2**30)
|
|
@@ -1558,7 +1574,7 @@ class LinuxMonitor:
|
|
|
1558
1574
|
|
|
1559
1575
|
try:
|
|
1560
1576
|
# Fetch the logs since the specified date
|
|
1561
|
-
command: str = f"sudo last --ip --hostlast --time-format iso --since '{past_date}' | grep 'pts/'"
|
|
1577
|
+
command: str = f"sudo last --ip --hostlast --time-format iso --since '{past_date}' | grep 'pts/' || true"
|
|
1562
1578
|
last_output: str = subprocess.check_output(
|
|
1563
1579
|
args=command,
|
|
1564
1580
|
shell=True,
|
|
@@ -2547,6 +2563,14 @@ class LinuxMonitor:
|
|
|
2547
2563
|
out_msg += "\n"
|
|
2548
2564
|
out_msg += msg
|
|
2549
2565
|
|
|
2566
|
+
# Load average
|
|
2567
|
+
if is_private:
|
|
2568
|
+
msg = self.check_load_average(display_only_if_critical=False)
|
|
2569
|
+
if msg != "":
|
|
2570
|
+
if out_msg != "":
|
|
2571
|
+
out_msg += "\n"
|
|
2572
|
+
out_msg += msg
|
|
2573
|
+
|
|
2550
2574
|
# CPU
|
|
2551
2575
|
if is_private:
|
|
2552
2576
|
msg = self.check_cpu_usage(display_only_if_critical=False)
|
|
@@ -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.5",
|
|
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
|
|
File without changes
|