Utility that takes logs from anywhere and sends them to Telegram.

Overview

logram crates.io

Utility that takes logs from anywhere and sends them to Telegram. Supports log collection from files, journald and docker containers. More about available log sources see at docs/log_sources.md.

Usage

  1. Create a Telegram bot via @BotFather
  2. Download the latest logram release
  3. Install it:
    • .deb based Linux: sudo dpkg -i logram-...amd64.deb
    • .rpm based Linux: sudo rpm -i logram-...x86_64.rpm
  4. Find out the chat id with your bot (see docs/chat_id.md)
  5. Change the config (/etc/logram.yaml in Linux) (see docs/config.md)
  6. Run logram: sudo systemctl start logram
  7. ... and add it to the autostart: sudo systemctl enable logram

Also logram can work with log, see docs/lib.md for detals.

Building

If you need to build a logram manually, do this:

  1. Clone repo: git clone [email protected]:mxseev/logram.git
  2. Choose the features you want:
    • bin_core - required for all log sources
    • ls_counter - Counter log source
    • ls_filesystem - Filesystem log source
    • ls_journald - Journald log source
    • ls_docker - Docker log source
  3. Build the project with these features: cargo build --release --features=bin_core,ls_filesystem

Making .deb package

  1. Install cargo-deb
  2. Edit package.metadata.deb.features in Cargo.toml
  3. Build package: cargo deb
  4. Use target/debian/logram_..._amd64.deb

Making .rpm package

  1. Install cargo-generate-rpm
  2. Build project: cargo build --release --features=bin_core,...
  3. Strip debug symbols: strip -s target/release/logram
  4. Build package: cargo generate-rpm
  5. Use target/generate-rpm/logram-...x86_64.rpm
