jordiromancastells / device-monitor-daemon

PHP script that scans local network devices and saves them on Firebase Realtime Database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Device Monitor Daemon

PHP script that scans local network devices and saves them on Firebase Realtime Database

New devices are registered and you can set a timeout to delete old devices. Device can also be marked as "persistent" in order to not be deleted

There is a POC about how to use generated data : https://github.com/ibonkonesa/device-monitor-client

Installation

Clone this repository

$ git clone https://github.com/ibonkonesa/device-monitor-daemon.git

Install composer dependencies

$ composer install

Configuration

There is a .env file where you can set some parameters. Firstly copy or rename the .env.example file

$ cp .env.example .env

The avalaible parameters are:

-DELETE_INACTIVE_DEVICES (boolean): delete devices after a time

-DELETE_INACTIVE_DEVICES_AFTER (string): relative time. Example: 5 minutes, 1 hour, 2 days

-INTERFACE: network interface. Example: eth0, wlan0

-ARP_SCAN_PATH: absolute path for arp-scan binary (cron needs that that path is absolute)

-NOTIFY_NEW_DEVICE (boolean): send push notification to deviceNew topic

-NOTIFY_DELETE_DEVICE (boolean): send push notification to deviceDelete topic

Firebase

You also need to start a Firebase project and download the google-services-account.json

Directions are avalaible here: https://firebase.google.com/docs/admin/setup?hl=es-419

Once you have created the project, you should put the google-service-account.json file in the project's root path

Update rules:

{
  "rules": {
    ".read": true,
    ".write": true,
      
      "devices": {
       ".indexOn": ["mac", "timestamp"]
    }
  }
}

Execution

You must launch this script as a regular user using sudo

$ sudo php daemon.php

or you can set a cron task using root user

* * * * * php /path/to/script/daemon.php

About

PHP script that scans local network devices and saves them on Firebase Realtime Database

License:MIT License


Languages

Language:PHP 100.0%