DiscordBotLinuxMonitor 1.0.3__tar.gz → 1.2.1__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,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiscordBotLinuxMonitor
3
- Version: 1.0.3
3
+ Version: 1.2.1
4
4
  Summary: From discord channels: 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
- Home-page: https://github.com/QuentinCG/Linux-Monitor-Python-Library
5
+ Home-page: https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library
6
6
  Author: Quentin Comte-Gaz
7
7
  Author-email: quentin@comte-gaz.com
8
8
  License: MIT
@@ -22,7 +22,7 @@ Classifier: Environment :: Console
22
22
  Requires-Python: >=3.3
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE.md
25
- Requires-Dist: linuxmonitor
25
+ Requires-Dist: linuxmonitor~=1.2.0
26
26
  Requires-Dist: discord.py
27
27
  Requires-Dist: typing
28
28
  Requires-Dist: asyncio
@@ -60,6 +60,9 @@ Displayed infos are not the same if you do the command in private or public chan
60
60
  - `/ping`: 🌐 Ping websites 🌐
61
61
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
62
62
 
63
+ - `/websites`: 🌐 Check websites access (GET requests) 🌐
64
+ <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/websites.jpg" height="150">
65
+
63
66
  - `/certificates`: 🔒 Check SSL certificates 🔒
64
67
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
65
68
 
@@ -1,4 +1,4 @@
1
- linuxmonitor
1
+ linuxmonitor~=1.2.0
2
2
  discord.py
3
3
  typing
4
4
  asyncio
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiscordBotLinuxMonitor
3
- Version: 1.0.3
3
+ Version: 1.2.1
4
4
  Summary: From discord channels: 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
- Home-page: https://github.com/QuentinCG/Linux-Monitor-Python-Library
5
+ Home-page: https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library
6
6
  Author: Quentin Comte-Gaz
7
7
  Author-email: quentin@comte-gaz.com
8
8
  License: MIT
@@ -22,7 +22,7 @@ Classifier: Environment :: Console
22
22
  Requires-Python: >=3.3
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE.md
25
- Requires-Dist: linuxmonitor
25
+ Requires-Dist: linuxmonitor~=1.2.0
26
26
  Requires-Dist: discord.py
27
27
  Requires-Dist: typing
28
28
  Requires-Dist: asyncio
@@ -60,6 +60,9 @@ Displayed infos are not the same if you do the command in private or public chan
60
60
  - `/ping`: 🌐 Ping websites 🌐
61
61
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
62
62
 
63
+ - `/websites`: 🌐 Check websites access (GET requests) 🌐
64
+ <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/websites.jpg" height="150">
65
+
63
66
  - `/certificates`: 🔒 Check SSL certificates 🔒
64
67
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
65
68
 
@@ -31,6 +31,9 @@ Displayed infos are not the same if you do the command in private or public chan
31
31
  - `/ping`: 🌐 Ping websites 🌐
32
32
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
33
33
 
34
+ - `/websites`: 🌐 Check websites access (GET requests) 🌐
35
+ <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/websites.jpg" height="150">
36
+
34
37
  - `/certificates`: 🔒 Check SSL certificates 🔒
35
38
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
36
39
 
@@ -74,6 +74,10 @@ def main() -> None:
74
74
  async def ping(interaction: discord.Interaction) -> None: # type: ignore
75
75
  await discord_bot_linux_monitor.ping(interaction)
76
76
 
77
+ @discord_bot.tree.command(name="websites", description="🌐 Check websites access (GET requests) 🌐")
78
+ async def websites(interaction: discord.Interaction) -> None: # type: ignore
79
+ await discord_bot_linux_monitor.websites(interaction)
80
+
77
81
  @discord_bot.tree.command(name="certificates", description="🔒 Check SSL certificates 🔒")
78
82
  async def certificates(interaction: discord.Interaction) -> None: # type: ignore
79
83
  await discord_bot_linux_monitor.certificates(interaction)
