An open API service indexing awesome lists of open source software.

https://github.com/orange-cloudfoundry/netdisco-bridges

This is a suite of bridges for netdisco
https://github.com/orange-cloudfoundry/netdisco-bridges

Last synced: 11 months ago
JSON representation

This is a suite of bridges for netdisco

Awesome Lists containing this project

README

          

# Netdisco-bridges

This is a suite of bridges for [netdisco](https://github.com/netdisco/netdisco). With this you will be able:

- find devices from criteria with dns queries (with this you can plug [prometheus](https://prometheus.io/) for monitoring)
- Get reports and device information on openmetrics format (usable on [prometheus](https://prometheus.io/))
- Use an api for
- getting suite of devices (entries) in list or by domain
- getting routes associated to entries for setting access to other system

## Getting started

1. Download latest release for your system
2. Create a `config.yml` file with this content for a dev deployment

```yaml
log:
level: debug
dns_server:
listen: 127.0.0.1:8853
http_server:
listen: 127.0.0.1:8080
netdisco:
endpoint: https://my.netdisco.com
username: user
password: 'password'

entries:
- domain: all.netdisco
routing:
scheme: https
host: '{{ .IP }}'
metadata:
entryPoints: [ https ]
targets:
- q: '%'
```

3. run with `./netdisco-bridges --config config.yml`

## Usable Bridges

### As DNS

- `dig @127.0.0.1 -p 8853 all.netdisco` - Gave all IPs set for entries
- `dig @127.0.0.1 -p 8853 all.netdisco SRV` - Gave all dns set for entries
- `dig @127.0.0.1 -p 8853 all.netdisco TXT` - Gave all devices information in base64 json encoded set for entries

### With API

- `http://127.0.0.1:8080/api/v1/entries/*/routes` - Gave all http routes formatted for all entries
- `http://127.0.0.1:8080/api/v1/entries/*/routes/traefik` - Gave all http routes formatted for all entries in traefik format for using as provider
- `http://127.0.0.1:8080/api/v1/entries/{domain entry}/routes?format=default` - Gave http routes formatted for specified entry
- `http://127.0.0.1:8080/api/v1/entries` - List all entries set
- `http://127.0.0.1:8080/api/v1/entries/{domain}/devices` - Gave all devices formatted for specified entry
- `http://127.0.0.1:8080/api/v1/entries/{domain}/hosts` - Gave all devices as list of hostname as found in netdisco
- `http://127.0.0.1:8080/api/v1/entries/{domain}/ips` - Gave all devices as list of ips as found in netdisco
- `http://127.0.0.1:8080/api/v1/search/devices?q={q}` - Gave all devices found with q value, return 404 if no device found

### Prometheus metrics

Simply hit `http://127.0.0.1:8080/metrics`

## Configuration

For understanding config definition format:

- `[]` means optional (by default parameter is required)
- `<>` means type to use

### Root configuration in config.yml

```yaml
dns_server:
# set to true to disable dns server
[ disabled: ]
# Listen address for listening for dns
[ listen: | default = 0.0.0.0:53 ]

http_server:
# set to true to disable http server
[ disabled: ]
# Listen address for listening for http
[ listen: | default = 0.0.0.0:8080 or 0.0.0.0:8443 if ssl enabled ]
# set to true to enable tls
[ enable_ssl: ]
tls_pem:
# cert chain in pem format when tls enabled
[ cert_chain: ]
# private key in pem format when tls enabled
[ private_key: ]

log:
# log level to use for server
# you can chose: `trace`, `debug`, `info`, `warn`, `error`, `fatal` or `panic`
[ level: | default = info ]
# Set to true to force not have color when seeing logs
[ no_color: ]
# et to true to see logs as json format
[ in_json: ]

netdisco:
# url pointing to your netdisco
endpoint:
# Username for connecting to netdisco
username:
# Password for connecting to netdisco
password:
# set to true to not verify ssl certificate
[ insecure_skip_verify: ]

# Netdisco-bridges load devices set in entries async for performance and caching purpose over netdisco
# you can change workers profile here
workers:
# number of workers to use for loading entries
# Set more than entries is useless
[ nb_workers: | default = 5 ]
# Interval for data to be refreshed from netdisco
[ refresh_interval: | default = "25m" ]

# Set to true to disable metrics from netdisco reports
[ disable_reports_metrics: ]

# list of entry (defined below)
entries:
-
```

### entry configuration

```yaml
# Domain will be used for dns/http api for getting list of devices associated
domain:
# set to true if you want to get netdisco_device_info metrics for getting information about devices in this domain
# in openmetrics format for prometheus usage
[ enable_metrics: ]
# Netdisco search criteria, at least one is required
targets:
# Partial match of Device contact, serial, chassis ID, module serials, location, name, description, dns, or any IP alias
# % can give all device
[ q: ]
# Partial match of the Device name
[ name: ]
# Partial match of the Device location
[ location: ]
# Partial match of any of the Device IP aliases
[ dns: ]
# IP or IP Prefix within which the Device must have an interface address
[ ip: ]
# Partial match of the Device description
[ description: ]
# MAC Address of the Device or any of its Interfaces
[ mac: ]
# Exact match of the Device model
[ model: ]
# Exact match of the Device operating system
[ os: ]
# Exact match of the Device operating system version
[ os_ver: ]
# Exact match of the Device vendor
[ vendor: ]
# OSI Layer which the device must support
[ layers: ]
# If true, all fields (except “q”) must match the Device
[ matchall: ]
# routing let create an http route based on criteria for each device found in entry
# if not set no route will be associated to this set of devices
# config defined below
[ routing: ]
```

### routing configuration

Templating is allowed here, you have access to all function defined here: https://masterminds.github.io/sprig/

Device information become accessible for each value, device has those informations:

- `UptimeAge`
- `Location`
- `SinceLastArpnip`
- `FirstSeenStamp`
- `OsVer`
- `Name`
- `LastArpnipStamp`
- `Model`
- `SinceFirstSeen`
- `IP`
- `Serial`
- `SinceLastMacsuck`
- `DNS`
- `SinceLastDiscover`
- `LastMacsuckStamp`
- `LastDiscoverStamp`

```yaml
# Scheme to use to create route
[ scheme: | default = "https" ]
# Port for accessing to route
[ port: | default = not set ]
# Host to set for the route
[ host: | default = not set ]
# metadata for let formatter do its magic
# for now, only traefik use it
# you can set `entryPoints` for traefik
# `enableTls` to true to enable resolve on traefik on tls also
# 'middlewares' is a list of string setting middleare to use on traefik
metadata:
:
```