ISC DHCP Scopes
Monitor linux dhcp pools with telegraf, influxdb and dhcpd-pools
monitor isc-dhcpd servers with telegraf, influxdb, dhcpd-pools, dhcpd

install dhcpd-pools  -  http://dhcpd-pools.sourceforge.net/

create a short script...

#!/bin/bash


/usr/local/bin/dhcpd-pools -c /etc/dhcp/dhcpd.conf --format=j > /var/www/html/dhcpd/dhcpd.json

test by hand... 


create telegraf config file

[[inputs.http]]

urls = [ "http://dhcp.host.address/dhcpd/dhcpd.json" ]

method = "GET"

timeout = "15s"

data_format = "json"

json_string_fields = ["fields.*"]

name_override = "dhcpd_stats"



once that's all working and tested manually, import the dashboard and update the queries to reflect the urls you're collecting from.

Last step is to add the script you created to the cron of the dhcpd server. I run it once a minute.

note: the gauge is calculated with nested select statements
{
  "__inputs": [
    {
      "name": "DS_TELEGRAPH",
      "label": "telegraph",
      "description": "dhcpd isc-dhcpd telegraf influxdb json linux http",
      "type": "datasource",
      "pluginId": "influxdb",
      "pluginName": "InfluxDB"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.7.3"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "influxdb",
      "name": "InfluxDB",
      "version": "1.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "$$hashKey": "object:2480",
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 12373,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_TELEGRAPH}",
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 0,
        "y": 0
      },
      "id": 17,
      "options": {
        "fieldOptions": {
          "calcs": [
            "last"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            },
            "unit": "percent"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "auto",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.3",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "orderByTime": "ASC",
          "policy": "default",
          "query": "SELECT 100*(\"mean_subnets_0_used\" / \"mean_subnets_0_defined\") from (\n\nSELECT mean(\"subnets_0_used\") AS \"mean_subnets_0_used\", mean(\"subnets_0_defined\") AS \"mean_subnets_0_defined\" FROM \"telegraf\".\"autogen\".\"dhcpd_stats\" WHERE \"url\"='http://dhcp.host.add.ress/iperf/dhcpd.json'  AND $timeFilter GROUP BY time($__interval)\n\n) ;",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Scope Used",
      "type": "gauge"
    },
    {
      "aliasColors": {
        "Free": "dark-green",
        "In Use": "dark-red",
        "Scope Size": "blue"
      },
      "bars": false,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_TELEGRAPH}",
      "decimals": 0,
      "description": "Touched IP - Number of IP’s which appear in the lease file, but who’s leases have expired. A touched IP is either expired or abandoned. The touched IP count is somewhat misleading when you try to determine if an IP pool is big enough; it is a better indicator of whether a pool is too large.",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 20,
        "x": 4,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 15,
      "interval": "",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sideWidth": null,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Scope Size",
          "fill": 0,
          "linewidth": 3
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "$col",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "dhcpd_stats",
          "orderByTime": "ASC",
          "policy": "autogen",
          "query": "SELECT mean(\"noAddFree0.0\") AS \"Scope0.0-Free\", mean(\"noAddInUse0.0\") AS \"Scope0.0-InUse\", mean(\"noAddFree201.0\") AS \"Scope201.0-Free\", mean(\"noAddInUse201.0\") AS \"Scope201.0-InUse\", sum(\"noAddFree0.0\",\"noAddInUse0.0\") FROM \"snmp\" WHERE (\"hostname\" = 'some.other.host.addr') AND $timeFilter GROUP BY time($__interval) fill(null)",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "subnets_0_defined"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "Scope Size"
                ],
                "type": "alias"
              }
            ]
          ],
          "tags": [
            {
              "key": "url",
              "operator": "=",
              "value": "http://dhcp.server.add.ress/iperf/dhcpd.json"
            }
          ]
        },
        {
          "alias": "$col",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "dhcpd_stats",
          "orderByTime": "ASC",
          "policy": "autogen",
          "query": "SELECT mean(\"subnets_0_used\") AS \"In Use\", mean(\"subnets_0_touched\") AS \"Touched\", mean(\"subnets_0_free\") AS \"Free\" FROM \"autogen\".\"dhcpd_stats\" WHERE (\"url\" = 'http://dhcp.server.add.ress/iperf/dhcpd.json') AND $timeFilter GROUP BY time($__interval) fill(null)",
          "rawQuery": false,
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "subnets_0_used"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "In Use"
                ],
                "type": "alias"
              }
            ],
            [
              {
                "params": [
                  "subnets_0_touched"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "Touched"
                ],
                "type": "alias"
              }
            ],
            [
              {
                "params": [
                  "subnets_0_free"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "Free"
                ],
                "type": "alias"
              }
            ]
          ],
          "tags": [
            {
              "key": "url",
              "operator": "=",
              "value": "http://shcp.server.add.ress/iperf/dhcpd.json"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "DHCP 192.168.2.0",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "transparent": true,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": "1m",
  "schemaVersion": 22,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-7d",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "ISC DHCP Scopes",
  "uid": "Vqb2AhkMk",
  "variables": {
    "list": []
  },
  "version": 6,
  "description": "Monitor linux dhcp pools with telegraf, influxdb and dhcpd-pools"
}