Commit 1b19e6ce3a6d1a135b309b956e072582e2592a9d

Authored by Imanol-Mikel Barba Sabariego
1 parent eb304da0

Fixed bugs

check_sensors/check_sensors.cpp
... ... @@ -45,6 +45,10 @@ int evalStatus(const std::string& sensorName, double warn, double crit, std::str
45 45 status = "Error retrieving temps from libsensors: " + int2str(rc);
46 46 return UNKN;
47 47 }
  48 + if(!temps.size()) {
  49 + status = "Sensor " + sensorName + " not found";
  50 + return UNKN;
  51 + }
48 52  
49 53 for(const std::pair<std::string, double>& entry : temps) {
50 54 std::string feature = entry.first;
... ... @@ -176,9 +180,9 @@ int main(int argc, char **argv) {
176 180 else if(returnCode == WARN) {std::cout << " WARNING - sensors: ";}
177 181 else if(returnCode == CRIT) {std::cout << " CRITICAL - sensors: ";}
178 182 else if(returnCode == UNKN) {std::cout << " UNKNOWN - sensors: ";}
179   - for(int i = 0; i < (argc-1); i++) {
  183 + for(int i = 0; i < results.size(); ++i) {
180 184 std::cout << results[i];
181   - if(i != (argc-2)) {std::cout << ", ";}
  185 + if(i != (results.size()-1)) {std::cout << ", ";}
182 186 }
183 187 std::cout << std::endl;
184 188 return returnCode;
... ...