Giter Club home page Giter Club logo

glass-isc-dhcp's Introduction

npm License: MIT

Glass Glass

  • Glass was created as a quick side project out of necessity to fulfill requirements not readily available through our production ISC DHCP Servers for our organization - I've decided to share it for anyone who would also find it useful
  • More features and application-level things could be extended into the interface but my goals were simply the high yield features for our production network needs
  • Disclaimer: Glass and its author has no affiliation with ISC and the authors of isc-dhcp-server
  • Original Author: Chris Miles: [email protected]

Table of Contents

Features

  • Standalone NodeJS application that has a web interface, listens to the dhcp log and the leases file to collect analytics and data realtime
  • DHCP IPv4 Support (No IPv6 at this time)
  • Full OUI Database
    • Has complete vendor to MAC OUI database - with a script to pull down and update live data
  • Realtime Alerting
    • Shared Subnet Utilization Alerting
      • Customize thresholds (IE: Warning: 80% Critical 95%)
    • Leases Per Minute - If your disk fills up - or your SAN is unavailable - alerting your team on absolutely zero activity on your production server can allow you to be on the 8-ball. This is a step-above process alerting because you can have the dhcp server process running and no leases being written
  • Alerting Destinations
    • Slack
    • E-Mail
    • SMS
  • Statistics (Available through REST API)
    • Shared Network Utilization
    • Individual Network Utilization
    • Vendor Counts by MAC
    • OUI Count
    • Excessive DHCP Requests
  • Log Streaming (Realtime via Websockets)
  • Lease Data
    • Full active DHCP lease data available via API and searchable through the web interface
    • All options are dynamically parsed into an easy to ingest JSON format
  • Config Edit (Only supports single DHCP config file configurations)
    • Edit the DHCP config using a full web-based text editor (Ace)
    • Before saving the config - Glass will run a syntax check against the file
    • Config editing through Glass creates a backup (snapshot) on success with no syntax errors and commits to production file * Start / Stop / Restart server process * Administrative Authentication enforced on administrative tasks (Restarts/Config/Glass Settings)
  • Uses AdminBSB UI with customizations and tweaks
  • Full Mobile support

Dashboard

  • Glass has a dashboard containing quick-glance important information pertaining to the health of the server and the pools configured - statistics update in realtime
    • DHCP Leases per second / minute
    • Total Active Leases
    • Server CPU Utilization
    • Shared Network Utilization
    • Subnet Utilization

dashboard_1

DHCP Config Editing

  • A built in config web editor that uses the dhcp server binary to check syntax before over-writing the production config with a bad configuration
  • Currently config editing only supports editing one single config file (No includes) due to syntax verification that glass performs

dhcp_config

DHCP Config Snapshots

  • Mess up a config? Snapshots are quickly available through the snapshots sidebar as long as you've been editing the config through the Glass interface

dhcp_config_snapshots

DHCP Server Restart

  • Server Stop / Start / Restarting can all be done through the Glass interface

dhcp_server_restart

Statistics

  • Glass exposes useful statistical information in the Web interface that is also available through the raw API interface

statistics_1

Log Streaming

  • Stream the DHCP syslog via Websockets to your browser, making troubleshooting efforts super easy by being able to add realtime filters and have MAC address be translated realtime to the vendor for readability

dhcp_log_stream_filter

log_stream

Glass API

  • Glass has a small but powerful REST API exposing data not otherwise available easily through raw isc-dhcp-server data formats

api_examples

Alerting

  • Realtime Alerting One of our biggest high value returns on this project was creating something that can keep us on top of any sort of outage issues.
    • "Is our server writing leases even though the process is alive?"
    • "Is any our shared networks filling up?"
  • Shared Subnet Utilization Alerting (Checked once a minute)
    • Customize thresholds
      • Default 80 (Warning)
      • Default 95 (Critical)
  • Leases Per Minute (Checked once every 5 seconds) - If your disk fills up - or your SAN is unavailable - alerting your team on absolutely zero activity on your production server can allow you to be on the 8-ball. This is a step-above process alerting because you can have the dhcp server process running and no leases being written.
    • Default: 50
    • Glass keeps track of a rolling average of leases being written on the minute, the counter can be seen realtime on the dashboard
  • 0 value in Glass Settings or in your glass_config.json will turn the alerting functionality OFF

Alert Delivery Methods

  • Glass currently supports the following alerting delivery methods

E-Mail

Slack

SMS - Simple Format

  • SMS gets cut off at 140 characters - but you get the core alert and should only be used as a backup measure to other methods

Installation

  • Instructions are per Debian/Ubuntu Distros

Install NodeJS (If not installed)

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Glass (as root)

cd /opt
git clone https://github.com/Akkadius/glass-isc-dhcp.git
cd glass-isc-dhcp
mkdir logs
chmod u+x ./bin/ -R
chmod u+x *.sh

sudo npm install
sudo npm install forever -g
sudo npm start
  • For Debian this is all that is needed and Glass should start immediately, you can browse via http://server-ip:3000
  • For Ubuntu users - you will have additional Apparmor config to add
  • Recommended to iptables port 3000 to close off Glass if you are facing the public on your server
  • Recommended to keep Glass up through reboots, see Glass Process Keepalive

Apparmor

  • Ubuntu uses AppArmor by default - you will most likely run into file access issues without exemptions
sed -i '/\/etc\/dhcp\/\*\*/a\ \ \/var\/lib\/dhcp\/\*\* lrw,' /etc/apparmor.d/usr.sbin.dhcpd 
sed -i '/\/etc\/dhcp\/\*\*/a\ \ \/opt\/glass-isc-dhcp\/\*\* lrw,' /etc/apparmor.d/usr.sbin.dhcpd 
service apparmor restart

Glass Configuration

  • Glass configuration is stored in ./config/glass_config.json
  • All of these settings can be edited in both Glass Settings and Glass Alerts within the Web Interface, if you have custom file locations you will need to edit this config file before starting

Defaults

{
  "admin_user": "glassadmin",
  "admin_password": "glassadmin",
  "leases_file": "/var/lib/dhcp/dhcpd.leases",
  "log_file": "/var/log/dhcp.log",
  "config_file": "/etc/dhcp/dhcpd.conf",
  "shared_network_critical_threshold": "95",
  "shared_network_warning_threshold": "0",
  "slack_webhook_url": "",
  "slack_alert_channel": "",
  "leases_per_minute_threshold": "50",
  "ip_ranges_to_allow": [
    ""
  ],
  "email_alert_to": "",
  "sms_alert_to": ""
}

Glass Process Keepalive

  • To keep your server alive through reboots, possible crashes and process restarts, we need to use a process monitor and for simplicity we will use NodeJS's Forever. Forever is already installed during Glass installation. We will add it to our crontab
crontab -l > mycrontab
echo "@reboot cd /opt/glass-isc-dhcp && /usr/bin/forever --minUptime 10000 --spinSleepTime 10000 -a -o ./logs/glass-process.log -e ./logs/glass-error.log ./bin/www" >> mycrontab
crontab mycrontab
rm mycrontab

Secure your Server

  • Glass runs on web port 3000 - if you're going to run this on a production server, make sure that you lock it down from the outside world if anyone can access it. Even if they don't have a password - vulnerabilities can surface at any point in the future and your system becomes a prime target

iptables (Recommended)

iptables -A INPUT -p tcp --dport 3000 -s 127.0.0.0/8 -j ACCEPT
iptables -A INPUT -p tcp --dport 3000 -s x.x.x.x/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 3000 -j REJECT --reject-with icmp-port-unreachable

Building dhcpd-pools (Optional)

  • Glass uses dhcpd-pools for shared network / subnet utilization and it is bundled by default (For Ubuntu and Debian) when you install. However, if you need to build the binary yourself on another distribution, use the following to build dhcpd-pools and it needs to be placed in the ./bin directory of glass
  • Below shows use of apt-get of unzip/libtool - you will have to use your respective package management system to pull pre-requisites down
  • Credit: dhcpd-pools: http://dhcpd-pools.sourceforge.net/
sudo apt-get install -y unzip
sudo apt-get install -y libtool

git clone https://github.com/Akkadius/dhcpd-pools.git

cd /tmp
wget https://github.com/troydhanson/uthash/archive/master.zip
unzip master.zip

cd /tmp/dhcpd-pools
./bootstrap	# only when building git clone
./configure --with-uthash=/tmp/uthash-master/include
make -j4
make check
make install

Glass API

Use Cases

  • If none of the in-web management features are appealing - at the very least the exposed real time data the Glass agent can expose via the API can be valuable in integrating with 3rd party applications. For example - if you need to query 5 DHCP servers for one device on a network - this makes it incredibly efficient to do so with real-time and accurate data
  • If you want to get all subnet details/utilization exposed into a 3rd party application, (For example graphing utilization in grafana) you can use the API calls to ingest into your InfluxDB or otherwise

Example Calls

GET: /api/get_active_leases

  • This call will return the full lease list unless you pass optional search parameter:
    • Ex: /api/get_active_leases?search=Cisco

Output example truncated - some info redacted

  "64.90.X.X": {
    "start": 1507177832,
    "end": 1507181432,
    "mac": "14:91:82:6e:77:0a",
    "mac_oui_vendor": "Belkin International Inc.",
    "options": {
      "ClientMac": "14:91:82:6e:77:a",
      "ClientIP": "64.90.X.X",
      "vendor-class-identifier": "udhcp 1.19.4",
      "vendor-string": "udhcp 1.19.4",
      "agent.remote-id": "3:c:0:0:d1:d4:29:81:f6:3:2:8a:0:be"
    },
    "host": "Vargo"
  },
  "209.212.X.X": {
    "start": 1507177401,
    "end": 1507181001,
    "mac": "20:aa:4b:12:bd:9b",
    "mac_oui_vendor": "Cisco-Linksys, LLC",
    "options": {
      "ClientMac": "20:aa:4b:12:bd:9b",
      "ClientIP": "209.212.X.X",
      "agent.remote-id": "3:c:0:0:d1:d4:29:81:f6:3:1:4e:4:51"
    },
    "host": "snarley55"
  },
...

GET: /api/get_subnet_details

Output example truncated - some info redacted

{
  "subnets": [
    {
      "location": "69.168.x.x/26",
      "range": "69.168.x.x - 69.168.x.x",
      "defined": 55,
      "used": 0,
      "touched": 0,
      "free": 55
    },
    {
      "location": "10.70.48.0/21",
      "range": "10.70.48.2 - 10.70.55.254",
      "defined": 2045,
      "used": 0,
      "touched": 0,
      "free": 2045
    },
...

GET: /api/get_mac_oui_list

Output example truncated - some info redacted

{
  "100000": "Private",
  "100501": "PEGATRON CORPORATION",
  "100723": "IEEE Registration Authority",
  "101212": "Vivo International Corporation Pty Ltd",
  "101218": "Korins Inc.",
  "101248": "ITG, Inc.",
  "101250": "Integrated Device Technology (Malaysia) Sdn. Bhd.",
  "101331": "Technicolor",
  "102279": "ZeroDesktop, Inc.",
...

GET: /api/get_server_info

Output example

{
  "cpu_utilization": 3.1,
  "leases_per_second": 4,
  "leases_per_minute": 310,
  "host_name": "DHCP-Server"
}

GET: /api/get_vendor_count

Output example truncated

{
  "Belkin International Inc.": 1230,
  "Cisco-Linksys, LLC": 1345,
  "Calix Inc.": 4368,
  "Billion Electric Co. Ltd.": 404,
  "Apple, Inc.": 528,
  "Wistron Corporation": 18,
  "ASUSTek COMPUTER INC.": 266,
  "Zyxel Communications Corporation": 320,
  "Billion Electric Co., Ltd.": 611,
  "NETGEAR": 2797,
  "Cisco Systems, Inc": 65,
  "Hewlett Packard": 87,
  "Sonicwall": 11,
...

GET: /api/get_mac_oui_count_by_vendor

Output example truncated

{
  "149182": {
    "count": 131,
    "mac_prefix": "149182",
    "vendor": "Belkin International Inc."
  },
  "180373": {
    "count": 4,
    "mac_prefix": "180373",
    "vendor": "Dell Inc."
  },
  "186590": {
    "count": 1,
    "mac_prefix": "186590",
    "vendor": "Apple, Inc."
  },
...

GET: /api/get_dhcp_requests

Output example truncated - some info redacted

{
  "20:aa:4b:1d:d0:17": {
    "request_for": "68.170.X.X",
    "request_via": "209.212.X.X",
    "request_count": 139,
    "request_vendor": "Cisco-Linksys, LLC"
  },
  "58:6d:8f:aa:37:6a": {
    "request_for": "68.170.X.X",
    "request_via": "209.212.X.X",
    "request_count": 171,
    "request_vendor": "Cisco-Linksys, LLC"
  },
...

glass-isc-dhcp's People

Contributors

akkadius avatar asteffen117 avatar averc0re avatar maechi avatar mhoffmann75 avatar rfdrake avatar smokes2345 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glass-isc-dhcp's Issues

Error starting up glass_start.sh nodemailer.createTransport SyntaxError: Unexpected identifier

Hi @Akkadius ,
I try to install Glass on my CentOS v6.5, after deployed, I've got this error when execute sudo npm start or ./glass_start.sh

It keeps appear this errors in /opt/glass-isc-dhcp/logs/glass-error.log

/opt/glass-isc-dhcp/app.js:673
let transporter = nodemailer.createTransport({
    ^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/glass-isc-dhcp/bin/www:7:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
error: Forever detected script exited with code: 8

Can you guide me how to troubleshoot this error?
Big Thanks in Advance,
Sharkrit

Include in config not supported

I run two dhcpd (on two servers) in failover. Glass installed on primary server. Primary functions of glass works fine (view, read config, monitoring, restart, api).

My dhcpd config splitted by subnets for easy sync on secondary server, for ex.:
include "/etc/dhcp/dhcpd.d/subnet01.conf";

"Leases" panel does not populate until you enter a search string

First off, amazing project. I was amazed to find not many ISC-DHCP front ends, until I found this, and it's great. Is there anywhere I can donate a few dollars?

One naggle I've found is I'd like to just click "leases" and get a nice big list of all leases. However it just pulls up a blank page. If I want to get a list populated with everything, I have to click in the box and hit enter (search for a blank string).

I'm assuming the intention here is to not auto-populate with potentially thousands of leases on large infrastructure (and maybe overwhelm the browser)? I can understand that, but is there any possibility of having it auto-populate if leases < 500 or something similar, or even just have an auto-populate-leases config option in glass_config.json ? Thanks!

If this is a simple add and you can point me in the right direction I can probably attempt a PR myself

DHCP Log missing

Thank you for publishing the glass-isc-dhcp.
The same issues as Device Chart missing. Another issues occurred.
Log is not output by DHCP Log.
However, it is a situation that is displayed on the server local browser.
Port 3000 is open with a firewall.
The location of Log File set in Glass Settings is correct, and the log is output to the log file.

Permission
////////////////////////////////////////////////////////////////
xxxxxxx@DHCP0101:~ $ ls -l /var/log/dhcpd/dhcpd.log
-rw-r--r-- 1 root adm 144255 5月 25 20:36 /var/log/dhcpd/dhcpd.log
////////////////////////////////////////////////////////////////

Part of the dhcpd.log
////////////////////////////////////////////////////////////////
May 25 20:40:43 DHCP0101 dhcpd[856]: DHCPDISCOVER from 00:14:5e:1e:a4:35 (IMM-00145E1EA435) via eth0
May 25 20:40:43 DHCP0101 dhcpd[856]: DHCPOFFER on 10.1.36.16 to 00:14:5e:1e:a4:35 (IMM-00145E1EA435) via eth0
May 25 20:40:43 DHCP0101 dhcpd[856]: reuse_lease: lease age 33 (secs) under 25% threshold, reply with unaltered, existing le
ase for 10.1.36.16
////////////////////////////////////////////////////////////////

We are operating in the following environment.

npm version
///////////////////////////////
{ 'dhcpd-glass': '0.0.0',
npm: '5.6.0',
ares: '1.10.1-DEV',
cldr: '32.0',
http_parser: '2.8.0',
icu: '60.1',
modules: '57',
napi: '3',
nghttp2: '1.29.0',
node: '8.11.2',
openssl: '1.0.2o',
tz: '2017c',
unicode: '10.0',
uv: '1.19.1',
v8: '6.2.414.54',
zlib: '1.2.11' }
///////////////////////////////

HW/OS/Browser
////////////////////////////////////////////
Raspberry pi type B
Raspbian Stretch with desktop 4.14
Chrom/Firefox/Edge
///////////////////////////////////////////

Error after some minutes

Hi,

I try to run the Web UI on a Raspberry 3 and Raspian lite.
After some Miuntes of runing I get the following error.

GET /get_stats 500 33.057 ms - 1004
RangeError: Invalid status code: 2
at ServerResponse.writeHead (_http_server.js:194:11)
at ServerResponse.writeHead (/opt/glass-isc-dhcp/node_modules/morgan/node_modules/on-headers/index.js:55:19)
at ServerResponse._implicitHeader (http_server.js:185:8)
at write
(_http_outgoing.js:632:9)
at ServerResponse.end (_http_outgoing.js:751:5)
at ServerResponse.send (/opt/glass-isc-dhcp/node_modules/express/lib/response.js:211:10)
at /opt/glass-isc-dhcp/app.js:75:9
at Layer.handle_error (/opt/glass-isc-dhcp/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/opt/glass-isc-dhcp/node_modules/express/lib/router/index.js:315:13)
at /opt/glass-isc-dhcp/node_modules/express/lib/router/index.js:284:7
GET /glass_settings?v_ajax 304 9.844 ms - -
/bin/sh: 1: ./bin/dhcpd-pools: Exec format error
child_process.js:644
throw err;
^

Error: Command failed: ./bin/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -f j -A -s e
/bin/sh: 1: ./bin/dhcpd-pools: Exec format error

at checkExecSyncError (child_process.js:601:13)
at execSync (child_process.js:641:13)
at Timeout._onTimeout (/opt/glass-isc-dhcp/app.js:555:22)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-25T16_29_09_440Z-debug.log

I can´t find the error, so hopfully you can help me.

Dieter

Upgrade Required

Hi
Here is my compose file, I searched other issues, but I have 3000 open and there's nothing listening only on 8085

  isc-dhcp:
    container_name: dhcp
    image: "networkboot/dhcpd"
    network_mode: host
    volumes:
    - /opt/docker/dhcp/:/data/
  glass:
    container_name: glass
    image: "node:8"
    working_dir: /home/node/app
    security_opt:
        - apparmor:unconfined
    environment:
      - NODE_ENV=production
    volumes:
      - /opt/docker/glass/glass-isc-dhcp:/home/node/app
      - /opt/docker/dhcp/:/var/lib/dhcp
      - /opt/docker/dhcp/dhcpd.conf:/etc/dhcp/dhcpd.conf
      #- /srv/dhcp/
    ports:
      - "8085:8080"
      - "3005:3000"
    command: "/bin/sh -c 'npm install && npm start'"

Passwords cannot contain spaces

While changing the default password, I discovered that passwords cannot contain spaces. This issue mannifests as repeated prompts for a password. Modifying the config/glass_config.json file to remove the spaces in the password works around this issue and allows system login again.

Support for websocket proxy

I'm working on getting this behind a TLS terminator (nginx) that I already have running on this server. I noticed a recent update allows for the HTTP port number to be configured, however, I do not see an option to configure the websocket port server-side.

My end goal is to configure the system to listen to ws:// on 3001, and have nginx listen for wss:// on 8443. I'll update this with my progress.

Web interface crashes on view

A second or two after viewing the glass interface the http process will crash and start over a few seconds later. When this happens this log entry is created.

Error: write EPIPE
    at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)

On Centos 7 with Node 8.15

Empty statistics

Hello,

I followed your installation instructions, except for nodejs, because I had this already:

root > /opt/glass-isc-dhcp # node -v
v8.11.4

Everything went fine, the files in the options are the correct ones (double checked), but in the webpanel everything is at value zero. my subnet is shown correctly, but there is nothing in the statistics (No data available in table)

I'm on Debian latest (Linux gboslave 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux)

Have I done something wrong?
Thank you in advance!

Here are the configuration files and more info:

root > /opt/glass-isc-dhcp # dhcpd --version
isc-dhcpd-4.3.5

root > /opt/glass-isc-dhcp # cat config/glass_config.json 
{
  "admin_user": "xxx",
  "admin_password": "xxx",
  "leases_file": "/var/lib/dhcp/dhcpd.leases",
  "log_file": "/var/log/dhcpd.log",
  "config_file": "/etc/dhcp/dhcpd.conf",
  "shared_network_critical_threshold": "95",
  "shared_network_warning_threshold": "0",
  "slack_webhook_url": "",
  "slack_alert_channel": "",
  "leases_per_minute_threshold": "50",
  "ip_ranges_to_allow": [
    ""
  ],
  "email_alert_to": "",
  "sms_alert_to": "",
  "ws_port": 8080
}
root > /opt/glass-isc-dhcp # cat /etc/dhcp/dhcpd.conf 
authoritative;
log-facility local7;
get-lease-hostnames true;
option domain-name "local";
option domain-name-servers 192.168.178.2, 192.168.178.1;
ping-check true;
next-server 192.168.178.2;

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.178.0 netmask 255.255.255.0 {
        range 192.168.178.100 192.168.178.199;
        option broadcast-address 192.168.178.255;
        option subnet-mask 255.255.255.0;
        option routers 192.168.178.1;
}
host gboslave {
        hardware ethernet 70:45:D2:19:4E:4B;
        fixed-address 192.168.178.2;
        option host-name "gboslave";
}

--- and about 40 other fixed-ip hosts

I'm starting like:

root > /opt/glass-isc-dhcp # npm start

> [email protected] start /opt/glass-isc-dhcp
> node ./bin/www

[Glass Server] Watching leases file '/var/lib/dhcp/dhcpd.leases'
[Glass Server] Config watcher initialized
[Glass Server] DHCP log watcher initialized
[Glass Server] Websocket server starting on port: 8080
[Glass Server] Bootup complete
[Glass Server] Leases file loaded
[Glass Server] OUI Database Loaded

Failed to restart isc-dhcp-server.service: Unit not found.

Received the following error on the CLI after running cd /opt/glass-isc-dhcp; npm start and selecting "Restart" in the web interface:

Redirecting to /bin/systemctl restart isc-dhcp-server.service
Failed to restart isc-dhcp-server.service: Unit not found.
POST /dhcp_start_stop_restart 500 325.151 ms - 984
RangeError: Invalid status code: 5
    at ServerResponse.writeHead (_http_server.js:199:11)
    at ServerResponse.writeHead (/opt/glass-isc-dhcp/node_modules/on-headers/index.js:55:19)
    at ServerResponse._implicitHeader (_http_server.js:190:8)
    at write_ (_http_outgoing.js:632:9)
    at ServerResponse.end (_http_outgoing.js:751:5)
    at ServerResponse.send (/opt/glass-isc-dhcp/node_modules/express/lib/response.js:221:10)
    at /opt/glass-isc-dhcp/app.js:84:6
    at Layer.handle_error (/opt/glass-isc-dhcp/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/opt/glass-isc-dhcp/node_modules/express/lib/router/index.js:315:13)
    at /opt/glass-isc-dhcp/node_modules/express/lib/router/index.js:284:7

Platform:
Hardware: Raspberry Pi 2 Model B Rev 1.1
Operating System: CentOS Linux 7 (AltArch)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 4.14.71-v7.1.el7
Architecture: arm

Was able to work around this issue using the following approach:
Create an alias to the Centos service (dhcpd.service):

  • Edit /usr/lib/systemd/system/dhcpd.service
  • Append Alias=isc-dhcp-server.service to the [Install] section
  • Save and re-read Systemd services: systemctl daemon-reload
  • Create the alias link: systemctl enable dhcpd
  • Test the alias: systemctl status isc-dhcp-server

The web console should now be able to restart/stop the service.

Glass Project Update

For anyone who is watching this project - I wanted to give a general update.

I've been very busy with work as of late, but it is within my intentions to test and make sure Glass works on all major distributions. I plan to do this within the next month or so when my workload frees up a bit.

I will correct any issues that I may run into with platform differences and update the documentation

I'm glad so many people have found their way to this project and have been enjoying using it, I didn't expect to see so much uptake

Thanks everyone!

sorted columns don't stay sorted

When I sort a column, the information will unsort a few seconds later. I can't seem to find a way to lock it or stop the refresh that unsorts it.

npm start issue on Raspbian v9

after running cmd : npm start ; this is the output of error
CONSOLE OUTPUT

[email protected] start /opt/glass-isc-dhcp
node ./bin/www

[Glass Server] Bootup complete
[Glass Server] Leases file loaded
[Glass Server] OUI Database Loaded
[WS] STATUS: Socket clients (0)
[WS] STATUS: Socket clients (0)
[Glass Server] Alert loop started
[Slack] ⚠️ CRITICAL: DHCP leases per minute have dropped below threshold (50) Current (0)
undefined
[Glass Server] Loading E-Mail template...
[Glass Server] Loading E-Mail template... DONE...
[Glass Server] Sending E-Mail Alert...

/bin/sh: 1: ./bin/dhcpd-pools: Exec format error
child_process.js:644
throw err;
^

Error: Command failed: ./bin/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -f j -A -s e
/bin/sh: 1: ./bin/dhcpd-pools: Exec format error

at checkExecSyncError (child_process.js:601:13)
at execSync (child_process.js:641:13)
at Timeout._onTimeout (/opt/glass-isc-dhcp/app.js:555:22)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:

=======================
DEBUG LOG OUTPUT

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 info lifecycle [email protected]
start: [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/glass-isc-dhcp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root:.
9 verbose lifecycle [email protected]start: CWD: /opt/glass-isc-dhcp
10 silly lifecycle [email protected]
start: Args: [ '-c', 'node ./bin/www' ]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: null
12 info lifecycle [email protected]
start: Failed to exec start script
13 verbose stack Error: [email protected] start: node ./bin/www
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /opt/glass-isc-dhcp
16 verbose Linux 4.14.52-v7+
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v8.11.3
19 verbose npm v6.2.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: node ./bin/www
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Permission Denied

Running in a docker container:
I don't think I'm use DHCPD pools, DHCPD is in another container, any ideas?
ror: Command failed: ./bin/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -f j -A -s e
/bin/sh: 1: ./bin/dhcpd-pools: Permission denied

OS Support : RHEL8

Hello everyone,

Did anyone has tried to install GLASS-ISC-DHCP on RHEL8 ?

i keep getting errors when i run : nmp start
error 1: no such file or directory, open '/var/lib/dhcp/dhcpd.leases'

But it exist !!..

error2:
npm ERR! code ELIFECYCLE
nmp ERR! errno 1
npm ERR: [email protected] start : node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in :
npm ERR! /root/.nmp/_logs/2020_01_08T23_41_30_708Z-debug.log

Help :(

Issue on start up - Cannot find Module 'asn1'

Just setup a dhcp server in my house and spotted this lovely looking application.

I installed it as per the instructions, ran npm, it gave vulnerability errors which i asked it to fix. It only did some of them and i didn't apply and that said it would force break something.

however, on running npm start it complained of being unable to find module asn1.

Could you recommend how i go about diagnosing the problem?

root@router:/opt/glass-isc-dhcp# cat /etc/debian_version
9.9
root@router:/opt/glass-isc-dhcp# uname -a
Linux router 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1 (2019-04-12) x86_64 GNU/Linux
root@router:/opt/glass-isc-dhcp#

root@router:/opt/glass-isc-dhcp# npm audit fix
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

  • [email protected]
  • [email protected]
    removed 8 packages and updated 7 packages in 2.673s
    fixed 8 of 19 vulnerabilities in 724 scanned packages
    8 vulnerabilities required manual review and could not be updated
    1 package update for 3 vulns involved breaking changes
    (use npm audit fix --force to install breaking changes; or refer to npm audit for steps to fix these manually)
    root@router:/opt/glass-isc-dhcp# npm start

[email protected] start /opt/glass-isc-dhcp
node ./bin/www

[Glass Server] Watching leases file '/var/lib/dhcp/dhcpd.leases'
[Glass Server] Config watcher initialized
[Glass Server] DHCP log watcher initialized
[Glass Server] Websocket server starting on port: 8080
module.js:550
throw err;
^

Error: Cannot find module 'asn1'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/opt/glass-isc-dhcp/node_modules/sshpk/lib/formats/pem.js:9:12)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-08-21T20_47_02_802Z-debug.log

and the info from the debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 info lifecycle [email protected]
start: [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/glass-isc-dhcp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle [email protected]start: CWD: /opt/glass-isc-dhcp
10 silly lifecycle [email protected]
start: Args: [ '-c', 'node ./bin/www' ]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: null
12 info lifecycle [email protected]
start: Failed to exec start script
13 verbose stack Error: [email protected] start: node ./bin/www
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:915:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /opt/glass-isc-dhcp
16 verbose Linux 4.9.0-9-amd64
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v8.16.1
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: node ./bin/www
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Glass on Centos 8

Hi,
nice project. I set it up on a clean Centos 8 system and wanted to share how I got it running. In case someone is interested:

As root install nodejs
$ yum -y install nodejs

do as in the original recipe:

$ cd /opt
$ git clone https://github.com/Akkadius/glass-isc-dhcp.git
$ cd glass-isc-dhcp
$ mkdir logs
$ chmod u+x ./bin/ -R
$ chmod u+x *.sh
$ npm install
$ npm install forever -g

You can ignore the npm warning about fsevent since you are not using MacOs:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/forever/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

Beforer testing you have to change a path in /opt/glass-isc-dhcp/config/glass_config.json:

 "leases_file": "/var/lib/dhcpd/dhcpd.leases",
  "log_file": "/var/log/dhcpd/dhcpd.log",

Then let the firewall know about glass, you may have to adjust the zone. We have an internal and external zone. Otherwise public would also be an option:

$ firewall-cmd --zone=internal --add-port=3000/tcp --permanent
$ firewall-cmd --reload

In a final step you may register glass as system service. Therefore create:
vim /etc/systemd/system/dhcpd_glass.service
with the content:

[Unit]
Description=Glass ISC DHCP Server Gui Service

[Service]
ExecStart=/usr/bin/node  /opt/glass-isc-dhcp/bin/www
# Required on some systems
WorkingDirectory=/opt/glass-isc-dhcp
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=glass-dhcp

[Install]
WantedBy=multi-user.target

Enable the service:
systemctl enable dhcpd_glass.service
and start it:
systemctl start dhcpd_glass.service

Have fun!

Feature Requests for larger networks

  1. Support for remote DHCP servers (i.e. connected over SSH to a remote server on our network)
  2. Support for multiple DHCP servers (not just the system it's running from)
  3. Support for include <filename.conf>'s in the DHCPd Config

Yes, those features would be awesome; yes, I'd love to beta test it in a closed environment if you decide to go this route

Failed to exec start script - Possible Syntax error

For starters, absolutely love this work! Have been looking for something like this for months as part of a home lab project.

Unfortunately with my absolutely limited skillset I have come across a script start error that I just cant seem to get past. It may well be my own stupidity that is the error but in the event there is actually an error with the script I would appreciate your advice.

The logfile is:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 info lifecycle [email protected]
start: [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/glass-isc-dhcp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
9 verbose lifecycle [email protected]start: CWD: /opt/glass-isc-dhcp
10 silly lifecycle [email protected]
start: Args: [ '-c', 'node ./bin/www' ]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: null
12 info lifecycle [email protected]
start: Failed to exec start script
13 verbose stack Error: [email protected] start: node ./bin/www
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /opt/glass-isc-dhcp
16 verbose Linux 4.4.38-v7+
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: node ./bin/www
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

error starting on centos

Hi,

After what appears to be a successful install, I get the following error when trying start glass:

[root@home glass-isc-dhcp]# npm start

[email protected] start /opt/glass-isc-dhcp
node ./bin/www

/opt/glass-isc-dhcp/app.js:673
let transporter = nodemailer.createTransport({
^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/opt/glass-isc-dhcp/bin/www:7:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
npm ERR! weird error 8
npm ERR! not ok code 0

perhaps it has something to do with my version of node.js? Here's the version of node and of the packages that I have installed. It's a centos 6.9 server.

[root@home glass-isc-dhcp]# node --version
v0.10.48

[root@home glass-isc-dhcp]# rpm -qa | grep node
nodejs-boom-0.4.2-2.el6.noarch
nodejs-sha-1.2.1-1.el6.noarch
nodejs-opener-1.3.0-7.el6.noarch
nodejs-glob-3.2.6-1.el6.noarch
nodejs-http-signature-0.10.0-3.el6.noarch
nodejs-which-1.0.5-8.el6.noarch
nodejs-promzard-0.2.0-6.el6.noarch
nodejs-init-package-json-0.0.10-1.el6.noarch
nodejs-npm-registry-client-0.2.28-3.el6.noarch
nodejs-fstream-0.1.24-1.el6.noarch
nodejs-retry-0.6.0-5.el6.noarch
nodejs-forever-agent-0.5.0-1.el6.noarch
nodejs-ctype-0.5.3-3.el6.noarch
nodejs-proto-list-1.2.2-5.el6.noarch
nodejs-ini-1.1.0-3.el6.noarch
nodejs-cryptiles-0.2.2-1.el6.noarch
nodejs-packaging-7-1.el6.noarch
nodejs-archy-0.0.2-8.el6.noarch
nodejs-tunnel-agent-0.3.0-1.el6.noarch
nodejs-0.10.48-3.el6.x86_64
nodejs-hoek-0.9.1-1.el6.noarch
nodejs-nopt-2.1.2-1.el6.noarch
nodejs-github-url-from-git-1.1.1-2.el6.noarch
nodejs-chmodr-0.1.0-4.el6.noarch
nodejs-aws-sign-0.3.0-1.el6.noarch
nodejs-editor-0.0.4-2.el6.noarch
nodejs-fstream-ignore-0.0.7-1.el6.noarch
nodejs-npmconf-0.1.2-1.el6.noarch
nodejs-mkdirp-0.3.5-3.el6.noarch
nodejs-osenv-0.0.3-5.el6.noarch
nodejs-once-1.1.1-5.el6.noarch
nodejs-hawk-1.0.0-1.el6.noarch
nodejs-npm-user-validate-0.0.3-1.el6.noarch
nodejs-assert-plus-0.1.4-1.el6.noarch
nodejs-minimatch-0.2.12-2.el6.noarch
nodejs-combined-stream-0.0.4-3.el6.noarch
nodejs-asn1-0.1.11-3.el6.noarch
nodejs-inherits-2.0.0-4.el6.noarch
nodejs-lru-cache-2.3.0-3.el6.noarch
nodejs-npmlog-0.0.4-1.el6.noarch
nodejs-sntp-0.2.4-1.el6.noarch
nodejs-oauth-sign-0.3.0-1.el6.noarch
nodejs-devel-0.10.48-3.el6.x86_64
nodejs-sigmund-1.0.0-5.el6.noarch
nodejs-delayed-stream-0.0.5-5.el6.noarch
nodejs-rimraf-2.2.2-1.el6.noarch
nodejs-block-stream-0.0.7-1.el6.noarch
nodejs-chownr-0.0.1-9.el6.noarch
nodejs-cmd-shim-1.1.0-3.el6.noarch
nodejs-lockfile-0.4.2-1.el6.noarch
nodejs-mute-stream-0.0.4-1.el6.noarch
nodejs-json-stringify-safe-5.0.0-1.el6.noarch
nodejs-read-package-json-1.1.3-1.el6.noarch
nodejs-uid-number-0.0.3-7.el6.noarch
nodejs-request-2.25.0-3.el6.noarch
nodejs-graceful-fs-2.0.0-2.el6.noarch
nodejs-mime-1.2.11-1.el6.noarch
nodejs-qs-0.6.6-3.el6.noarch
nodejs-node-uuid-1.4.1-1.el6.noarch
nodejs-form-data-0.1.1-1.el6.noarch
nodejs-slide-1.1.5-1.el6.noarch
nodejs-abbrev-1.0.4-6.el6.noarch
nodejs-child-process-close-0.1.1-2.el6.noarch
nodejs-cookie-jar-0.3.0-1.el6.noarch
nodejs-config-chain-1.1.7-1.el6.noarch
nodejs-tar-0.1.18-1.el6.noarch
nodejs-read-1.0.5-1.el6.noarch
nodejs-read-installed-0.2.4-1.el6.noarch
node-gyp-0.10.6-2.el6.noarch
nodejs-semver-2.1.0-1.el6.noarch
nodejs-ansi-0.2.1-1.el6.noarch
nodejs-normalize-package-data-0.2.1-1.el6.noarch
nodejs-async-0.2.10-1.el6.noarch
nodejs-fstream-npm-0.1.5-1.el6.noarch

Error on startup with Ubuntu 16.04

Hi,
I'd love to use glass but I'm not able to start it.

Output is

> > [email protected] start /opt/glass-isc-dhcp
> > node ./bin/www
> 
> /opt/glass-isc-dhcp/app.js:674
> let transporter = nodemailer.createTransport({
> ^^^
> 
> SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
>     at exports.runInThisContext (vm.js:53:16)
>     at Module._compile (module.js:414:25)
>     at Object.Module._extensions..js (module.js:442:10)
>     at Module.load (module.js:356:32)
>     at Function.Module._load (module.js:311:12)
>     at Module.require (module.js:366:17)
>     at require (module.js:385:17)
>     at Object.<anonymous> (/opt/glass-isc-dhcp/bin/www:7:11)
>     at Module._compile (module.js:435:26)
>     at Object.Module._extensions..js (module.js:442:10)
> 
> npm ERR! Linux 4.4.0-119-generic
> npm ERR! argv "/root/.nvm/versions/node/v4.2.2/bin/node" "/root/.nvm/versions/node/v4.2.2/bin/npm" "start"
> npm ERR! node v4.2.2
> npm ERR! npm  v2.14.7
> npm ERR! code ELIFECYCLE
> npm ERR! [email protected] start: `node ./bin/www`
> npm ERR! Exit status 1
> npm ERR!
> npm ERR! Failed at the [email protected] start script 'node ./bin/www'.
> npm ERR! This is most likely a problem with the dhcpd-glass package,
> npm ERR! not with npm itself.
> npm ERR! Tell the author that this fails on your system:
> npm ERR!     node ./bin/www
> npm ERR! You can get their info via:
> npm ERR!     npm owner ls dhcpd-glass
> npm ERR! There is likely additional logging output above.
> 
> npm ERR! Please include the following file with any support request:
> npm ERR!     /opt/glass-isc-dhcp/npm-debug.log

and npm-debug.log is

0 info it worked if it ends with ok
1 verbose cli [ '/root/.nvm/versions/node/v4.2.2/bin/node',
1 verbose cli   '/root/.nvm/versions/node/v4.2.2/bin/npm',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart [email protected]
6 info start [email protected]
7 verbose unsafe-perm in lifecycle true
8 info [email protected] Failed to exec start script
9 verbose stack Error: [email protected] start: `node ./bin/www`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/root/.nvm/versions/node/v4.2.2/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at EventEmitter.emit (events.js:172:7)
9 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v4.2.2/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at ChildProcess.emit (events.js:172:7)
9 verbose stack     at maybeClose (internal/child_process.js:818:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid [email protected]
11 verbose cwd /opt/glass-isc-dhcp
12 error Linux 4.4.0-119-generic
13 error argv "/root/.nvm/versions/node/v4.2.2/bin/node" "/root/.nvm/versions/node/v4.2.2/bin/npm" "start"
14 error node v4.2.2
15 error npm  v2.14.7
16 error code ELIFECYCLE
17 error [email protected] start: `node ./bin/www`
17 error Exit status 1
18 error Failed at the [email protected] start script 'node ./bin/www'.
18 error This is most likely a problem with the dhcpd-glass package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     node ./bin/www
18 error You can get their info via:
18 error     npm owner ls dhcpd-glass
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

any idea?

Thanks

Feature request: class support and stats

First things first: thank you for such a beautiful piece of code. Amazing!

I have a shared network where I define some classes to ease management, like this:

On dhcpd.conf:

# Class Desktop
class "clsDesktop" {
    match pick-first-value (option dhcp-client-identifier, hardware);
}

On an included file:

# Host boss-notebook
subclass "clsDesktop" 1:c4:6e:1f:ab:cd:ef;

Would be nice to have stats about how many devices are defined by class and how many have an active lease by class.

Side note, I define the clients on includes, so include support would be also nice.

Best regards.

Saving Configuration (Permission Denied)

Hey,

im getting a weird error on saving the configuration.

Internet Systems Consortium DHCP Server 4.3.5
Copyright 2004-2016 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Can't open ./syntax_verify_config: Permission denied If you think you have received this message due to a bug rather than a configuration issue please read the section on submitting bugs on either our web page at www.isc.org or in the README file before submitting a bug
These pages explain the proper process and the information we find helpful for debugging.. exiting.

I tried the following:

chmod +x /opt
chmod +x /opt/glass-isc-dhcp

I also tried replacing the relative path in routes/dhcp_config_save with the absolute one, still getting permission denied.

Using cat /opt/glass-isc-dhcp/syntax_verify_config as a non-root User its working fine, dont know why i get a permission denied there...

OS Infos:

Ubuntu 18.04.3 LTS
isc-dhcp-server 4.3.5

Support for CentOS/RHEL starter services

Hello!

First of all, great work! I was able to get this running in under a day. However, I had to make a minor change to the start/stop code that allows this application to control the CentOS/RHEL-based ISC DHCPD service.

On these distros, the service is in systemd as dhcpd.service instead of isc-dhcp-server.service as it is in Debian-based distros.

It's a pretty simple fix:

diff --git a/routes/dhcp_start_stop_restart.js b/routes/dhcp_start_stop_restart.js
index 77acbb9..90d5e67 100644
--- a/routes/dhcp_start_stop_restart.js
+++ b/routes/dhcp_start_stop_restart.js
@@ -49,15 +49,15 @@ router.post('/', authorize.auth, function(req, res, next) {

        switch (request.action) {
                case "stop":
-                       dhcp_exec = execSync('/usr/sbin/service isc-dhcp-server stop && /bin/sleep 1');
+                       dhcp_exec = execSync('/usr/sbin/service dhcpd stop && /bin/sleep 1');
                        res.send("<script type='text/javascript'>notification('DHCP Server Stopped');ignore_cache = 1;do_pjax_request
                        break;
                case "start":
-                       dhcp_exec = execSync('/usr/sbin/service isc-dhcp-server start');
+                       dhcp_exec = execSync('/usr/sbin/service dhcpd start');
                        res.send("<script type='text/javascript'>notification('DHCP Server Started');ignore_cache = 1;do_pjax_request
                        break;
                case "restart":
-                       dhcp_exec = execSync('/usr/sbin/service isc-dhcp-server restart && /bin/sleep 1');
+                       dhcp_exec = execSync('/usr/sbin/service dhcpd restart && /bin/sleep 1');
                        res.send("<script type='text/javascript'>notification('DHCP Server Restarted " + dhcp_exec + "');ignore_cache
                        break;
                default:

Since the service command redirects to systemctl (at least for now), everything's all fine and happy.

Additionally, I have created a systemd starter service for this Node app and an rsyslog conf snippet that picks up the node output and dumps it into its own log file so it's not in /var/log/messages or /var/log/syslog if you want one or both of those as well. With the starter service, systemd can intelligently detect when the process needs to be started/stopped, and you can use it to make sure that this starts after dhcpd. Note that due to the service naming difference between CentOS/RHEL and Debian, a minor modification would be needed to get it working on a Debian-based system.

When I start the container I receive: Error: EISDIR: illegal operation on a directory, read errno: -21, code: 'EISDIR', syscall: 'read

╭───────────────────────────────────────────────────────────────╮

  │                                                               │

  │      New minor version of npm available! 6.4.1 -> 6.9.0       │

  │   Changelog: https://github.com/npm/cli/releases/tag/v6.9.0   │

  │               Run npm install -g npm to update!               │

  │                                                               │

  ╰───────────────────────────────────────────────────────────────╯





> [email protected] start /opt/glass

> node ./bin/www



[Glass Server] Watching leases file '/var/lib/dhcp/dhcpd.leases'

[Glass Server] Config watcher initialized

[Glass Server] DHCP log watcher initialized

[Glass Server] Websocket server starting on port: 8080

[Glass Server] Bootup complete

[Glass Server] OUI Database Loaded

{ Error: EISDIR: illegal operation on a directory, read errno: -21, code: 'EISDIR', syscall: 'read' }

/bin/sh: 1: top: not found

[WS] STATUS: Socket clients (0)

/bin/sh: 1: top: not found

/bin/sh: 1: top: not found

[WS] STATUS: Socket clients (0)

[Glass Server] Alert loop started

/bin/sh: 1: top: not found

[Glass Server] Slack alert triggered, but no webhook configured...

[Glass Server] Loading E-Mail template...

[Glass Server] Loading E-Mail template... DONE...

[Glass Server] Sending E-Mail Alert...

Certificate - www file modified for https

Below is the /opt/glass-isc-dhcp/bin/www file that has been modified to use the certificates created for another service (Librenms) my Ubuntu server provides. It took some hunting around and progressive failures to get it right...especially since this is my first foray into Nodejs. Incidentally the Nodjs version the ubuntu server is on is v10.19.0 so those of you who were wondering about the outdated 8 version in the installation docs. As of the date of writing this Ubuntu is fully patched. The following code was added:

/**
 * Set up for https.
 */

const https = require('https');
const fs    = require('fs');
var   tls   = require('tls');

const options = {
  key:   fs.readFileSync('/etc/ssl/private/server.key'),
  cert:  fs.readFileSync('/etc/ssl/certs/cmg-net01.pem')
};

and the server line was modified to include the options from above:

/**
 * Create HTTPs server.
 */

var server = https.createServer(options,app);

DHCP Config and Snapshots not working

I found this very beautyfull and usefull tool for my isc-dhcp-server, but i run on Ubuntu and Debian into the same issues if i want to access the configs.

In the Logs there is a Error 500 (internal server error)
In Chrome i see in the logs if i press on the Save Config Button: "fs is not defined"
If i click on DHCP Config Snapshots i have a greyed out screen and the error: "ENOENT: no such file or directory, scandir './config_backups'"

The npm Package fs ist installed, but i get a warning that fsevents is unsopported on amd64 platforms, i tried also other nodejs versions like 6.14 and the newest 9.11 with no success.

Read out the Config Files and the lease table and so on works fine, paths in the config are default and all correct...

If it helps: I´m able to start/stop/restart the dhcp server from the Glass UI and can save the glass settings, only the dhcp settings and snapshots won´t run

Please help! :)

NodeJS 8.x is Deprecated

Hi,

The version of NodeJS suggested in the installation instructions (8.x Carbon) is now deprecated.

Following the installation instructions gives a big red warning to this effect.

Does Glass support either NodeJS 10.x or 12.x, which are the newer LTS releases?

I found a error

Can you give me a sample configuration of dhcpd.lease?


Now I use your project, but the Statistics View module can't display the data, all the information related to the lease is missing, I need your help urgently.

Tks! 🙇🏼‍♂️

No Device chart and cannot get OUI Count by Vendor

New install on Ubuntu 18.04 on the statistics page I have no device chart and nothing under Get OUI count by vendor. I have found a 500 error on the api for get_mac_oui_count_by_vendor and get this error when accessing the api directly. Cannot read property 'split' of undefined I have not found the issue with the Device Chart as of yet and also cannot search for any leases the search shows blank when using a known IP address. Any help would be greatly appreciated. Thanks

Phil

Loss of Service Control after installing cron job

After adding the prescribed line in root's crontab, the service starts on reboot, however, the service controls do not work and I was unable to save edits to the dhcp.conf file.

glass-error.log file contained:
/bin/sh: 1: service: not found

and the DHCP Config page showed:
/bin/sh: 1: dhcpd: not found

I was able to correct this by adding the absolute path /usr/sbin/ before the service command in ./routes/dhcp_start_stop_restart.js on lines 52, 56, 60

dhcp_exec = execSync('/usr/sbin/service isc-dhcp-server stop && sleep 1');
dhcp_exec = execSync('/usr/sbin/service isc-dhcp-server start');
dhcp_exec = execSync('/usr/sbin/service isc-dhcp-server restart && sleep 1');

AND

Adding the abs path before the dhcpd command in ./routes/dhcp_config_save.js on line 18
exec('/usr/sbin/dhcpd -t -cf ./syntax_verify_config > verify_output 2> verify_output', function(err, stdout, stderr)

bin/dhcpd-pools is x86 only

I'd like to use glass-isc-dhcp on a raspberry pi, but there are some x86 elf binaries.
I propose detecting architecture on install and copying/linking appropriate binaries

Glass Dashboard CPU percent not correct

Recent install on CentOS 7.5. Pulled install from GitHub using sept 28 updates.
The app is fully functional and performing well, except that the Dashboard CPU utilization seems off by a power of 10.

My system detail: ProLiant DL380p Gen8 Xeon w/8 cores

Linux system monitor tools never report more than 24% user utilization on this server yet Glass Dashboard reports 160% to 250% CPU percentage.

Is there an update for centos or this HP platform that will align system information correctly?

Can this be corrected by a configuration change to a Glass specific file?

Thanks in advance for the feedback.

Server doesn't properly load when offline

I want to use this web app in a closed network but the Icons and Fonts are imported from external websites. If you could maybe localize those assets, so it would work properly offline that'd be great.

During fresh install and Starting of glass-isc-dhcp on raspberry pi 3b

glass is freshly installed and starting up but failing and gives following error output. Can you please help?

/bin/sh: 1: ./bin/dhcpd-pools: Exec format error
child_process.js:645
throw err;
^

Error: Command failed: ./bin/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -f j -A -s e
/bin/sh: 1: ./bin/dhcpd-pools: Exec format error

at checkExecSyncError (child_process.js:602:13)
at execSync (child_process.js:642:13)
at Timeout._onTimeout (/opt/glass-isc-dhcp/app.js:322:21)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

Interface name in MAC field

imagen

This only happens with huawei switchs, in other equipment works perfectly. i'm running on Ubuntu Server 16.04.4 x64bits

Kea DHCP

Kudos! This looks awesome.

Do you have any plans to move to Kea DHCP? It has a REST API built-in.

I've only used ISC DHCP in the past, but, it seems like ISC is recommending that new deployments use Kea.

npm start error about oui-reader

----- SOLVED with new server install with Centos 7 -----

I installed with npm install and npm install forever -g... But it is failed on npm start..
How can I fix this issue after npm start?
(Linux system is Centos 6.10)

[email protected] start /opt/glass-isc-dhcp
node ./bin/www

/opt/glass-isc-dhcp/app.js:121
let oui_reader = require('./core/oui-reader');
^^^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/opt/glass-isc-dhcp/bin/www:7:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
npm ERR! weird error 8
npm ERR! not ok code 0

Possible to disable admin functions?

Is it possible to install Glass with the admin functions (e.g. editing DHCP server config, restarting DHCP server) disabled?

I would like my users to be able to see the DHCP leases easily, but don't want them being able to change the configuration.

Obviously I could put random strings for the "admin_user" and "admin_password" fields, but they are held in plain text in a configuration file

Device Chart missing

Hi,
while everything is working fine there are two little issues:

The "Device Chart" graphic is not showing up.
In "Active Leases" I cant search for IP addresses or blocks.

Tested browsers are Chromium and Firefox.

Upgrade Required

Installation okay, Server up an runing but when I try to access the page I get: Upgrade Required

So what now?

ps: using latest versions on Debian 9

Leases Start and End Times NaN

This is more of an FYI. I'm not sure if there is a good long-term resolution for both use cases. However, I have diff code attached that will resolve the issue on a case-by-case basis.

If your ISC DHCP server config has the option 'db-time-format' set to 'local', your Active Leases page will not properly display the start and end times for the lease. This is because the timestamp is written differently in the leases file. Below are the differences when this option is set to 'local' instead of 'default' ('default' is the default if the option is not explicitly configured).

default setting - works fine with Glass:
lease x.x.x.x {
starts 2 2019/06/11 15:38:11;
ends 3 2019/06/12 15:38:11;
cltt 2 2019/06/11 15:38:11;
binding state active;
next binding state free;
rewind binding state free;
}

local setting:
lease x.x.x.x {
starts epoch 1560262460; # Tue Jun 11 10:14:20 2019
ends epoch 1560348860; # Wed Jun 12 10:14:20 2019
cltt epoch 1560262460; # Tue Jun 11 10:14:20 2019
binding state active;
next binding state free;
rewind binding state free;
}

If you're not in a position to remove the 'db-time-format' option, then to resolve this issue, you have to tweak /opt/glass-isc-dhcp/core/lease-parser.js. I've attached some git diff output. Disclaimer: I haven't triple-verified if this tweak has negative side effects in other parts of the app, but I don't believe it does.

lease-parser-js-git-diff.txt

amount of writes

I'm running Debian configured as a router from an USB flash drive, since USB flash drives do not come with wear leveling (that I know of ) the amount of writes needs to be limited.

Judging from the "Install Glass (as root)" part, Glass doesn't save logs in /var/log which is running in ramdisk.

How much writing does this program actually do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.