WatchDogs
A simple server monitoring tool written in node and websockets.
The client-server-viewer on diagram
WATCHDOGS
CLIENTS +----------------+
+---------------+ | Viewer |
| Server 1 |+-----+ +----------------+
+---------------+ | ^
| |
+---------------+ | | Connect using
| Server 2 |+-----| +----------------+ | key
+---------------+ | | | |
+->| Watchdogs |<--------------+
+---------------+ | | Server |
| Server 3 |+-----| | |
+---------------+ | +----------------+
|
+---------------+ |
| Server 4 |+-----+
+---------------+
Client: Is the app you run on the machines you want to get info from.
Server: Is where your clients connect to. The central hub.
Viewer: Is a javascript interface that connect to the server and retrieves info from the machines via websockets.
Quickstart
Just to see it in action, install from npm
and get the example config files for client and server.
Start the server, start the client and open the example viewer html on your browser.
$ npm install watchdogs -g
...
$ watchdogs_server /path/to/config.toml
# or
$ watchdogs_client /path/to/config.toml
You should see something like this:
Usage
Install watchdogs via npm
on your client and server.
Server
Configure the server:
key = "randomkeyhere"
port = 1337
hostname = "watchdogs.myawesomeserver.lol:1337"
update_interval = 5
cache_updates = true
Save it as watchdogs.toml
, or with another filename if you want (but if you use the first you don't need to specify the config location to the server), and start the server:
$ watchdogs_server /path/to/config.toml
info - socket.io started
-------------------------------------------------------------
| WatchDogs Server [ONLINE]
| Scripts to include in your application:
| http://watchdogs.myawesomeserver.lol:1337/socket.io/socket.io.js
| http://watchdogs.myawesomeserver.lol:1337/viewer?key=randomkeyhere
-------------------------------------------------------------
Clients
Configure the clients:
server = "watchdogs.myawesomeserver.lol:1337"
name = "srv1" # MUST BE UNIQUE!
expose = [
"hostname",
"type",
"platform",
"arch",
"uptime",
"load",
"memory"
]
The server
variable is the same hostname
we specified in the server. The name
must be unique for each client, and the services we want to show. Save it as watchdogs.toml
or wathever you want, and start the client:
$ watchdogs_client /path/to/config.toml
Registered on server.
The server must show something like: [register] server: srv1
and a lot of websockets transactions after that (depeding on the update interval you configured).
Repeat for every client you need.
see example)
Viewer (Register your code to the event WatchdogsLoaded
, inside that do wathever you want. You have access to the watchdogs
object that can give you a list of the servers, and overriding the onUpdate
method you will receive changes whenever new server info is received.
TODO
License
See LICENSE file.