Beaujr / nmap_prometheus

Monitoring house with NMAP / Prometheus
GNU General Public License v3.0
12 stars 2 forks source link

nmap_prometheus

A client/server application set for exporting nmap results to prometheus metrics.

Metrics

# Example
home_detector_device{ip="192.168.1.5",mac="31:AB:CF:34:B1:2L",name="Beaus Phone"} 1
home_detector_device_lastseen{ip="192.168.1.5",mac="31:AB:CF:34:B1:2L",name="Beaus Phone"} 1.592911572e+09

One of each of the above metrics will be posted for each device found on the network.

home_detector_device is 1 if away=false and 0 if away=true home_detector_device_lastseen is a unix timestamp of the last time it was reported to the server.

Design

GOOS & GOARCH

Docker builds are multiplatform for armv7 and amd64

Tested and working on RaspberryPi 3 and Intel Nuc

Client

The client is a gRPC/nmap client application which communicates with the server.

Made possible due to Ullaakut/nmap

Flags

    -server=<nmap_prometheus_server>:<port>
    -subnet=<your subnet range>

Server

The Server is a GRPC server which accepts and logs the payloads as prometheus metrics.

 --timeout <number of seconds since last reported used determine device away>

Currently all detected devices will be saved to a config/devices.yaml file.

The initial plan was for the server to talk to:

This will be supported in limited capacity with the following flags.

  --assistant=https://<assistant_relay_url>
  --assistantUser=<your_assistant_relay_user>
  --fcm=https://<go_fcm_server>/fcm/send/<topic>

Devices.yaml

Example

- id:
    ip: 192.168.1.110
    mac: 31:AB:CF:34:B1:2L
  lastseen: 1592902392
  away: false
  name: Beau
  person: true
  command: ""
  smart: false

Fields

Name Type Description Example
Id Object Mac & Ip Address see above
lastSeen int64 Unix Timestamp of the last time the device was reported 1592902392
away bool Device hasn't been reported for > the servers --timeout flag true
name string Device Name, defaults to devices Mac / Ip TV
person bool if set to true will update false
command string Command to get state from Assistant relay Is The TV On?
smart bool If true will used command string to get state from Assistant Relay | true

Debug

   --debug=true

This disables the server trying to talk to other services.

The initial plan was for the server to talk to:

This will be supported in limited capacity with the following flags.

  --assistant=https://<assistant_relay_url>
  --assistantUser=<your_assistant_relay_user>
  --fcm=https://<go_fcm_server>/fcm/send/<topic>

Installation