LinuxMonitor 1.3.10__tar.gz → 1.4.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.
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0/LinuxMonitor.egg-info}/PKG-INFO +1 -1
- {linuxmonitor-1.3.10/LinuxMonitor.egg-info → linuxmonitor-1.4.0}/PKG-INFO +1 -1
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/linuxmonitor/__main__.py +1 -1
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/linuxmonitor/linuxmonitor.py +23 -9
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/setup.py +1 -1
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/LICENSE.md +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/LinuxMonitor.egg-info/SOURCES.txt +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/LinuxMonitor.egg-info/dependency_links.txt +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/LinuxMonitor.egg-info/requires.txt +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/LinuxMonitor.egg-info/top_level.txt +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/README.md +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/linuxmonitor/__init__.py +0 -0
- {linuxmonitor-1.3.10 → linuxmonitor-1.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: LinuxMonitor
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
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.
|
|
3
|
+
Version: 1.4.0
|
|
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
|
|
@@ -180,7 +180,7 @@ def main() -> None:
|
|
|
180
180
|
if args.list_processes:
|
|
181
181
|
handled = True
|
|
182
182
|
print("Listing active processes...")
|
|
183
|
-
out_msg: str = monitoring.get_ordered_processes(get_non_consuming_processes=False)
|
|
183
|
+
out_msg: str = asyncio.run(monitoring.get_ordered_processes(get_non_consuming_processes=False))
|
|
184
184
|
print(out_msg)
|
|
185
185
|
|
|
186
186
|
if args.kill_process is not None:
|
|
@@ -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.
|
|
36
|
+
__version__ = "1.4.0 (2024/10/07)"
|
|
37
37
|
__status__ = "Usable for any Linux project"
|
|
38
38
|
|
|
39
39
|
import json
|
|
@@ -146,6 +146,8 @@ class LinuxMonitor:
|
|
|
146
146
|
raise ValueError("The basic configuration must contain the 'warning_uptime_seconds' key")
|
|
147
147
|
self.warning_uptime_seconds: int = basic_config.get('warning_uptime_seconds') # type: ignore
|
|
148
148
|
|
|
149
|
+
self.excluded_interfaces: List[str] = basic_config.get('excluded_interfaces', []) # type: ignore
|
|
150
|
+
|
|
149
151
|
# Get the scheduled tasks for issues configuration
|
|
150
152
|
if self.allow_scheduled_tasks_check_for_issues:
|
|
151
153
|
schedule_check_for_issues_config: Dict[str, Any] = self.config.get('scheduled_tasks_check_for_issues', {}) # type: ignore
|
|
@@ -1670,7 +1672,7 @@ class LinuxMonitor:
|
|
|
1670
1672
|
|
|
1671
1673
|
#region Processes
|
|
1672
1674
|
|
|
1673
|
-
def get_ordered_processes(self, get_non_consuming_processes: bool = False) -> str:
|
|
1675
|
+
async def get_ordered_processes(self, get_non_consuming_processes: bool = False) -> str:
|
|
1674
1676
|
"""
|
|
1675
1677
|
Get the ordered list of processes by memory and CPU usage.
|
|
1676
1678
|
|
|
@@ -1679,7 +1681,18 @@ class LinuxMonitor:
|
|
|
1679
1681
|
:return: A string containing the result message.
|
|
1680
1682
|
"""
|
|
1681
1683
|
try:
|
|
1682
|
-
|
|
1684
|
+
processes = []
|
|
1685
|
+
|
|
1686
|
+
# To get meaningful results, we need to ask cpu percent and wait a bit to get valid cpu_percent values on second iteration
|
|
1687
|
+
for dummy_process in psutil.process_iter(['pid', 'name', 'username', 'cpu_percent', 'memory_info', 'create_time', 'cmdline']):
|
|
1688
|
+
try:
|
|
1689
|
+
# First call to cpu_percent to initialize it
|
|
1690
|
+
dummy_process.cpu_percent(interval=None)
|
|
1691
|
+
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
|
1692
|
+
continue
|
|
1693
|
+
await asyncio.sleep(delay=0.1)
|
|
1694
|
+
|
|
1695
|
+
# Then we can get the processes
|
|
1683
1696
|
for process in psutil.process_iter(['pid', 'name', 'username', 'cpu_percent', 'memory_info', 'create_time', 'cmdline']):
|
|
1684
1697
|
try:
|
|
1685
1698
|
create_time = datetime.fromtimestamp(process.info['create_time']).strftime("%Y-%m-%d %H:%M:%S")
|
|
@@ -1831,11 +1844,8 @@ class LinuxMonitor:
|
|
|
1831
1844
|
stats = psutil.net_if_stats()
|
|
1832
1845
|
network_usage: str = ""
|
|
1833
1846
|
|
|
1834
|
-
# List of interfaces to exclude (e.g., local interface)
|
|
1835
|
-
excluded_interfaces = {"lo"}
|
|
1836
|
-
|
|
1837
1847
|
for interface in interfaces:
|
|
1838
|
-
if interface in excluded_interfaces or interface not in stats:
|
|
1848
|
+
if interface in self.excluded_interfaces or interface not in stats:
|
|
1839
1849
|
continue
|
|
1840
1850
|
|
|
1841
1851
|
ip_addresses = []
|
|
@@ -1924,7 +1934,9 @@ class LinuxMonitor:
|
|
|
1924
1934
|
is_content_json: bool = self.config['commands'][command_config_key].get('is_content_json', False)
|
|
1925
1935
|
timeout_in_sec: int = self.config['commands'][command_config_key].get('timeout_in_sec', 10)
|
|
1926
1936
|
|
|
1927
|
-
res: str = await self._execute_command(command=command, display_name=display_name, show_content_if_success=show_content_if_success,
|
|
1937
|
+
res: str = await self._execute_command(command=command, display_name=display_name, show_content_if_success=show_content_if_success,
|
|
1938
|
+
show_content_if_issue=show_content_if_issue, is_content_json=is_content_json,
|
|
1939
|
+
timeout_in_sec=timeout_in_sec, display_only_if_critical=False)
|
|
1928
1940
|
if res != "":
|
|
1929
1941
|
if out_msg != "":
|
|
1930
1942
|
out_msg += "\n"
|
|
@@ -1962,7 +1974,9 @@ class LinuxMonitor:
|
|
|
1962
1974
|
if is_scheduled_tasks_for_infos and not self.config['commands'][command_config_key].get('execute_in_scheduled_tasks_for_infos', False):
|
|
1963
1975
|
continue
|
|
1964
1976
|
|
|
1965
|
-
res: str = await self._execute_command(command=command, display_name=display_name, show_content_if_success=show_content_if_success,
|
|
1977
|
+
res: str = await self._execute_command(command=command, display_name=display_name, show_content_if_success=show_content_if_success, # type: ignore
|
|
1978
|
+
show_content_if_issue=show_content_if_issue, is_content_json=is_content_json,
|
|
1979
|
+
timeout_in_sec=timeout_in_sec, display_only_if_critical=display_only_if_critical)
|
|
1966
1980
|
if res != "":
|
|
1967
1981
|
if out_msg != "":
|
|
1968
1982
|
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.
|
|
9
|
+
version="1.4.0",
|
|
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
|