vergoh / vnstat-docker

vnStat in a container with image output via http
https://humdi.net/vnstat/
MIT License
107 stars 13 forks source link

Add Telegram monthly summary #18

Open tabacman86 opened 5 months ago

tabacman86 commented 5 months ago

Hi, Thank you for this container!

May I ask to add a monthly summary over Telegram to get the summary in a push?

Thanks!

vergoh commented 5 months ago

Could you clarify your request; are you looking for some new style of monthly output which would be the "monthly summary" (text or image?) or having some kind of Telegram support in the current container?

Regardless of which one of those (or even if it's not either), what kind of behaviour / configurability did you also have in mind or how would the usage flow work?

tabacman86 commented 5 months ago

Hi,

It would be great to have a monthly summary in a text message over Telegram, including the tx,rx, and total bandwidth. Additionally, we need a 'listener' feature that can 'push' the notification at the beginning of every month for the previous month's data. For example, on July 1st, I will get the monthly summary for June.

For configuration, the container should have the following ENVs:

  1. TELEGRAM_ALLOWED_ID - the chat ID the bot allows to send messages and push the notification.
  2. TELEGRAM_API_KEY - the API key of the bot that is sending this type of message
vergoh commented 5 months ago

Currently there aren't any plans on adding push notifications to vnStat directly. As for the container, it would probably make more sense to use the current container image as base and then extend with some cron capable service and the tooling necessary for sending push notifications to whichever messaging services are wanted.

However, the catch here is that usually these sort of solutions are better developed and maintained by someone actually using those messaging services (and Telegram wouldn't likely be the only one "nice to have"). As a result, I'm gravitating towards declining this feature request but I could still provide some implementation pointers if necessary from vnStat's point of view and if a suitable output can't be generated from vnStat's current options then such could be added.

JSouthGB commented 3 months ago

(and Telegram wouldn't likely be the only one "nice to have")

This library (Shoutrrr) encompasses over 15 notification services. I haven't implemented it myself. Just wanted to share, not trying to push the issue.

vergoh commented 3 months ago

@JSouthGB - Thanks, that's an interesting find. It does indeed appear to be supporting a rather large set of different services and I also like that the configuration is done using a URL which defines the used service and possible service specific parameters. That way the number of input parameters stays the same so integrating it to something wouldn't require service specific parameters to be defined.

The library is written in Go so it wouldn't be (as far as I'm aware) directly possibly to import it to vnStat (which is written in C). However, I don't really see that as a problem as I'd kind of prefer to keep any container provided extra/optional services separated from vnStat itself. Since there's also a CLI version of Shoutrrr available, that should be usable enough when paired with some cron daemon for scheduling and enough configuration options to define which output to send (some wrapper script would likely be needed for this part), when (cron configuration) and to where (Shoutrrr URL).

Looking at Shoutrrr's GitHub project page does however raise some concerns. There's already one issue open asking if the project is still alive (since there hasn't been any recent commits) which has yet to been answered and for example the notification that the Microsoft Teams API is about to change hasn't seen any reaction either. Possibly searching and comparing alternatives for Shoutrrr would be needed before starting any implementation.

JSouthGB commented 3 months ago

Looking at Shoutrrr's GitHub project page does however raise some concerns. There's already one issue open asking if the project is still alive (since there hasn't been any recent commits) which has yet to been answered and for example the notification that the Microsoft Teams API is about to change hasn't seen any reaction either. Possibly searching and comparing alternatives for Shoutrrr would be needed before starting any implementation.

I completely missed the lack of recent updates. It's the same person/group behind Watchtower, which is quite popular based on my following of the r/selfhosted subreddit, and I wrongly assumed there was active development. Looking at Watchtower, it's been without updates for the same time frame. I only know of Shoutrrr from a docker application I recently setup as it's what the app used for notifications.

A popular alternative from a quick search would possibly be Apprise. It appears to be active with a new release just three weeks ago. It also boasts of support for over 100 notification services, an API, as well as a CLI.