Created
March 10, 2017 13:23
-
-
Save denizozger/14ecd1be149784a57fee756c100b30c0 to your computer and use it in GitHub Desktop.
New Relic Synthetics Monitoring Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var options = { | |
'auth': { | |
'user': 'USER', | |
'pass': 'PASS', | |
'sendImmediately': false | |
} | |
}; | |
console.log('Node ', process.version) | |
$http.get('SOME-URL', options, function (err, response, bodyStr) { | |
console.log('Response:', bodyStr); | |
assert.equal(response.statusCode, 200, 'Expected a 200 OK response'); | |
var body = null | |
try { | |
body = JSON.parse(bodyStr) | |
} catch (e) { | |
// this service didn't implement the new format, validation above will need to be enough.. | |
} | |
if (body) { | |
Object.keys(body).forEach(function(k) { | |
const v = body[k] | |
assert(v.toLowerCase().indexOf('up') !== -1, (k + ' is not up')) | |
}) | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment