Tracking systemd log (journal) and send them to discord or slack.
java -jar SystemdLogTracker.jar
etc.Configuration
below.Register with Systemd
below.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"
}
-f
or --follow
argument. If not specified, monitoring will fail. -a
or --all
. This shows everything even when output is very long. -u
or --unit=UNIT|PATTERN
is 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.json
etc.)
After executing systemctl daemon-reload
, start the service with systemctl start <ServiceName>
. <ServiceName>
is SystemdLogTracker
if service file is SystemdLogTracker.service
.
The license for this project is MIT License.
LICENSE