LinuxMonitor 1.2.7__tar.gz → 1.2.8__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.2.7 → linuxmonitor-1.2.8/LinuxMonitor.egg-info}/PKG-INFO +2 -2
- {linuxmonitor-1.2.7/LinuxMonitor.egg-info → linuxmonitor-1.2.8}/PKG-INFO +2 -2
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/README.md +1 -1
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/linuxmonitor/__main__.py +1 -1
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/linuxmonitor/linuxmonitor.py +22 -11
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/setup.py +1 -1
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/LICENSE.md +0 -0
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/LinuxMonitor.egg-info/SOURCES.txt +0 -0
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/LinuxMonitor.egg-info/dependency_links.txt +0 -0
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/LinuxMonitor.egg-info/requires.txt +0 -0
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/LinuxMonitor.egg-info/top_level.txt +0 -0
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/linuxmonitor/__init__.py +0 -0
- {linuxmonitor-1.2.7 → linuxmonitor-1.2.8}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: LinuxMonitor
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.8
|
|
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
|
|
@@ -84,7 +84,7 @@ echo "USERNAME_HERE ALL=(ALL) NOPASSWD: /etc/init.d/mariadb" >> /etc/sudoers.d/U
|
|
|
84
84
|
|
|
85
85
|
## How to use in shell
|
|
86
86
|
|
|
87
|
-
```
|
|
87
|
+
```sh
|
|
88
88
|
# Get help
|
|
89
89
|
python3 -m linuxmonitor --help
|
|
90
90
|
# Use "--debug" to show more information during command
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: LinuxMonitor
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.8
|
|
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
|
|
@@ -84,7 +84,7 @@ echo "USERNAME_HERE ALL=(ALL) NOPASSWD: /etc/init.d/mariadb" >> /etc/sudoers.d/U
|
|
|
84
84
|
|
|
85
85
|
## How to use in shell
|
|
86
86
|
|
|
87
|
-
```
|
|
87
|
+
```sh
|
|
88
88
|
# Get help
|
|
89
89
|
python3 -m linuxmonitor --help
|
|
90
90
|
# Use "--debug" to show more information during command
|
|
@@ -105,7 +105,7 @@ def main() -> None:
|
|
|
105
105
|
if args.websites:
|
|
106
106
|
handled = True
|
|
107
107
|
print("Checking websites availability...")
|
|
108
|
-
out_msg: str = asyncio.run(monitoring.check_all_websites(is_private=True, display_only_if_critical=False))
|
|
108
|
+
out_msg: str = asyncio.run(monitoring.check_all_websites(is_private=True, display_only_if_critical=False, restart_if_down=False))
|
|
109
109
|
print(out_msg)
|
|
110
110
|
|
|
111
111
|
if args.certificates:
|
|
@@ -30,7 +30,7 @@ __email__ = "quentin@comte-gaz.com"
|
|
|
30
30
|
__license__ = "MIT License"
|
|
31
31
|
__copyright__ = "Copyright Quentin Comte-Gaz (2024)"
|
|
32
32
|
__python_version__ = "3.+"
|
|
33
|
-
__version__ = "1.2.
|
|
33
|
+
__version__ = "1.2.8 (2024/09/19)"
|
|
34
34
|
__status__ = "Usable for any Linux project"
|
|
35
35
|
|
|
36
36
|
import json
|
|
@@ -795,7 +795,10 @@ class LinuxMonitor:
|
|
|
795
795
|
|
|
796
796
|
#region Check website response
|
|
797
797
|
|
|
798
|
-
async def _check_website(self, url: str, display_name: str,
|
|
798
|
+
async def _check_website(self, url: str, display_name: str, show_content_if_issue: bool, service_name: str = "",
|
|
799
|
+
timeout_in_sec: int = 5, auth_type: Optional[str] = None, username: Optional[str] = None,
|
|
800
|
+
password: Optional[str] = None, token: Optional[str] = None, additional_allowed_statuses: List[int] = [],
|
|
801
|
+
display_only_if_critical: bool=False) -> Tuple[bool, str]:
|
|
799
802
|
try:
|
|
800
803
|
display_name = f"[{display_name}]({url})"
|
|
801
804
|
|
|
@@ -834,9 +837,11 @@ class LinuxMonitor:
|
|
|
834
837
|
# Get the reason phrase (e.g., "Unauthorized" for 401)
|
|
835
838
|
status_reason: str = responses.get(response.status, "Unknown status")
|
|
836
839
|
out_msg = f"❌ **{display_name} answered with invalid status code {response.status} - {status_reason}**."
|
|
840
|
+
if show_content_if_issue:
|
|
841
|
+
content: str = (await response.text()).replace('`', '"').strip()
|
|
842
|
+
out_msg += f"\n```sh\n{content}\n```"
|
|
837
843
|
logging.warning(msg=out_msg)
|
|
838
844
|
return False, out_msg
|
|
839
|
-
|
|
840
845
|
except asyncio.TimeoutError:
|
|
841
846
|
out_msg = f"⚠️ **Error checking {display_name}: Timeout**"
|
|
842
847
|
return False, out_msg
|
|
@@ -844,7 +849,7 @@ class LinuxMonitor:
|
|
|
844
849
|
out_msg = f"⚠️ **Error checking {display_name}**:\n```sh\n{e}\n```"
|
|
845
850
|
return False, out_msg
|
|
846
851
|
|
|
847
|
-
async def check_all_websites(self, is_private: bool, display_only_if_critical: bool=False) -> str:
|
|
852
|
+
async def check_all_websites(self, is_private: bool, display_only_if_critical: bool=False, restart_if_down: bool=False) -> str:
|
|
848
853
|
try:
|
|
849
854
|
out_msg: str = ""
|
|
850
855
|
for website_config in self.config['websites']:
|
|
@@ -852,22 +857,28 @@ class LinuxMonitor:
|
|
|
852
857
|
timeout_in_sec: int = website_config.get('timeout_in_sec', 5)
|
|
853
858
|
url: str = website_config['url']
|
|
854
859
|
display_name: str = website_config.get('display_name', url)
|
|
860
|
+
show_content_if_issue: bool = website_config.get('show_content_if_issue', False)
|
|
861
|
+
service_name_to_restart: str = website_config.get('service_name_to_restart', "")
|
|
855
862
|
auth_type: Optional[str] = website_config.get('auth_type', None)
|
|
856
863
|
username: Optional[str] = website_config.get('username', None)
|
|
857
864
|
password: Optional[str] = website_config.get('password', None)
|
|
858
865
|
token: Optional[str] = website_config.get('token', None)
|
|
859
866
|
additional_allowed_statuses: List[int] = website_config.get('additional_allowed_statuses', [])
|
|
860
867
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
868
|
+
res, msg = await self._check_website(url=url, display_name=display_name, timeout_in_sec=timeout_in_sec,
|
|
869
|
+
show_content_if_issue=show_content_if_issue,
|
|
870
|
+
auth_type=auth_type, username=username, password=password, token=token,
|
|
871
|
+
additional_allowed_statuses=additional_allowed_statuses,
|
|
872
|
+
display_only_if_critical=display_only_if_critical)
|
|
866
873
|
if msg != "":
|
|
867
874
|
if out_msg:
|
|
868
875
|
out_msg += "\n"
|
|
869
876
|
out_msg += f"- {msg}"
|
|
870
877
|
|
|
878
|
+
if not res and restart_if_down and service_name_to_restart != "":
|
|
879
|
+
restart_msg = await self.restart_service(is_private=is_private, service_name=service_name_to_restart)
|
|
880
|
+
out_msg += f"\n - {restart_msg}"
|
|
881
|
+
|
|
871
882
|
if out_msg != "":
|
|
872
883
|
out_msg = f"# 🌐 Website access state 🌐\n{out_msg}"
|
|
873
884
|
|
|
@@ -1898,7 +1909,7 @@ class LinuxMonitor:
|
|
|
1898
1909
|
logging.info(msg="- ✅ Ping of all websites are OK.")
|
|
1899
1910
|
|
|
1900
1911
|
# Websites availability (GET request)
|
|
1901
|
-
msg = await self.check_all_websites(is_private=is_private, display_only_if_critical=True)
|
|
1912
|
+
msg = await self.check_all_websites(is_private=is_private, display_only_if_critical=True, restart_if_down=True)
|
|
1902
1913
|
if msg != "":
|
|
1903
1914
|
logging.warning(msg=msg)
|
|
1904
1915
|
if datetime_last_websites_error_displayed is None or ((datetime.now() - datetime_last_websites_error_displayed).total_seconds() > self.max_duration_seconds_showing_same_error_again_in_scheduled_tasks):
|
|
@@ -2135,7 +2146,7 @@ class LinuxMonitor:
|
|
|
2135
2146
|
out_msg += msg
|
|
2136
2147
|
|
|
2137
2148
|
# Websites availability (GET request)
|
|
2138
|
-
msg = await self.check_all_websites(is_private=is_private, display_only_if_critical=False)
|
|
2149
|
+
msg = await self.check_all_websites(is_private=is_private, display_only_if_critical=False, restart_if_down=False)
|
|
2139
2150
|
if msg != "":
|
|
2140
2151
|
if out_msg != "":
|
|
2141
2152
|
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.2.
|
|
9
|
+
version="1.2.8",
|
|
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
|