|
|
@ -51,5 +51,40 @@ function check(check, hostName, status, parameters, callback){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
check: check |
|
|
|
|
|
|
|
|
check: check, |
|
|
|
|
|
getUsage: function(){ |
|
|
|
|
|
return [ |
|
|
|
|
|
"${command} servicecheck check <check> <host> <status> [--time <timestamp>] [--message <message>] [--tags <tags>]" |
|
|
|
|
|
]; |
|
|
|
|
|
}, |
|
|
|
|
|
getHelp: function(){ |
|
|
|
|
|
return [ |
|
|
|
|
|
"Service Check:", |
|
|
|
|
|
" Commands:", |
|
|
|
|
|
" check <check> <host> <status> add a new service check for <check> and <host> at level <status>", |
|
|
|
|
|
"", |
|
|
|
|
|
" Options:", |
|
|
|
|
|
" <status> 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN", |
|
|
|
|
|
" --time <timestamp> the POSIX timestamp to use for the check", |
|
|
|
|
|
" --message <message> an optional message to accompany the check", |
|
|
|
|
|
" --tags <tags> a comma separated list of \"tag:value\"'s for the check" |
|
|
|
|
|
]; |
|
|
|
|
|
}, |
|
|
|
|
|
handleCli: function(subcommand, args, callback){ |
|
|
|
|
|
if(args._.length > 6){ |
|
|
|
|
|
var parameters = {}; |
|
|
|
|
|
if(args["time"]){ |
|
|
|
|
|
parameters.time = parseInt(args["time"]); |
|
|
|
|
|
} |
|
|
|
|
|
if(args["message"]){ |
|
|
|
|
|
paramaters.message = args["message"]; |
|
|
|
|
|
} |
|
|
|
|
|
if(args["tags"]){ |
|
|
|
|
|
parameters.tags = args["tags"].split(","); |
|
|
|
|
|
} |
|
|
|
|
|
check(args._[4], args._[5], parseInt(args._[6]), parameters, callback); |
|
|
|
|
|
} else { |
|
|
|
|
|
callback("not enough arguments try `dogapi servicecheck --help` for help", false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |