Browse Source

add servicecheck check command to cli

pull/14/head
Brett Langdon 11 years ago
parent
commit
8c0cc5920e
2 changed files with 41 additions and 1 deletions
  1. +5
    -0
      bin/dogapi
  2. +36
    -1
      lib/api/serviceCheck.js

+ 5
- 0
bin/dogapi View File

@ -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){


+ 36
- 1
lib/api/serviceCheck.js View File

@ -51,5 +51,40 @@ function check(check, hostName, status, parameters, callback){
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);
}
}
};

Loading…
Cancel
Save