Changeset 7354aa1 in nscp for include/client/command_line_parser.cpp
- Timestamp:
- 01/09/12 22:34:25 (17 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- ba63b95
- Parents:
- a87ce04
- File:
-
- 1 edited
-
include/client/command_line_parser.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
include/client/command_line_parser.cpp
ra87ce04 r7354aa1 25 25 desc.add_options() 26 26 ("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") 27 28 ("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") 29 30 ; 30 31 } … … 52 53 } 53 54 55 int 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 } 54 70 55 71 int client::command_line_parser::do_execute_command_as_exec(configuration &config, const std::wstring &command, std::list<std::wstring> &arguments, std::string &result) { … … 226 242 modify_header(config, message.mutable_header(), config.data->recipient); 227 243 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); 229 245 230 246 return config.handler->submit(config.data, message.mutable_header(), message.SerializeAsString(), result);
Note: See TracChangeset
for help on using the changeset viewer.








