Tracking systemd log (journal) and send them to discord or slack.
- Choose sending by Discord Bot, sending by discord webhook or slack incoming webhook in the config file.
- All journalctl command arguments can be set.
- Java 16+
- One of the following
- Valid Discord Bot Token and Discord Channel ID
- Valid Discord Webhook URL
- Valid Slack Incoming Message Webhook URL
- Go to Release page.
- Download latest version or any older version
- First start it using
java -jar SystemdLogTracker.jaretc. - A configuration file is generated. Check and edit the
Configurationbelow. - Please start again after editing.
- (if necessary) Let's register with Systemd etc. Check
Register with Systemdbelow.
Run the following command:
java -jar SystemdLogTracker.jar [Config file path][Config file path] can specify the path of the config file. For example: java -jar SystemdLogTracker.jar Tester.json
If not specified, config.json is used.
The default config file is config.json. But, the config file path can be changed by the argument when executing jar.
{
"discordWebhookUrl": "https://discord.com/api/webhooks/00000000000000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"arguments": "-a -o cat -f -n 0 -u sshd"
}Be sure to set discordToken and discordChannelId, discordWebhookUrl, or slackWebhookUrl.
Required when using Discord Bot.
Please specify a token for Discord Bot.
{
"discordToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}Required when using Discord Bot.
Please specify the destination channel ID.
{
"discordChannelId": "00000000000000"
}Required when using Discord Webhook.
Please specify the URL of the Discord Webhook.
{
"discordWebhookUrl": "https://discord.com/api/webhooks/00000000000000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}Required when using Slack Incoming Webhook.
Please specify the URL of the Slack Webhook.
{
"slackWebhookUrl": "https://hooks.slack.com/services/xxxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}It is an option, but it is recommended to set it.
Please specify argument of journalctl.
Default value: arguments=-a -o cat -f -n 0
{
"arguments": "-a -o cat -f -n 0 -u sshd"
}- Please be sure to specified the
-for--followargument. If not specified, monitoring will fail. - It is recommended to specify
-aor--all. This shows everything even when output is very long. - The argument
-uor--unit=UNIT|PATTERNis very useful. This can specify a systemd service (unit).
Not required.
Please specify the interval milliseconds for processing the output.
Default value: 5000
{
"sendInterval": 5000
}Not required.
All messages are checked to see if they contain any of these strings. If there is a match, the message is discarded.
Default value: empty
{
"filteredWords": ["sshd", "[UFW ALLOW]"]
}-
Create a service file under
/etc/systemd/system/. For example:/etc/systemd/system/SystemdLogTracker.service -
Open the file with your favorite editor and write the following:
[Unit] Description=Systemd Log Tracker [Service] User=root Group=root ExecStart=<Command> Restart=always [Install] WantedBy=multi-user.target
(For
<Command>specify/usr/bin/java -jar /var/SystemdLogTracker/SystemdLogTracker.jar /var/SystemdLogTracker/Tester.jsonetc.) -
After executing
systemctl daemon-reload, start the service withsystemctl start <ServiceName>.<ServiceName>isSystemdLogTrackerif service file isSystemdLogTracker.service.
The license for this project is MIT License.
LICENSE