Skip to content

Instantly share code, notes, and snippets.

@julien-f
Created June 18, 2018 16:17
Show Gist options
  • Save julien-f/27516663724579d07ac77c73fedcc97c to your computer and use it in GitHub Desktop.
Save julien-f/27516663724579d07ac77c73fedcc97c to your computer and use it in GitHub Desktop.
Test RRDs
#!/usr/bin/env node
const hrp = require('http-request-plus').default
const JSON5 = require('json5')
const required = param => {
throw new Error(`missing required param ${param}`)
}
async function main (args) {
if (args.length < 2 || args.some(_ => _ === '-h' || _ === '--help')) {
return console.log('test-rrds <XenServer host URL> <start> [<interval>]')
}
const [url, start, interval] = args
const { meta } = await hrp(url, {
pathname: '/rrd_updates',
query: {
interval,
json: 'true',
start: start < 0 ? Math.floor(Date.now() / 1e3) + +start : start,
}
}).readAll().then(JSON5.parse)
console.log(meta)
}
main(process.argv.slice(2)).catch(console.error.bind(console, 'error'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment