Changeset 36c340d in nscp
- Timestamp:
- 02/25/05 21:47:45 (8 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 8223547
- Parents:
- a1e1922
- Files:
-
- 27 edited
-
NSCPlugin.cpp (modified) (2 diffs)
-
NSCPlugin.h (modified) (1 diff)
-
NSClient++.cpp (modified) (10 diffs)
-
NSClient++.h (modified) (3 diffs)
-
NSClient++.sln (modified) (3 diffs)
-
NSClient++.vcproj (modified) (4 diffs)
-
Settings.h (modified) (1 diff)
-
include/NSCAPI.h (modified) (2 diffs)
-
include/NSCHelper.cpp (modified) (1 diff)
-
include/NSCHelper.h (modified) (2 diffs)
-
include/PDHCounter.h (modified) (1 diff)
-
include/thread.h (modified) (1 diff)
-
modules/CheckDisk/CheckDisk.cpp (modified) (2 diffs)
-
modules/CheckDisk/CheckDisk.def (modified) (1 diff)
-
modules/CheckDisk/CheckDisk.h (modified) (1 diff)
-
modules/CheckDisk/CheckDisk.vcproj (modified) (4 diffs)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (16 diffs)
-
modules/CheckEventLog/CheckEventLog.def (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.vcproj (modified) (3 diffs)
-
modules/CheckEventLog/stdafx.h (modified) (1 diff)
-
modules/ConsoleLogger/ConsoleLogger.vcproj (modified) (2 diffs)
-
modules/FileLogger/FileLogger.vcproj (modified) (2 diffs)
-
modules/NSClientCompat/NSClientCompat.cpp (modified) (1 diff)
-
modules/NSClientCompat/NSClientCompat.vcproj (modified) (2 diffs)
-
modules/NSClientCompat/PDHCollector.cpp (modified) (3 diffs)
-
modules/SysTray/SysTray.vcproj (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
NSCPlugin.cpp
rac676a8 r36c340d 8 8 * @param file The file (DLL) to load as a NSC plug in. 9 9 */ 10 NSCPlugin::NSCPlugin( std::string file)10 NSCPlugin::NSCPlugin(const std::string file) 11 11 : file_(file) 12 12 ,fLoadModule(NULL) … … 130 130 */ 131 131 void NSCPlugin::handleMessage(int msgType, const char* file, const int line, const char *message) { 132 if (! isLoaded())132 if (!fHandleMessage) 133 133 throw NSPluginException(file_, "Library is not loaded"); 134 134 fHandleMessage(msgType, file, line, message); -
NSCPlugin.h
rac676a8 r36c340d 107 107 108 108 public: 109 NSCPlugin( std::string file);109 NSCPlugin(const std::string file); 110 110 virtual ~NSCPlugin(void); 111 111 -
NSClient++.cpp
r3baaa4d r36c340d 144 144 * @param plugins A list with plug-ins (DLL files) to load 145 145 */ 146 void NSClientT::loadPlugins(std::list<std::string> plugins) { 146 void NSClientT::loadPlugins(const std::list<std::string> plugins) { 147 MutexLock lock(pluginMutex); 148 if (!lock.hasMutex()) { 149 LOG_ERROR("FATAL ERROR: Could not get mutex."); 150 return; 151 } 147 152 std::list<std::string>::const_iterator it; 148 153 for (it = plugins.begin(); it != plugins.end(); ++it) { … … 154 159 */ 155 160 void NSClientT::unloadPlugins() { 161 MutexLock lock(pluginMutex); 162 if (!lock.hasMutex()) { 163 LOG_ERROR("FATAL ERROR: Could not get mutex."); 164 return; 165 } 156 166 pluginList::reverse_iterator it; 157 167 for (it = plugins_.rbegin(); it != plugins_.rend(); ++it) { … … 175 185 * @param file The DLL file 176 186 */ 177 void NSClientT::loadPlugin( std::string file) {187 void NSClientT::loadPlugin(const std::string file) { 178 188 addPlugin(new NSCPlugin(file)); 179 189 } … … 183 193 */ 184 194 void NSClientT::addPlugin(plugin_type plugin) { 195 MutexLock lock(pluginMutex); 196 if (!lock.hasMutex()) { 197 LOG_ERROR("FATAL ERROR: Could not get mutex."); 198 return; 199 } 185 200 plugin->load(); 186 201 LOG_DEBUG_STD("Loading: " + plugin->getName()); … … 198 213 * @return The result, empty string if no result 199 214 */ 200 std::string NSClientT::inject( std::string buffer) {215 std::string NSClientT::inject(const std::string buffer) { 201 216 std::list<std::string> args = charEx::split(buffer.c_str(), '&'); 202 if (args.size() < 2) {203 LOG_MESSAGE("Insufficient arguments!");204 }205 217 std::string command = args.front(); args.pop_front(); 206 218 LOG_MESSAGE_STD("Injecting: " + command); … … 230 242 */ 231 243 std::string NSClientT::execute(std::string password, std::string cmd, std::list<std::string> args) { 244 MutexLock lock(pluginMutex); 245 if (!lock.hasMutex()) { 246 LOG_ERROR("FATAL ERROR: Could not get mutex."); 247 return "FATAL ERROR"; 248 } 232 249 static unsigned int bufferSize = 0; 233 250 if (bufferSize == 0) … … 257 274 break; 258 275 } else if (c == NSCAPI::isfalse) { // Module ignored the message 276 LOG_DEBUG("A module ignored this message"); 259 277 } else if (c == NSCAPI::invalidBufferLen) { // Buffer is to small 260 278 LOG_ERROR("Return buffer to small, need to increase it in the ini file."); … … 279 297 * @param msgType Message type 280 298 * @param file Filename generally __FILE__ 281 * @param line Line number, general y __LINE__299 * @param line Line number, generally __LINE__ 282 300 * @param message The message as a human readable string. 283 301 */ 284 302 void NSClientT::reportMessage(int msgType, const char* file, const int line, std::string message) { 285 303 MutexLock lock(messageMutex); 304 if (!lock.hasMutex()) { 305 LOG_ERROR("FATAL ERROR: Could not get mutex."); 306 return; 307 } 308 if (msgType == NSCAPI::debug) { 309 typedef enum status {unknown, debug, nodebug }; 310 static status d = unknown; 311 if (d == unknown) { 312 if (Settings::getInstance()->getInt("log", "debug", 0) == 1) 313 d = debug; 314 else 315 d = nodebug; 316 } 317 if (d == nodebug) 318 return; 319 } 286 320 pluginList::const_iterator plit; 287 321 for (plit = messageHandlers_.begin(); plit != messageHandlers_.end(); ++plit) { … … 290 324 } catch(const NSPluginException& e) { 291 325 // Here we are pretty much fucked! (as logging this might cause a loop :) 292 throw "This shouldn't have happened...";326 std::cout << "This is *really really* bad, now the world is about to end..." << std::endl; 293 327 } 294 328 } 295 329 } 296 330 std::string NSClientT::getBasePath(void) { 331 MutexLock lock(pluginMutex); 332 if (!lock.hasMutex()) { 333 LOG_ERROR("FATAL ERROR: Could not get mutex."); 334 return "FATAL ERROR"; 335 } 297 336 if (!basePath.empty()) 298 337 return basePath; … … 314 353 return Settings::getInstance()->getInt(section, key, defaultValue); 315 354 } 316 317 318 355 int NSAPIGetBasePath(char*buffer, unsigned int bufLen) { 319 356 return NSCHelper::wrapReturnString(buffer, bufLen, mainClient.getBasePath()); -
NSClient++.h
rac676a8 r36c340d 44 44 TCPSocketResponderThread socketThread; 45 45 std::string basePath; 46 MutexHandler pluginMutex; 46 47 MutexHandler messageMutex; 47 48 … … 60 61 static std::string getPassword(void); 61 62 std::string getBasePath(void); 62 std::string inject( std::string buffer);63 std::string inject(const std::string buffer); 63 64 std::string execute(std::string password, std::string cmd, std::list<std::string> args); 64 65 void reportMessage(int msgType, const char* file, const int line, std::string message); 65 66 66 void loadPlugins( std::list<std::string> plugins);67 void loadPlugin( std::string plugin);67 void loadPlugins(const std::list<std::string> plugins); 68 void loadPlugin(const std::string plugin); 68 69 void loadPlugins(void); 69 70 void unloadPlugins(void); … … 106 107 #define LOG_MESSAGE(msg) \ 107 108 NSAPIMessage(NSCAPI::log, __FILE__, __LINE__, msg) 108 #ifdef _DEBUG109 109 #define LOG_DEBUG_STD(msg) LOG_DEBUG(((std::string)msg).c_str()) 110 110 #define LOG_DEBUG(msg) \ 111 111 NSAPIMessage(NSCAPI::debug, __FILE__, __LINE__, msg) 112 #else113 #define LOG_DEBUG_STD(msg)114 #define LOG_DEBUG(msg)115 #endif116 -
NSClient++.sln
rdb70efa r36c340d 2 2 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NSClient++", "NSClient++.vcproj", "{2286162D-7571-4735-BAC8-4A8D33A4F42D}" 3 3 ProjectSection(ProjectDependencies) = postProject 4 {BA246C01-063A-4548-8957-32D5CC76171B} = {BA246C01-063A-4548-8957-32D5CC76171B}5 4 {BBFF8362-C626-4838-B0A2-F695D638AD24} = {BBFF8362-C626-4838-B0A2-F695D638AD24} 6 5 {2D78C363-02BD-4171-8F91-6B4D669A98BF} = {2D78C363-02BD-4171-8F91-6B4D669A98BF} 7 6 {79F1F571-78A6-4B20-8BD5-0F65CD60012C} = {79F1F571-78A6-4B20-8BD5-0F65CD60012C} 7 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45} = {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45} 8 8 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F} = {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F} 9 9 EndProjectSection … … 39 39 GlobalSection(SolutionConfiguration) = preSolution 40 40 Debug = Debug 41 Debug Dynamic Linkage = Debug Dynamic Linkage 41 42 Release = Release 43 Release Dynamic Linkage = Release Dynamic Linkage 42 44 Release M$ STL = Release M$ STL 43 45 EndGlobalSection … … 45 47 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug.ActiveCfg = Debug|Win32 46 48 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug.Build.0 = Debug|Win32 49 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 50 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 47 51 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release.ActiveCfg = Release|Win32 48 52 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release.Build.0 = Release|Win32 53 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 54 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 49 55 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release M$ STL.ActiveCfg = Release M$ STL|Win32 50 56 {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release M$ STL.Build.0 = Release M$ STL|Win32 51 57 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug.ActiveCfg = Debug|Win32 52 58 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug.Build.0 = Debug|Win32 59 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 60 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 53 61 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release.ActiveCfg = Release|Win32 54 62 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release.Build.0 = Release|Win32 63 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 64 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 55 65 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release M$ STL.ActiveCfg = Release|Win32 56 66 {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release M$ STL.Build.0 = Release|Win32 57 67 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug.ActiveCfg = Debug|Win32 58 68 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug.Build.0 = Debug|Win32 69 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 70 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 59 71 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release.ActiveCfg = Release|Win32 60 72 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release.Build.0 = Release|Win32 73 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 74 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 61 75 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release M$ STL.ActiveCfg = Release|Win32 62 76 {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release M$ STL.Build.0 = Release|Win32 63 77 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug.ActiveCfg = Debug|Win32 64 78 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug.Build.0 = Debug|Win32 79 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 80 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 65 81 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release.ActiveCfg = Release|Win32 66 82 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release.Build.0 = Release|Win32 83 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 84 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 67 85 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release M$ STL.ActiveCfg = Release|Win32 68 86 {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release M$ STL.Build.0 = Release|Win32 69 87 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug.ActiveCfg = Debug|Win32 70 88 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug.Build.0 = Debug|Win32 89 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 90 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 71 91 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release.ActiveCfg = Release|Win32 72 92 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release.Build.0 = Release|Win32 93 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 94 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 73 95 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release M$ STL.ActiveCfg = Release|Win32 74 96 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release M$ STL.Build.0 = Release|Win32 75 97 {BA246C01-063A-4548-8957-32D5CC76171B}.Debug.ActiveCfg = Debug|Win32 76 98 {BA246C01-063A-4548-8957-32D5CC76171B}.Debug.Build.0 = Debug|Win32 99 {BA246C01-063A-4548-8957-32D5CC76171B}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 100 {BA246C01-063A-4548-8957-32D5CC76171B}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 77 101 {BA246C01-063A-4548-8957-32D5CC76171B}.Release.ActiveCfg = Release|Win32 78 102 {BA246C01-063A-4548-8957-32D5CC76171B}.Release.Build.0 = Release|Win32 103 {BA246C01-063A-4548-8957-32D5CC76171B}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 104 {BA246C01-063A-4548-8957-32D5CC76171B}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 79 105 {BA246C01-063A-4548-8957-32D5CC76171B}.Release M$ STL.ActiveCfg = Release|Win32 80 106 {BA246C01-063A-4548-8957-32D5CC76171B}.Release M$ STL.Build.0 = Release|Win32 81 107 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug.ActiveCfg = Debug|Win32 82 108 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug.Build.0 = Debug|Win32 109 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 110 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 83 111 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release.ActiveCfg = Release|Win32 84 112 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release.Build.0 = Release|Win32 113 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 114 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 85 115 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release M$ STL.ActiveCfg = Release|Win32 86 116 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release M$ STL.Build.0 = Release|Win32 -
NSClient++.vcproj
ra0528c4 r36c340d 209 209 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 210 210 </Configuration> 211 <Configuration 212 Name="Dynamic Linkage|Win32" 213 OutputDirectory="$(ConfigurationName)" 214 IntermediateDirectory="$(ConfigurationName)" 215 ConfigurationType="1" 216 UseOfMFC="0" 217 ATLMinimizesCRunTimeLibraryUsage="FALSE" 218 CharacterSet="2"> 219 <Tool 220 Name="VCCLCompilerTool" 221 Optimization="2" 222 InlineFunctionExpansion="1" 223 AdditionalIncludeDirectories="include" 224 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 225 StringPooling="TRUE" 226 RuntimeLibrary="2" 227 EnableFunctionLevelLinking="TRUE" 228 UsePrecompiledHeader="3" 229 PrecompiledHeaderThrough="stdafx.h" 230 PrecompiledHeaderFile=".\Release/IconService.pch" 231 AssemblerListingLocation=".\Release/" 232 ObjectFile=".\Release/" 233 ProgramDataBaseFileName=".\Release/" 234 WarningLevel="3" 235 SuppressStartupBanner="TRUE"/> 236 <Tool 237 Name="VCCustomBuildTool"/> 238 <Tool 239 Name="VCLinkerTool" 240 AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib" 241 OutputFile=".\Release/NSClient++.exe" 242 LinkIncremental="1" 243 SuppressStartupBanner="TRUE" 244 IgnoreAllDefaultLibraries="FALSE" 245 IgnoreDefaultLibraryNames="" 246 ModuleDefinitionFile="" 247 ProgramDatabaseFile=".\Release/IconService.pdb" 248 SubSystem="1" 249 OptimizeForWindows98="1" 250 TargetMachine="1"/> 251 <Tool 252 Name="VCMIDLTool" 253 TypeLibraryName=".\Release/IconService.tlb" 254 HeaderFileName=""/> 255 <Tool 256 Name="VCPostBuildEventTool"/> 257 <Tool 258 Name="VCPreBuildEventTool"/> 259 <Tool 260 Name="VCPreLinkEventTool"/> 261 <Tool 262 Name="VCResourceCompilerTool" 263 PreprocessorDefinitions="NDEBUG" 264 Culture="1036" 265 AdditionalIncludeDirectories="./res/"/> 266 <Tool 267 Name="VCWebServiceProxyGeneratorTool"/> 268 <Tool 269 Name="VCXMLDataGeneratorTool"/> 270 <Tool 271 Name="VCWebDeploymentTool"/> 272 <Tool 273 Name="VCManagedWrapperGeneratorTool"/> 274 <Tool 275 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 276 </Configuration> 277 <Configuration 278 Name="Debug Dynamic Linkage|Win32" 279 OutputDirectory="$(ConfigurationName)" 280 IntermediateDirectory="$(ConfigurationName)" 281 ConfigurationType="1" 282 UseOfMFC="0" 283 ATLMinimizesCRunTimeLibraryUsage="FALSE" 284 CharacterSet="2"> 285 <Tool 286 Name="VCCLCompilerTool" 287 Optimization="0" 288 AdditionalIncludeDirectories="include" 289 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 290 BasicRuntimeChecks="3" 291 RuntimeLibrary="3" 292 UsePrecompiledHeader="3" 293 PrecompiledHeaderThrough="stdafx.h" 294 PrecompiledHeaderFile=".\Debug/IconService.pch" 295 AssemblerListingLocation=".\Debug/" 296 ObjectFile=".\Debug/" 297 ProgramDataBaseFileName=".\Debug/" 298 WarningLevel="3" 299 SuppressStartupBanner="TRUE" 300 DebugInformationFormat="4"/> 301 <Tool 302 Name="VCCustomBuildTool"/> 303 <Tool 304 Name="VCLinkerTool" 305 AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib" 306 OutputFile=".\Debug/NSClient++.exe" 307 LinkIncremental="1" 308 SuppressStartupBanner="TRUE" 309 ModuleDefinitionFile="" 310 GenerateDebugInformation="TRUE" 311 ProgramDatabaseFile=".\Debug/IconService.pdb" 312 SubSystem="1" 313 TargetMachine="1"/> 314 <Tool 315 Name="VCMIDLTool" 316 TypeLibraryName=".\Debug/IconService.tlb" 317 HeaderFileName=""/> 318 <Tool 319 Name="VCPostBuildEventTool"/> 320 <Tool 321 Name="VCPreBuildEventTool"/> 322 <Tool 323 Name="VCPreLinkEventTool"/> 324 <Tool 325 Name="VCResourceCompilerTool" 326 PreprocessorDefinitions="_DEBUG" 327 Culture="1036" 328 AdditionalIncludeDirectories="./res/"/> 329 <Tool 330 Name="VCWebServiceProxyGeneratorTool"/> 331 <Tool 332 Name="VCXMLDataGeneratorTool"/> 333 <Tool 334 Name="VCWebDeploymentTool"/> 335 <Tool 336 Name="VCManagedWrapperGeneratorTool"/> 337 <Tool 338 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 339 </Configuration> 211 340 </Configurations> 212 341 <References> … … 256 385 Optimization="2" 257 386 PreprocessorDefinitions="" 387 UsePrecompiledHeader="1"/> 388 </FileConfiguration> 389 <FileConfiguration 390 Name="Dynamic Linkage|Win32"> 391 <Tool 392 Name="VCCLCompilerTool" 393 Optimization="2" 394 PreprocessorDefinitions="" 395 UsePrecompiledHeader="1"/> 396 </FileConfiguration> 397 <FileConfiguration 398 Name="Debug Dynamic Linkage|Win32"> 399 <Tool 400 Name="VCCLCompilerTool" 401 Optimization="0" 402 PreprocessorDefinitions="" 403 BasicRuntimeChecks="3" 258 404 UsePrecompiledHeader="1"/> 259 405 </FileConfiguration> … … 328 474 "/> 329 475 </FileConfiguration> 476 <FileConfiguration 477 Name="Dynamic Linkage|Win32"> 478 <Tool 479 Name="VCCustomBuildTool" 480 CommandLine="doxygen.exe $(InputPath) 481 " 482 Outputs=".\Doc"/> 483 </FileConfiguration> 484 <FileConfiguration 485 Name="Debug Dynamic Linkage|Win32" 486 ExcludedFromBuild="TRUE"> 487 <Tool 488 Name="VCCustomBuildTool" 489 CommandLine="doxygen.exe $(InputPath) 490 "/> 491 </FileConfiguration> 330 492 </File> 331 493 <File … … 353 515 <FileConfiguration 354 516 Name="Release M$ STL|Win32"> 517 <Tool 518 Name="VCCustomBuildTool" 519 CommandLine="copy $(InputPath) $(OutDir)\$(InputFileName) 520 " 521 Outputs="$(OutDir)\$(InputFileName)"/> 522 </FileConfiguration> 523 <FileConfiguration 524 Name="Dynamic Linkage|Win32" 525 ExcludedFromBuild="TRUE"> 526 <Tool 527 Name="VCCustomBuildTool" 528 CommandLine="copy $(InputPath) $(OutDir)\$(InputFileName) 529 " 530 AdditionalDependencies="" 531 Outputs="$(OutDir)\$(InputFileName)"/> 532 </FileConfiguration> 533 <FileConfiguration 534 Name="Debug Dynamic Linkage|Win32" 535 ExcludedFromBuild="TRUE"> 355 536 <Tool 356 537 Name="VCCustomBuildTool" -
Settings.h
ra0528c4 r36c340d 58 58 * @return The value or defaultValue if the key is not found 59 59 */ 60 std::string getString(std::string section, std::string key, std::string defaultValue = "") {60 std::string getString(std::string section, std::string key, std::string defaultValue = "") const { 61 61 char* buffer = new char[1024]; 62 62 GetPrivateProfileString(section.c_str(), key.c_str(), defaultValue.c_str(), buffer, 1023, file_.c_str()); -
include/NSCAPI.h
ra0528c4 r36c340d 2 2 3 3 namespace NSCAPI { 4 5 // Various Nagios codes 6 const int returnCRIT = 2; 7 const int returnOK = 0; 8 const int returnWARN = 1; 9 const int returnUNKNOWN = 4; 10 typedef int returnCodes; 4 11 5 12 // Various Return codes … … 16 23 const int critical = -10; // Critical error 17 24 const int warning = 1; // Warning 18 const int debug = 666; // Deb aug message25 const int debug = 666; // Debug message 19 26 20 27 typedef int messageTypes; // Message type -
include/NSCHelper.cpp
r3baaa4d r36c340d 56 56 return "unknown"; 57 57 } 58 std::string NSCHelper::translateReturn(NSCAPI::returnCodes returnCode) { 59 if (returnCode == NSCAPI::returnOK) 60 return "OK"; 61 else if (returnCode == NSCAPI::returnCRIT) 62 return "CRITICAL"; 63 else if (returnCode == NSCAPI::returnWARN) 64 return "WARNING"; 65 else 66 return "UNKNOWN"; 67 } 68 58 69 59 70 -
include/NSCHelper.h
r3baaa4d r36c340d 10 10 std::list<std::string> makelist(const unsigned int argLen, char **argument); 11 11 std::string translateMessageType(NSCAPI::messageTypes msgType); 12 std::string translateReturn(NSCAPI::returnCodes returnCode); 13 inline std::string returnNSCP(NSCAPI::returnCodes returnCode, std::string str) { 14 return translateReturn(returnCode) + "&" + str; 15 } 16 17 /* 18 / * ************************************************************************** 19 * max_state(STATE_x, STATE_y) 20 * compares STATE_x to STATE_y and returns result based on the following 21 * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL 22 * 23 * Note that numerically the above does not hold 24 **************************************************************************** / 25 26 int 27 max_state (int a, int b) 28 { 29 if (a == STATE_CRITICAL || b == STATE_CRITICAL) 30 return STATE_CRITICAL; 31 else if (a == STATE_WARNING || b == STATE_WARNING) 32 return STATE_WARNING; 33 else if (a == STATE_OK || b == STATE_OK) 34 return STATE_OK; 35 else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) 36 return STATE_UNKNOWN; 37 else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) 38 return STATE_DEPENDENT; 39 else 40 return max (a, b); 41 } 42 @bug Use this sceme instead!! 43 */ 44 45 46 inline void escalteReturnCode(NSCAPI::returnCodes ¤tReturnCode, NSCAPI::returnCodes newReturnCode) { 47 if (newReturnCode == NSCAPI::returnCRIT) 48 currentReturnCode = NSCAPI::returnCRIT; 49 else if ((newReturnCode == NSCAPI::returnWARN) && (currentReturnCode != NSCAPI::returnCRIT) ) 50 currentReturnCode = NSCAPI::returnWARN; 51 else if ((newReturnCode == NSCAPI::returnUNKNOWN) 52 && (currentReturnCode != NSCAPI::returnCRIT) 53 && (currentReturnCode != NSCAPI::returnWARN) ) 54 currentReturnCode = NSCAPI::returnUNKNOWN; 55 } 56 inline void escalteReturnCodeToCRIT(NSCAPI::returnCodes ¤tReturnCode) { 57 currentReturnCode = NSCAPI::returnCRIT; 58 } 59 inline void escalteReturnCodeToWARN(NSCAPI::returnCodes ¤tReturnCode) { 60 if (currentReturnCode != NSCAPI::returnCRIT) 61 currentReturnCode = NSCAPI::returnWARN; 62 } 63 12 64 }; 13 65 … … 83 135 NSCModuleHelper::Message(NSCAPI::log, __FILE__, __LINE__, msg) 84 136 85 #ifdef _DEBUG86 137 #define NSC_DEBUG_MSG_STD(msg) NSC_DEBUG_MSG(((std::string)msg).c_str()) 87 138 #define NSC_DEBUG_MSG(msg) \ 88 139 NSCModuleHelper::Message(NSCAPI::debug, __FILE__, __LINE__, msg) 89 #else90 #define NSC_DEBUG_MSG_STD(msg)91 #define NSC_DEBUG_MSG(msg)92 #endif93 140 94 141 ////////////////////////////////////////////////////////////////////////// -
include/PDHCounter.h
ra0528c4 r36c340d 9 9 namespace PDH { 10 10 class PDHException { 11 p rivate:11 public: 12 12 std::string str_; 13 13 int errCode_; -
include/thread.h
r55159fd r36c340d 158 158 /** 159 159 * Ask the thread to terminate (within 5 seconds) if not return false. 160 * @param delay The time to wait for the thread 160 161 * @return true if the thread has terminated 161 162 */ 162 bool exitThread( ) {163 bool exitThread(const unsigned int delay = 5000L) { 163 164 if (!pObject_) 164 165 throw "Could not terminate thread, has not been started yet..."; 165 166 pObject_->exitThread(); 166 DWORD dwWaitResult = endMutext.wait( 5000L);167 DWORD dwWaitResult = endMutext.wait(delay); 167 168 switch (dwWaitResult) { 168 169 // The thread got mutex ownership. -
modules/CheckDisk/CheckDisk.cpp
ra1e1922 r36c340d 50 50 if (!(wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) { 51 51 size += (wfd.nFileSizeHigh * ((long long)MAXDWORD+1)) + (long long)wfd.nFileSizeLow; 52 NSC_LOG_ERROR_STD(wfd.cFileName + ": " + strEx::itos((wfd.nFileSizeHigh * ((long long)MAXDWORD+1)) + (long long)wfd.nFileSizeLow) + " --- " + strEx::itos(size));53 52 } 54 53 return true; … … 83 82 } 84 83 85 86 // CheckDirectorySize&<Directory>&<Directory>... 87 // request: CheckDirectorySize&<warning>&<max>&<Directory>&<Directory>... 88 // Return: <return state>&<return string>... 89 // <return state> 0 - No errors 90 // 1 - Unknown 91 // 2 - Errors 92 // <return string> <directory> <size mb> ... 93 // test: CheckDirectorySize&1024M&4096M&c:\WINDOWS\*.* 94 // CheckDirectorySize 84 std::string CheckDisk::CheckFileSize(const unsigned int argLen, char **char_args) { 85 // CheckFileSize 86 // request: CheckFileSize&<option>&<option>... 87 // <option> MaxWarn=<size gmkb> 88 // MaxCrit=<size gmkb> 89 // MinWarn=<size gmkb> 90 // MinCrit=<size gmkb> 91 // ShowAll 92 // File=<path> 93 // File:<shortname>=<path> 94 // 95 // Return: <return state>&<return string>... 96 // <return state> 0 - No errors 97 // 1 - Unknown 98 // 2 - Errors 99 // <size gmkb> is a size with a possible modifier letter (such as G for gigabyte, M for Megabyte, K for kilobyte etc) 100 // Examples: 101 // <return string> <directory> <size gmkb> ... |<shortname>=<size>:<warn>:<crit> 102 // test: CheckFileSize&ShowAll&MaxWarn=1024M&MaxCrit=4096M&File:WIN=c:\WINDOWS\*.* 103 // CheckFileSize 104 // 105 // check_nscp -H <ip> -p <port> -s <passwd> -c <commandstring> 106 // 107 // ./check_nscp -H 192.168.0.167 -p 1234 -s pwd -c 'CheckFileSize&ShowAll&MaxWarn=1024M&MaxCrit=4096M&File:WIN=c:\WINDOWS\*.*' 108 // WIN: 1G (2110962363B)|WIN:2110962363:1073741824:4294967296 109 NSC_DEBUG_MSG("CheckFileSize"); 110 std::string perfData; 111 std::string ret; 112 NSCAPI::returnCodes returnCode = NSCAPI::returnOK; 113 std::list<std::string> args = NSCHelper::makelist(argLen, char_args); 114 if (args.empty()) 115 return "Missing argument(s)."; 116 long long maxWarn = 0; 117 long long maxCrit = 0; 118 long long minWarn = 0; 119 long long minCrit = 0; 120 bool bShowAll = false; 121 std::list<std::pair<std::string,std::string> > paths; 122 123 std::list<std::string>::const_iterator cit; 124 for (cit=args.begin();cit!=args.end();++cit) { 125 std::string arg = *cit; 126 std::pair<std::string,std::string> p = strEx::split(arg,"="); 127 if (p.first == "File") { 128 paths.push_back(std::pair<std::string,std::string>("",p.second)); 129 } else if (p.first == "MaxWarn") { 130 maxWarn = strEx::stoi64_as_BKMG(p.second); 131 } else if (p.first == "MinWarn") { 132 minWarn = strEx::stoi64_as_BKMG(p.second); 133 } else if (p.first == "MaxCrit") { 134 maxCrit = strEx::stoi64_as_BKMG(p.second); 135 } else if (p.first == "MinCrit") { 136 minCrit = strEx::stoi64_as_BKMG(p.second); 137 } else if (p.first == "ShowAll") { 138 bShowAll = true; 139 } else if (p.first.find(":") != std::string::npos) { 140 std::pair<std::string,std::string> p2 = strEx::split(p.first,":"); 141 if (p2.first == "File") { 142 paths.push_back(std::pair<std::string,std::string>(p2.second,p.second)); 143 } else { 144 return "Unknown command: " + p.first; 145 } 146 } else { 147 return "Unknown command: " + p.first; 148 } 149 } 150 NSC_DEBUG_MSG_STD("Bounds: critical " + strEx::itos(minCrit) + " > siez > " + strEx::itos(maxCrit)); 151 NSC_DEBUG_MSG_STD("Bounds: warning " + strEx::itos(minWarn) + " > size > " + strEx::itos(maxWarn)); 152 NSC_DEBUG_MSG_STD("Showall: " + ((bShowAll)?"yeap":"noop")); 153 154 std::list<std::pair<std::string,std::string> >::const_iterator pit; 155 for (pit = paths.begin(); pit != paths.end(); ++pit) { 156 std::string tstr; 157 GetSize sizeFinder; 158 std::string sName = (*pit).first; 159 if (sName.empty()) 160 sName = (*pit).second; 161 RecursiveScanDirectory((*pit).second, sizeFinder); 162 163 if ((maxCrit!=0) && (sizeFinder.getSize() > maxCrit)) { 164 tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 165 returnCode = NSCAPI::returnCRIT; 166 } else if (sizeFinder.getSize() < minCrit) { 167 tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 168 NSCHelper::escalteReturnCodeToCRIT(returnCode); 169 } else if ((maxWarn!=0)&&(sizeFinder.getSize() > maxWarn)) { 170 tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 171 NSCHelper::escalteReturnCodeToWARN(returnCode); 172 } else if (sizeFinder.getSize() < minWarn) { 173 tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 174 NSCHelper::escalteReturnCodeToWARN(returnCode); 175 } else if (bShowAll) { 176 tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 177 } 178 if (!(*pit).first.empty()) 179 perfData += (*pit).first + "=" + strEx::itos(sizeFinder.getSize()) + ";" + strEx::itos(maxWarn) + ";" + strEx::itos(maxCrit) + " "; 180 if (!ret.empty() && !tstr.empty()) 181 ret += ", "; 182 if (!tstr.empty()) 183 ret += tstr; 184 } 185 if (ret.empty()) 186 ret = "OK all file sizes are within bounds."; 187 if (!perfData.empty()) 188 ret += "|" + perfData; 189 return NSCHelper::returnNSCP(returnCode, ret); 190 } 191 192 95 193 #define BUFFER_SIZE 1024*64 96 194 97 195 std::string CheckDisk::handleCommand(const std::string command, const unsigned int argLen, char **char_args) { 98 std::string ret; 99 if (command == "CheckDirectorySize") { 100 std::list<std::string> args = NSCHelper::makelist(argLen, char_args); 101 if (args.size() < 3) 102 return "Missing argument(s)." + strEx::itos((int)args.size()); 103 int iWarn = strEx::stoi64_as_BKMG(args.front()); args.pop_front(); 104 int iMax = strEx::stoi64_as_BKMG(args.front()); args.pop_front(); 105 106 std::list<std::string>::const_iterator cit; 107 for (cit=args.begin();cit!=args.end();++cit) { 108 GetSize size; 109 RecursiveScanDirectory(*cit, size); 110 if (!ret.empty()) 111 ret += ", "; 112 ret += (*cit) + ": " + strEx::itos_as_BKMG(size.getSize()); 113 } 114 } 115 return ret; 196 if (command == "CheckFileSize") { 197 return CheckFileSize(argLen, char_args); 198 // } else if (command == "CheckFileDate") { 199 } 200 return ""; 116 201 } 117 202 -
modules/CheckDisk/CheckDisk.def
ra1e1922 r36c340d 1 LIBRARY NSClientCompat1 LIBRARY CheckDisk 2 2 3 3 EXPORTS -
modules/CheckDisk/CheckDisk.h
ra1e1922 r36c340d 15 15 bool hasMessageHandler(); 16 16 std::string handleCommand(const std::string command, const unsigned int argLen, char **args); 17 18 // Check commands 19 std::string CheckFileSize(const unsigned int argLen, char **char_args); 17 20 }; -
modules/CheckDisk/CheckDisk.vcproj
ra1e1922 r36c340d 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CHECKDISK_EXPORTS" 22 AdditionalIncludeDirectories="../include;../../include" 23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;_STLP_USE_NEWALLOC" 23 24 MinimalRebuild="TRUE" 24 25 BasicRuntimeChecks="3" … … 32 33 <Tool 33 34 Name="VCLinkerTool" 34 OutputFile=" $(OutDir)/CheckDisk.dll"35 OutputFile="../../Debug/modules/$(ProjectName).dll" 35 36 LinkIncremental="2" 37 ModuleDefinitionFile="CheckDisk.def" 36 38 GenerateDebugInformation="TRUE" 37 39 ProgramDatabaseFile="$(OutDir)/CheckDisk.pdb" … … 86 88 OptimizeReferences="2" 87 89 EnableCOMDATFolding="2" 90 ImportLibrary="$(OutDir)/CheckDisk.lib" 91 TargetMachine="1"/> 92 <Tool 93 Name="VCMIDLTool"/> 94 <Tool 95 Name="VCPostBuildEventTool"/> 96 <Tool 97 Name="VCPreBuildEventTool"/> 98 <Tool 99 Name="VCPreLinkEventTool"/> 100 <Tool 101 Name="VCResourceCompilerTool"/> 102 <Tool 103 Name="VCWebServiceProxyGeneratorTool"/> 104 <Tool 105 Name="VCXMLDataGeneratorTool"/> 106 <Tool 107 Name="VCWebDeploymentTool"/> 108 <Tool 109 Name="VCManagedWrapperGeneratorTool"/> 110 <Tool 111 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 112 </Configuration> 113 <Configuration 114 Name="Dynamic Linkage|Win32" 115 OutputDirectory="$(ConfigurationName)" 116 IntermediateDirectory="$(ConfigurationName)" 117 ConfigurationType="2" 118 CharacterSet="2"> 119 <Tool 120 Name="VCCLCompilerTool" 121 AdditionalIncludeDirectories="../include;../../include" 122 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 123 RuntimeLibrary="2" 124 UsePrecompiledHeader="3" 125 WarningLevel="3" 126 Detect64BitPortabilityProblems="TRUE" 127 DebugInformationFormat="3"/> 128 <Tool 129 Name="VCCustomBuildTool"/> 130 <Tool 131 Name="VCLinkerTool" 132 OutputFile="../../Release/modules/$(ProjectName).dll" 133 LinkIncremental="1" 134 ModuleDefinitionFile="CheckDisk.def" 135 GenerateDebugInformation="TRUE" 136 SubSystem="2" 137 OptimizeReferences="2" 138 EnableCOMDATFolding="2" 139 ImportLibrary="$(OutDir)/CheckDisk.lib" 140 TargetMachine="1"/> 141 <Tool 142 Name="VCMIDLTool"/> 143 <Tool 144 Name="VCPostBuildEventTool"/> 145 <Tool 146 Name="VCPreBuildEventTool"/> 147 <Tool 148 Name="VCPreLinkEventTool"/> 149 <Tool 150 Name="VCResourceCompilerTool"/> 151 <Tool 152 Name="VCWebServiceProxyGeneratorTool"/> 153 <Tool 154 Name="VCXMLDataGeneratorTool"/> 155 <Tool 156 Name="VCWebDeploymentTool"/> 157 <Tool 158 Name="VCManagedWrapperGeneratorTool"/> 159 <Tool 160 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 161 </Configuration> 162 <Configuration 163 Name="Debug Dynamic Linkage|Win32" 164 OutputDirectory="$(ConfigurationName)" 165 IntermediateDirectory="$(ConfigurationName)" 166 ConfigurationType="2" 167 CharacterSet="2"> 168 <Tool 169 Name="VCCLCompilerTool" 170 Optimization="0" 171 AdditionalIncludeDirectories="../include;../../include" 172 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 173 MinimalRebuild="TRUE" 174 BasicRuntimeChecks="3" 175 RuntimeLibrary="3" 176 UsePrecompiledHeader="3" 177 WarningLevel="3" 178 Detect64BitPortabilityProblems="TRUE" 179 DebugInformationFormat="4"/> 180 <Tool 181 Name="VCCustomBuildTool"/> 182 <Tool 183 Name="VCLinkerTool" 184 OutputFile="../../Debug/modules/$(ProjectName).dll" 185 LinkIncremental="2" 186 ModuleDefinitionFile="CheckDisk.def" 187 GenerateDebugInformation="TRUE" 188 ProgramDatabaseFile="$(OutDir)/CheckDisk.pdb" 189 SubSystem="2" 88 190 ImportLibrary="$(OutDir)/CheckDisk.lib" 89 191 TargetMachine="1"/> … … 133 235 <FileConfiguration 134 236 Name="Release|Win32"> 237 <Tool 238 Name="VCCLCompilerTool" 239 UsePrecompiledHeader="1"/> 240 </FileConfiguration> 241 <FileConfiguration 242 Name="Dynamic Linkage|Win32"> 243 <Tool 244 Name="VCCLCompilerTool" 245 UsePrecompiledHeader="1"/> 246 </FileConfiguration> 247 <FileConfiguration 248 Name="Debug Dynamic Linkage|Win32"> 135 249 <Tool 136 250 Name="VCCLCompilerTool" -
modules/CheckEventLog/CheckEventLog.cpp
ra0528c4 r36c340d 29 29 30 30 std::string CheckEventLog::getModuleName() { 31 return " NSClient compatibility Module.";31 return "Event log Checker."; 32 32 } 33 33 NSCModuleWrapper::module_version CheckEventLog::getModuleVersion() { … … 104 104 DWORD eventType_; 105 105 std::string eventSource_; 106 boost::regex eventSourceRegExp_; 106 107 bool notSetValue_; 107 108 DWORD writtenBeforeDelta_ ; … … 109 110 DWORD generatedBeforeDelta_; 110 111 DWORD generatedAfterDelta_; 112 boost::regex regexp_; 111 113 112 114 searchQueryItem(bool notSetValue) … … 115 117 generatedBeforeDelta_(0), generatedAfterDelta_(0) 116 118 {} 119 searchQueryItem& operator=(const searchQueryItem &other) { 120 eventType_ = other.eventType_; 121 eventSource_ = other.eventSource_; 122 notSetValue_ = other.notSetValue_; 123 writtenBeforeDelta_ = other.writtenBeforeDelta_; 124 writtenAfterDelta_ = other.writtenAfterDelta_; 125 generatedBeforeDelta_ = other.generatedBeforeDelta_; 126 generatedAfterDelta_ = other.generatedAfterDelta_; 127 try { 128 regexp_ = other.regexp_; 129 } catch (const boost::bad_expression e) { 130 throw (std::string)"Invalid syntax in regular expression:" + other.toString(); 131 } 132 try { 133 eventSourceRegExp_ = other.eventSourceRegExp_; 134 } catch (const boost::bad_expression e) { 135 throw (std::string)"Invalid syntax in event source regular expression:" + other.toString(); 136 } 137 return *this; 138 } 117 139 118 140 inline bool matchDateWritten(DWORD now, DWORD written) const { … … 150 172 } 151 173 inline bool matchSource(std::string eventSource) const { 152 if ( eventSource_.empty())174 if ((eventSource_.empty())&&eventSourceRegExp_.empty()) 153 175 return notSetValue_; 154 return eventSource_ == eventSource; 176 else if (eventSource_.empty()) 177 return boost::regex_match(eventSource, eventSourceRegExp_); 178 else if (eventSourceRegExp_.empty()) 179 return eventSource_ == eventSource; 180 return boost::regex_match(eventSource, eventSourceRegExp_) && (eventSource_ == eventSource); 181 } 182 inline bool matchRegexp(std::string msg) const { 183 if (regexp_.empty()) 184 return notSetValue_; 185 return boost::regex_match(msg, regexp_); 155 186 } 156 187 std::string toString() const { 157 188 std::stringstream ss; 189 ss << " Regexp: " << regexp_ << std::endl; 158 190 ss << " Event type: " << eventType_ << std::endl; 159 191 ss << " Event source: " << eventSource_ << std::endl; 192 ss << " Event source Regexp: " << eventSourceRegExp_ << std::endl; 160 193 ss << " Written delta: " << writtenAfterDelta_ << " > " << writtenBeforeDelta_ << std::endl; 161 194 ss << " Generated delta: " << generatedAfterDelta_ << " > " << generatedBeforeDelta_ << std::endl; … … 167 200 searchQueryBundle() : require(true), exclude(false) {} 168 201 std::string toString() { 169 return " Required:\n" + require.toString() + "\n Ex lude:\n" + exclude.toString();202 return " Required:\n" + require.toString() + "\n Exclude:\n" + exclude.toString(); 170 203 } 171 204 }; … … 189 222 else if (p.first == "eventSource") 190 223 item.eventSource_ = p.second; 224 else if (p.first == "eventSourceRegexp") { 225 try { 226 std::string s = p.second; 227 NSC_DEBUG_MSG_STD("Attempting to make regexp from: " + s); 228 item.eventSourceRegExp_ = s; 229 NSC_DEBUG_MSG_STD("success..."); 230 } catch (const boost::bad_expression e) { 231 item.eventSourceRegExp_ = ""; 232 throw (std::string)"Invalid syntax in regular expression:" + p.second; 233 } 234 } 235 else if (p.first == "generatedBeforeDelta") 236 item.generatedBeforeDelta_ = strEx::stoi(p.second); 237 else if (p.first == "generatedAfterDelta") 238 item.generatedAfterDelta_ = strEx::stoi(p.second); 239 else if (p.first == "writtenBeforeDelta") 240 item.writtenBeforeDelta_ = strEx::stoi(p.second); 241 else if (p.first == "writtenAfterDelta") 242 item.writtenAfterDelta_ = strEx::stoi(p.second); 243 else if (p.first == "regexp") { 244 try { 245 item.regexp_ = p.second; 246 } catch (const boost::bad_expression e) { 247 item.regexp_ = ""; 248 throw (std::string)"Invalid syntax in regular expression:" + p.second; 249 } 250 } else 251 throw (std::string)"Invalid argument: " + p.first; 191 252 } 192 253 void addToQueryBundle(searchQuery::searchQueryBundle &bundle, std::string arg) { … … 196 257 else if (p.first == "exclude") 197 258 addToQueryItem(bundle.exclude, p.second); 259 else 260 throw (std::string)"Invalid require/exclude: " + p.first; 198 261 } 199 262 void addToQuery(searchQuery &q, std::string arg) { … … 212 275 else if (p.first == "descriptions") 213 276 q.descriptions = true; 214 } 215 } 216 217 searchQuery buildQury(std::list<std::string> args) { 218 searchQuery ret; 277 else 278 throw (std::string)"Invalid argument: " + arg; 279 } 280 } 281 282 void buildQury(searchQuery &query, std::list<std::string> args) { 219 283 for (std::list<std::string>::const_iterator it = args.begin(); it!=args.end(); it++) { 220 addToQuery(ret,*it);221 }222 return ret;223 } 224 // huffa&CheckEventLog&Application&1&<type>&<query>&huffa...284 NSC_DEBUG_MSG_STD("Adding: " + *it); 285 addToQuery(query, *it); 286 } 287 } 288 // CheckEventLog 225 289 // request: CheckEventLog&<logfile>&<Query strings> 226 290 // Return: <return state>&<log entry 1> - <log entry 2>... … … 228 292 // 1 - Unknown 229 293 // 2 - Errors 294 // Examples: 295 // CheckEventLog&Application&1&<type>&<query>&huffa... 296 // CheckEventLog&Application&warn.require.eventType=warning&critical.require.eventType=error&truncate=1024&descriptions&all.exclude.eventSourceRegexp=^(Win|Msi|NSClient\+\+|Userenv|ASP\.NET|LoadPerf|Outlook|Application E|NSClient).* 230 297 #define BUFFER_SIZE 1024*64 231 298 … … 233 300 if (command != "CheckEventLog") 234 301 return ""; 302 NSCAPI::returnCodes rCode = NSCAPI::returnOK; 235 303 std::list<std::string> args = NSCHelper::makelist(argLen, char_args); 236 304 if (args.size() < 2) … … 238 306 std::string ret; 239 307 bool critical = false; 308 searchQuery query; 240 309 std::string logFile = args.front(); args.pop_front(); 241 searchQuery query = buildQury(args); 310 try { 311 buildQury(query, args); 312 } catch (std::string s) { 313 return NSCHelper::returnNSCP(NSCAPI::returnUNKNOWN, s); 314 } 242 315 NSC_DEBUG_MSG_STD("Base query: " + query.toString()); 243 316 244 317 HANDLE hLog = OpenEventLog(NULL, logFile.c_str()); 245 318 if (hLog == NULL) 246 return "Could not open the Application event log.";319 return NSCHelper::returnNSCP(NSCAPI::returnUNKNOWN, "Could not open the Application event log."); 247 320 248 321 DWORD dwThisRecord, dwRead, dwNeeded; … … 271 344 query.critical.require.matchSource(record.eventSource()) && 272 345 query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) && 273 query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 346 query.critical.require.matchDateWritten(currentTime, record.timeWritten()) && 347 query.critical.require.matchRegexp(record.enumStrings()) 274 348 ) { 275 349 match = true; … … 278 352 if ( query.critical.exclude.matchType(record.eventType()) || 279 353 query.critical.exclude.matchSource(record.eventSource()) || 280 query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) || 281 query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 354 query.critical.exclude.matchDateGenerated(currentTime, record.timeGenerated()) || 355 query.critical.exclude.matchDateWritten(currentTime, record.timeWritten()) || 356 query.critical.exclude.matchRegexp(record.enumStrings()) 282 357 ) { 283 358 match = false; … … 287 362 if ( query.warn.require.matchType(record.eventType()) && 288 363 query.warn.require.matchSource(record.eventSource()) && 289 query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) && 290 query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 364 query.warn.require.matchDateGenerated(currentTime, record.timeGenerated()) && 365 query.warn.require.matchDateWritten(currentTime, record.timeWritten()) && 366 query.warn.require.matchRegexp(record.enumStrings()) 291 367 ) 292 368 match = true; 293 369 if ( query.warn.exclude.matchType(record.eventType()) || 294 370 query.warn.exclude.matchSource(record.eventSource()) || 295 query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) || 296 query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 371 query.warn.exclude.matchDateGenerated(currentTime, record.timeGenerated()) || 372 query.warn.exclude.matchDateWritten(currentTime, record.timeWritten()) || 373 query.warn.exclude.matchRegexp(record.enumStrings()) 297 374 ) 298 375 match = false; … … 324 401 ret = "WARNING: " + ret; 325 402 else 326 ret = "OK: No errors/warnings in event log.";403 ret = "OK: No errors/warnings in event log."; 327 404 if (query.truncate != 0) 328 405 ret = ret.substr(0, query.truncate); 329 return ret;406 return NSCHelper::returnNSCP(rCode, ret); 330 407 } 331 408 -
modules/CheckEventLog/CheckEventLog.def
ra0528c4 r36c340d 1 LIBRARY C onsoleLogger1 LIBRARY CheckEventLog 2 2 3 3 EXPORTS -
modules/CheckEventLog/CheckEventLog.vcproj
ra0528c4 r36c340d 21 21 Optimization="0" 22 22 AdditionalIncludeDirectories="../include;../../include" 23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;_STLP_USE_NEWALLOC "23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;_STLP_USE_NEWALLOC,_STLP_DEBUG" 24 24 MinimalRebuild="TRUE" 25 25 BasicRuntimeChecks="3" … … 96 96 <Tool 97 97 Name="VCPreBuildEventTool"/> 98 <Tool 99 Name="VCPreLinkEventTool"/> 100 <Tool 101 Name="VCResourceCompilerTool"/> 102 <Tool 103 Name="VCWebServiceProxyGeneratorTool"/> 104 <Tool 105 Name="VCXMLDataGeneratorTool"/> 106 <Tool 107 Name="VCWebDeploymentTool"/> 108 <Tool 109 Name="VCManagedWrapperGeneratorTool"/> 110 <Tool 111 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 112 </Configuration> 113 <Configuration 114 Name="Dynamic Linkage|Win32" 115 OutputDirectory="$(ConfigurationName)" 116 IntermediateDirectory="$(ConfigurationName)" 117 ConfigurationType="2" 118 CharacterSet="2"> 119 <Tool 120 Name="VCCLCompilerTool" 121 AdditionalIncludeDirectories="../include;../../include" 122 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;SYSTRAY_EXPORTS" 123 RuntimeLibrary="0" 124 UsePrecompiledHeader="3" 125 WarningLevel="3" 126 Detect64BitPortabilityProblems="TRUE" 127 DebugInformationFormat="3"/> 128 <Tool 129 Name="VCCustomBuildTool"/> 130 <Tool 131 Name="VCLinkerTool" 132 OutputFile="../../Release/modules/$(ProjectName).dll" 133 LinkIncremental="1" 134 ModuleDefinitionFile="CheckEventLog.def" 135 GenerateDebugInformation="TRUE" 136 SubSystem="2" 137 OptimizeReferences="2" 138 EnableCOMDATFolding="2" 139 ImportLibrary="$(OutDir)/CheckEventLog.lib" 140 TargetMachine="1"/> 141 <Tool 142 Name="VCMIDLTool"/> 143 <Tool 144 Name="VCPostBuildEventTool"/> 145 <Tool 146 Name="VCPreBuildEventTool" 147 ExcludedFromBuild="TRUE"/> 148 <Tool 149 Name="VCPreLinkEventTool"/> 150 <Tool 151 Name="VCResourceCompilerTool"/> 152 <Tool 153 Name="VCWebServiceProxyGeneratorTool"/> 154 <Tool 155 Name="VCXMLDataGeneratorTool"/> 156 <Tool 157 Name="VCWebDeploymentTool"/> 158 <Tool 159 Name="VCManagedWrapperGeneratorTool"/> 160 <Tool 161 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 162 </Configuration> 163 <Configuration 164 Name="Debug Dynamic Linkage|Win32" 165 OutputDirectory="$(ConfigurationName)" 166 IntermediateDirectory="$(ConfigurationName)" 167 ConfigurationType="2" 168 CharacterSet="2"> 169 <Tool 170 Name="VCCLCompilerTool" 171 Optimization="0" 172 AdditionalIncludeDirectories="../include;../../include" 173 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 174 MinimalRebuild="TRUE" 175 BasicRuntimeChecks="3" 176 RuntimeLibrary="3" 177 UsePrecompiledHeader="3" 178 WarningLevel="3" 179 Detect64BitPortabilityProblems="TRUE" 180 DebugInformationFormat="4"/> 181 <Tool 182 Name="VCCustomBuildTool"/> 183 <Tool 184 Name="VCLinkerTool" 185 OutputFile="../../Debug/modules/$(ProjectName).dll" 186 LinkIncremental="2" 187 ModuleDefinitionFile="CheckEventLog.def" 188 GenerateDebugInformation="TRUE" 189 ProgramDatabaseFile="$(OutDir)/CheckEventLog.pdb" 190 SubSystem="2" 191 ImportLibrary="$(OutDir)/CheckEventLog.lib" 192 TargetMachine="1"/> 193 <Tool 194 Name="VCMIDLTool"/> 195 <Tool 196 Name="VCPostBuildEventTool"/> 197 <Tool 198 Name="VCPreBuildEventTool" 199 ExcludedFromBuild="TRUE"/> 98 200 <Tool 99 201 Name="VCPreLinkEventTool"/> … … 135 237 <FileConfiguration 136 238 Name="Release|Win32"> 239 <Tool 240 Name="VCCLCompilerTool" 241 UsePrecompiledHeader="1"/> 242 </FileConfiguration> 243 <FileConfiguration 244 Name="Dynamic Linkage|Win32"> 245 <Tool 246 Name="VCCLCompilerTool" 247 UsePrecompiledHeader="1"/> 248 </FileConfiguration> 249 <FileConfiguration 250 Name="Debug Dynamic Linkage|Win32"> 137 251 <Tool 138 252 Name="VCCLCompilerTool" -
modules/CheckEventLog/stdafx.h
ra1e1922 r36c340d 10 10 // Windows Header Files: 11 11 #include <windows.h> 12 12 #include <boost/regex.hpp> 13 13 #include <string> 14 15 14 16 15 #include <NSCAPI.h> -
modules/ConsoleLogger/ConsoleLogger.vcproj
ra0528c4 r36c340d 111 111 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 112 112 </Configuration> 113 <Configuration 114 Name="Dynamic Linkage|Win32" 115 OutputDirectory="$(ConfigurationName)" 116 IntermediateDirectory="$(ConfigurationName)" 117 ConfigurationType="2" 118 CharacterSet="2"> 119 <Tool 120 Name="VCCLCompilerTool" 121 AdditionalIncludeDirectories="../include;../../include" 122 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 123 RuntimeLibrary="2" 124 UsePrecompiledHeader="3" 125 WarningLevel="3" 126 Detect64BitPortabilityProblems="TRUE" 127 DebugInformationFormat="3"/> 128 <Tool 129 Name="VCCustomBuildTool"/> 130 <Tool 131 Name="VCLinkerTool" 132 OutputFile="../../Release/modules/$(ProjectName).dll" 133 LinkIncremental="1" 134 ModuleDefinitionFile="ConsoleLogger.def" 135 GenerateDebugInformation="TRUE" 136 SubSystem="2" 137 OptimizeReferences="2" 138 EnableCOMDATFolding="2" 139 ImportLibrary="$(OutDir)/ConsoleLogger.lib" 140 TargetMachine="1"/> 141 <Tool 142 Name="VCMIDLTool"/> 143 <Tool 144 Name="VCPostBuildEventTool"/> 145 <Tool 146 Name="VCPreBuildEventTool"/> 147 <Tool 148 Name="VCPreLinkEventTool"/> 149 <Tool 150 Name="VCResourceCompilerTool"/> 151 <Tool 152 Name="VCWebServiceProxyGeneratorTool"/> 153 <Tool 154 Name="VCXMLDataGeneratorTool"/> 155 <Tool 156 Name="VCWebDeploymentTool"/> 157 <Tool 158 Name="VCManagedWrapperGeneratorTool"/> 159 <Tool 160 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 161 </Configuration> 162 <Configuration 163 Name="Debug Dynamic Linkage|Win32" 164 OutputDirectory="$(ConfigurationName)" 165 IntermediateDirectory="$(ConfigurationName)" 166 ConfigurationType="2" 167 CharacterSet="2"> 168 <Tool 169 Name="VCCLCompilerTool" 170 Optimization="0" 171 AdditionalIncludeDirectories="../include;../../include" 172 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 173 MinimalRebuild="TRUE" 174 BasicRuntimeChecks="3" 175 RuntimeLibrary="3" 176 UsePrecompiledHeader="3" 177 WarningLevel="3" 178 Detect64BitPortabilityProblems="TRUE" 179 DebugInformationFormat="4"/> 180 <Tool 181 Name="VCCustomBuildTool"/> 182 <Tool 183 Name="VCLinkerTool" 184 OutputFile="../../Debug/modules/$(ProjectName).dll" 185 LinkIncremental="2" 186 ModuleDefinitionFile="ConsoleLogger.def" 187 GenerateDebugInformation="TRUE" 188 ProgramDatabaseFile="$(OutDir)/ConsoleLogger.pdb" 189 SubSystem="2" 190 ImportLibrary="$(OutDir)/ConsoleLogger.lib" 191 TargetMachine="1"/> 192 <Tool 193 Name="VCMIDLTool"/> 194 <Tool 195 Name="VCPostBuildEventTool"/> 196 <Tool 197 Name="VCPreBuildEventTool"/> 198 <Tool 199 Name="VCPreLinkEventTool"/> 200 <Tool 201 Name="VCResourceCompilerTool"/> 202 <Tool 203 Name="VCWebServiceProxyGeneratorTool"/> 204 <Tool 205 Name="VCXMLDataGeneratorTool"/> 206 <Tool 207 Name="VCWebDeploymentTool"/> 208 <Tool 209 Name="VCManagedWrapperGeneratorTool"/> 210 <Tool 211 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 212 </Configuration> 113 213 </Configurations> 114 214 <References> … … 135 235 <FileConfiguration 136 236 Name="Release|Win32"> 237 <Tool 238 Name="VCCLCompilerTool" 239 UsePrecompiledHeader="1"/> 240 </FileConfiguration> 241 <FileConfiguration 242 Name="Dynamic Linkage|Win32"> 243 <Tool 244 Name="VCCLCompilerTool" 245 UsePrecompiledHeader="1"/> 246 </FileConfiguration> 247 <FileConfiguration 248 Name="Debug Dynamic Linkage|Win32"> 137 249 <Tool 138 250 Name="VCCLCompilerTool" -
modules/FileLogger/FileLogger.vcproj
ra0528c4 r36c340d 111 111 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 112 112 </Configuration> 113 <Configuration 114 Name="Dynamic Linkage|Win32" 115 OutputDirectory="$(ConfigurationName)" 116 IntermediateDirectory="$(ConfigurationName)" 117 ConfigurationType="2" 118 CharacterSet="2"> 119 <Tool 120 Name="VCCLCompilerTool" 121 AdditionalIncludeDirectories="../include;../../include" 122 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 123 RuntimeLibrary="2" 124 UsePrecompiledHeader="3" 125 WarningLevel="3" 126 Detect64BitPortabilityProblems="TRUE" 127 DebugInformationFormat="3"/> 128 <Tool 129 Name="VCCustomBuildTool"/> 130 <Tool 131 Name="VCLinkerTool" 132 OutputFile="../../Release/modules/$(ProjectName).dll" 133 LinkIncremental="1" 134 ModuleDefinitionFile="FileLogger.def" 135 GenerateDebugInformation="TRUE" 136 SubSystem="2" 137 OptimizeReferences="2" 138 EnableCOMDATFolding="2" 139 ImportLibrary="$(OutDir)/FileLogger.lib" 140 TargetMachine="1"/> 141 <Tool 142 Name="VCMIDLTool"/> 143 <Tool 144 Name="VCPostBuildEventTool"/> 145 <Tool 146 Name="VCPreBuildEventTool"/> 147 <Tool 148 Name="VCPreLinkEventTool"/> 149 <Tool 150 Name="VCResourceCompilerTool"/> 151 <Tool 152 Name="VCWebServiceProxyGeneratorTool"/> 153 <Tool 154 Name="VCXMLDataGeneratorTool"/> 155 <Tool 156 Name="VCWebDeploymentTool"/> 157 <Tool 158 Name="VCManagedWrapperGeneratorTool"/> 159 <Tool 160 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 161 </Configuration> 162 <Configuration 163 Name="Debug Dynamic Linkage|Win32" 164 OutputDirectory="$(ConfigurationName)" 165 IntermediateDirectory="$(ConfigurationName)" 166 ConfigurationType="2" 167 CharacterSet="2"> 168 <Tool 169 Name="VCCLCompilerTool" 170 Optimization="0" 171 AdditionalIncludeDirectories="../include;../../include" 172 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 173 MinimalRebuild="TRUE" 174 BasicRuntimeChecks="3" 175 RuntimeLibrary="3" 176 UsePrecompiledHeader="3" 177 WarningLevel="3" 178 Detect64BitPortabilityProblems="TRUE" 179 DebugInformationFormat="4"/> 180 <Tool 181 Name="VCCustomBuildTool"/> 182 <Tool 183 Name="VCLinkerTool" 184 OutputFile="../../Debug/modules/$(ProjectName).dll" 185 LinkIncremental="2" 186 ModuleDefinitionFile="FileLogger.def" 187 GenerateDebugInformation="TRUE" 188 ProgramDatabaseFile="$(OutDir)/FileLogger.pdb" 189 SubSystem="2" 190 ImportLibrary="$(OutDir)/FileLogger.lib" 191 TargetMachine="1"/> 192 <Tool 193 Name="VCMIDLTool"/> 194 <Tool 195 Name="VCPostBuildEventTool"/> 196 <Tool 197 Name="VCPreBuildEventTool"/> 198 <Tool 199 Name="VCPreLinkEventTool"/> 200 <Tool 201 Name="VCResourceCompilerTool"/> 202 <Tool 203 Name="VCWebServiceProxyGeneratorTool"/> 204 <Tool 205 Name="VCXMLDataGeneratorTool"/> 206 <Tool 207 Name="VCWebDeploymentTool"/> 208 <Tool 209 Name="VCManagedWrapperGeneratorTool"/> 210 <Tool 211 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 212 </Configuration> 113 213 </Configurations> 114 214 <References> … … 135 235 <FileConfiguration 136 236 Name="Release|Win32"> 237 <Tool 238 Name="VCCLCompilerTool" 239 UsePrecompiledHeader="1"/> 240 </FileConfiguration> 241 <FileConfiguration 242 Name="Dynamic Linkage|Win32"> 243 <Tool 244 Name="VCCLCompilerTool" 245 UsePrecompiledHeader="1"/> 246 </FileConfiguration> 247 <FileConfiguration 248 Name="Debug Dynamic Linkage|Win32"> 137 249 <Tool 138 250 Name="VCCLCompilerTool" -
modules/NSClientCompat/NSClientCompat.cpp
r3baaa4d r36c340d 47 47 */ 48 48 bool NSClientCompat::unloadModule() { 49 if (!pdhThread.exitThread( ))49 if (!pdhThread.exitThread(20000)) 50 50 NSC_LOG_ERROR("Could not exit the thread, memory leak and potential corruption may be the result..."); 51 51 return true; -
modules/NSClientCompat/NSClientCompat.vcproj
ra1e1922 r36c340d 113 113 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 114 114 </Configuration> 115 <Configuration 116 Name="Dynamic Linkage|Win32" 117 OutputDirectory="$(ConfigurationName)" 118 IntermediateDirectory="$(ConfigurationName)" 119 ConfigurationType="2" 120 CharacterSet="2"> 121 <Tool 122 Name="VCCLCompilerTool" 123 AdditionalIncludeDirectories="../include;../../include" 124 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 125 RuntimeLibrary="2" 126 UsePrecompiledHeader="3" 127 WarningLevel="3" 128 Detect64BitPortabilityProblems="TRUE" 129 DebugInformationFormat="3"/> 130 <Tool 131 Name="VCCustomBuildTool"/> 132 <Tool 133 Name="VCLinkerTool" 134 AdditionalDependencies="Pdh.lib" 135 OutputFile="../../Release/modules/$(ProjectName).dll" 136 LinkIncremental="1" 137 ModuleDefinitionFile="NSClientCompat.def" 138 GenerateDebugInformation="TRUE" 139 SubSystem="2" 140 OptimizeReferences="2" 141 EnableCOMDATFolding="2" 142 ImportLibrary="$(OutDir)/NSClientCompat.lib" 143 TargetMachine="1"/> 144 <Tool 145 Name="VCMIDLTool"/> 146 <Tool 147 Name="VCPostBuildEventTool"/> 148 <Tool 149 Name="VCPreBuildEventTool"/> 150 <Tool 151 Name="VCPreLinkEventTool"/> 152 <Tool 153 Name="VCResourceCompilerTool"/> 154 <Tool 155 Name="VCWebServiceProxyGeneratorTool"/> 156 <Tool 157 Name="VCXMLDataGeneratorTool"/> 158 <Tool 159 Name="VCWebDeploymentTool"/> 160 <Tool 161 Name="VCManagedWrapperGeneratorTool"/> 162 <Tool 163 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 164 </Configuration> 165 <Configuration 166 Name="Debug Dynamic Linkage|Win32" 167 OutputDirectory="$(ConfigurationName)" 168 IntermediateDirectory="$(ConfigurationName)" 169 ConfigurationType="2" 170 CharacterSet="2"> 171 <Tool 172 Name="VCCLCompilerTool" 173 Optimization="0" 174 AdditionalIncludeDirectories="../include;../../include" 175 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 176 MinimalRebuild="TRUE" 177 BasicRuntimeChecks="3" 178 RuntimeLibrary="3" 179 UsePrecompiledHeader="3" 180 WarningLevel="3" 181 Detect64BitPortabilityProblems="TRUE" 182 DebugInformationFormat="4"/> 183 <Tool 184 Name="VCCustomBuildTool"/> 185 <Tool 186 Name="VCLinkerTool" 187 AdditionalDependencies="Pdh.lib" 188 OutputFile="../../Debug/modules/$(ProjectName).dll" 189 LinkIncremental="2" 190 ModuleDefinitionFile="NSClientCompat.def" 191 GenerateDebugInformation="TRUE" 192 ProgramDatabaseFile="$(OutDir)/NSClientCompat.pdb" 193 SubSystem="2" 194 ImportLibrary="$(OutDir)/NSClientCompat.lib" 195 TargetMachine="1"/> 196 <Tool 197 Name="VCMIDLTool"/> 198 <Tool 199 Name="VCPostBuildEventTool"/> 200 <Tool 201 Name="VCPreBuildEventTool"/> 202 <Tool 203 Name="VCPreLinkEventTool"/> 204 <Tool 205 Name="VCResourceCompilerTool"/> 206 <Tool 207 Name="VCWebServiceProxyGeneratorTool"/> 208 <Tool 209 Name="VCXMLDataGeneratorTool"/> 210 <Tool 211 Name="VCWebDeploymentTool"/> 212 <Tool 213 Name="VCManagedWrapperGeneratorTool"/> 214 <Tool 215 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 216 </Configuration> 115 217 </Configurations> 116 218 <References> … … 153 255 UsePrecompiledHeader="1"/> 154 256 </FileConfiguration> 257 <FileConfiguration 258 Name="Dynamic Linkage|Win32"> 259 <Tool 260 Name="VCCLCompilerTool" 261 UsePrecompiledHeader="1"/> 262 </FileConfiguration> 263 <FileConfiguration 264 Name="Debug Dynamic Linkage|Win32"> 265 <Tool 266 Name="VCCLCompilerTool" 267 UsePrecompiledHeader="1"/> 268 </FileConfiguration> 155 269 </File> 156 270 </Filter> -
modules/NSClientCompat/PDHCollector.cpp
ra1e1922 r36c340d 85 85 pdh.addCounter("\\\\.\\Processor(_total)\\% Processor Time", &cpu); 86 86 87 pdh.open(); 87 try { 88 pdh.open(); 89 } catch (const PDH::PDHException &e) { 90 NSC_LOG_ERROR_STD("Failed to open performance counters: " + e.str_); 91 return 0; 92 } 88 93 89 94 startRunning(); … … 93 98 if (!mutex.hasMutex()) 94 99 NSC_LOG_ERROR("Failed to get Mutex!"); 95 else 96 pdh.collect(); 100 else { 101 try { 102 pdh.collect(); 103 } catch (const PDH::PDHException &e) { 104 NSC_LOG_ERROR_STD("Failed to query performance counters: " + e.str_); 105 } 106 } 97 107 } 98 108 Sleep(CHECK_INTERVAL*1000); 99 109 } 100 110 101 pdh.close(); 111 try { 112 pdh.close(); 113 } catch (const PDH::PDHException &e) { 114 NSC_LOG_ERROR_STD("Failed to close performance counters: " + e.str_); 115 } 102 116 NSC_DEBUG_MSG("PDHCollector - shutdown!"); 103 117 return 0; … … 153 167 /** 154 168 * 155 * Memory commit ed bytes (your guess is as good as mine to what this is :)169 * Memory committed bytes (your guess is as good as mine to what this is :) 156 170 * @return Some form of memory check 157 171 */ -
modules/SysTray/SysTray.vcproj
ra0528c4 r36c340d 108 108 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 109 109 </Configuration> 110 <Configuration 111 Name="Dynamic Linkage|Win32" 112 OutputDirectory="$(ConfigurationName)" 113 IntermediateDirectory="$(ConfigurationName)" 114 ConfigurationType="2" 115 CharacterSet="2"> 116 <Tool 117 Name="VCCLCompilerTool" 118 AdditionalIncludeDirectories="../include;../../include" 119 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 120 RuntimeLibrary="2" 121 UsePrecompiledHeader="3" 122 WarningLevel="3" 123 Detect64BitPortabilityProblems="TRUE" 124 DebugInformationFormat="3"/> 125 <Tool 126 Name="VCCustomBuildTool"/> 127 <Tool 128 Name="VCLinkerTool" 129 OutputFile="../../Release/modules/$(ProjectName).dll" 130 LinkIncremental="1" 131 ModuleDefinitionFile="SysTray.def" 132 GenerateDebugInformation="TRUE" 133 SubSystem="2" 134 OptimizeReferences="2" 135 EnableCOMDATFolding="2" 136 ImportLibrary="$(OutDir)/SysTray.lib" 137 TargetMachine="1"/> 138 <Tool 139 Name="VCMIDLTool"/> 140 <Tool 141 Name="VCPostBuildEventTool"/> 142 <Tool 143 Name="VCPreBuildEventTool"/> 144 <Tool 145 Name="VCPreLinkEventTool"/> 146 <Tool 147 Name="VCResourceCompilerTool"/> 148 <Tool 149 Name="VCWebServiceProxyGeneratorTool"/> 150 <Tool 151 Name="VCXMLDataGeneratorTool"/> 152 <Tool 153 Name="VCWebDeploymentTool"/> 154 <Tool 155 Name="VCManagedWrapperGeneratorTool"/> 156 <Tool 157 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 158 </Configuration> 159 <Configuration 160 Name="Debug Dynamic Linkage|Win32" 161 OutputDirectory="$(ConfigurationName)" 162 IntermediateDirectory="$(ConfigurationName)" 163 ConfigurationType="2" 164 CharacterSet="2"> 165 <Tool 166 Name="VCCLCompilerTool" 167 Optimization="0" 168 AdditionalIncludeDirectories="../include;../../include" 169 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 170 MinimalRebuild="TRUE" 171 BasicRuntimeChecks="3" 172 RuntimeLibrary="3" 173 UsePrecompiledHeader="3" 174 WarningLevel="3" 175 Detect64BitPortabilityProblems="TRUE" 176 DebugInformationFormat="4"/> 177 <Tool 178 Name="VCCustomBuildTool"/> 179 <Tool 180 Name="VCLinkerTool" 181 OutputFile="../../Debug/modules/$(ProjectName).dll" 182 ModuleDefinitionFile="SysTray.def" 183 GenerateDebugInformation="TRUE" 184 ImportLibrary="$(OutDir)/SysTray.lib" 185 TargetMachine="1"/> 186 <Tool 187 Name="VCMIDLTool"/> 188 <Tool 189 Name="VCPostBuildEventTool"/> 190 <Tool 191 Name="VCPreBuildEventTool"/> 192 <Tool 193 Name="VCPreLinkEventTool"/> 194 <Tool 195 Name="VCResourceCompilerTool"/> 196 <Tool 197 Name="VCWebServiceProxyGeneratorTool"/> 198 <Tool 199 Name="VCXMLDataGeneratorTool"/> 200 <Tool 201 Name="VCWebDeploymentTool"/> 202 <Tool 203 Name="VCManagedWrapperGeneratorTool"/> 204 <Tool 205 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 206 </Configuration> 110 207 </Configurations> 111 208 <References> … … 133 230 UsePrecompiledHeader="1"/> 134 231 </FileConfiguration> 232 <FileConfiguration 233 Name="Dynamic Linkage|Win32"> 234 <Tool 235 Name="VCCLCompilerTool" 236 UsePrecompiledHeader="1"/> 237 </FileConfiguration> 238 <FileConfiguration 239 Name="Debug Dynamic Linkage|Win32"> 240 <Tool 241 Name="VCCLCompilerTool" 242 UsePrecompiledHeader="1"/> 243 </FileConfiguration> 135 244 </File> 136 245 <File -
readme.txt
r3baaa4d r36c340d 1 ** ROUGH DRAFT **2 ** Spelling missate etc... :) **3 4 5 1 NSClient++ is a windows service that allows performance metrics to be gathered by Nagios 6 2 (and possibly other monitoring tools). It is an attempt to create a NSClient compatible … … 8 4 9 5 6 This is an initial NSClient++ test release. 7 8 This version has many of the features from NSClient. 9 The following commands (from check_nt) are supported. 10 * CLIENTVERSION 11 * CPULOAD 12 * UPTIME 13 * USEDDISKSPACE 14 * MEMUSE 15 * SERVICESTATE 16 * PROCSTATE 17 10 18 Installation: 11 NSClient++ -install 12 Will install the NT service 19 To install simply copy all files to directory on the server and run 20 the following command: "NSClient++ /install" to uninstall run: 21 "NSClient++ /uninstall". 13 22 14 NSClient++ -uninstall 15 Will uninstall the service 23 The NSClient++ has the following command syntax: 24 NSClient++ -<command> 25 <command> 26 install - Install the service 27 start - Start the service 28 stop - Stop the service 29 about - Show some info (version et.al.) 30 version - Show some info 31 test - Run interactively (hint: enable ConsoleLogger for 32 this to make sense). Useful for debugging purposes. 16 33 17 NSClient++ -start 18 Will start the service 34 The directory structure: 35 <install root> 36 - NSClient++.exe - The executable (and service) 37 - NSC.ini - The INI file (settings) 38 <modules> 39 - Various NSClient++ modules available to this instance. 19 40 20 NSClient++ -stop 21 Will stop the service 41 The default modules: 42 CheckEventLog.dll 43 An eventlog checker (has yet to get a Unix client) 44 ConsoleLogger.dll 45 Log messages to console. (Usefull when run with -test) 46 FileLogger.dll 47 Log messages to file (Usefull when run as service) 48 NSClientCompat.dll 49 NSCLient compatibility module. Provides NSClient commands. 50 SysTray.dll 51 Shows a sytray when the service (exe) is started and allows you to 52 view the logfile and inject commands. 22 53 23 NSClient++ -test 24 Will start in interactive mode: 25 enter exit<return> to exit. ANything else will be interpreted as a command ie: foo&bar<enter> will be interpreted as a command name foo with argument bar. 26 It also listens to the port in this mode so it can be used to run the client standalone. 27 Notice output is *NOT* piped t othe stdard output unless you enable the console logger module. 54 Settings: 55 The following things can be changed ion the NSC.ini file. 56 57 [generic] 58 password=secret-password 59 # The password to use. 60 61 port=1234 62 # The port to bind to 63 64 [main] 65 bufferSize=4096 66 # Maximum buffer size for commands to return 67 68 [log] 69 file=nsclient.log 70 # The file to log to. 71 72 [nsclient compat] 73 version=modern 74 # The version string to return to the client. 75 # Modern returns the nsclient++ version string in a new syntax: 76 # <application> <version> <date> 77 # Notice this is not automated as of yet (as in date/version is not updated). 78 79 [systray] 80 defaultCommand= 81 # The default command to show in the inject command dialog. 28 82 29 83 30 31 32 33 The API is quite simple: 84 Using the API: 34 85 The following functions are available for a module to "export": (think DLL) 35 86
Note: See TracChangeset
for help on using the changeset viewer.








