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