Git Product home page Git Product logo

telegrep's Introduction

telegrep

Monitor journald in real time and get Telegram messages when patterns match.

Usage

Getting a Telegram bot

If you don't have a Telegram bot, go ahead and create one. This will give you the access token for your bot. Next, you need to start a conversation with it and send at least one message. Then you can do curl https://api.telegram.org/bot<TOKEN>/getUpdates and the JSON response will contain an id value in the chat object. This is your chat id.

Configuration

Copy settings.config.TEMPLATE to settings.config and enter both your bot's token, as well as the chat id of the conversation you have with it. Then enter your regular expression that you want to watch the journal for.

Once everything is configured, simply run ./telegrep and whenever the pattern you defined in the configuration is encountered in the systemd journal, you will receive a message with that line from the log. For testing purposes, you can write messages to the journal with logger "This is my message".

Installation

Edit telegrep.service and change the user to the one you want to run it with. Ideally, this is an unprivileged user, but keep in mind that it may need to be in the systemd-journal group to have access to the journal. Also update both paths to point to where you keep the directory. After that, the installation could be something like this:

# Copy the unit file to the appropriate location
sudo cp telegrep.service /etc/systemd/system/
# Start it
sudo systemctl start telegrep
# Check the status
systemctl status telegrep
# Enable it to start on boot
sudo systemctl enable telegrep

License

GNU General Public License v3.0

telegrep's People

Contributors

martindisch avatar

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.