Comments
  • Unable to run cargo test on Windows 10

    Unable to run cargo test on Windows 10

    Unable to run cargo test on Windows 10:

    error: failed to run custom build command for `libsystemd-sys v0.2.2`
    
    Caused by:
      process didn't exit successfully: `C:\dev\pr\logram\target\debug\build\libsystemd-sys-ebc25a8bfa53dc04\build-script-build` (exit code: 101)
    --- stdout
    Failed to run `"pkg-config" "--libs" "--cflags" "libsystemd"`: The system cannot find the file specified. (os error 2)
    
    --- stderr
    thread 'main' panicked at 'systemd was not found via pkg-config nor via the env var LIBSYSTEMD_LDFLAGS', C:\Users\iamlo\.cargo\registry\src\github.com-1ecc6299db9ec823\libsystemd-sys-0.2.2\build.rs:19:13
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
    
    opened by incker2 2
  • changing telegram bot does not work

    changing telegram bot does not work

    I tried changing the token a new (tried 2 different) bot(s) and got:

    Apr 10 10:22:55 rex logram[198306]: Error: An error while parsing JSON: data did not match any variant of untagged enum TelegramResponse
    Apr 10 10:22:55 rex logram[198306]: Caused by:
    Apr 10 10:22:55 rex logram[198306]:     data did not match any variant of untagged enum TelegramResponse
    Apr 10 10:22:55 rex systemd[1]: logram.service: Main process exited, code=exited, status=1/FAILURE
    Apr 10 10:22:55 rex systemd[1]: logram.service: Failed with result 'exit-code'.
    

    Sending via curl works for these bots, also tried other applications that can send to bots and they worked fine. Do you have any ideeas? Suggestions? Thanks!

    opened by WladyX 0
  • constant restarts

    constant restarts

    I get a lot of: Logram 2.0.0 started at rex something like very 2h, looking in logs i see:

    Mar 15 18:46:33 rex logram[2275209]: thread '<unknown>' has overflowed its stack
    Mar 15 18:46:33 rex logram[2275209]: fatal runtime error: stack overflow
    Mar 15 18:46:33 rex systemd[1]: logram.service: Main process exited, code=killed, status=6/ABRT
    Mar 15 18:46:33 rex systemd[1]: logram.service: Failed with result 'signal'.
    Mar 15 18:47:03 rex systemd[1]: logram.service: Scheduled restart job, restart counter is at 46.
    

    any ideeas? Thanks,

    PS: recompiled, made a deb, installed it from deb, still restarts.

    opened by WladyX 0
  • Crashes when it cannot send a message

    Crashes when it cannot send a message

    I had logram try to send a message while my Internet was down:

    Jan 25 03:06:37 logram[44771]: Error: A network error: error sending request for url (https://api.telegram.org/botXXXX/sendMessage): connection error: Connection reset by peer (os error 104)
    Jan 25 03:06:37 logram[44771]: Caused by:
    Jan 25 03:06:37 logram[44771]:     0: error sending request for url (https://api.telegram.org/botXXXX/sendMessage): connection error: Connection reset by peer (os error 104)
    Jan 25 03:06:37 logram[44771]:     1: connection error: Connection reset by peer (os error 104)
    Jan 25 03:06:37 logram[44771]:     2: Connection reset by peer (os error 104)
    Jan 25 03:06:37 systemd[1]: logram.service: Main process exited, code=exited, status=1/FAILURE
    Jan 25 03:06:37 systemd[1]: logram.service: Failed with result 'exit-code'.
    

    I would love for an option for logram to keep trying to send the message for N amount of time. In my case, the process crashed, and the message was never sent.

    opened by hugoh 1
  • produce statically linked binary

    produce statically linked binary

    with this patch and using cargo build --release --target x86_64-unknown-linux-musl --features bin_core,ls_filesystem,vendored you can make statically linked binary (now binary depends on glibc 2.32 and cant run on centos7 (and some other distrs))

    From 218fe816aa5bcd37590868d92e4556ce0086a730 Mon Sep 17 00:00:00 2001
    From: admin <[email protected]>
    Date: Fri, 18 Jun 2021 10:04:15 +0300
    Subject: [PATCH] add musl support
    
    ---
     Cargo.lock | 11 +++++++++++
     Cargo.toml |  5 +++++
     2 files changed, 16 insertions(+)
    
    diff --git a/Cargo.lock b/Cargo.lock
    index dce7bc0..df04fc8 100644
    --- a/Cargo.lock
    +++ b/Cargo.lock
    @@ -808,6 +808,7 @@ dependencies = [
      "hostname",
      "log",
      "notify",
    + "openssl-sys",
      "reqwest",
      "serde",
      "serde_json",
    @@ -1029,6 +1030,15 @@ version = "0.1.2"
     source = "registry+https://github.com/rust-lang/crates.io-index"
     checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
     
    +[[package]]
    +name = "openssl-src"
    +version = "111.15.0+1.1.1k"
    +source = "registry+https://github.com/rust-lang/crates.io-index"
    +checksum = "b1a5f6ae2ac04393b217ea9f700cd04fa9bf3d93fae2872069f3d15d908af70a"
    +dependencies = [
    + "cc",
    +]
    +
     [[package]]
     name = "openssl-sys"
     version = "0.9.60"
    @@ -1038,6 +1048,7 @@ dependencies = [
      "autocfg",
      "cc",
      "libc",
    + "openssl-src",
      "pkg-config",
      "vcpkg",
     ]
    diff --git a/Cargo.toml b/Cargo.toml
    index 51885af..a1185e0 100644
    --- a/Cargo.toml
    +++ b/Cargo.toml
    @@ -14,6 +14,10 @@ ls_filesystem = ["notify"]
     ls_journald = ["systemd"]
     ls_docker = ["bollard"]
     
    +# Force openssl-sys to staticly link in the openssl library. Necessary when
    +# cross compiling to x86_64-unknown-linux-musl.
    +vendored = ["openssl-sys/vendored"]
    +
     [[bin]]
     name = "logram"
     doc = false
    @@ -28,6 +32,7 @@ path = "src/lib/mod.rs"
     anyhow = "1.0"
     serde = { version = "1.0", features = ["derive"] }
     reqwest = { version = "0.10", features = ["blocking", "json", "socks"] }
    +openssl-sys = "*"
     
     # bin
     clap = { version = "2.33", optional = true }
    -- 
    2.32.0
    
    opened by dafanasiev 1
Releases(v2.0.0)
Owner
Max Eliseev
Anykey Developer
Max Eliseev
It is a backup tool that creates backups and stores them on an object storage

Hold My Backup It is a backup tool that creates backups and stores them on an object storage. By default it uses minio but you can use AWS: S3 as well

Taylan Dogan 13 Feb 17, 2022
CLI utility to move (or rename) your files to a new location and redirect all of its symbolic links, to the new path

Move Links CLI utility to move (or rename) your files to a new location and redirect all of its symbolic links, to the new path (or name). Usage execu

Ben Mefteh 18 May 22, 2022
A simple and fast download accelerator, written in Rust

zou A simple and fast download accelerator, written in Rust Zou is a Snatch fork by @k0pernicus. Snatch is a fast and interruptable download accelerat

Antonin Carette 173 Dec 4, 2022
GTK application for browsing and installing fonts from Google's font archive

Font Finder This project is a from-scratch implementation of TypeCatcher in Rust. It is a GTK3 application for browsing through and installing fonts f

Michael Murphy 252 Dec 26, 2022
Linux Kernel Manager and Activity Monitor 🐧💻

Linux Kernel Manager and Activity Monitor ?? ?? The kernel is the part of the operating system that facilitates interactions between hardware and soft

Orhun Parmaksız 1.7k Jan 5, 2023
A project for automatically generating and maintaining Debian repositories from a TOML spec.

Debian Repository Builder A simple utility for constructing and maintaining Debian repositories. Configuration of a repo is based on the directory hie

Pop!_OS 52 Feb 7, 2022
A safe and ergonomic alternative to rm

rip (Rm ImProved) rip is a command-line deletion tool focused on safety, ergonomics, and performance. It favors a simple interface, and does not imple

Kevin Liu 781 Jan 7, 2023
A simple, fast and user-friendly alternative to 'find'

fd [中文] [한국어] fd is a program to find entries in your filesytem. It is a simple, fast and user-friendly alternative to find. While it does not aim to

David Peter 25.8k Dec 30, 2022
Untrusted IPC with maximum performance and minimum latency. On Rust, on Linux.

Untrusted IPC with maximum performance and minimum latency. On Rust, on Linux. When is this Rust crate useful? Performance or latency is crucial, and

null 72 Jan 3, 2023
A tool to simplify reprovisioning a fresh OS. Installs packages and manages dotfiles.

[[TOC]] Comtrya This is better, yes? Warning This tool is ridiculously early in its development. I'm building out features as I migrate my dotfiles ov

David McKay 2 Dec 29, 2022
A tool to simplify reprovisioning a fresh OS. Installs packages and manages dotfiles.

Comtrya This is better, yes? Warning This tool is ridiculously early in its development. I'm building out features as I migrate my dotfiles over. Thos

Comtrya 272 Jan 7, 2023
Parallel finance a decentralized lending protocol built on top of the Polkadot ecosystem. Our unique approach will allow users to earn "double interests" from staking and lending their tokens simultaneously.

Parallel Finance A new Cumulus-based Substrate node, ready for hacking ?? Getting Started Follow these steps to get started with the Cumulus Template

parallel-finance 100 Dec 17, 2022
idf-env tool helps set up and manage ESP-IDF installations

idf-env Tool for maintaining ESP-IDF environment. Quick start Install serial drivers for ESP boards on Windows. Execute following command in PowerShel

Espressif Systems 19 Dec 4, 2022
A system handler to get information and interact with processes written in Rust

A system handler to get information and interact with processes written in Rust

Guillaume Gomez 1.1k Jan 3, 2023
OCI Runtime, Image and Distribution Spec in Rust

oci-spec-rs Open Container Initiative (OCI) Specifications for Rust This library provides a convenient way to interact with the specifications defined

Containers 119 Dec 29, 2022
desktop automation, screen capture, input listen/simulation, asar compress, color picker for nodejs and electron based on rust

desktop automation, screen capture, input listen/simulation, asar compress, color picker for nodejs and electron based on rust. 基于 Rust / WASM 提供截图、取色、键鼠事件监听模拟、压缩解压、图像处理、获取已安装应用等跨平台功能的现代异步 Nodejs 模块,占用空间小, 安装便捷, 使用简单, 高性能, 资源占用极小, 可取代 iohook 和 robotjs

null 48 Dec 15, 2022
`haproxy_autconfd` is a daemon that automatically assembles a HAProxy config and restarts HAProxy if the config changes

haproxy_autconfd Welcome to haproxy_autconfd ?? haproxy_autconfd is a daemon that automatically assembles a HAProxy config and restarts HAProxy if the

null 0 Nov 9, 2021
Reproducible builds, dev envs and deployments.

?? Toros An implementation of Nix in Rust. Syntax support: With NixEL Interpreter support: Int Binding (aliasing) Let-in (flat bindings without interp

Kevin Amado 35 Dec 23, 2022
A fast and minimalistic image viewer forked from the now discontinued emulsion.

Alloy Image viewer based on (now-discontinued) Emulsion. Alloy targets Windows, Mac, and Linux (with more targets to come!). A note for Linux users: W

Ardaku Systems 9 Dec 1, 2022