我试图使用脚本运行NewRelic合成文件时过滤时间范围。只是想知道这样做的可能方法。
$http.get(options,
// Callback
function (err, response, body) {
var path = response.request.uri.pathname;
if(response != undefined or TimeRanges(SINCE '00:00:00' UNTIL '08:00:00') ){
// any statuscode other than 200, alert
var statusMessage = path + " returns status code: " + response.statusCode +". \n";
console.log("Status message : ",statusMessage);
if(response.statusCode !== 200){
failMessage += statusMessage;
console.log("status code is not 200");
}
else {
console.log("Status code is 200");
var responseContent = JSON.parse(body)
console.log('Response from ' + path + ':', responseContent.isHealthy);
if(!responseContent.isHealthy){
failMessage += path + " seems not healthy. \n";
}
}
}
else {
console.log("No response from endpoint");
failMessage += path + " seems to be down. \n";
}
}, function(){
console.log("Fail message : ", failMessage);
}
但是下面没有按预期编译。 if(response != undefined or TimeRanges(SINCE '00:00:00' UNTIL '08:00:00') )
错误:
Job failed before completion (id: "undefined"): Unexpected identifier
SyntaxError: Unexpected identifier
at JobResource.getScriptFn (/opt/runtimes/3.0.0/modules/synthetics-runner/lib/job-resource/index.js:76:19)
at ApiScriptRunner.value [as run] (/opt/runtimes/3.0.0/modules/synthetics-runner/lib/runner/0.5.0/script-runner.js:67:44)
at Object. (/opt/runtimes/3.0.0/main.js:15:35)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
基本上,我不想在此时间范围内运行合成程序。