Giter VIP home page Giter VIP logo

systemdlogtracker's Introduction

SystemdLogTracker

日本語の README はこちらから

Tracking systemd log (journal) and send them to discord or slack.

Feature

  • Choose sending by Discord Bot, sending by discord webhook or slack incoming webhook in the config file.
  • All journalctl command arguments can be set.

Requirements

  • Java 16+
  • One of the following
    • Valid Discord Bot Token and Discord Channel ID
    • Valid Discord Webhook URL
    • Valid Slack Incoming Message Webhook URL

Install

from release

  1. Go to Release page.
  2. Download latest version or any older version
  3. First start it using java -jar SystemdLogTracker.jar etc.
  4. A configuration file is generated. Check and edit the Configuration below.
  5. Please start again after editing.
  6. (if necessary) Let's register with Systemd etc. Check Register with Systemd below.

Run

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.

Configuration

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.

discordToken

Required when using Discord Bot.

Please specify a token for Discord Bot.

{
  "discordToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

discordChannelId

Required when using Discord Bot.

Please specify the destination channel ID.

{
  "discordChannelId": "00000000000000"
}

discordWebhookUrl

Required when using Discord Webhook.

Please specify the URL of the Discord Webhook.

{
  "discordWebhookUrl": "https://discord.com/api/webhooks/00000000000000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

slackWebhookUrl

Required when using Slack Incoming Webhook.

Please specify the URL of the Slack Webhook.

{
  "slackWebhookUrl": "https://hooks.slack.com/services/xxxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

arguments

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 -f or --follow argument. If not specified, monitoring will fail.
  • It is recommended to specify -a or --all. This shows everything even when output is very long.
  • The argument -u or --unit=UNIT|PATTERN is very useful. This can specify a systemd service (unit).

sendInterval

Not required.

Please specify the interval milliseconds for processing the output.
Default value: 5000

{
  "sendInterval": 5000
}

filteredWords

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]"]
}

Register with Systemd

  1. Create a service file under /etc/systemd/system/. For example: /etc/systemd/system/SystemdLogTracker.service

  2. 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.)

  3. After executing systemctl daemon-reload, start the service with systemctl start <ServiceName>. <ServiceName> is SystemdLogTracker if service file is SystemdLogTracker.service.

License

The license for this project is MIT License.
LICENSE

systemdlogtracker's People

Contributors

book000 avatar notactuallyterry avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

asmuelle

systemdlogtracker's Issues

[feature request] codeblock highlight language support in config

Hi,

thank you so much for this nice handy tool. It works really well.

Would it be possible for you to add feature for custom codeblock highlight for python or JS etc which is supported by Discord for codeblock markdown? Also it looks bit weird inline on mobile (android app) because of lack of new line after first 3 backticks. 😅

100% core usage, spiking temps, high server load

Hello. Thank you for providing this app I've found it quite useful. Although, I have noticed an issue with it running.. One thread on my server gets maxed out at 100% and causes temps to rise while the program is running. I am unsure why this is happening.. I did read the code but I don't know much Java so I can't figure out what the cause is. I thought I would let you know.

I am using the Discord Webhook functionality to monitor a Minecraft server console.

Here are some screenshots of the issue.

Htop showing high load, and 100% use on one thread
htop

Output of sensors
high-temps

Normal stats for my server without the application running.
normal-htop-stats
temp-drop

Steps to reproduce:
Run the application as suggested in readme
Watch htop, and core temps spike
Stop the application
Htop stats, and temps return to normal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.