diff --git a/bin/dogapi b/bin/dogapi index 10a6acf..882ac85 100755 --- a/bin/dogapi +++ b/bin/dogapi @@ -40,6 +40,11 @@ var args = minimist(process.argv); var command = args._[2]; var subcommand = args._[3]; +// this is the one unusual case +if(command === "servicecheck"){ + command = "serviceCheck"; +} + if(command === "now"){ console.log(dogapi.now()); } else if(command === "then" && args._.length > 3){ diff --git a/lib/api/serviceCheck.js b/lib/api/serviceCheck.js index 5db6ea0..39edf5f 100644 --- a/lib/api/serviceCheck.js +++ b/lib/api/serviceCheck.js @@ -51,5 +51,40 @@ function check(check, hostName, status, parameters, callback){ module.exports = { - check: check + check: check, + getUsage: function(){ + return [ + "${command} servicecheck check [--time ] [--message ] [--tags ]" + ]; + }, + getHelp: function(){ + return [ + "Service Check:", + " Commands:", + " check add a new service check for and at level ", + "", + " Options:", + " 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN", + " --time the POSIX timestamp to use for the check", + " --message an optional message to accompany the check", + " --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); + } + } };