LinuxMonitor 1.2.4__tar.gz → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LinuxMonitor
3
- Version: 1.2.4
3
+ Version: 1.2.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.2.4
3
+ Version: 1.2.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
@@ -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.3 (2024/09/16)"
33
+ __version__ = "1.2.6 (2024/09/16)"
34
34
  __status__ = "Usable for any Linux project"
35
35
 
36
36
  import json
@@ -232,13 +232,13 @@ class LinuxMonitor:
232
232
  # Command returned an error code
233
233
  if not show_only_std_and_exception:
234
234
  out_msg = f"❌ **Error {display_name}**\n"
235
- out_msg += f"- Error code: {returncode}"
235
+ out_msg += f" - Error code: `{returncode}`"
236
236
 
237
237
  if stderr_str != "":
238
- out_msg += f"\n- Error log:\n```sh\n{stderr_str}\n```"
238
+ out_msg += f"\n - Error log:\n```sh\n{stderr_str}\n```"
239
239
 
240
240
  if stdout_str != "":
241
- out_msg += f"\n- Info:\n```sh\n{stdout_str}\n```"
241
+ out_msg += f"\n - Info:\n```sh\n{stdout_str}\n```"
242
242
  elif res == None:
243
243
  # Command timed out
244
244
  if not show_only_std_and_exception:
@@ -944,13 +944,18 @@ class LinuxMonitor:
944
944
  logging.info(f"Trying to restart {display_name} (command: {service_call}) in less than {timeout_in_sec}sec...")
945
945
 
946
946
  start_time: float = time.time()
947
- res, out_msg = await self.execute_and_verify(command=service_call, display_name=f"restart {display_name}", show_only_std_and_exception=False, timeout_in_sec=timeout_in_sec, display_only_if_critical=False)
947
+ res, res_msg = await self.execute_and_verify(command=service_call, display_name=f"restart {display_name}", show_only_std_and_exception=True, timeout_in_sec=timeout_in_sec, display_only_if_critical=False)
948
948
  end_time: float = time.time()
949
949
 
950
950
  if res == True:
951
951
  readable_duration: str = "{:.2f}".format(end_time - start_time)
952
952
  out_msg = f"✅ **{display_name} restarted with success** in {readable_duration}sec."
953
953
  logging.info(msg=out_msg)
954
+ else:
955
+ out_msg = f"❌ **Error restarting service {display_name}**"
956
+ if res_msg and res_msg != "":
957
+ out_msg += f"\n{res_msg}"
958
+ logging.warning(msg=out_msg)
954
959
 
955
960
  return out_msg
956
961
  except Exception as e:
@@ -1071,10 +1076,11 @@ class LinuxMonitor:
1071
1076
  out_msg_full: str = ""
1072
1077
  try:
1073
1078
  for service_name in self.config["services"].keys():
1079
+ out_msg: str = ""
1074
1080
  if is_private or self.config["services"][service_name]['is_private'] == is_private:
1075
1081
  status, status_msg = await self._get_service_status(is_private=is_private, service_name=service_name)
1076
1082
  if status is False:
1077
- out_msg: str = f"❌ **{self.config['services'][service_name]['display_name']} inactive**. Restarting the service is necessary."
1083
+ out_msg = f"- ❌ **{self.config['services'][service_name]['display_name']} inactive**. Restarting the service is necessary."
1078
1084
  logging.warning(msg=out_msg)
1079
1085
  if status_msg != "":
1080
1086
  out_msg += f"\n{status_msg}"
@@ -1082,13 +1088,16 @@ class LinuxMonitor:
1082
1088
  out_msg_full += out_msg + "\n"
1083
1089
  out_msg_full += await self.restart_service(is_private=is_private, service_name=service_name) + "\n"
1084
1090
  elif status is None:
1085
- out_msg: str = f"⚠️ **Error checking status of {self.config['services'][service_name]['display_name']}** (not restarting it)."
1091
+ out_msg: str = f"- ⚠️ **Error checking status of {self.config['services'][service_name]['display_name']}** (not restarting it)."
1086
1092
  logging.error(msg=out_msg)
1087
1093
  out_msg_full += out_msg + "\n"
1088
1094
  except Exception as e:
1089
- out_msg_full = f"**Internal error during service status check.**:\n```sh\n{e}\n```"
1095
+ out_msg_full = f"- **Internal error during service status check.**:\n```sh\n{e}\n```"
1090
1096
  logging.exception(msg=out_msg_full)
1091
1097
 
1098
+ if out_msg_full != "":
1099
+ out_msg_full = f"# 📱 Services status 📱\n{out_msg_full}"
1100
+
1092
1101
  return out_msg_full
1093
1102
 
1094
1103
  #endregion
@@ -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.4",
9
+ version="1.2.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