mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
implemented apprise notifications + readme updates
This commit is contained in:
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
jokobsk/pi.alert
|
||||
jokobsk/pi.alert_dev
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
|
||||
10
README.md
10
README.md
@@ -23,13 +23,13 @@ JavaScript)*
|
||||
<img alt="Docker last pushed" src="https://img.shields.io/badge/dynamic/json?color=blue&label=Last%20pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&?link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert">
|
||||
</a>
|
||||
|
||||
🥇 Pi.Alert credit goes to [pucherot/Pi.Alert](https://github.com/pucherot/Pi.Alert). <br/>
|
||||
🐳 Docker Image: [jokobsk/Pi.Alert](https://registry.hub.docker.com/r/jokobsk/pi.alert). <br/>
|
||||
🥇 Pi.Alert credit goes to [pucherot/Pi.Alert](https://github.com/pucherot/Pi.Alert) <br/>
|
||||
🐳 Docker Image: [jokobsk/Pi.Alert](https://registry.hub.docker.com/r/jokobsk/pi.alert) <br/>
|
||||
📄 [Dockerfile](https://github.com/jokob-sk/Pi.Alert/blob/main/Dockerfile) <br/>
|
||||
📚 [Dockerfile instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md).
|
||||
📚 [Dockerfile instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md)
|
||||
|
||||
|
||||
Dark mode (and Device presence over time) within this fork courtesy of [leiweibau](https://github.com/leiweibau/Pi.Alert)
|
||||
Dark mode (and much more) within this fork courtesy of [leiweibau](https://github.com/leiweibau/Pi.Alert)
|
||||
|
||||
## How it works
|
||||
The system continuously scans the network for:
|
||||
@@ -61,7 +61,7 @@ In charge of:
|
||||
- Scan the network searching connected devices using the scanning methods
|
||||
described
|
||||
- Store the information in the DB
|
||||
- Report the changes detected by e-mail and/or other services (Pushsafer, NTFY, Gotify, Webhooks ([sample JSON](docs/webhook_json_sample.json)))
|
||||
- Report the changes detected by e-mail and/or other services ([Apprise](https://hub.docker.com/r/caronc/apprise), [Pushsafer](https://www.pushsafer.com/), [NTFY](https://ntfy.sh/), Webhooks ([sample JSON](docs/webhook_json_sample.json)))
|
||||
- Optional speedtest for Device "Internet"
|
||||
- DB cleanup tasks via cron
|
||||
- a pialert-cli that helps to configure login and password
|
||||
|
||||
@@ -1424,6 +1424,11 @@ def email_reporting ():
|
||||
send_email (mail_text, mail_html)
|
||||
else :
|
||||
print (' Skip mail...')
|
||||
if REPORT_APPRISE :
|
||||
print (' Sending report by Apprise...')
|
||||
send_apprise (mail_html)
|
||||
else :
|
||||
print (' Skip Apprise...')
|
||||
if REPORT_WEBHOOK :
|
||||
print (' Sending report by webhook...')
|
||||
send_webhook (json_final)
|
||||
@@ -1602,10 +1607,24 @@ def send_webhook (_json):
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
# write stdout and stderr into .log files for debugging if needed
|
||||
if stderr != None:
|
||||
append_file_binary (LOG_PATH + '/stderr.log', stderr)
|
||||
if stdout != None:
|
||||
append_file_binary (LOG_PATH + '/stdout.log', stdout)
|
||||
logResult (stdout, stderr)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
def send_apprise (html):
|
||||
#Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution)
|
||||
_json_payload={
|
||||
"urls": APPRISE_URL,
|
||||
"title": "Pi.Alert Notifications",
|
||||
"format": "html",
|
||||
"body": html
|
||||
}
|
||||
|
||||
p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), APPRISE_HOST], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
# write stdout and stderr into .log files for debugging if needed
|
||||
logResult (stdout, stderr)
|
||||
|
||||
|
||||
#===============================================================================
|
||||
@@ -1744,6 +1763,14 @@ def add_json_list (row, list):
|
||||
|
||||
return list
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
def logResult (stdout, stderr):
|
||||
if stderr != None:
|
||||
append_file_binary (LOG_PATH + '/stderr.log', stderr)
|
||||
if stdout != None:
|
||||
append_file_binary (LOG_PATH + '/stdout.log', stdout)
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# BEGIN
|
||||
|
||||
@@ -36,6 +36,12 @@ REPORT_DASHBOARD_URL = 'http://pi.alert/'
|
||||
REPORT_WEBHOOK = False
|
||||
WEBHOOK_URL = 'http://n8n.local:5555/webhook-test/aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaaaa'
|
||||
|
||||
# Apprise settings
|
||||
#-----------------------
|
||||
REPORT_APPRISE = False
|
||||
APPRISE_HOST = 'http://localhost:8000/notify'
|
||||
APPRISE_URL = 'mailto://smtp-relay.sendinblue.com:587?from=user@gmail.com&name=apprise&user=user@gmail.com&pass=password&to=user@gmail.com'
|
||||
|
||||
# NTFY (https://ntfy.sh/) settings
|
||||
# ----------------------
|
||||
REPORT_NTFY = False
|
||||
@@ -64,6 +70,7 @@ DHCP_ACTIVE = False
|
||||
DHCP_LEASES = '/etc/pihole/dhcp.leases'
|
||||
|
||||
# arp-scan options & samples
|
||||
# ----------------------
|
||||
#
|
||||
# Scan local network (default)
|
||||
# SCAN_SUBNETS = '--localnet'
|
||||
@@ -79,3 +86,4 @@ SCAN_SUBNETS = '--localnet'
|
||||
# Maintenance Tasks Cron
|
||||
# ----------------------
|
||||
DAYS_TO_KEEP_EVENTS = 90
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
# 🐳 A docker image for Pi.Alert
|
||||
|
||||
🥇 Pi.Alert credit goes to [pucherot/Pi.Alert](https://github.com/pucherot/Pi.Alert). <br/>
|
||||
🐳 Docker Image: [jokobsk/Pi.Alert](https://registry.hub.docker.com/r/jokobsk/pi.alert). <br/>
|
||||
🥇 Pi.Alert credit goes to [pucherot/Pi.Alert](https://github.com/pucherot/Pi.Alert) <br/>
|
||||
🐳 Docker Image: [jokobsk/Pi.Alert](https://registry.hub.docker.com/r/jokobsk/pi.alert) <br/>
|
||||
📄 [Dockerfile](https://github.com/jokob-sk/Pi.Alert/blob/main/Dockerfile) <br/>
|
||||
📚 [Dockerfile instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md).
|
||||
📚 [Dockerfile instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md)
|
||||
|
||||
Big thanks to <a href="https://github.com/Macleykun">@Macleykun</a> for help and tips&tricks for Dockerfile(s):
|
||||
|
||||
|
||||
@@ -573,7 +573,7 @@ function PiaToggleArpScan()
|
||||
// laod footer asynchronously not to block the page load/other sections
|
||||
window.onload = function asyncFooter()
|
||||
{
|
||||
$("#lastCommit").append('<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/jokob-sk/pi.alert/main?logo=github&style=plastic">');
|
||||
$("#lastCommit").append('<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/jokob-sk/pi.alert/main?logo=github">');
|
||||
|
||||
$("#lastDockerUpdate").append(
|
||||
'<img alt="Docker last pushed" src="https://img.shields.io/badge/dynamic/json?color=blue&label=Last%20pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&?link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert">');
|
||||
|
||||
Reference in New Issue
Block a user