unifi-activity-statistics
unifi-activity-statistics is a Node.js module that allows you to listen for activity statistics and shows you the current RX and TX speeds from a specified port on your UnfiFi Dreammachine (UniFi is Ubiquiti Networks wifi controller software).
This package is heavily based on the awesome work of oznu's unifi-events.
Please follow the link and buy him a coffee.
Requirements
- Node.js v6 or later
- UniFi-Controller v5
Installation
$ npm install unifi-activity-statistics
Example
const UnifiActivityStatistics = require('unifi-activity-statistics');
let unifi = new UnifiActivityStatistics({
host: 'unifi', // The hostname or ip address of the unifi controller (default: 'unifi')
port: 8443, // Port of the unifi controller (default: 8443)
username: 'admin', // Username (default: 'admin').
password: 'ubnt', // Password (default: 'ubnt').
uplink_interface: 'eth9', // Port you want to listen to (default: eth9).
site: 'default', // The UniFi site to connect to (default: 'default').
insecure: true, // Allow connections if SSL certificate check fails (default: false).
unifios: true // For devices with UnifiOS turn this on
});
// Listen for event
unifi.on('uplink_activity', (data) => {
console.log('RX: ' + (data.rx / 125000).toFixed(2) + ' TX: ' + (data.tx / 125000).toFixed(2));
});
Events
unifi-activity-statistics uses EventEmitter2 and namespaced events.
ctrl
namespace These events indicate the status of the connection to the UniFi controller
-
ctrl.connect
- emitted when the connection to the controller is established -
ctrl.disconnect
- emitted when the connection to the controller is lost -
ctrl.error
- -
ctrl.reconnect
-
License
- MIT © 2023-2024 flazer
- MIT © 2017-2021 oznu
- MIT © 2018 Sebastian Raff