npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dhcpd-notifier

v1.0.1

Published

Alert (notify) when dhcpd gives out new leases over Pushover or stdout

Downloads

6

Readme

dhcpd-notifier

Alert (notify) when dhcpd gives out new leases

NOTE: This is a command-line tool to be run as a daemon

Installation

[sudo] npm install -g dhcpd-notifier

Usage

Create a configuration JSON file

{
  "leases": "/var/db/isc-dhcp/dhcpd.leases",
  "interval": 10,
  "loglevel": "debug",
  "aliases": {
    "00:00:00:00:00:01": "My Custom Host"
  },
  "ignore": [
    "00:00:00:00:00:02"
  ],
  "exec": {
    "file": "./example-script",
    "timeout": 30
  }
}

exec.file is a script/program that will be executed whenever a new lease is given that will contain lease information passed in as environmental variables, see example-script as an example.

Start the daemon with the config - logging is done via bunyan

$ dhcpd-notifier example-config.json | bunyan
[2018-04-09T18:16:59.231Z] DEBUG: dhcpd-notifier/10312 on dhcp.rapture.com: loaded config
config: {
  "leases": "/var/db/isc-dhcp/dhcpd.leases",
  "interval": 10,
  "loglevel": "debug",
  "aliases": {
    "00:00:00:00:00:01": "My Custom Host"
  },
  "ignore": [
    "00:00:00:00:00:02"
  ],
  "exec": {
    "file": "./example-script",
    "timeout": 30
  }
}
[2018-04-09T18:16:59.236Z]  INFO: dhcpd-notifier/10312 on dhcp.rapture.com: watching file /var/db/isc-dhcp/dhcpd.leases for changes every 10 seconds
[2018-04-09T18:17:39.336Z]  INFO: dhcpd-notifier/10312 on dhcp.rapture.com: new lease: "DESKTOP-FH2DLSM" 10.0.1.183 c8:3a:35:XX:XX:XX (n/a)
[2018-04-09T18:17:39.340Z] DEBUG: dhcpd-notifier/10312 on dhcp.rapture.com: executing "./example-script"
opts: {
  "env": {
    "USER": "dave",
    "PATH": "/opt/local/sbin:/opt/local/bin:/opt/custom/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/dave/bin",
    "PWD": "/home/dave/dev/node-dhcpd-notifier",
    "LANG": "en_US.UTF-8",
    "TZ": "US/Eastern",
    "HOME": "/home/dave",
    "DHCPD_NOTIFIER_LEASE": "{\"ip\":\"10.0.1.183\",\"starts\":\"2018-04-09T18:17:35.000Z\",\"ends\":\"2018-04-09T20:17:35.000Z\",\"cltt\":\"2018-04-09T18:17:35.000Z\",\"binding state\":\"active\",\"next binding state\":\"free\",\"rewind binding state\":\"free\",\"hardware ethernet\":\"c8:3a:35:XX:XX:XX\",\"uid\":\"\\\\001\\\\310:5\\\\300\\\\305\\\\024\",\"set vendor-class-identifier\":\"= \\\"MSFT 5.0\\\"\",\"client-hostname\":\"DESKTOP-FH2DLSM\"}",
    "DHCPD_NOTIFIER_ALIAS": "",
    "DHCPD_NOTIFIER_HOSTNAME": "DESKTOP-FH2DLSM",
    "DHCPD_NOTIFIER_MAC": "c8:3a:35:XX:XX:XX",
    "DHCPD_NOTIFIER_IP": "10.0.1.183"
  },
  "timeout": 30000,
  "encoding": "utf8"
}
[2018-04-09T18:17:39.405Z] DEBUG: dhcpd-notifier/10312 on dhcp.rapture.com: execution succeeded (stderr="")
stdout: dhcp lease for 'DESKTOP-FH2DLSM' (alias=) 10.0.1.183 - c8:3a:35:XX:XX:XX

Configuration

  • config.leases the dhcpd.leases(5) file used by dhcpd
  • config.interval number of seconds to reread the leases file
  • config.aliases a mapping of mac address to custom host name to be used when a new lease is found. This is useful if a host does not provide an accurate hostname when requesting a lease
  • config.ignore an array of mac address to ignore when generating notifications
  • config.loglevel bunyan log level to use, defaults to info
  • config.exec.file program/script to execute when a new lease is given
  • config.exec.timeout timeout (in seconds) to allow config.exec.file to run

License

MIT License