From 18be42603954710f7a5f958b4aec95e4cd254f3c Mon Sep 17 00:00:00 2001 From: Nigel Hanlon Date: Wed, 9 Sep 2015 18:06:33 +0100 Subject: [PATCH] Initial commit --- README.md | 24 ++++++++++++++++++++++++ index.js | 17 +++++++++++++++++ package.json | 27 +++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 README.md create mode 100644 index.js create mode 100644 package.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..d2de68a --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +## Netclock + +Netclock is a very simple command line tool for querying ntp and comparing the result with the system time. + +Uses pool.ntp.org as a time server. + +## Usage + +``` +$ npm install netclock + +$ netclock + ____________________________________________________ + + System time : Wed Sep 09 2015 17:51:15 GMT+0100 (IST) + Network time : Wed Sep 09 2015 17:51:33 GMT+0100 (IST) + + ____________________________________________________ + +``` + +## License + +MIT License (MIT) diff --git a/index.js b/index.js new file mode 100644 index 0000000..bce04f8 --- /dev/null +++ b/index.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +var colors = require('colors'); +var ntpClient = require('ntp-client'); + +ntpClient.getNetworkTime("pool.ntp.org", 123, function(err, date) { + if(err) { + console.error("%s".red, err); + process.exit(1) + return; + } + console.log(' ____________________________________________________\n'.blue); + console.log(" System time : %s".blue, new Date()); + console.log(" Network time : %s".green, date); + console.log('\n ____________________________________________________'.blue); + process.exit(0) +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..8c1da1e --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "netclock", + "version": "1.0.0", + "description": "A simple tool for querying network timeservers", + "main": "index.js", + "bin": { + "netclock": "index.js" + }, + "keywords": [ + "time", + "net", + "server", + "ntp" + ], + "author": "Nigel Hanlon ", + "contributors": [ + { + "name": "Nigel Hanlon", + "email": "nigel@mapwolf.net" + } + ], + "license": "MIT", + "dependencies": { + "colors" : "*", + "ntp-client": "*" + } +}