Ignore:
Timestamp:
01/09/12 22:34:25 (17 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
ba63b95
Parents:
a87ce04
Message:
  • Fixed hostname issue in NSCAClient (hostname = auto now auto detects hostname
  • Fixed some minor issues in NSCA and CLI api
  • Added CLI based (exec) APIs to NSCA unit tests (now 697 test for NSCA)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/client/command_line_parser.cpp

    ra87ce04 r7354aa1  
    2525  desc.add_options() 
    2626    ("command,c", po::wvalue<std::wstring>(&command_data->command), "The name of the command that the remote daemon should run") 
     27    ("alias,a", po::wvalue<std::wstring>(&command_data->command), "Same as command") 
    2728    ("message,m", po::wvalue<std::wstring>(&command_data->message), "Message") 
    28     ("result,r", po::value<unsigned int>(&command_data->result), "Result code") 
     29    ("result,r", po::wvalue<std::wstring>(&command_data->result), "Result code either a number or OK, WARN, CRIT, UNKNOWN") 
    2930    ; 
    3031} 
     
    5253} 
    5354 
     55int parse_result(std::wstring key) { 
     56  if (key == _T("UNKNOWN") || key == _T("unknown")) 
     57    return NSCAPI::returnUNKNOWN; 
     58  if (key == _T("warn") || key == _T("WARN") || key == _T("WARNING") || key == _T("warning")) 
     59    return NSCAPI::returnWARN; 
     60  if (key == _T("crit") || key == _T("CRIT") || key == _T("CRITICAL") || key == _T("critical")) 
     61    return NSCAPI::returnWARN; 
     62  if (key == _T("OK") || key == _T("ok")) 
     63    return NSCAPI::returnUNKNOWN; 
     64  try { 
     65    return strEx::stoi(key); 
     66  } catch (...) { 
     67    return NSCAPI::returnUNKNOWN; 
     68  } 
     69} 
    5470 
    5571int client::command_line_parser::do_execute_command_as_exec(configuration &config, const std::wstring &command, std::list<std::wstring> &arguments, std::string &result) { 
     
    226242  modify_header(config, message.mutable_header(), config.data->recipient); 
    227243  message.set_channel("CLI"); 
    228   nscapi::functions::append_simple_submit_request_payload(message.add_payload(), config.data->command, config.data->result, config.data->message); 
     244  nscapi::functions::append_simple_submit_request_payload(message.add_payload(), config.data->command, parse_result(config.data->result), config.data->message); 
    229245 
    230246  return config.handler->submit(config.data, message.mutable_header(), message.SerializeAsString(), result); 
Note: See TracChangeset for help on using the changeset viewer.