Created
May 28, 2019 10:54
-
-
Save kurochan/07ab93e66b6d0e9bb0ad48f174853ed2 to your computer and use it in GitHub Desktop.
custom_dhcpd.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init_config: | |
instances: | |
- name: scala-matsuri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment