("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning threshold")
("critical,c", po::wvalue<wstring>(), "critical threshold")
- ("drives,d", po::wvalue<vector<std::wstring>>()->multitoken(), "declare explicitly which drives to check (default checks all)")
+ ("path,p", po::wvalue<vector<std::wstring>>()->multitoken(), "declare explicitly which drives to check (default checks all)")
("unit,u", po::wvalue<wstring>(), "assign unit possible are: B, kB, MB, GB, TB")
;
}
}
- if (vm.count("drives"))
- printInfo.drives = vm["drives"].as<vector<wstring>>();
+ if (vm.count("path"))
+ printInfo.drives = vm["path"].as<vector<wstring>>();
if (vm.count("unit")) {
try {
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
+
+#include "thresholds.h"
+#include <boost/program_options.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
#include <Pdh.h>
#include <Shlwapi.h>
#include <pdhmsg.h>
#include <iostream>
-#include "thresholds.h"
-
-#include "boost/program_options.hpp"
-
#define VERSION 1.0
namespace po = boost::program_options;
if (vm.count("warning")) {
try {
- printInfo.warn = threshold(vm["warning"].as<wstring>());
+ std::wstring wthreshold = vm["warning"].as<wstring>();
+ std::vector<std::wstring> tokens;
+ boost::algorithm::split(tokens, wthreshold, boost::algorithm::is_any_of(","));
+ printInfo.warn = threshold(tokens[0]);
} catch (std::invalid_argument& e) {
cout << e.what() << endl;
return 3;
}
if (vm.count("critical")) {
try {
- printInfo.crit = threshold(vm["critical"].as<wstring>());
+ std::wstring cthreshold = vm["critical"].as<wstring>();
+ std::vector<std::wstring> tokens;
+ boost::algorithm::split(tokens, cthreshold, boost::algorithm::is_any_of(","));
+ printInfo.crit = threshold(tokens[0]);
} catch (std::invalid_argument& e) {
cout << e.what() << endl;
return 3;
switch (state) {
case OK:
- wcout << L"USERS OK " << printInfo.users << L"User|users=" << printInfo.users << L";"
+ wcout << L"USERS OK " << printInfo.users << L" User(s)|users=" << printInfo.users << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl;
break;
case WARNING:
- wcout << L"USERS WARNING " << printInfo.users << L"User|users=" << printInfo.users << L";"
+ wcout << L"USERS WARNING " << printInfo.users << L" User(s)|users=" << printInfo.users << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl;
break;
case CRITICAL:
- wcout << L"USERS CRITICAL " << printInfo.users << L"User|users=" << printInfo.users << L";"
+ wcout << L"USERS CRITICAL " << printInfo.users << L" User(s)|users=" << printInfo.users << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl;
break;
}
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#include <vector>
-#include <iostream>
#include "thresholds.h"
+#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
+#include <vector>
+#include <iostream>
-#include "boost/algorithm/string.hpp"
-#include "boost/lexical_cast.hpp"
-
using namespace boost::algorithm;
using std::wstring;
}
try {
- double d1 = boost::lexical_cast<double>(str1);
- double d2 = boost::lexical_cast<double>(str2);
- lower = d1; upper = d2; legal = !low; perc = pc; set = true;
+ boost::algorithm::trim(str1);
+ lower = boost::lexical_cast<double>(str1);
+ boost::algorithm::trim(str2);
+ upper = boost::lexical_cast<double>(str2);
+ legal = !low; perc = pc; set = true;
} catch (const boost::bad_lexical_cast&) {
throw std::invalid_argument("Unknown Threshold type");
}
str = wstring(str.begin(), str.end() - 1);
}
try {
- double d = boost::lexical_cast<double>(str);
- lower = d; upper = d; legal = !low; perc = pc; set = true;
+ boost::algorithm::trim(str);
+ lower = upper = boost::lexical_cast<double>(str);
+ legal = !low; perc = pc; set = true;
} catch (const boost::bad_lexical_cast&) {
throw std::invalid_argument("Unknown Threshold type");
}