From 53375ff559c8a326afd3e5f8f4e947254fe9d672 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Tue, 15 Mar 2022 08:27:17 -0400 Subject: [PATCH] Examples --- docs/deprecations.md | 4 ++-- docs/examples.md | 31 +++++++++++++++++++++++++++++++ docs/faq.md | 7 ++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/docs/deprecations.md b/docs/deprecations.md index 133a8314..e34b492a 100644 --- a/docs/deprecations.md +++ b/docs/deprecations.md @@ -5,13 +5,13 @@ This page is used to list deprecation notices for ntfy. Deprecated commands and ## Active deprecations ### Android app: WebSockets will become the default connection protocol -> since 2022-03-13 +> since 2022-03-13, behavior will change in **June 2022** In future versions of the Android app, instant delivery connections and connections to self-hosted servers will be using the WebSockets protocol. This potentially requires [configuration changes in your proxy](https://ntfy.sh/docs/config/#nginxapache2caddy). ### Android app: Using `since=` instead of `since=` -> since 2022-02-27 +> since 2022-02-27, behavior will change in **May 2022** In about 3 months, the Android app will start using `since=` instead of `since=`, which means that it will not work with servers older than v1.16.0 anymore. This is to simplify handling of deduplication in the Android app. diff --git a/docs/examples.md b/docs/examples.md index 67aa73ff..ebcc37d2 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -16,6 +16,27 @@ rsync -a root@laptop /backups/laptop \ || curl -H tags:warning -H prio:high -d "Laptop backup failed" ntfy.sh/backups ``` +## Low disk space alerts +Here's a simple cronjob that I use to alert me when the disk space on the root disk is running low. It's simple, but +effective. + +``` bash +#!/bin/bash + +mingigs=10 +avail=$(df | awk '$6 == "/" && $4 < '$mingigs' * 1024*1024 { print $4/1024/1024 }') +topicurl=https://ntfy.sh/mytopic + +if [ -n "$avail" ]; then + curl \ + -d "Only $avail GB available on the root disk. Better clean that up." \ + -H "Title: Low disk space alert on $(hostname)" \ + -H "Priority: high" \ + -H "Tags: warning,cd" \ + $topicurl +fi +``` + ## Server-sent messages in your web app Just as you can [subscribe to topics in the Web UI](subscribe/web.md), you can use ntfy in your own web application. Check out the live example or just look the source of this page. @@ -93,3 +114,13 @@ Or, if you only want to send notifications using shoutrrr: ``` shoutrrr send -u "generic+https://ntfy.sh/my_watchtower_topic?title=WatchtowerUpdates" -m "testMessage" ``` + +## Random cronjobs +Alright, here's one for the history books. I desperately want the `github.com/ntfy` organization, but all my tickets with +GitHub have been hopeless. In case it ever becomes available, I want to know immediately. + +``` cron +# Check github/ntfy user +*/6 * * * * if curl -s https://api.github.com/users/ntfy | grep "Not Found"; then curl -d "github.com/ntfy is available" -H "Tags: tada" -H "Prio: high" ntfy.sh/my-alerts; fi +~ +``` diff --git a/docs/faq.md b/docs/faq.md index 5105cc85..a1c385e2 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -33,10 +33,11 @@ If you do not care for Firebase, I suggest you install the [F-Droid version](htt of the app and [self-host your own ntfy server](install.md). ## How much battery does the Android app use? -If you use the ntfy.sh server and you don't use the [instant delivery](subscribe/phone.md#instant-delivery) feature, +If you use the ntfy.sh server, and you don't use the [instant delivery](subscribe/phone.md#instant-delivery) feature, the Android app uses no additional battery, since Firebase Cloud Messaging (FCM) is used. If you use your own server, -or you use *instant delivery*, the app has to maintain a constant connection to the server, which consumes about 4% of -battery in 17h of use (on my phone). I use it, and it makes no difference to me. +or you use *instant delivery*, the app has to maintain a constant connection to the server, which consumes about 0-1% of +battery in 17h of use (on my phone). There has been a ton of testing and improvement around this. I think it's pretty +decent now. ## What is instant delivery? [Instant delivery](subscribe/phone.md#instant-delivery) is a feature in the Android app. If turned on, the app maintains a constant connection to the