Skip to content

Instantly share code, notes, and snippets.

@kurochan
Created May 28, 2019 10:54
Show Gist options
  • Save kurochan/07ab93e66b6d0e9bb0ad48f174853ed2 to your computer and use it in GitHub Desktop.
Save kurochan/07ab93e66b6d0e9bb0ad48f174853ed2 to your computer and use it in GitHub Desktop.
custom_dhcpd.py
from datadog_checks.checks import AgentCheck
from isc_dhcp_leases import IscDhcpLeases
__version__ = "0.0.1"
class DhcpCheck(AgentCheck):
def check(self, instance):
name = instance['name']
lease_file_path = '/var/lib/dhcp/dhcpd.leases'
location = None
if instance.has_key('location'):
location = instance['location']
if instance.has_key('lease_file_path'):
location = instance['lease_file_path']
leases = IscDhcpLeases(lease_file_path)
lease_count = len(leases.get_current())
self.gauge('custom_dhcpd.lease_count', lease_count, tags = ["name:%s" % name, "location:%s" % location])
init_config:
instances:
- name: scala-matsuri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment