1.6.1 • Published 3 months ago

homebridge-grumptech-netnanny v1.6.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

Homebridge Net Nanny

Homebridge Net Nanny, by GrumpTech, is a Homebridge dynamic platform plug-in that publishes metrics measuring the health of a network. This plugin was inspired by Dave Hamilton's, of the Mac Geek Gab, 3-Ping strategy for evaluating network health.

Change Log

The change history can be viewed here

Security Policy

Please refer to our security policy for information on which versions are receiving security updates and how to report security vulnerabilities.

Installation

This plug-in is intended to be used with the homebridge-config-ui-x homebridge management tool. If using homebridge-config-ui-x, simply search for homebridge-grumptech-netnanny for installation, plug-in management, and configuration.

To install the plugin manually: npm install -g homebridge-grumptech-netnanny

Configuration

homebridge-config-ui-x

This plugin is best experienced when running as a module installed and managed by the homebridge-config-ui-x plugin. When running under homebridge-config-ui-x, visiting the plugin settings will allow you to change the polling interval and the low space alarm threshold, as shown below.

Additionally, especially if this system will be running other homebridge modules, it is strongly encouraged to run this plugin as an isolated child bridge. This setting page can be found by clicking on the wrench icon on the plugin and then selecting Bridge Settings. With the child bridge enabled, revisiting the setting page after homebridge is rebooted will show a QR code for pairing to the child bridge. The username (mac address) and port are randomly generaged by homebridge-config-ui-x.

Configuration Settings

SettingDescriptionField NameParameter TypeData TypeUnitsDefaultMinimum or Allowed ValuesMaximumComments
Ping PeriodThe time, in seconds, to initiate a series of ping requests.ping_periodCommonNumberTime:seconds206N/A
Ping IntervalThe time, in seconds, between each ping request.ping_intervalCommonNumberTime:seconds11N/A
Ping CountThe number of ping request for each series.ping_countCommonNumberCount53N/A
Packet SizeThe size, in bytes, of each ping request.packet_sizeCommonNumberBytes5656N/A
Enable History LoggingEnables / Disables logging of ping resultsenable_history_loggingCommonBooleanN/ATrueFalseTrue
History Reporting PeriodThe time, in days, for generating report logs of network performancehistory_logging:reporting_periodCommonNumberTime:days10.041667100
Maximum History SizeMaximum number of result sets to record in the history databasehistory_logging:maximum_history_sizeCommonNumberN/A25000025005000000
Oretention PeriodNumber of days to retain history log files.history_logging:retention_periodCommonNumberTime:days301365
Target TypeType of target.ping_targets:items:target_typePer TargetStringN/Aipv4uri, ipv4, ipv6, gateway, cable_modem
Modem TypeType of cable modem.ping_targets:items:modem_typePer TargetStringN/Aotherxfinity, netgear, otherOnly valud when the target type is set to cable_modem
Target DestinationDestination for the pingping_targets:items:target_destPer TargetStringNot applicable for gateway or cable_modem
Packet Loss LimitThe limit, in percent, of lost packets that will be tolerated.ping_targets:items:loss_limitPer TargetNumberPercent50100
Expected LatencyThe expected latency, in milliseconds, for the ping.ping_targets:items:expected_latencyPer TargetNumberTime:milliseconds10>0N/A
Expected JitterThe expected jitter, in milliseconds, of the ping latency.ping_targets:items:expected_jitterPer TargetNumberTime:milliseconds1>0N/A
Peak Expiration TimeThe time, in hours, used to reset the peak values.ping_targets:items:peak_expirationPer TargetNumberTime:hours120N/A
Data Filter Time WindowThe time, in seconds, over which to filter the ping results.data_filter_time_windowPer TargetNumberTime:seconds1806N/AValues less than the 'Ping Period' will be ignored.
Sensor AlertIndicates which of the Carbon Dioxide sensors issue CO2 aleets when the data exceeds specified limits.sensor_alert_maskPer TargetNumberBitmask707Bit#0:Time, Bit#1:Packet Loss; Bit#2:Standard Deviation

Manual Configuration

If you would rather manually configure and run the plugin, you will find a sample config.json file in the ./config folder. It is left to the user to get the plugin up and running within homebridge. Refer to the section above for specifics on the configuration parameters.

Usage

The plugin will create, or restore, a dynamic accessory for each network target specified in the configuration. Each accessory will advertise four services: (1) switch, and (3) carbon dioxide sensors. All of the data presented for the carbon dioxide sensors is the result of the ping results. In an effort to keep outliers from affecting the reported values, the data collected will be run through a filter, as discussed below. In addition to the services provided by each network targer, the plugin will adversise an additional a collection of switch services.

  • Power: A switch, with the name of the Target Destination, that controls the active state of the network performance target.
  • Latency: The average ping latency, in milliseconds. The peak value is also displayed. Alerts are triggered when the reported value exceeds: Expected Latency + (3 * Expected Jitter)
  • Jitter: The jitter, in milliseconds, of the ping latency results. The peak value is also displayed. Alerts are triggered when the reported value exceeds: Expected Jitter
  • Packet Loss: The packet loss, in percent. The peak value is also displayed. Alerts are triggered when the reported value exceeds: Packet Loss Limit
  • NetNanny-Switches: A collection of switches. At the present time, this collection contains a single switch. This switch will be used perform an off-cycle export of the database and flush all existing data.

When the current value for any of the carbon dioxide sensors exceeds the user-specified expected limits, the sensor’s alert will be set and, in addition, the sensor’s Detected value will be set to abnormal levels, if configured. Each Carbon Dioxide sensor can be configured to not set the Detected value to abnormal when a fault is encountered. Setting the Detected value to abnormal levels should result in am alert noticiation from HomeKit.

Because the ping results can be noisy, the results are filtered using the AVT (Antonyan Vardan Transform) algorithm. The amount of data considered in the filter is implicitly set via the Data Filter Time Window configuration parameter on each network target. The size of the data buffer is computed as the ratio Data Filter Time Window to Ping Period. The larger this ratio, the more ping results that will be considered in the filter. The value reported by the filter is the median value after excluding the data points that are beyond one standard deviation. Therefore, one can assume that the alerts will not be detected until at least half of the Data Filter Time Window has elapsed with raw results that exceed the user specified limits. This should have the tendency to limit false positive detections. However, if the ratio is too small (not enough data in the buffer), then the reporting will be more responsive and alerts will be issued for transient glitches in the network performance that do not necessarially indicate a systemic problem.

It should also be noted, that the Detected value will not be set to abnormal until the Data Filter Time Window has elapsed after startup. This will prevent an occasional bad result from immediately resulting in the detection of abnormal carbon dioxide levels at startup.

When the accessory is inactive, the Active and Low Battery Status are set.

When Enable History Logging is active, the filtered ping results will be stored in an in-memory database. The data will be exported to a CSV data file periodically or upon manual request. The exported data will be saved to a folder named GrumpTechHomebridgeNetNanny located in the homebridge configuration folder. For example, on macOS ~/.homebridge/GrumpTechHomebridgeNetNanny/.

Restrictions

This module operates by using shell commands to the ping and route programs. At this time, the plugin assumes macOS output when parsing the results. While the ping output is consistent across operating systems, the route output is operating system specific. As a result, the gateway/router type selection is limited to macOS and linux.

Known Issues and Planned Enhancements

Refer to the bugs and enhancements listed here

Contributing

  1. Fork it!
  2. Create your feature/fix branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Credits

Many thanks to all the folks contributing to Homebridge and to oznu for homebridge-config-ui-x, allowing for the possibility of this sort of fun and learning. Special thanks to Dave Hamilton's, and the MacGeekGab podcast for inspiring the idea for this plugin.

License

Refer to LICENSE.md for information regarding licensincg of this source code.

1.6.1

3 months ago

1.6.0

5 months ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago