Giter Site home page Giter Site logo

tborychowski / unifi-event-monitor Goto Github PK

View Code? Open in Web Editor NEW
26.0 5.0 3.0 59 KB

Monitors Unifi Controller events and push them as notifications to slack (or any other platform)

Home Page: https://hub.docker.com/repository/docker/tborychowski/unifi-event-monitor

License: GNU General Public License v3.0

JavaScript 96.11% Dockerfile 3.89%
unifi-controller unifi monitoring notifications slack docker docker-image

unifi-event-monitor's Introduction

Listens for events from Unifi controller and pushes them as notifications to apprise.

Get started

Create .apprise file with your channels, e.g.:

slack://<token1>/<token2>/<token3>
mailtos://<userid>:<pass>@<domain.com>

2. Unifi Controller credentials

Create .env file with the following:

HOST=https://<controllerIP>:8443
USERNAME=<username>
PASSWORD=<password>

Setup using docker image

1. Create docker-compose.yml file:

---
version: "3.7"
services:
  unifi-event-monitor:
    container_name: unifi-event-monitor
    image: tborychowski/unifi-event-monitor
    restart: unless-stopped
    env_file:
      - ./.env
    volumes:
      - ./.apprise:/app/.apprise
      - ./blacklist.txt:/app/blacklist.txt

2a. Run:

docker-compose up -d

2b. Alternatively, you can run:

docker run -d --rm --env-file=./.env \
  --mount "type=bind,src=/absolute/path/to/.apprise,dst=/app/.apprise" \
  --mount "type=bind,src=/absolute/path/to/blacklist.txt,dst=/app/blacklist.txt" \
  tborychowski/unifi-event-monitor:latest

Filtering events

By default the app listens to all events and forwards the messages as notifications. It is possible to filter out some of the messages.

  • Create blacklist.txt file (in the same folder as the .apprise)
  • Add text of a message that you don't want to be pushed to your selected notification platform
  • You can have multiple filters, but keep 1 filter per line, e.g.
    my laptop disconnected from
    my laptop has connected to
    
  • This file is re-read before every event, so there's no need to restart the app after changing the file.

Setup locally (with nodejs)

git clone https://github.com/tborychowski/unifi-event-monitor.git
cd unifi-event-monitor
npm ci
node index.js

Credit

I used some code from: https://github.com/oznu/unifi-events

unifi-event-monitor's People

Contributors

dependabot[bot] avatar tborychowski avatar tom-sap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

unifi-event-monitor's Issues

Events not pulling into UniFi Event Monitor

First and foremost, this is an awesome project, and I'm excited to run it in my environment!

I'm currently running unifi-event-monitor in a Kubernetes cluster, and have it pointed to my UniFi Controller on the public Internet.

Looking at the environment vars, the three expected ones from the documentation are there:

HOST=https://unifi.[redacted]:8443
USERNAME=my-service-account
PASSWORD=[absolutely redacted]

And looking at the filesystem within the container, the volume mounts for the other two flat files are present, as well:

/app/.apprise

slack://[redacted]/[redacted]/[redacted]

/app/blacklist.txt

dummy text to blacklist
ensure that something is in this file and that it is populated

Looking at the pod logs, I see the following being sent to stdout:

Connected To UniFi Controller

But no events make it through to the event monitor, despite being very active within the UniFi Controller, and seeing a number of events enter the pane in the web console over the past hour. A sampling is here:

Admin Admin [REDACTED] log in from [PUBLIC IP]	1:15 am	Oct 05 2022	
[SOME SWITCH] was upgraded from "4.0.80.10875" to "6.3.13.14104"	1:10 am	Oct 05 2022	
[MAC ADDRESS] disconnected from [NETWORK NAME] (7m connected, 0 B)	1:07 am	Oct 05 2022	
[MAC ADDRESS] has connected to  with SSID [SSID] on channel 11	1:06 am	Oct 05 2022	
[SOME SWITCH] was scheduled for upgrade by Admin [USERNAME]	1:05 am	Oct 05 2022	
[MAC ADDRESS] disconnected from [SSID] (1h 43m connected, 119 KB, last )	1:05 am	Oct 05 2022	
Admin Admin [REDACTED] log in from [PUBLIC IP]	12:59 am	Oct 05 2022	

Looking in the source code, I don't see a method of turning on a debug mode via an environment variable or similar, but am open to suggestions. Any thoughts?

Thanks!

What events is it looking at?

Thank you so much for this. We have it up and running. We are using SNS notifications to push unifi events to Sumo Logic.

Wondering what events it looks for and how to control what is picked up...

In the Unifi controller I can see "push me", "alert me" and "email me" ....

Is this looking to one of those options?

thanks again!

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.