Changeset 22d2739 in nscp
- Timestamp:
- 11/06/07 21:26:06 (6 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 3ece2bd
- Parents:
- b749b8d
- Files:
-
- 12 edited
-
AutoBuild.h (modified) (1 diff)
-
NSCPlugin.h (modified) (1 diff)
-
NSClient++.cpp (modified) (2 diffs)
-
NSClient++.vcproj (modified) (13 diffs)
-
changelog (modified) (1 diff)
-
include/NSCHelper.cpp (modified) (1 diff)
-
modules/CheckWMI/CheckWMI.cpp (modified) (3 diffs)
-
modules/CheckWMI/CheckWMI.def (modified) (1 diff)
-
modules/CheckWMI/CheckWMI.h (modified) (3 diffs)
-
modules/CheckWMI/CheckWMI.vcproj (modified) (1 diff)
-
modules/CheckWMI/WMIQuery.cpp (modified) (1 diff)
-
modules/CheckWMI/WMIQuery.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
AutoBuild.h
rb749b8d r22d2739 3 3 // change the FALSE to TRUE for autoincrement of build number 4 4 #define INCREMENT_VERSION TRUE 5 #define FILEVER 0,2,7,4 26 #define PRODUCTVER 0,2,7,14 07 #define STRFILEVER "0.2.7.4 2"8 #define STRPRODUCTVER "0.2.7.14 0"9 #define STRPRODUCTDATE "2007-11-0 4"5 #define FILEVER 0,2,7,44 6 #define PRODUCTVER 0,2,7,142 7 #define STRFILEVER "0.2.7.44" 8 #define STRPRODUCTVER "0.2.7.142" 9 #define STRPRODUCTDATE "2007-11-06" 10 10 #endif // AUTOBUILD_H -
NSCPlugin.h
rdc65e35 r22d2739 153 153 std::string getCongifurationMeta(); 154 154 int commandLineExec(const char* command, const unsigned int argLen, char **arguments); 155 std::string getModule() { 156 if (file_.empty()) 157 return ""; 158 std::string ret = file_; 159 int pos = ret.find_last_of("\\"); 160 if (pos != std::string::npos && ++pos < ret.length()) { 161 ret = ret.substr(pos); 162 } 163 pos = ret.find_last_of("."); 164 if (pos != std::string::npos) { 165 ret = ret.substr(0, pos); 166 } 167 return ret; 168 } 155 169 156 170 private: -
NSClient++.cpp
rb749b8d r22d2739 241 241 return -1; 242 242 } 243 std::string moduleList = ""; 243 244 for (pluginList::size_type i=0;i<plugins_.size();++i) { 244 245 NSCPlugin *p = plugins_[i]; 245 if (p->getName() == sModule) { 246 if (!moduleList.empty()) 247 moduleList += ", "; 248 moduleList += p->getModule(); 249 if (p->getModule() == sModule) { 246 250 LOG_DEBUG_STD("Found module: " + p->getName() + "..."); 247 251 try { … … 249 253 } catch (NSPluginException e) { 250 254 LOG_ERROR_STD("Could not execute command: " + e.error_ + " in " + e.file_); 251 } 252 } 253 } 254 LOG_ERROR("Module not found."); 255 return -1; 256 } 257 } 258 } 259 LOG_ERROR_STD("Module not found: " + module + " available modules are: " + moduleList); 255 260 return 0; 256 261 } -
NSClient++.vcproj
r12edcec r22d2739 418 418 <Tool 419 419 Name="VCPreBuildEventTool" 420 CommandLine="XAutobuild.exe -f $(ProjectDir)"420 CommandLine="XAutobuild.exe -f "$(ProjectDir)"" 421 421 /> 422 422 <Tool 423 423 Name="VCCustomBuildTool" 424 CommandLine="echo Copying dependency DLLs
cmd /c "xcopy /Q /Y $(InputDir)\dist_dll\*.dll $(InputDir)\Dist\"
echo Removing old archive
cmd /c "del $(InputDir)\Dist\modules\*.pdb"
cmd /c "del $(InputDir)\Dist\*.zip"
echo Making archive
7z.exe a -r -tzip -bd $(TargetDir)\$(InputName)-$(PlatformName).zip $(TargetDir)\*
echo Renaming archive
postbuild.pl "$(TargetDir)\$(InputName)-$(PlatformName).zip"
echo Sending to server
echo pscp.exe $(TargetDir)\*.zip mickem@ssl.nakednuns.org:/var/www/files/nightly/
pscp.exe $(TargetDir)\*.zipmickem@ssl.nakednuns.org:/var/www/files/nightly/
"424 CommandLine="echo Copying dependency DLLs
cmd /c "xcopy /Q /Y $(InputDir)\dist_dll\*.dll $(InputDir)\Dist\"
echo Removing old archive
cmd /c "del "$(InputDir)\Dist\modules\*.pdb""
cmd /c "del "$(InputDir)\Dist\*.zip""
echo Making archive: 7z.exe a -r -tzip -bd "$(TargetDir)\$(InputName)-$(PlatformName).zip" "$(TargetDir)\*"
7z.exe a -r -tzip -bd "$(TargetDir)\$(InputName)-$(PlatformName).zip" "$(TargetDir)\*"
echo Renaming archive
postbuild.pl "$(TargetDir)\$(InputName)-$(PlatformName).zip"
echo Sending to server
echo pscp.exe "$(TargetDir)\*.zip" mickem@ssl.nakednuns.org:/var/www/files/nightly/
pscp.exe "$(TargetDir)\*.zip" mickem@ssl.nakednuns.org:/var/www/files/nightly/
" 425 425 Outputs="$(InputDir)\Dist\$(ProjectName).zip" 426 426 /> … … 1391 1391 <Tool 1392 1392 Name="VCCustomBuildTool" 1393 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputName)" "$(InputDir)\Dist\""
" 1394 Outputs="$(InputDir)\Dist\$(InputFileName)" 1395 /> 1396 </FileConfiguration> 1397 <FileConfiguration 1398 Name="Distribution|x64" 1399 > 1400 <Tool 1401 Name="VCCustomBuildTool" 1393 1402 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputName) $(InputDir)\Dist\"
" 1394 1403 Outputs="$(InputDir)\Dist\$(InputFileName)" … … 1396 1405 </FileConfiguration> 1397 1406 <FileConfiguration 1398 Name="Distribution|x64" 1407 Name="Nightly|Win32" 1408 > 1409 <Tool 1410 Name="VCCustomBuildTool" 1411 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputName)" "$(InputDir)\Dist\""
" 1412 Outputs="$(InputDir)\Dist\$(InputFileName)" 1413 /> 1414 </FileConfiguration> 1415 <FileConfiguration 1416 Name="Nightly|x64" 1399 1417 > 1400 1418 <Tool … … 1404 1422 /> 1405 1423 </FileConfiguration> 1406 <FileConfiguration1407 Name="Nightly|Win32"1408 >1409 <Tool1410 Name="VCCustomBuildTool"1411 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputName)" "$(InputDir)\Dist\""
"1412 Outputs="$(InputDir)\Dist\$(InputFileName)"1413 />1414 </FileConfiguration>1415 <FileConfiguration1416 Name="Nightly|x64"1417 >1418 <Tool1419 Name="VCCustomBuildTool"1420 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputName) $(InputDir)\Dist\"
"1421 Outputs="$(InputDir)\Dist\$(InputFileName)"1422 />1423 </FileConfiguration>1424 1424 </File> 1425 1425 <File … … 1467 1467 <Tool 1468 1468 Name="VCCustomBuildTool" 1469 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(TargetDir)""
" 1470 Outputs="$(TargetDir)$(InputFileName)" 1471 /> 1472 </FileConfiguration> 1473 <FileConfiguration 1474 Name="Distribution|x64" 1475 > 1476 <Tool 1477 Name="VCCustomBuildTool" 1469 1478 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputFileName) $(TargetDir)"
" 1470 1479 Outputs="$(TargetDir)$(InputFileName)" … … 1472 1481 </FileConfiguration> 1473 1482 <FileConfiguration 1474 Name="Distribution|x64" 1483 Name="Nightly|Win32" 1484 > 1485 <Tool 1486 Name="VCCustomBuildTool" 1487 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(TargetDir)""
" 1488 Outputs="$(TargetDir)$(InputFileName)" 1489 /> 1490 </FileConfiguration> 1491 <FileConfiguration 1492 Name="Nightly|x64" 1475 1493 > 1476 1494 <Tool … … 1480 1498 /> 1481 1499 </FileConfiguration> 1482 <FileConfiguration1483 Name="Nightly|Win32"1484 >1485 <Tool1486 Name="VCCustomBuildTool"1487 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(TargetDir)""
"1488 Outputs="$(TargetDir)$(InputFileName)"1489 />1490 </FileConfiguration>1491 <FileConfiguration1492 Name="Nightly|x64"1493 >1494 <Tool1495 Name="VCCustomBuildTool"1496 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputFileName) $(TargetDir)"
"1497 Outputs="$(TargetDir)$(InputFileName)"1498 />1499 </FileConfiguration>1500 1500 </File> 1501 1501 <File … … 1589 1589 <Tool 1590 1590 Name="VCCustomBuildTool" 1591 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(TargetDir)""
" 1592 Outputs="$(TargetDir)\$(InputFileName) " 1593 /> 1594 </FileConfiguration> 1595 <FileConfiguration 1596 Name="Distribution|x64" 1597 > 1598 <Tool 1599 Name="VCCustomBuildTool" 1591 1600 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputFileName) $(TargetDir)"
" 1592 1601 Outputs="$(TargetDir)\$(InputFileName) " … … 1594 1603 </FileConfiguration> 1595 1604 <FileConfiguration 1596 Name="Distribution|x64" 1605 Name="Nightly|Win32" 1606 > 1607 <Tool 1608 Name="VCCustomBuildTool" 1609 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(TargetDir)""
" 1610 Outputs="$(TargetDir)\$(InputFileName) " 1611 /> 1612 </FileConfiguration> 1613 <FileConfiguration 1614 Name="Nightly|x64" 1597 1615 > 1598 1616 <Tool … … 1602 1620 /> 1603 1621 </FileConfiguration> 1604 <FileConfiguration1605 Name="Nightly|Win32"1606 >1607 <Tool1608 Name="VCCustomBuildTool"1609 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(TargetDir)""
"1610 Outputs="$(TargetDir)\$(InputFileName) "1611 />1612 </FileConfiguration>1613 <FileConfiguration1614 Name="Nightly|x64"1615 >1616 <Tool1617 Name="VCCustomBuildTool"1618 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputFileName) $(TargetDir)"
"1619 Outputs="$(TargetDir)\$(InputFileName) "1620 />1621 </FileConfiguration>1622 1622 </File> 1623 1623 <File … … 1629 1629 <Tool 1630 1630 Name="VCCustomBuildTool" 1631 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy $(InputDir)\$(InputFileName) $(InputDir)\Dist\$(InputName).ini"
"1631 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(InputDir)\Dist\$(InputName).ini""
" 1632 1632 Outputs="$(InputDir)\Dist\$(InputName).ini" 1633 1633 /> … … 1689 1689 <Tool 1690 1690 Name="VCCustomBuildTool" 1691 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(InputDir)\$(OutDir)"" "1691 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(InputDir)\$(OutDir)""
" 1692 1692 Outputs="$(InputDir)\$(OutDir)\$(InputFileName)" 1693 1693 /> … … 1698 1698 <Tool 1699 1699 Name="VCCustomBuildTool" 1700 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(InputDir)\$(OutDir)"" "1700 CommandLine="echo Copying $(InputFileName)...
cmd /c "copy "$(InputDir)\$(InputFileName)" "$(InputDir)\$(OutDir)""
" 1701 1701 Outputs="$(InputDir)\$(OutDir)\$(InputFileName)" 1702 1702 /> -
changelog
rb749b8d r22d2739 4 4 * Fix installer (after configuration UI) 5 5 * Add module for relaying events 6 * Add filtering to WMI module7 6 * Fix WMI module 8 7 * Fix PDH problems 9 8 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 9 10 2007-11-06 MickeM 11 + Added CLI interface to CheckWMI to check queries 10 12 11 13 2007-11-04 MickeM -
include/NSCHelper.cpp
r478588b r22d2739 156 156 if ((msgType == NSCAPI::debug) && (!logDebug())) 157 157 return; 158 std::string::size_type pos = file.find_last_of("\\"); 159 if (pos != std::string::npos) 160 file = file.substr(pos); 158 161 return fNSAPIMessage(msgType, file.c_str(), line, message.c_str()); 159 162 } -
modules/CheckWMI/CheckWMI.cpp
rb749b8d r22d2739 25 25 #include <time.h> 26 26 #include <map> 27 #include <vector> 27 28 28 29 … … 155 156 return NSCAPI::returnIgnored; 156 157 } 158 int CheckWMI::commandLineExec(const char* command, const unsigned int argLen, char** char_args) { 159 //WMIQuery wmiQuery; 160 std::string query = command; 161 query += " " + arrayBuffer::arrayBuffer2string(char_args, argLen, " "); 162 WMIQuery::result_type rows; 163 try { 164 rows = wmiQuery.execute(query); 165 } catch (WMIException e) { 166 std::cout << "WMIQuery failed: " + e.getMessage() << std::endl; 167 return -1; 168 } 169 std::vector<int> widths; 170 for (WMIQuery::result_type::iterator citRow = rows.begin(); citRow != rows.end(); ++citRow) { 171 const WMIQuery::wmi_row vals = *citRow; 172 if (citRow == rows.begin()) { 173 for (WMIQuery::wmi_row::list_type::const_iterator citCol = vals.results.begin(); citCol != vals.results.end(); ++citCol) { 174 widths.push_back( (*citCol).first.length()+1 ); 175 } 176 } 177 int i=0; 178 for (WMIQuery::wmi_row::list_type::const_iterator citCol = vals.results.begin(); citCol != vals.results.end(); ++citCol, i++) { 179 widths[i] = max(widths[i], (*citCol).second.string.length()+1); 180 } 181 } 182 183 std::string row2 = "|"; 184 for (WMIQuery::result_type::iterator citRow = rows.begin(); citRow != rows.end(); ++citRow) { 185 const WMIQuery::wmi_row vals = *citRow; 186 if (citRow == rows.begin()) { 187 int i=0; 188 std::string row1 = "|"; 189 for (WMIQuery::wmi_row::list_type::const_iterator citCol = vals.results.begin(); citCol != vals.results.end(); ++citCol, i++) { 190 int w = widths[i]-(*citCol).first.length(); 191 if (w<0) w=0; 192 row1 += std::string(w, ' ') + (*citCol).first + " |"; 193 row2 += std::string(widths[i], '-') + "-+"; 194 195 } 196 NSC_LOG_MESSAGE(row2); 197 NSC_LOG_MESSAGE(row1); 198 NSC_LOG_MESSAGE(row2); 199 } 200 int i=0; 201 std::string row = "|"; 202 for (WMIQuery::wmi_row::list_type::const_iterator citCol = vals.results.begin(); citCol != vals.results.end(); ++citCol, i++) { 203 int w = widths[i]-(*citCol).second.string.length(); 204 if (w<0) w=0; 205 row += std::string(w, ' ') + (*citCol).second.string + " |"; 206 } 207 NSC_LOG_MESSAGE(row); 208 } 209 NSC_LOG_MESSAGE(row2); 210 return 0; 211 } 157 212 158 213 … … 160 215 NSC_WRAPPERS_IGNORE_MSG_DEF(); 161 216 NSC_WRAPPERS_HANDLE_CMD_DEF(gCheckWMI); 217 NSC_WRAPPERS_CLI_DEF(gCheckWMI); -
modules/CheckWMI/CheckWMI.def
r1b7ae3d r22d2739 12 12 NSUnloadModule 13 13 NSGetModuleDescription 14 NSCommandLineExec 14 15 -
modules/CheckWMI/CheckWMI.h
rb749b8d r22d2739 20 20 ***************************************************************************/ 21 21 NSC_WRAPPERS_MAIN(); 22 NSC_WRAPPERS_CLI(); 23 22 24 #include <config.h> 23 25 #include <strEx.h> … … 38 40 39 41 std::string getModuleName() { 40 return "CheckWMI Various Disk related checks.";42 return "CheckWMI"; 41 43 } 42 44 std::string getModuleDescription() { … … 51 53 bool hasMessageHandler(); 52 54 NSCAPI::nagiosReturn handleCommand(const strEx::blindstr command, const unsigned int argLen, char **char_args, std::string &message, std::string &perf); 55 int CheckWMI::commandLineExec(const char* command,const unsigned int argLen,char** args); 53 56 54 57 // Check commands -
modules/CheckWMI/CheckWMI.vcproj
rb749b8d r22d2739 758 758 </File> 759 759 <File 760 RelativePath=".\CheckWMI.def" 761 > 762 </File> 763 <File 760 764 RelativePath="..\..\include\NSCHelper.cpp" 761 765 > -
modules/CheckWMI/WMIQuery.cpp
rb749b8d r22d2739 62 62 } 63 63 64 std::string WMIQuery::sanitize_string(LPTSTR in) { 65 TCHAR *p = in; 66 while (*p) { 67 if (p[0] < ' ' || p[0] > '}') 68 p[0] = '.'; 69 p++; 70 } 71 return in; 72 } 64 73 65 74 WMIQuery::result_type WMIQuery::execute(std::string query) -
modules/CheckWMI/WMIQuery.h
rb749b8d r22d2739 152 152 153 153 result_type execute(std::string query); 154 std::string sanitize_string(LPTSTR in); 154 155 155 156 bool initialize();
Note: See TracChangeset
for help on using the changeset viewer.