@@ -11,6 +11,7 @@ Non exhaustive list of features (available by using it in shell or in python scr
11
11
  - Check disk usage
12
12
  - Check folder usage
13
13
  - Check websites basic availability (ping)
14
+ - Check websites access with optional authentication (GET request)
14
15
  - Check services status and restart them if needed
15
16
  - Check certificates expiration and validity
16
17
  - Check last user connections IPs
@@ -30,7 +31,7 @@ __email__ = "quentin@comte-gaz.com"
30
31
  __license__ = "MIT License"
31
32
  __copyright__ = "Copyright Quentin Comte-Gaz (2024)"
32
33
  __python_version__ = "3.+"
33
- __version__ = "1.0.3 (2024/09/14)"
34
+ __version__ = "1.2.1 (2024/09/16)"
34
35
  __status__ = "Usable for any Linux project"
35
36
 
36
37
  # pyright: reportMissingTypeStubs=false
@@ -537,7 +538,7 @@ class DiscordBotLinuxMonitor:
537
538
 
538
539
  try:
539
540
  is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
540
- out_msg: str = self.monitoring.ping_all_websites(is_private=is_private, display_only_if_critical=False)
541
+ out_msg: str = await self.monitoring.ping_all_websites(is_private=is_private, display_only_if_critical=False)
541
542
 
542
543
  # Respond to the user
543
544
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -546,6 +547,26 @@ class DiscordBotLinuxMonitor:
546
547
  logging.exception(msg=out_msg)
547
548
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
548
549
 
550
+ async def websites(self, interaction: discord.Interaction) -> None:
551
+ if not self._check_if_valid_guild(guild=interaction.guild):
552
+ return
553
+ if not (await self._is_bot_channel_interaction(interaction=interaction, send_message_if_not_bot=True)):
554
+ return
555
+
556
+ # Say to the user that the command is being processed
557
+ await interaction.response.defer()
558
+
559
+ try:
560
+ is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
561
+ out_msg: str = await self.monitoring.check_all_websites(is_private=is_private, display_only_if_critical=False)
562
+
563
+ # Respond to the user
564
+ await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
565
+ except Exception as e:
566
+ out_msg = f"**Internal error during websites access check **:\n```sh\n{e}\n```"
567
+ logging.exception(msg=out_msg)
568
+ await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
569
+
549
570
  async def certificates(self, interaction: discord.Interaction) -> None:
550
571
  if not self._check_if_valid_guild(guild=interaction.guild):
551
572
  return
@@ -579,7 +600,7 @@ class DiscordBotLinuxMonitor:
579
600
  await interaction.response.defer()
580
601
 
581
602
  try:
582
- out_msg: str = self.monitoring.reboot_server()
603
+ out_msg: str = await self.monitoring.reboot_server()
583
604
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
584
605
 
585
606
  except Exception as e:
@@ -598,7 +619,7 @@ class DiscordBotLinuxMonitor:
598
619
 
599
620
  try:
600
621
  is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
601
- out_msg: str = self.monitoring.check_all_services_status(is_private=is_private)
622
+ out_msg: str = await self.monitoring.check_all_services_status(is_private=is_private)
602
623
 
603
624
  # Respond to the user
604
625
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -619,7 +640,7 @@ class DiscordBotLinuxMonitor:
619
640
  try:
620
641
  # Restart all services and get the results
621
642
  is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
622
- out_msg: str = self.monitoring.restart_all_services(is_private=is_private)
643
+ out_msg: str = await self.monitoring.restart_all_services(is_private=is_private)
623
644
 
624
645
  # Respond to the user
625
646
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -640,7 +661,7 @@ class DiscordBotLinuxMonitor:
640
661
  try:
641
662
  # Redémarrer le service et récupérer le message de sortie
642
663
  is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
643
- out_msg: str = self.monitoring.restart_service(is_private=is_private, service_name=service_name)
664
+ out_msg: str = await self.monitoring.restart_service(is_private=is_private, service_name=service_name)
644
665
 
645
666
  # Répondre à l'utilisateur
646
667
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -683,7 +704,7 @@ class DiscordBotLinuxMonitor:
683
704
  try:
684
705
  # Récupérer le statut des ports
685
706
  is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
686
- out_msg: str = self.monitoring.check_all_ports(restart_if_down=True, is_private=is_private, display_only_if_critical=False)
707
+ out_msg: str = await self.monitoring.check_all_ports(restart_if_down=True, is_private=is_private, display_only_if_critical=False)
687
708
 
688
709
  # Répondre à l'utilisateur
689
710
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -729,7 +750,7 @@ class DiscordBotLinuxMonitor:
729
750
 
730
751
  try:
731
752
  # Arrêter le processus et récupérer le message de sortie
732
- out_msg: str = self.monitoring.kill_process(pid=pid)
753
+ out_msg: str = await self.monitoring.kill_process(pid=pid)
733
754
 
734
755
  # Répondre à l'utilisateur
735
756
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -6,11 +6,11 @@ with io.open(file='README.md', mode='r', encoding='utf-8') as readme_file:
6
6
 
7
7
  setup(
8
8
  name="DiscordBotLinuxMonitor",
9
- version="1.0.3",
9
+ version="1.2.1",
10
10
  description="From discord channels: 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",
13
- url='https://github.com/QuentinCG/Linux-Monitor-Python-Library',
13
+ url='https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library',
14
14
  packages=['discordbotlinuxmonitor'],
15
15
  author='Quentin Comte-Gaz',
16
16
  author_email='quentin@comte-gaz.com',
@@ -36,7 +36,7 @@ setup(
36
36
  keywords='discord bot warning info linux monitor monitoring server service port ping ssl certificate disk folder cpu ram swap usage ip connection',
37
37
  platforms='Linux',
38
38
  install_requires=[
39
- "linuxmonitor",
39
+ "linuxmonitor~=1.2.0", # follows the {MAJOR}.{MINOR}.x version range (because LinuxMonitor and DiscordBotLinuxMonitor are tightly coupled and should have same major and minor version)
40
40
  "discord.py",
41
41
  "typing",
42
42
  "asyncio",