DiscordBotLinuxMonitor 1.0.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.
- discordbotlinuxmonitor-1.0.1/DiscordBotLinuxMonitor.egg-info/PKG-INFO +200 -0
- discordbotlinuxmonitor-1.0.1/DiscordBotLinuxMonitor.egg-info/SOURCES.txt +12 -0
- discordbotlinuxmonitor-1.0.1/DiscordBotLinuxMonitor.egg-info/dependency_links.txt +1 -0
- discordbotlinuxmonitor-1.0.1/DiscordBotLinuxMonitor.egg-info/requires.txt +4 -0
- discordbotlinuxmonitor-1.0.1/DiscordBotLinuxMonitor.egg-info/top_level.txt +1 -0
- discordbotlinuxmonitor-1.0.1/LICENSE.md +21 -0
- discordbotlinuxmonitor-1.0.1/PKG-INFO +200 -0
- discordbotlinuxmonitor-1.0.1/README.md +171 -0
- discordbotlinuxmonitor-1.0.1/discordbotlinuxmonitor/__init__.py +1 -0
- discordbotlinuxmonitor-1.0.1/discordbotlinuxmonitor/__main__.py +125 -0
- discordbotlinuxmonitor-1.0.1/discordbotlinuxmonitor/discordbotlinuxmonitor.py +741 -0
- discordbotlinuxmonitor-1.0.1/setup.cfg +7 -0
- discordbotlinuxmonitor-1.0.1/setup.py +44 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: DiscordBotLinuxMonitor
|
|
3
|
+
Version: 1.0.1
|
|
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
|
|
6
|
+
Author: Quentin Comte-Gaz
|
|
7
|
+
Author-email: quentin@comte-gaz.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: discord bot warning info linux monitor monitoring server service port ping ssl certificate disk folder cpu ram swap usage ip connection
|
|
10
|
+
Platform: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: System Administrators
|
|
17
|
+
Classifier: Topic :: System :: Monitoring
|
|
18
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
19
|
+
Classifier: Topic :: System :: Systems Administration
|
|
20
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
21
|
+
Classifier: Environment :: Console
|
|
22
|
+
Requires-Python: >=3.3
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE.md
|
|
25
|
+
Requires-Dist: linuxmonitor
|
|
26
|
+
Requires-Dist: discord.py
|
|
27
|
+
Requires-Dist: typing
|
|
28
|
+
Requires-Dist: asyncio
|
|
29
|
+
|
|
30
|
+
# Discord Bot Linux Monitor (Python library)
|
|
31
|
+
[](https://pypi.org/project/DiscordBotLinuxMonitor/) [](https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/blob/master/LICENSE.md) [](https://paypal.me/QuentinCG) [](https://pepy.tech/project/DiscordBotLinuxMonitor) [](https://pepy.tech/project/DiscordBotLinuxMonitor)
|
|
32
|
+
|
|
33
|
+
## What is it
|
|
34
|
+
|
|
35
|
+
This python library is designed to be used as a Linux service to monitor the Linux server manually with discord commands and to send warning or information of the Linux server status to a discord channel periodically (if relevant).
|
|
36
|
+
|
|
37
|
+
It is possible to have separate 'private discord channel' and 'public discord channel' for:
|
|
38
|
+
- Sendind discord commands to the bot (visual example in next section)
|
|
39
|
+
- Getting periodic status of the Linux server (doing periodically some commands from next section)
|
|
40
|
+
- Getting warnings if there is an issue in the Linux server (periodic status check)
|
|
41
|
+
|
|
42
|
+
Example of warning:
|
|
43
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/warning_from_periodic_check.jpg" height="400">
|
|
44
|
+
|
|
45
|
+
It is compatible with python 3+ and usable only on Linux.
|
|
46
|
+
|
|
47
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/discord.png" width="300">
|
|
48
|
+
|
|
49
|
+
## List of Discord commands:
|
|
50
|
+
|
|
51
|
+
### Public and private discord channel commands
|
|
52
|
+
Displayed infos are not the same if you do the command in private or public channel (all info are displayed in private channel, some are hidden from public channels)
|
|
53
|
+
|
|
54
|
+
- `/usage`: 📊 View disk space, CPU, RAM, ... 📊
|
|
55
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/usage.jpg" height="400">
|
|
56
|
+
|
|
57
|
+
- `/os_infos`: 🖥 View basic system information 🖥
|
|
58
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/os_infos.jpg" height="300">
|
|
59
|
+
|
|
60
|
+
- `/ping`: 🌐 Ping websites 🌐
|
|
61
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
|
|
62
|
+
|
|
63
|
+
- `/certificates`: 🔒 Check SSL certificates 🔒
|
|
64
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
|
|
65
|
+
|
|
66
|
+
- `/services_status`: 🩺 Check services are running 🩺
|
|
67
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/services_status.jpg" height="150">
|
|
68
|
+
|
|
69
|
+
- `/restart_all`: 🚀 Restart all services 🚀
|
|
70
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/restart_all.jpg" height="150">
|
|
71
|
+
|
|
72
|
+
- `/restart_service {service_name}`: 🚀 Restart a service 🚀
|
|
73
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/restart_service.jpg" height="150">
|
|
74
|
+
|
|
75
|
+
- `/list_services`: 📋 List all available services 📋
|
|
76
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/list_services.jpg" height="150">
|
|
77
|
+
|
|
78
|
+
- `/ports`: 🔒 Check ports 🔒
|
|
79
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ports.jpg" height="200">
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Private discord channel commands:
|
|
83
|
+
- `/force_sync`: 🔄 Force discord command synchronization 🔄
|
|
84
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/force_sync.jpg" height="300">
|
|
85
|
+
|
|
86
|
+
- `/users`: 👥 View connected users 👥
|
|
87
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/users.jpg" height="150">
|
|
88
|
+
|
|
89
|
+
- `/user_logins`: 👥 View last user connections 👥
|
|
90
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/user_logins.jpg" height="150">
|
|
91
|
+
|
|
92
|
+
- `/reboot_server`: 🔄 Restart the entire server 🔄
|
|
93
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/reboot_server.jpg" height="100">
|
|
94
|
+
|
|
95
|
+
- `/list_processes`: 📋 List active processes 📋
|
|
96
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/list_processes.jpg" height="200">
|
|
97
|
+
|
|
98
|
+
- `/kill_process`: 🚫 Stop a process by PID 🚫
|
|
99
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/kill_process.jpg" height="200">
|
|
100
|
+
|
|
101
|
+
## How to install (for first launch)
|
|
102
|
+
|
|
103
|
+
- Install package calling `python -m pip install discordbotlinuxmonitor` (or `python setup.py install` from the root of this repository)
|
|
104
|
+
- Copy and edit [config-example.json file](https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/blob/master/config-example.json) depending on your need (on first launch, remove all `restart_command` from config file to prevent potential looping service restart issues on your server in case your config file is not well configured)
|
|
105
|
+
- Launch the lib for testing it works:
|
|
106
|
+
```shell
|
|
107
|
+
# Get help
|
|
108
|
+
python3 -m discordbotlinuxmonitor --help
|
|
109
|
+
# Use "--debug" to show more information during command
|
|
110
|
+
# Use "--nodebug" to not show any warning information during command
|
|
111
|
+
|
|
112
|
+
# Start the discord bot Linux monitor (First time)
|
|
113
|
+
python3 -m discordbotlinuxmonitor --config_file config-example.json --force_sync_on_startup True --debug
|
|
114
|
+
|
|
115
|
+
# Start the discord bot Linux monitor (after first time)
|
|
116
|
+
python3 -m discordbotlinuxmonitor --config_file config-example.json --force_sync_on_startup False
|
|
117
|
+
```
|
|
118
|
+
- Go to discord (restart discord if you were already in it)
|
|
119
|
+
- You should see welcome messages on channels you configured in the config file and be able to communicate with the bot using command defined in previous section
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## How to install this lib as a service (to keep it running in the Linux server as a monitor)
|
|
123
|
+
|
|
124
|
+
- Stop the discord bot and create a service to have it running even after computer reboot:
|
|
125
|
+
```sh
|
|
126
|
+
### Define all base info
|
|
127
|
+
DISCORD_BOT_SERVICE_USER="discordbotlinuxmonitor"
|
|
128
|
+
DISCORD_BOT_SERVICE_GROUP="discordbotlinuxmonitor"
|
|
129
|
+
DISCORD_BOT_SERVICE_NAME="discord-bot"
|
|
130
|
+
DISCORD_BOT_SERVICE_FILE="/etc/systemd/system/${DISCORD_BOT_SERVICE_NAME}.service"
|
|
131
|
+
DISCORD_BOT_FOLDER="/opt/Discord/"
|
|
132
|
+
|
|
133
|
+
### Add rights to user launching the library depending on what you want it to do ###
|
|
134
|
+
# Only if this library should be able to reboot the server on demand:
|
|
135
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /sbin/reboot" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
136
|
+
# Only if this library should be able to kill a process on demand:
|
|
137
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /bin/kill" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
138
|
+
# Add also all processes added in your config JSON file you want the library to be able to execute
|
|
139
|
+
# Example for the existing config-example.json file:
|
|
140
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /bin/systemctl" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
141
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /etc/init.d/apache2" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
142
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /etc/init.d/mariadb" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
143
|
+
|
|
144
|
+
### Create a specific user and group to launch the discord bot service ###
|
|
145
|
+
echo "Creating user $DISCORD_BOT_SERVICE_USER..."
|
|
146
|
+
sudo useradd -r -s /usr/sbin/nologin $DISCORD_BOT_SERVICE_USER
|
|
147
|
+
sudo mkdir -p /home/$DISCORD_BOT_SERVICE_USER
|
|
148
|
+
sudo chown $DISCORD_BOT_SERVICE_USER:$DISCORD_BOT_SERVICE_GROUP /home/$DISCORD_BOT_SERVICE_USER
|
|
149
|
+
sudo usermod -d /home/$DISCORD_BOT_SERVICE_USER $DISCORD_BOT_SERVICE_USER
|
|
150
|
+
|
|
151
|
+
### Install DiscordBotLinuxMonitor lib for the user ###
|
|
152
|
+
echo "Installing DiscordBotLinuxMonitor for user $DISCORD_BOT_SERVICE_USER..."
|
|
153
|
+
sudo -u $DISCORD_BOT_SERVICE_USER -s
|
|
154
|
+
python3 -m venv /home/$DISCORD_BOT_SERVICE_USER/venv
|
|
155
|
+
source /home/$DISCORD_BOT_SERVICE_USER/venv/bin/activate
|
|
156
|
+
python3 -m pip install discordbotlinuxmonitor
|
|
157
|
+
deactivate
|
|
158
|
+
exit
|
|
159
|
+
|
|
160
|
+
# Create the Discord bot folder where you should put the json file
|
|
161
|
+
sudo mkdir $DISCORD_BOT_FOLDER
|
|
162
|
+
|
|
163
|
+
### Create a systemd service file for the Discord bot ###
|
|
164
|
+
cat <<EOF > $DISCORD_BOT_SERVICE_FILE
|
|
165
|
+
[Unit]
|
|
166
|
+
Description=Discord Bot Linux Monitor Service
|
|
167
|
+
After=network.target
|
|
168
|
+
|
|
169
|
+
[Service]
|
|
170
|
+
ExecStart=/home/$DISCORD_BOT_SERVICE_USER/venv/bin/python3 -m discordbotlinuxmonitor --config_file ${DISCORD_BOT_FOLDER}config.json
|
|
171
|
+
WorkingDirectory=$DISCORD_BOT_FOLDER
|
|
172
|
+
User=$DISCORD_BOT_SERVICE_USER
|
|
173
|
+
Group=$DISCORD_BOT_SERVICE_GROUP
|
|
174
|
+
Restart=always
|
|
175
|
+
RestartSec=3
|
|
176
|
+
|
|
177
|
+
[Install]
|
|
178
|
+
WantedBy=multi-user.target
|
|
179
|
+
EOF
|
|
180
|
+
|
|
181
|
+
echo "Service file created at $DISCORD_BOT_SERVICE_FILE"
|
|
182
|
+
|
|
183
|
+
### Reload systemd to recognize the new service ###
|
|
184
|
+
echo "Reloading systemd..."
|
|
185
|
+
sudo systemctl daemon-reload
|
|
186
|
+
|
|
187
|
+
### Enable and start the service ###
|
|
188
|
+
echo "Enabling and starting the Discord bot service..."
|
|
189
|
+
sudo systemctl enable $DISCORD_BOT_SERVICE_NAME
|
|
190
|
+
```
|
|
191
|
+
- Copy your config file into `$DISCORD_BOT_FOLDER/config.json`
|
|
192
|
+
- Launch the service: `sudo systemctl start $DISCORD_BOT_SERVICE_NAME`
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
This project is under MIT license. This means you can use it as you want (just don't delete the library header).
|
|
197
|
+
|
|
198
|
+
## Contribute
|
|
199
|
+
|
|
200
|
+
If you want to add more examples or improve the library, just create a pull request with proper commit message and right wrapping.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE.md
|
|
2
|
+
README.md
|
|
3
|
+
setup.cfg
|
|
4
|
+
setup.py
|
|
5
|
+
DiscordBotLinuxMonitor.egg-info/PKG-INFO
|
|
6
|
+
DiscordBotLinuxMonitor.egg-info/SOURCES.txt
|
|
7
|
+
DiscordBotLinuxMonitor.egg-info/dependency_links.txt
|
|
8
|
+
DiscordBotLinuxMonitor.egg-info/requires.txt
|
|
9
|
+
DiscordBotLinuxMonitor.egg-info/top_level.txt
|
|
10
|
+
discordbotlinuxmonitor/__init__.py
|
|
11
|
+
discordbotlinuxmonitor/__main__.py
|
|
12
|
+
discordbotlinuxmonitor/discordbotlinuxmonitor.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
discordbotlinuxmonitor
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Quentin Comte-Gaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: DiscordBotLinuxMonitor
|
|
3
|
+
Version: 1.0.1
|
|
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
|
|
6
|
+
Author: Quentin Comte-Gaz
|
|
7
|
+
Author-email: quentin@comte-gaz.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: discord bot warning info linux monitor monitoring server service port ping ssl certificate disk folder cpu ram swap usage ip connection
|
|
10
|
+
Platform: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: System Administrators
|
|
17
|
+
Classifier: Topic :: System :: Monitoring
|
|
18
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
19
|
+
Classifier: Topic :: System :: Systems Administration
|
|
20
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
21
|
+
Classifier: Environment :: Console
|
|
22
|
+
Requires-Python: >=3.3
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE.md
|
|
25
|
+
Requires-Dist: linuxmonitor
|
|
26
|
+
Requires-Dist: discord.py
|
|
27
|
+
Requires-Dist: typing
|
|
28
|
+
Requires-Dist: asyncio
|
|
29
|
+
|
|
30
|
+
# Discord Bot Linux Monitor (Python library)
|
|
31
|
+
[](https://pypi.org/project/DiscordBotLinuxMonitor/) [](https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/blob/master/LICENSE.md) [](https://paypal.me/QuentinCG) [](https://pepy.tech/project/DiscordBotLinuxMonitor) [](https://pepy.tech/project/DiscordBotLinuxMonitor)
|
|
32
|
+
|
|
33
|
+
## What is it
|
|
34
|
+
|
|
35
|
+
This python library is designed to be used as a Linux service to monitor the Linux server manually with discord commands and to send warning or information of the Linux server status to a discord channel periodically (if relevant).
|
|
36
|
+
|
|
37
|
+
It is possible to have separate 'private discord channel' and 'public discord channel' for:
|
|
38
|
+
- Sendind discord commands to the bot (visual example in next section)
|
|
39
|
+
- Getting periodic status of the Linux server (doing periodically some commands from next section)
|
|
40
|
+
- Getting warnings if there is an issue in the Linux server (periodic status check)
|
|
41
|
+
|
|
42
|
+
Example of warning:
|
|
43
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/warning_from_periodic_check.jpg" height="400">
|
|
44
|
+
|
|
45
|
+
It is compatible with python 3+ and usable only on Linux.
|
|
46
|
+
|
|
47
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/discord.png" width="300">
|
|
48
|
+
|
|
49
|
+
## List of Discord commands:
|
|
50
|
+
|
|
51
|
+
### Public and private discord channel commands
|
|
52
|
+
Displayed infos are not the same if you do the command in private or public channel (all info are displayed in private channel, some are hidden from public channels)
|
|
53
|
+
|
|
54
|
+
- `/usage`: 📊 View disk space, CPU, RAM, ... 📊
|
|
55
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/usage.jpg" height="400">
|
|
56
|
+
|
|
57
|
+
- `/os_infos`: 🖥 View basic system information 🖥
|
|
58
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/os_infos.jpg" height="300">
|
|
59
|
+
|
|
60
|
+
- `/ping`: 🌐 Ping websites 🌐
|
|
61
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
|
|
62
|
+
|
|
63
|
+
- `/certificates`: 🔒 Check SSL certificates 🔒
|
|
64
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
|
|
65
|
+
|
|
66
|
+
- `/services_status`: 🩺 Check services are running 🩺
|
|
67
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/services_status.jpg" height="150">
|
|
68
|
+
|
|
69
|
+
- `/restart_all`: 🚀 Restart all services 🚀
|
|
70
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/restart_all.jpg" height="150">
|
|
71
|
+
|
|
72
|
+
- `/restart_service {service_name}`: 🚀 Restart a service 🚀
|
|
73
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/restart_service.jpg" height="150">
|
|
74
|
+
|
|
75
|
+
- `/list_services`: 📋 List all available services 📋
|
|
76
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/list_services.jpg" height="150">
|
|
77
|
+
|
|
78
|
+
- `/ports`: 🔒 Check ports 🔒
|
|
79
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ports.jpg" height="200">
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Private discord channel commands:
|
|
83
|
+
- `/force_sync`: 🔄 Force discord command synchronization 🔄
|
|
84
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/force_sync.jpg" height="300">
|
|
85
|
+
|
|
86
|
+
- `/users`: 👥 View connected users 👥
|
|
87
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/users.jpg" height="150">
|
|
88
|
+
|
|
89
|
+
- `/user_logins`: 👥 View last user connections 👥
|
|
90
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/user_logins.jpg" height="150">
|
|
91
|
+
|
|
92
|
+
- `/reboot_server`: 🔄 Restart the entire server 🔄
|
|
93
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/reboot_server.jpg" height="100">
|
|
94
|
+
|
|
95
|
+
- `/list_processes`: 📋 List active processes 📋
|
|
96
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/list_processes.jpg" height="200">
|
|
97
|
+
|
|
98
|
+
- `/kill_process`: 🚫 Stop a process by PID 🚫
|
|
99
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/kill_process.jpg" height="200">
|
|
100
|
+
|
|
101
|
+
## How to install (for first launch)
|
|
102
|
+
|
|
103
|
+
- Install package calling `python -m pip install discordbotlinuxmonitor` (or `python setup.py install` from the root of this repository)
|
|
104
|
+
- Copy and edit [config-example.json file](https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/blob/master/config-example.json) depending on your need (on first launch, remove all `restart_command` from config file to prevent potential looping service restart issues on your server in case your config file is not well configured)
|
|
105
|
+
- Launch the lib for testing it works:
|
|
106
|
+
```shell
|
|
107
|
+
# Get help
|
|
108
|
+
python3 -m discordbotlinuxmonitor --help
|
|
109
|
+
# Use "--debug" to show more information during command
|
|
110
|
+
# Use "--nodebug" to not show any warning information during command
|
|
111
|
+
|
|
112
|
+
# Start the discord bot Linux monitor (First time)
|
|
113
|
+
python3 -m discordbotlinuxmonitor --config_file config-example.json --force_sync_on_startup True --debug
|
|
114
|
+
|
|
115
|
+
# Start the discord bot Linux monitor (after first time)
|
|
116
|
+
python3 -m discordbotlinuxmonitor --config_file config-example.json --force_sync_on_startup False
|
|
117
|
+
```
|
|
118
|
+
- Go to discord (restart discord if you were already in it)
|
|
119
|
+
- You should see welcome messages on channels you configured in the config file and be able to communicate with the bot using command defined in previous section
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## How to install this lib as a service (to keep it running in the Linux server as a monitor)
|
|
123
|
+
|
|
124
|
+
- Stop the discord bot and create a service to have it running even after computer reboot:
|
|
125
|
+
```sh
|
|
126
|
+
### Define all base info
|
|
127
|
+
DISCORD_BOT_SERVICE_USER="discordbotlinuxmonitor"
|
|
128
|
+
DISCORD_BOT_SERVICE_GROUP="discordbotlinuxmonitor"
|
|
129
|
+
DISCORD_BOT_SERVICE_NAME="discord-bot"
|
|
130
|
+
DISCORD_BOT_SERVICE_FILE="/etc/systemd/system/${DISCORD_BOT_SERVICE_NAME}.service"
|
|
131
|
+
DISCORD_BOT_FOLDER="/opt/Discord/"
|
|
132
|
+
|
|
133
|
+
### Add rights to user launching the library depending on what you want it to do ###
|
|
134
|
+
# Only if this library should be able to reboot the server on demand:
|
|
135
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /sbin/reboot" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
136
|
+
# Only if this library should be able to kill a process on demand:
|
|
137
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /bin/kill" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
138
|
+
# Add also all processes added in your config JSON file you want the library to be able to execute
|
|
139
|
+
# Example for the existing config-example.json file:
|
|
140
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /bin/systemctl" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
141
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /etc/init.d/apache2" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
142
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /etc/init.d/mariadb" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
143
|
+
|
|
144
|
+
### Create a specific user and group to launch the discord bot service ###
|
|
145
|
+
echo "Creating user $DISCORD_BOT_SERVICE_USER..."
|
|
146
|
+
sudo useradd -r -s /usr/sbin/nologin $DISCORD_BOT_SERVICE_USER
|
|
147
|
+
sudo mkdir -p /home/$DISCORD_BOT_SERVICE_USER
|
|
148
|
+
sudo chown $DISCORD_BOT_SERVICE_USER:$DISCORD_BOT_SERVICE_GROUP /home/$DISCORD_BOT_SERVICE_USER
|
|
149
|
+
sudo usermod -d /home/$DISCORD_BOT_SERVICE_USER $DISCORD_BOT_SERVICE_USER
|
|
150
|
+
|
|
151
|
+
### Install DiscordBotLinuxMonitor lib for the user ###
|
|
152
|
+
echo "Installing DiscordBotLinuxMonitor for user $DISCORD_BOT_SERVICE_USER..."
|
|
153
|
+
sudo -u $DISCORD_BOT_SERVICE_USER -s
|
|
154
|
+
python3 -m venv /home/$DISCORD_BOT_SERVICE_USER/venv
|
|
155
|
+
source /home/$DISCORD_BOT_SERVICE_USER/venv/bin/activate
|
|
156
|
+
python3 -m pip install discordbotlinuxmonitor
|
|
157
|
+
deactivate
|
|
158
|
+
exit
|
|
159
|
+
|
|
160
|
+
# Create the Discord bot folder where you should put the json file
|
|
161
|
+
sudo mkdir $DISCORD_BOT_FOLDER
|
|
162
|
+
|
|
163
|
+
### Create a systemd service file for the Discord bot ###
|
|
164
|
+
cat <<EOF > $DISCORD_BOT_SERVICE_FILE
|
|
165
|
+
[Unit]
|
|
166
|
+
Description=Discord Bot Linux Monitor Service
|
|
167
|
+
After=network.target
|
|
168
|
+
|
|
169
|
+
[Service]
|
|
170
|
+
ExecStart=/home/$DISCORD_BOT_SERVICE_USER/venv/bin/python3 -m discordbotlinuxmonitor --config_file ${DISCORD_BOT_FOLDER}config.json
|
|
171
|
+
WorkingDirectory=$DISCORD_BOT_FOLDER
|
|
172
|
+
User=$DISCORD_BOT_SERVICE_USER
|
|
173
|
+
Group=$DISCORD_BOT_SERVICE_GROUP
|
|
174
|
+
Restart=always
|
|
175
|
+
RestartSec=3
|
|
176
|
+
|
|
177
|
+
[Install]
|
|
178
|
+
WantedBy=multi-user.target
|
|
179
|
+
EOF
|
|
180
|
+
|
|
181
|
+
echo "Service file created at $DISCORD_BOT_SERVICE_FILE"
|
|
182
|
+
|
|
183
|
+
### Reload systemd to recognize the new service ###
|
|
184
|
+
echo "Reloading systemd..."
|
|
185
|
+
sudo systemctl daemon-reload
|
|
186
|
+
|
|
187
|
+
### Enable and start the service ###
|
|
188
|
+
echo "Enabling and starting the Discord bot service..."
|
|
189
|
+
sudo systemctl enable $DISCORD_BOT_SERVICE_NAME
|
|
190
|
+
```
|
|
191
|
+
- Copy your config file into `$DISCORD_BOT_FOLDER/config.json`
|
|
192
|
+
- Launch the service: `sudo systemctl start $DISCORD_BOT_SERVICE_NAME`
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
This project is under MIT license. This means you can use it as you want (just don't delete the library header).
|
|
197
|
+
|
|
198
|
+
## Contribute
|
|
199
|
+
|
|
200
|
+
If you want to add more examples or improve the library, just create a pull request with proper commit message and right wrapping.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Discord Bot Linux Monitor (Python library)
|
|
2
|
+
[](https://pypi.org/project/DiscordBotLinuxMonitor/) [](https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/blob/master/LICENSE.md) [](https://paypal.me/QuentinCG) [](https://pepy.tech/project/DiscordBotLinuxMonitor) [](https://pepy.tech/project/DiscordBotLinuxMonitor)
|
|
3
|
+
|
|
4
|
+
## What is it
|
|
5
|
+
|
|
6
|
+
This python library is designed to be used as a Linux service to monitor the Linux server manually with discord commands and to send warning or information of the Linux server status to a discord channel periodically (if relevant).
|
|
7
|
+
|
|
8
|
+
It is possible to have separate 'private discord channel' and 'public discord channel' for:
|
|
9
|
+
- Sendind discord commands to the bot (visual example in next section)
|
|
10
|
+
- Getting periodic status of the Linux server (doing periodically some commands from next section)
|
|
11
|
+
- Getting warnings if there is an issue in the Linux server (periodic status check)
|
|
12
|
+
|
|
13
|
+
Example of warning:
|
|
14
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/warning_from_periodic_check.jpg" height="400">
|
|
15
|
+
|
|
16
|
+
It is compatible with python 3+ and usable only on Linux.
|
|
17
|
+
|
|
18
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/discord.png" width="300">
|
|
19
|
+
|
|
20
|
+
## List of Discord commands:
|
|
21
|
+
|
|
22
|
+
### Public and private discord channel commands
|
|
23
|
+
Displayed infos are not the same if you do the command in private or public channel (all info are displayed in private channel, some are hidden from public channels)
|
|
24
|
+
|
|
25
|
+
- `/usage`: 📊 View disk space, CPU, RAM, ... 📊
|
|
26
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/usage.jpg" height="400">
|
|
27
|
+
|
|
28
|
+
- `/os_infos`: 🖥 View basic system information 🖥
|
|
29
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/os_infos.jpg" height="300">
|
|
30
|
+
|
|
31
|
+
- `/ping`: 🌐 Ping websites 🌐
|
|
32
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
|
|
33
|
+
|
|
34
|
+
- `/certificates`: 🔒 Check SSL certificates 🔒
|
|
35
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
|
|
36
|
+
|
|
37
|
+
- `/services_status`: 🩺 Check services are running 🩺
|
|
38
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/services_status.jpg" height="150">
|
|
39
|
+
|
|
40
|
+
- `/restart_all`: 🚀 Restart all services 🚀
|
|
41
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/restart_all.jpg" height="150">
|
|
42
|
+
|
|
43
|
+
- `/restart_service {service_name}`: 🚀 Restart a service 🚀
|
|
44
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/restart_service.jpg" height="150">
|
|
45
|
+
|
|
46
|
+
- `/list_services`: 📋 List all available services 📋
|
|
47
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/list_services.jpg" height="150">
|
|
48
|
+
|
|
49
|
+
- `/ports`: 🔒 Check ports 🔒
|
|
50
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ports.jpg" height="200">
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Private discord channel commands:
|
|
54
|
+
- `/force_sync`: 🔄 Force discord command synchronization 🔄
|
|
55
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/force_sync.jpg" height="300">
|
|
56
|
+
|
|
57
|
+
- `/users`: 👥 View connected users 👥
|
|
58
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/users.jpg" height="150">
|
|
59
|
+
|
|
60
|
+
- `/user_logins`: 👥 View last user connections 👥
|
|
61
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/user_logins.jpg" height="150">
|
|
62
|
+
|
|
63
|
+
- `/reboot_server`: 🔄 Restart the entire server 🔄
|
|
64
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/reboot_server.jpg" height="100">
|
|
65
|
+
|
|
66
|
+
- `/list_processes`: 📋 List active processes 📋
|
|
67
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/list_processes.jpg" height="200">
|
|
68
|
+
|
|
69
|
+
- `/kill_process`: 🚫 Stop a process by PID 🚫
|
|
70
|
+
<img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/kill_process.jpg" height="200">
|
|
71
|
+
|
|
72
|
+
## How to install (for first launch)
|
|
73
|
+
|
|
74
|
+
- Install package calling `python -m pip install discordbotlinuxmonitor` (or `python setup.py install` from the root of this repository)
|
|
75
|
+
- Copy and edit [config-example.json file](https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/blob/master/config-example.json) depending on your need (on first launch, remove all `restart_command` from config file to prevent potential looping service restart issues on your server in case your config file is not well configured)
|
|
76
|
+
- Launch the lib for testing it works:
|
|
77
|
+
```shell
|
|
78
|
+
# Get help
|
|
79
|
+
python3 -m discordbotlinuxmonitor --help
|
|
80
|
+
# Use "--debug" to show more information during command
|
|
81
|
+
# Use "--nodebug" to not show any warning information during command
|
|
82
|
+
|
|
83
|
+
# Start the discord bot Linux monitor (First time)
|
|
84
|
+
python3 -m discordbotlinuxmonitor --config_file config-example.json --force_sync_on_startup True --debug
|
|
85
|
+
|
|
86
|
+
# Start the discord bot Linux monitor (after first time)
|
|
87
|
+
python3 -m discordbotlinuxmonitor --config_file config-example.json --force_sync_on_startup False
|
|
88
|
+
```
|
|
89
|
+
- Go to discord (restart discord if you were already in it)
|
|
90
|
+
- You should see welcome messages on channels you configured in the config file and be able to communicate with the bot using command defined in previous section
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## How to install this lib as a service (to keep it running in the Linux server as a monitor)
|
|
94
|
+
|
|
95
|
+
- Stop the discord bot and create a service to have it running even after computer reboot:
|
|
96
|
+
```sh
|
|
97
|
+
### Define all base info
|
|
98
|
+
DISCORD_BOT_SERVICE_USER="discordbotlinuxmonitor"
|
|
99
|
+
DISCORD_BOT_SERVICE_GROUP="discordbotlinuxmonitor"
|
|
100
|
+
DISCORD_BOT_SERVICE_NAME="discord-bot"
|
|
101
|
+
DISCORD_BOT_SERVICE_FILE="/etc/systemd/system/${DISCORD_BOT_SERVICE_NAME}.service"
|
|
102
|
+
DISCORD_BOT_FOLDER="/opt/Discord/"
|
|
103
|
+
|
|
104
|
+
### Add rights to user launching the library depending on what you want it to do ###
|
|
105
|
+
# Only if this library should be able to reboot the server on demand:
|
|
106
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /sbin/reboot" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
107
|
+
# Only if this library should be able to kill a process on demand:
|
|
108
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /bin/kill" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
109
|
+
# Add also all processes added in your config JSON file you want the library to be able to execute
|
|
110
|
+
# Example for the existing config-example.json file:
|
|
111
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /bin/systemctl" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
112
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /etc/init.d/apache2" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
113
|
+
echo "$DISCORD_BOT_SERVICE_USER ALL=(ALL) NOPASSWD: /etc/init.d/mariadb" >> /etc/sudoers.d/$DISCORD_BOT_SERVICE_USER
|
|
114
|
+
|
|
115
|
+
### Create a specific user and group to launch the discord bot service ###
|
|
116
|
+
echo "Creating user $DISCORD_BOT_SERVICE_USER..."
|
|
117
|
+
sudo useradd -r -s /usr/sbin/nologin $DISCORD_BOT_SERVICE_USER
|
|
118
|
+
sudo mkdir -p /home/$DISCORD_BOT_SERVICE_USER
|
|
119
|
+
sudo chown $DISCORD_BOT_SERVICE_USER:$DISCORD_BOT_SERVICE_GROUP /home/$DISCORD_BOT_SERVICE_USER
|
|
120
|
+
sudo usermod -d /home/$DISCORD_BOT_SERVICE_USER $DISCORD_BOT_SERVICE_USER
|
|
121
|
+
|
|
122
|
+
### Install DiscordBotLinuxMonitor lib for the user ###
|
|
123
|
+
echo "Installing DiscordBotLinuxMonitor for user $DISCORD_BOT_SERVICE_USER..."
|
|
124
|
+
sudo -u $DISCORD_BOT_SERVICE_USER -s
|
|
125
|
+
python3 -m venv /home/$DISCORD_BOT_SERVICE_USER/venv
|
|
126
|
+
source /home/$DISCORD_BOT_SERVICE_USER/venv/bin/activate
|
|
127
|
+
python3 -m pip install discordbotlinuxmonitor
|
|
128
|
+
deactivate
|
|
129
|
+
exit
|
|
130
|
+
|
|
131
|
+
# Create the Discord bot folder where you should put the json file
|
|
132
|
+
sudo mkdir $DISCORD_BOT_FOLDER
|
|
133
|
+
|
|
134
|
+
### Create a systemd service file for the Discord bot ###
|
|
135
|
+
cat <<EOF > $DISCORD_BOT_SERVICE_FILE
|
|
136
|
+
[Unit]
|
|
137
|
+
Description=Discord Bot Linux Monitor Service
|
|
138
|
+
After=network.target
|
|
139
|
+
|
|
140
|
+
[Service]
|
|
141
|
+
ExecStart=/home/$DISCORD_BOT_SERVICE_USER/venv/bin/python3 -m discordbotlinuxmonitor --config_file ${DISCORD_BOT_FOLDER}config.json
|
|
142
|
+
WorkingDirectory=$DISCORD_BOT_FOLDER
|
|
143
|
+
User=$DISCORD_BOT_SERVICE_USER
|
|
144
|
+
Group=$DISCORD_BOT_SERVICE_GROUP
|
|
145
|
+
Restart=always
|
|
146
|
+
RestartSec=3
|
|
147
|
+
|
|
148
|
+
[Install]
|
|
149
|
+
WantedBy=multi-user.target
|
|
150
|
+
EOF
|
|
151
|
+
|
|
152
|
+
echo "Service file created at $DISCORD_BOT_SERVICE_FILE"
|
|
153
|
+
|
|
154
|
+
### Reload systemd to recognize the new service ###
|
|
155
|
+
echo "Reloading systemd..."
|
|
156
|
+
sudo systemctl daemon-reload
|
|
157
|
+
|
|
158
|
+
### Enable and start the service ###
|
|
159
|
+
echo "Enabling and starting the Discord bot service..."
|
|
160
|
+
sudo systemctl enable $DISCORD_BOT_SERVICE_NAME
|
|
161
|
+
```
|
|
162
|
+
- Copy your config file into `$DISCORD_BOT_FOLDER/config.json`
|
|
163
|
+
- Launch the service: `sudo systemctl start $DISCORD_BOT_SERVICE_NAME`
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
This project is under MIT license. This means you can use it as you want (just don't delete the library header).
|
|
168
|
+
|
|
169
|
+
## Contribute
|
|
170
|
+
|
|
171
|
+
If you want to add more examples or improve the library, just create a pull request with proper commit message and right wrapping.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .discordbotlinuxmonitor import DiscordBotLinuxMonitor # type: ignore
|