Changeset a34b229 in nscp
- Timestamp:
- 09/09/08 10:11:36 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 7221dc8
- Parents:
- dc59b0e
- Files:
-
- 2 added
- 1 deleted
- 23 edited
-
AutoBuild.h (modified) (1 diff)
-
NSC.dist (modified) (1 diff)
-
NSCPlugin.cpp (modified) (3 diffs)
-
NSCPlugin.h (modified) (1 diff)
-
NSClient++-2005.sln (modified) (3 diffs)
-
NSClient++-2005.vcproj (modified) (2 diffs)
-
NSClient++.cpp (modified) (15 diffs)
-
NSClient++.rc (modified) (3 diffs)
-
changelog (modified) (1 diff)
-
helpers/systray_helper/ReadMe.txt (deleted)
-
helpers/systray_helper/TrayWidget.cpp (modified) (10 diffs)
-
helpers/systray_helper/TrayWidget.h (modified) (1 diff)
-
helpers/systray_helper/res/standby.ico (added)
-
include/NSCHelper.cpp (modified) (1 diff)
-
include/NSCHelper.h (modified) (1 diff)
-
include/NTService.h (modified) (3 diffs)
-
include/config.h (modified) (1 diff)
-
include/nsclient_session.hpp (modified) (3 diffs)
-
include/sysinfo.h (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (6 diffs)
-
modules/CheckEventLog/CheckEventLog.h (modified) (1 diff)
-
modules/CheckSystem/PDHCollector.cpp (modified) (1 diff)
-
modules/NSClientListener/NSClientListener.cpp (modified) (4 diffs)
-
modules/SysTray/res/standby.ico (modified) (previous)
-
res/standby.ico (modified) (previous)
-
resource.h (added)
Legend:
- Unmodified
- Added
- Removed
-
AutoBuild.h
rdc59b0e ra34b229 3 3 // change the FALSE to TRUE for autoincrement of build number 4 4 #define INCREMENT_VERSION TRUE 5 #define FILEVER 0,3,4, 46 #define PRODUCTVER 0,3,4, 47 #define STRFILEVER _T("0.3.4. 4")8 #define STRPRODUCTVER _T("0.3.4. 4")9 #define STRPRODUCTDATE _T("2008-09-0 8")5 #define FILEVER 0,3,4,23 6 #define PRODUCTVER 0,3,4,23 7 #define STRFILEVER _T("0.3.4.23") 8 #define STRPRODUCTVER _T("0.3.4.23") 9 #define STRPRODUCTDATE _T("2008-09-09") 10 10 #endif // AUTOBUILD_H -
NSC.dist
rdc59b0e ra34b229 300 300 check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments 301 301 302 ;# LUA SCRIPT SECTION 303 ; A list of all Lua scripts to load. 304 ;[LUA Scripts] 305 ;scripts\test.lua -
NSCPlugin.cpp
rc0522cd ra34b229 45 45 ,fHideTray(NULL) 46 46 ,bLoaded_(false) 47 ,lastIsMsgPlugin_(false) 47 48 { 48 49 } … … 63 64 ,fHideTray(NULL) 64 65 ,bLoaded_(false) 66 ,lastIsMsgPlugin_(false) 65 67 { 66 68 if (other.bLoaded_) { … … 179 181 throw NSPluginException(file_, _T("Module not loaded")); 180 182 try { 181 if (fHasMessageHandler()) 183 if (fHasMessageHandler()) { 184 lastIsMsgPlugin_ = true; 182 185 return true; 186 } 183 187 return false; 184 188 } catch (...) { -
NSCPlugin.h
rc0522cd ra34b229 160 160 return ret; 161 161 } 162 bool getLastIsMsgPlugin() { 163 return lastIsMsgPlugin_; 164 } 162 165 163 166 private: 167 bool lastIsMsgPlugin_; 164 168 bool isLoaded() const { 165 169 return bLoaded_; -
NSClient++-2005.sln
rdc59b0e ra34b229 139 139 EndProjectSection 140 140 ProjectSection(ProjectDependencies) = postProject 141 {BA246C01-063A-4548-8957-32D5CC76171B} = {BA246C01-063A-4548-8957-32D5CC76171B} 142 {2286162D-7571-4735-BAC8-4A8D33A4F42D} = {2286162D-7571-4735-BAC8-4A8D33A4F42D} 143 {8F1C3E39-D6C6-4414-AAD2-FE03C9A8655F} = {8F1C3E39-D6C6-4414-AAD2-FE03C9A8655F} 144 {43718644-173B-42D8-8AD1-E359BFB2BB20} = {43718644-173B-42D8-8AD1-E359BFB2BB20} 145 {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129} = {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129} 146 {2FCAF54B-AAD3-4F59-895A-8F9CEAFDC65D} = {2FCAF54B-AAD3-4F59-895A-8F9CEAFDC65D} 147 {BBFF8362-C626-4838-B0A2-F695D638AD24} = {BBFF8362-C626-4838-B0A2-F695D638AD24} 148 {626EB00E-A4D2-4B02-9BF4-4C655CA2B7E4} = {626EB00E-A4D2-4B02-9BF4-4C655CA2B7E4} 149 {08D6246D-1B4A-47A3-965D-296DCC54A4E8} = {08D6246D-1B4A-47A3-965D-296DCC54A4E8} 150 {F3401E75-60FB-4A0E-A18C-6505587D5B1A} = {F3401E75-60FB-4A0E-A18C-6505587D5B1A} 151 {26B84883-BE52-40E6-9BEE-55AD056D5751} = {26B84883-BE52-40E6-9BEE-55AD056D5751} 152 {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45} = {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45} 153 {05DE66AC-E55C-43B3-849F-7EC695D8B8D0} = {05DE66AC-E55C-43B3-849F-7EC695D8B8D0} 154 {6F55C9BF-57F6-4A15-A058-C83A52F539EE} = {6F55C9BF-57F6-4A15-A058-C83A52F539EE} 155 {4241C6CF-EC01-4AD9-89B0-B75EBA8A5996} = {4241C6CF-EC01-4AD9-89B0-B75EBA8A5996} 156 {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F} = {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F} 157 {2FF60AF6-09AA-49AB-B414-2E8FD01655C6} = {2FF60AF6-09AA-49AB-B414-2E8FD01655C6} 158 EndProjectSection 159 EndProject 160 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UploadInstaller", "helpers\UploadInstaller\UploadInstaller.vcproj", "{6206F046-3D36-4258-BB03-3291A7070117}" 161 ProjectSection(WebsiteProperties) = preProject 162 Debug.AspNetCompiler.Debug = "True" 163 Release.AspNetCompiler.Debug = "False" 164 EndProjectSection 165 ProjectSection(ProjectDependencies) = postProject 141 166 {2286162D-7571-4735-BAC8-4A8D33A4F42D} = {2286162D-7571-4735-BAC8-4A8D33A4F42D} 142 167 {43718644-173B-42D8-8AD1-E359BFB2BB20} = {43718644-173B-42D8-8AD1-E359BFB2BB20} 143 EndProjectSection 144 EndProject 145 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UploadInstaller", "helpers\UploadInstaller\UploadInstaller.vcproj", "{6206F046-3D36-4258-BB03-3291A7070117}" 168 {A3CF4E23-1D1B-4D93-A16A-48C52D118560} = {A3CF4E23-1D1B-4D93-A16A-48C52D118560} 169 EndProjectSection 170 EndProject 171 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UploadBinaries", "helpers\UploadBinaries\UploadBinaries.vcproj", "{D96F7075-F6CD-4921-B5D8-8488E2D24BDB}" 146 172 ProjectSection(WebsiteProperties) = preProject 147 173 Debug.AspNetCompiler.Debug = "True" … … 150 176 ProjectSection(ProjectDependencies) = postProject 151 177 {2286162D-7571-4735-BAC8-4A8D33A4F42D} = {2286162D-7571-4735-BAC8-4A8D33A4F42D} 152 {A3CF4E23-1D1B-4D93-A16A-48C52D118560} = {A3CF4E23-1D1B-4D93-A16A-48C52D118560}153 EndProjectSection154 EndProject155 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UploadBinaries", "helpers\UploadBinaries\UploadBinaries.vcproj", "{D96F7075-F6CD-4921-B5D8-8488E2D24BDB}"156 ProjectSection(WebsiteProperties) = preProject157 Debug.AspNetCompiler.Debug = "True"158 Release.AspNetCompiler.Debug = "False"159 EndProjectSection160 ProjectSection(ProjectDependencies) = postProject161 178 {43718644-173B-42D8-8AD1-E359BFB2BB20} = {43718644-173B-42D8-8AD1-E359BFB2BB20} 162 {2286162D-7571-4735-BAC8-4A8D33A4F42D} = {2286162D-7571-4735-BAC8-4A8D33A4F42D}163 179 EndProjectSection 164 180 EndProject … … 1173 1189 {F3401E75-60FB-4A0E-A18C-6505587D5B1A} = {9757464B-C125-4307-A84A-F4181AE6A081} 1174 1190 {0E2B21D9-F432-4127-8E92-7716B1072510} = {9A087442-7BB2-4CF0-9F58-5D1BC3C32CD2} 1191 {A3CF4E23-1D1B-4D93-A16A-48C52D118560} = {9A087442-7BB2-4CF0-9F58-5D1BC3C32CD2} 1175 1192 {6206F046-3D36-4258-BB03-3291A7070117} = {9A087442-7BB2-4CF0-9F58-5D1BC3C32CD2} 1176 1193 {D96F7075-F6CD-4921-B5D8-8488E2D24BDB} = {9A087442-7BB2-4CF0-9F58-5D1BC3C32CD2} 1177 {A3CF4E23-1D1B-4D93-A16A-48C52D118560} = {9A087442-7BB2-4CF0-9F58-5D1BC3C32CD2}1178 1194 {630857C0-6AD8-4CEE-B5F7-CA1DF620CA9A} = {C8DCE3D7-A802-4C5D-ABB1-B478F545B6E5} 1179 1195 {B6D08289-B8AE-4391-9D07-93B22618BE58} = {C8DCE3D7-A802-4C5D-ABB1-B478F545B6E5} -
NSClient++-2005.vcproj
rc0522cd ra34b229 2429 2429 </File> 2430 2430 <File 2431 RelativePath=".\resource.h" 2432 > 2433 </File> 2434 <File 2431 2435 RelativePath=".\include\ServiceCmd.h" 2432 2436 > … … 2469 2473 Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 2470 2474 > 2475 <File 2476 RelativePath=".\NSClient++.rc" 2477 > 2478 </File> 2479 <File 2480 RelativePath=".\res\standby.ico" 2481 > 2482 </File> 2471 2483 </Filter> 2472 2484 <Filter -
NSClient++.cpp
rbc97cd8 ra34b229 189 189 } catch (const serviceControll::SCException& e) { 190 190 LOG_MESSAGE_STD(_T("Couldn't set service description: ") + e.error_); 191 return -1; 191 192 } 192 193 LOG_MESSAGE(_T("Service installed!")); 194 return 0; 193 195 } else if ( _wcsicmp( _T("uninstall"), argv[1]+1 ) == 0 ) { 194 196 g_bConsoleLog = true; … … 197 199 } catch (const serviceControll::SCException& e) { 198 200 LOG_MESSAGE_STD(_T("Service deinstallation failed; ") + e.error_); 199 return -1;200 201 } 201 202 LOG_MESSAGE(_T("Service uninstalled!")); 203 return 0; 202 204 } else if ( _wcsicmp( _T("encrypt"), argv[1]+1 ) == 0 ) { 203 205 g_bConsoleLog = true; … … 521 523 522 524 bool NSClientT::exitCore(bool boot) { 525 plugins_loaded_ = false; 523 526 LOG_MESSAGE(_T("Attempting to stop NSCLient++ - " SZVERSION)); 524 527 if (boot) { … … 527 530 mainClient.unloadPlugins(false); 528 531 } catch(NSPluginException e) { 529 std::wcout << _T("Exception raised: ") << e.error_ << _T(" in module: ") << e.file_ << std::endl;;532 LOG_ERROR_STD(_T("Exception raised when unloading non msg plguins: ") + e.error_ + _T(" in module: ") + e.file_); 530 533 } catch(...) { 531 std::wcout << _T("UNknown exception raised: ") << std::endl;;534 LOG_ERROR_STD(_T("Unknown exception raised when unloading non msg plugins")); 532 535 } 533 536 } … … 557 560 } 558 561 } catch(nsclient_session::session_exception &e) { 559 std::wcout << _T("Exception closing shared client session: ") << e.what() << std::endl;;562 LOG_ERROR_STD(_T("Exception closing shared client session: ") + e.what()); 560 563 } catch(...) { 561 std::wcout << _T("Exception closing shared client session: Unknown exception!") << std::endl;;564 LOG_ERROR_STD(_T("Exception closing shared client session: Unknown exception!")); 562 565 } 563 566 try { … … 568 571 } 569 572 } catch(...) { 570 std::wcout << _T("UNknown exception raised: ") << std::endl;;573 LOG_ERROR_STD(_T("UNknown exception raised: When closing shared session")); 571 574 } 572 575 if (boot) { … … 575 578 mainClient.unloadPlugins(true); 576 579 } catch(NSPluginException e) { 577 std::wcout << _T("Exception raised: ") << e.error_ << _T(" in module: ") << e.file_ << std::endl;;580 LOG_ERROR_STD(_T("Exception raised when unloading msg plugins: ") + e.error_ + _T(" in module: ") + e.file_); 578 581 } catch(...) { 579 std::wcout << _T("UNknown exception raised: ") << std::endl;;582 LOG_ERROR_STD(_T("UNknown exception raised: When stopping message plguins")); 580 583 } 581 584 } … … 713 716 return; 714 717 } 715 for (pluginList::size_type i=plugins_.size();i>0;i--) { 716 NSCPlugin *p = plugins_[i-1]; 718 for (pluginList::reverse_iterator it = plugins_.rbegin(); it != plugins_.rend(); ++it) { 719 NSCPlugin *p = *it; 720 if (p == NULL) 721 continue; 717 722 if (!unloadLoggers && p->hasMessageHandler()) { 718 723 LOG_DEBUG_STD(_T("Skipping log plugin: ") + p->getModule() + _T("...")); … … 729 734 return; 730 735 } 731 for (pluginList::size_type i=plugins_.size();i>0;i--) { 732 NSCPlugin *p = plugins_[i-1]; 733 if (unloadLoggers || !p->hasMessageHandler()) { 734 LOG_DEBUG_STD(_T("Deleating plugin instance: ") + p->getModule() + _T("...")); 735 plugins_[i-1] = NULL; 736 delete p; 737 plugins_.erase(plugins_.begin() + i-1); 738 --i; 739 } 740 } 741 //plugins_.clear(); 736 for (pluginList::iterator it = plugins_.begin(); it != plugins_.end(); ++it) { 737 NSCPlugin *p = (*it); 738 if (p == NULL) 739 continue; 740 try { 741 if (unloadLoggers || !p->getLastIsMsgPlugin()) { 742 *it = NULL; 743 delete p; 744 it = plugins_.erase(it); 745 } 746 } catch(NSPluginException e) { 747 LOG_ERROR_STD(_T("Exception raised when unloading plugin: ") + e.error_ + _T(" in module: ") + e.file_); 748 } catch(...) { 749 LOG_ERROR_STD(_T("Unknown exception raised when unloading plugin")); 750 } 751 } 742 752 } 743 753 } … … 948 958 } 949 959 960 void log_broken_message(std::wstring msg) { 961 OutputDebugString(msg.c_str()); 962 std::wcout << msg << std::endl; 963 } 950 964 /** 951 965 * Report a message to all logging enabled modules. … … 964 978 shared_server_->sendLogMessageToClients(msgType, file, line, message); 965 979 } catch (nsclient_session::session_exception e) { 966 std::wcout << _T("Failed to send message to clients: ") << e.what() << std::endl;980 log_broken_message(_T("Failed to send message to clients: ") + e.what()); 967 981 } 968 982 } … … 974 988 ReadLock readLock(&m_mutexRW, true, 5000); 975 989 if (!readLock.IsLocked()) { 976 OutputDebugString(_T("Message was lost as the core was locked...")); 977 std::wcout << _T("Message was lost as the core was locked...") << std::endl; 990 log_broken_message(_T("Message was lost as the (mutexRW) core was locked: ") + message); 978 991 return; 979 992 } 980 993 MutexLock lock(messageMutex); 981 994 if (!lock.hasMutex()) { 982 OutputDebugString(_T("Message was lost as the core was locked...")); 983 OutputDebugString(message.c_str()); 984 std::wcout << _T("Message was lost as the core was locked...") << std::endl; 985 std::wcout << message << std::endl; 995 log_broken_message(_T("Message was lost as the core was locked: ") + message); 986 996 return; 987 997 } … … 1012 1022 } else { 1013 1023 if (log_cache_.size() > 0) { 1014 std::wcout << _T("*** SENDING CACHE***") << std::endl;1015 1024 for (log_cache_type::const_iterator cit=log_cache_.begin();cit!=log_cache_.end();++cit) { 1016 1025 for (pluginList::size_type i = 0; i< messageHandlers_.size(); i++) { … … 1018 1027 messageHandlers_[i]->handleMessage((*cit).msgType, (_T("CACHE") + (*cit).file).c_str(), (*cit).line, (*cit).message.c_str()); 1019 1028 } catch(const NSPluginException& e) { 1020 // Here we are pretty much fucked! (as logging this might cause a loop :) 1021 std::wcout << _T("Caught: ") << e.error_ << _T(" when trying to log a message...") << std::endl; 1022 std::wcout << _T("This is *really really* bad, now the world is about to end...") << std::endl; 1029 log_broken_message(_T("Caught: ") + e.error_ + _T(" when trying to log a message...")); 1030 return; 1031 } catch(...) { 1032 log_broken_message(_T("Caught: Unknown Exception when trying to log a message...")); 1033 return; 1023 1034 } 1024 1035 } … … 1030 1041 messageHandlers_[i]->handleMessage(msgType, file, line, message.c_str()); 1031 1042 } catch(const NSPluginException& e) { 1032 // Here we are pretty much fucked! (as logging this might cause a loop :) 1033 std::wcout << _T("Caught: ") << e.error_ << _T(" when trying to log a message...") << std::endl; 1034 std::wcout << _T("This is *really really* bad, now the world is about to end...") << std::endl; 1043 log_broken_message(_T("Caught: ") + e.error_ + _T(" when trying to log a message...")); 1044 return; 1045 } catch(...) { 1046 log_broken_message(_T("Caught: Unknown Exception when trying to log a message...")); 1047 return; 1035 1048 } 1036 1049 } -
NSClient++.rc
ra0528c4 ra34b229 30 30 // remains consistent on all systems. 31 31 IDI_STANDBY ICON "res/standby.ico" 32 33 /////////////////////////////////////////////////////////////////////////////34 //35 // Menu36 //37 38 39 32 #endif // English (U.S.) resources 40 /////////////////////////////////////////////////////////////////////////////41 42 43 #ifdef APSTUDIO_INVOKED44 /////////////////////////////////////////////////////////////////////////////45 //46 // TEXTINCLUDE47 //48 49 1 TEXTINCLUDE50 BEGIN51 "resource.h\0"52 END53 54 2 TEXTINCLUDE55 BEGIN56 "#include ""afxres.h""\r\n"57 "\0"58 END59 60 #endif // APSTUDIO_INVOKED61 62 63 /////////////////////////////////////////////////////////////////////////////64 //65 // String Table66 //67 68 STRINGTABLE69 BEGIN70 IDS_HELLO "Hello from MFC!"71 END72 73 #endif // French (France) resources74 33 ///////////////////////////////////////////////////////////////////////////// 75 34 … … 84 43 #endif //_WIN32 85 44 45 #ifdef APSTUDIO_INVOKED 86 46 ///////////////////////////////////////////////////////////////////////////// 87 47 // 88 // DESIGNINFO48 // TEXTINCLUDE 89 49 // 90 50 51 1 TEXTINCLUDE 52 BEGIN 53 "resource.\0" 54 END 91 55 92 /////////////////////////////////////////////////////////////////////////////93 //94 // Dialog95 //96 56 57 3 TEXTINCLUDE 58 BEGIN 59 "\r\0" 60 END 61 62 #endif // APSTUDIO_INVOKED 97 63 98 64 #endif // Swedish resources … … 101 67 102 68 69 #ifndef APSTUDIO_INVOKED 70 ///////////////////////////////////////////////////////////////////////////// 71 // 72 // Generated from the TEXTINCLUDE 3 resource. 73 // 74 75 76 ///////////////////////////////////////////////////////////////////////////// 77 #endif // not APSTUDIO_INVOKED 78 -
changelog
rdc59b0e ra34b229 4 4 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 5 5 * Improved socket performance (would be nice if we could be used as a "hub") 6 7 2008-09-09 MickeM 8 * Fixed issue with & and some commands via check_nt. 9 * Fixed a crash on exit (which I added in Rc1). 10 * Added 10 "bytes" the CPU buffer: (#174) 11 + Added new option to [EventLog] section buffer_size to change the size of the buffer used when scanning the evenlotg (defaults to 64k). 12 * Fixed error handling in CHeckEventLog so errors are repoorted properly (#184) 13 14 2008-09-08 MickeM 15 * Fixed issue in windows 2008 with system tray (shared_session). 16 * Fixed installer issue (should run (i hope) service installer on install now on 64 bit os) 17 * Fixed issue with unloading plugins and log (causing "timeouts" when exiting some times) 6 18 7 19 2008-09-07 MickeM -
helpers/systray_helper/TrayWidget.cpp
rbc97cd8 ra34b229 33 33 34 34 logging::file_logger g_log_instance(_T("nsclient++"),_T("systray.log")); 35 HINSTANCE ghInstance = NULL; 36 TrayWidget *gTrayInstance = NULL; 35 37 36 38 #define LOG_ERROR_FILE(x) g_log_instance.log(_T("error"), __FILEW__, __LINE__, std::wstring(x).c_str()); … … 41 43 42 44 #define LOG_ERROR_TO_TRAY(x) gTrayInstance->log(_T("error"), __FILEW__, __LINE__, std::wstring(x).c_str()); 45 #define LOG_MESSAGE_TO_TRAY(x) gTrayInstance->log(_T("message"), __FILEW__, __LINE__, std::wstring(x).c_str()); 43 46 44 47 #if WINVER < 0x0600 … … 52 55 HMODULE hMod = GetModuleHandle(TEXT("user32")); 53 56 if (hMod == NULL) 54 return false;57 return FALSE; 55 58 fnChangeWindowMessageFilter = (LPFN_CHANGEWINDOWMESSAGEFILTER)GetProcAddress(hMod,"ChangeWindowMessageFilter"); 56 59 } 57 60 if (fnChangeWindowMessageFilter == NULL) { 58 return true; 59 } 61 LOG_ERROR_FILE(_T("Could not find ChangeWindowMessageFilter: ") + error::lookup::last_error()); 62 return TRUE; 63 } 64 LOG_ERROR_FILE(_T("registred windows thingy...")); 60 65 return fnChangeWindowMessageFilter(message,what); 61 66 } … … 72 77 return _T(""); 73 78 } 74 HINSTANCE ghInstance = NULL;75 TrayWidget *gTrayInstance = NULL;76 79 TrayWidget::TrayWidget(std::wstring cmdLine) { 77 80 strEx::splitList list = strEx::splitEx(cmdLine, _T(" ")); … … 124 127 125 128 129 126 130 void TrayWidget::createDialog(HINSTANCE hInstance) { 131 LOG_MESSAGE_TRAY(_T("Creating dialog...")); 127 132 ghInstance = hInstance; 128 hDlgWnd = ::CreateDialog(hInstance,MAKEINTRESOURCE(IDD_NSTRAYDLG),NULL,TrayIcon::DialogProc); 129 if ((hDlgWnd == NULL)||!IsWindow(hDlgWnd)) { 130 LOG_ERROR_TRAY(_T("Failed to create windows: ") + error::lookup::last_error()); 131 } 133 //hDlgWnd = ::CreateDialog(hInstance,MAKEINTRESOURCE(IDD_NSTRAYDLG),NULL,TrayIcon::DialogProc); 134 //if ((hDlgWnd == NULL)||!IsWindow(hDlgWnd)) { 135 // LOG_ERROR_TRAY(_T("Failed to create windows: ") + error::lookup::last_error()); 136 // } 137 138 WNDCLASSEX wndclass; 139 wndclass.lpszMenuName=NULL; 140 wndclass.cbSize=sizeof(wndclass); 141 wndclass.lpfnWndProc=TrayIcon::DialogProc; 142 wndclass.cbClsExtra=0; 143 wndclass.cbWndExtra=0; 144 wndclass.hInstance=hInstance; 145 wndclass.hIcon=NULL; 146 wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); 147 wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); 148 wndclass.hIconSm=NULL; 149 wndclass.lpszClassName=_T("NSClient_pp_TrayClass"); 150 wndclass.style=0; 151 // register task bar restore event after crash 152 //WM_TASKBARCREATED=RegisterWindowMessage(TEXT("TaskbarCreated")); 153 //MyChangeWindowMessageFilter(WM_TASKBARCREATED, MSGFLT_ADD); 132 154 133 155 UINT UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); … … 139 161 } 140 162 163 if (!RegisterClassEx(&wndclass)) { 164 LOG_ERROR_TRAY(_T("Failed to register window class: ") + error::lookup::last_error()); 165 } 166 167 MSG msg; 168 hDlgWnd=CreateWindow(_T("NSClient_pp_TrayClass"),NULL,0,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL); 169 if(hDlgWnd==NULL) 170 { 171 LOG_ERROR_TRAY(_T("Failed to create window: ") + error::lookup::last_error()); 172 return; 173 } 174 while(GetMessage(&msg,NULL,0,0)) 175 { 176 if (msg.message == WM_MY_CLOSE) { 177 ::DestroyWindow(hDlgWnd); 178 } else if (msg.message == UDM_TASKBARCREATED) { 179 LOG_MESSAGE_TRAY(_T("Recreating systray icon...")); 180 TrayIcon::addIcon(msg.hwnd); 181 } else { 182 TranslateMessage(&msg); 183 DispatchMessage(&msg); 184 } 185 } 186 return; 187 188 /* 141 189 MSG Msg; 142 190 BOOL bRet; … … 158 206 } 159 207 } 208 */ 160 209 } 161 210 … … 529 578 namespace TrayIcon 530 579 { 580 UINT UDM_TASKBARCREATED = -1; 531 581 HMENU hPopupMenu_ = NULL; 532 582 } 533 INT_PTR CALLBACK TrayIcon::DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) 583 //LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); 584 LRESULT CALLBACK TrayIcon::DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) 534 585 { 586 if (uMsg == UDM_TASKBARCREATED) { 587 addIcon(hwndDlg); 588 LOG_MESSAGE_TO_TRAY(_T("UDM_TASKBARCREATED")); 589 } 590 535 591 switch (uMsg) 536 592 { … … 542 598 return 0; 543 599 600 case WM_CREATE: 544 601 case WM_INITDIALOG: 602 LOG_MESSAGE_TO_TRAY(_T("WM_INITDIALOG")); 603 604 605 UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); 606 if (UDM_TASKBARCREATED == 0) { 607 LOG_MESSAGE_TO_TRAY(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 608 } 609 if (!ChangeWindowMessageFilter(UDM_TASKBARCREATED, MSGFLT_ADD)) { 610 LOG_MESSAGE_TO_TRAY(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 611 } 612 545 613 addIcon(hwndDlg); 546 614 break; … … 601 669 break; 602 670 } 603 return FALSE; 671 return DefWindowProc(hwndDlg,uMsg,wParam,lParam); 672 //return FALSE; 604 673 } 605 674 void TrayIcon::addIcon(HWND hWnd) { -
helpers/systray_helper/TrayWidget.h
rbc97cd8 ra34b229 75 75 namespace TrayIcon 76 76 { 77 INT_PTRCALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);77 LRESULT CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam); 78 78 INT_PTR CALLBACK InjectDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam); 79 79 INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam); -
include/NSCHelper.cpp
rbc97cd8 ra34b229 257 257 return retC; 258 258 } 259 260 /** 261 * Inject a request command in the core (this will then be sent to the plug-in stack for processing) 262 * @param command Command to inject (password should not be included. 263 * @param argLen The length of the argument buffer 264 * @param **argument The argument buffer 265 * @param message The return message buffer 266 * @param perf The return performance data buffer 267 * @return The return of the command 268 */ 269 NSCAPI::nagiosReturn NSCModuleHelper::InjectCommand(const TCHAR* command, std::list<std::wstring> argument, std::wstring & message, std::wstring & perf) 270 { 271 if (!fNSAPIInject) 272 throw NSCMHExcpetion(_T("NSCore has not been initiated...")); 273 unsigned int buf_len = getBufferLength(); 274 275 276 unsigned int argLen; 277 TCHAR ** aBuffer = arrayBuffer::list2arrayBuffer(argument, argLen); 278 TCHAR *msgBuffer = new TCHAR[buf_len+1]; 279 TCHAR *perfBuffer = new TCHAR[buf_len+1]; 280 msgBuffer[0] = 0; 281 perfBuffer[0] = 0; 282 NSCAPI::nagiosReturn retC = InjectCommandRAW(command, argLen, aBuffer, msgBuffer, buf_len, perfBuffer, buf_len); 283 switch (retC) { 284 case NSCAPI::returnIgnored: 285 NSC_LOG_MESSAGE_STD(_T("No handler for command '") + command + _T("'.")); 286 break; 287 case NSCAPI::returnInvalidBufferLen: 288 NSC_LOG_ERROR(_T("Inject buffer to small, increase the value of: string_length.")); 289 break; 290 case NSCAPI::returnOK: 291 case NSCAPI::returnCRIT: 292 case NSCAPI::returnWARN: 293 case NSCAPI::returnUNKNOWN: 294 message = msgBuffer; 295 perf = perfBuffer; 296 break; 297 default: 298 delete [] msgBuffer; 299 delete [] perfBuffer; 300 throw NSCMHExcpetion(_T("Unknown return code when injecting: ") + std::wstring(command)); 301 } 302 delete [] msgBuffer; 303 delete [] perfBuffer; 304 return retC; 305 } 306 259 307 /** 260 308 * A wrapper around the InjetCommand that is simpler to use. -
include/NSCHelper.h
rc0522cd ra34b229 135 135 NSCAPI::nagiosReturn InjectCommandRAW(const TCHAR* command, const unsigned int argLen, TCHAR **argument, TCHAR *returnMessageBuffer, unsigned int returnMessageBufferLen, TCHAR *returnPerfBuffer, unsigned int returnPerfBufferLen); 136 136 NSCAPI::nagiosReturn InjectCommand(const TCHAR* command, const unsigned int argLen, TCHAR **argument, std::wstring & message, std::wstring & perf); 137 NSCAPI::nagiosReturn InjectCommand(const TCHAR* command, std::list<std::wstring> argument, std::wstring & message, std::wstring & perf); 137 138 NSCAPI::nagiosReturn InjectSplitAndCommand(const TCHAR* command, TCHAR* buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf); 138 139 NSCAPI::nagiosReturn InjectSplitAndCommand(const std::wstring command, const std::wstring buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf, bool escape = false); -
include/NTService.h
rbc97cd8 ra34b229 139 139 OutputDebugString(_T("Not >w2k so sessiong messages disabled...")); 140 140 } 141 ssStatus.dwControlsAccepted = dwControlsAccepted;142 141 if (sshStatusHandle == 0) 143 142 throw service_exception(_T("Failed to register service: ") + error::lookup::last_error()); … … 146 145 ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; 147 146 ssStatus.dwServiceSpecificExitCode = 0; 147 ssStatus.dwControlsAccepted = dwControlsAccepted; 148 148 149 149 // report the status to the service control manager. … … 153 153 } 154 154 try { 155 OutputDebugString( _T("Attempting to start service..."));155 OutputDebugString(std::wstring(_T("Attempting to start service with: ") + strEx::ihextos(dwControlsAccepted)).c_str()); 156 156 ServiceStart(dwArgc, lpszArgv); 157 157 } catch (...) { -
include/config.h
rdc59b0e ra34b229 161 161 #define EVENTLOG_SYNTAX _T("syntax") 162 162 #define EVENTLOG_SYNTAX_DEFAULT _T("") 163 #define EVENTLOG_BUFFER _T("buffer_size") 164 #define EVENTLOG_BUFFER_DEFAULT 1024*64 163 165 164 166 #define NSCA_AGENT_SECTION_TITLE _T("NSCA Agent") -
include/nsclient_session.hpp
rdc59b0e ra34b229 650 650 remote_channel::local_message_type msg; 651 651 msg.command = message_inject; 652 error(__FILEW__, __LINE__, _T("splitter") + strEx::ctos(splitter));653 error(__FILEW__, __LINE__, _T("splitter") + splitter);654 652 655 653 msg.arguments.push_back(command); … … 658 656 msg.arguments.push_back(escape?_T("1"):_T("0")); 659 657 660 error(__FILEW__, __LINE__, _T("arg1") + msg.arguments[1]);661 error(__FILEW__, __LINE__, _T("arg2") + msg.arguments[2]);662 error(__FILEW__, __LINE__, _T("arg3") + msg.arguments[3]);658 //error(__FILEW__, __LINE__, _T("arg1") + msg.arguments[1]); 659 //error(__FILEW__, __LINE__, _T("arg2") + msg.arguments[2]); 660 //error(__FILEW__, __LINE__, _T("arg3") + msg.arguments[3]); 663 661 664 662 unsigned int msg_id = send_server(msg); … … 779 777 if (msg.arguments.size() == 4) { 780 778 try { 781 error(__FILEW__, __LINE__, _T("arg1") + msg.arguments[1]);782 error(__FILEW__, __LINE__, _T("arg2") + msg.arguments[2]);783 error(__FILEW__, __LINE__, _T("arg3") + msg.arguments[3]);779 //error(__FILEW__, __LINE__, _T("arg1") + msg.arguments[1]); 780 //error(__FILEW__, __LINE__, _T("arg2") + msg.arguments[2]); 781 //error(__FILEW__, __LINE__, _T("arg3") + msg.arguments[3]); 784 782 ret = handler_->session_inject(msg.arguments[0], msg.arguments[1], strEx::stoc(msg.arguments[2]), msg.arguments[3]==_T("1"), message, perf); 785 783 } catch (...) { -
include/sysinfo.h
rbc97cd8 ra34b229 59 59 } 60 60 inline bool isAboveXP(const OSVERSIONINFO &osVersion) { 61 if ((osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osVersion.dwMajorVersion>=4)&&(osVersion.dwMinorVersion>=1)) 61 if ((osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osVersion.dwMajorVersion==4)&&(osVersion.dwMinorVersion>=1)) 62 return true; 63 if ((osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osVersion.dwMajorVersion>4)) 62 64 return true; 63 65 return false; -
modules/CheckEventLog/CheckEventLog.cpp
rdc59b0e ra34b229 49 49 debug_ = NSCModuleHelper::getSettingsInt(EVENTLOG_SECTION_TITLE, EVENTLOG_DEBUG, EVENTLOG_DEBUG_DEFAULT)==1; 50 50 syntax_ = NSCModuleHelper::getSettingsString(EVENTLOG_SECTION_TITLE, EVENTLOG_SYNTAX, EVENTLOG_SYNTAX_DEFAULT); 51 buffer_ = NSCModuleHelper::getSettingsInt(EVENTLOG_SECTION_TITLE, EVENTLOG_BUFFER, EVENTLOG_BUFFER_DEFAULT); 51 52 } catch (NSCModuleHelper::NSCMHExcpetion &e) { 52 53 NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); … … 387 388 else if (p__.first == value) { eventlog_filter filter; filter.obj = p__.second; filter_chain.push_back(filteritem_type(filtermode, filter)); } 388 389 389 390 #define BUFFER_SIZE 1024*64 390 struct event_log_buffer { 391 BYTE *bBuffer; 392 DWORD bufferSize_; 393 event_log_buffer(DWORD bufferSize) : bufferSize_(bufferSize) { 394 bBuffer = new BYTE[bufferSize+10]; 395 } 396 ~event_log_buffer() { 397 delete [] bBuffer; 398 } 399 EVENTLOGRECORD* getBufferUnsafe() { 400 return reinterpret_cast<EVENTLOGRECORD*>(bBuffer); 401 } 402 DWORD getBufferSize() { 403 return bufferSize_; 404 } 405 }; 406 391 407 NSCAPI::nagiosReturn CheckEventLog::handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf) { 392 408 if (command != _T("CheckEventLog")) … … 414 430 const int filter_normal = 3; 415 431 const int filter_compat = 3; 432 event_log_buffer buffer(buffer_); 416 433 417 434 try { … … 486 503 //DWORD dwThisRecord; 487 504 DWORD dwRead, dwNeeded; 488 EVENTLOGRECORD *pevlr; 489 BYTE bBuffer[BUFFER_SIZE]; 490 491 pevlr = reinterpret_cast<EVENTLOGRECORD*>(&bBuffer); 505 492 506 493 507 __time64_t ltime; … … 497 511 498 512 while (ReadEventLog(hLog, EVENTLOG_FORWARDS_READ|EVENTLOG_SEQUENTIAL_READ, 499 0, pevlr, BUFFER_SIZE, &dwRead, &dwNeeded))513 0, buffer.getBufferUnsafe(), buffer.getBufferSize(), &dwRead, &dwNeeded)) 500 514 { 501 while (dwRead > 0)502 {515 EVENTLOGRECORD *pevlr = buffer.getBufferUnsafe(); 516 while (dwRead > 0) { 503 517 //bool bMatch = bFilterAll; 504 518 bool bMatch = !bFilterIn; … … 590 604 } 591 605 dwRead -= pevlr->Length; 592 pevlr = (EVENTLOGRECORD *) ((LPBYTE)pevlr + pevlr->Length);606 pevlr = reinterpret_cast<EVENTLOGRECORD*>((LPBYTE)pevlr + pevlr->Length); 593 607 } 594 pevlr = (EVENTLOGRECORD *) &bBuffer; 595 } 608 } 609 DWORD err = GetLastError(); 610 if (err == ERROR_INSUFFICIENT_BUFFER) { 611 NSC_LOG_ERROR_STD(_T("EvenlogBuffer is too small (set the value of ") + EVENTLOG_BUFFER + _T("): ") + error::lookup::last_error(err)); 612 message = std::wstring(_T("EvenlogBuffer is too small (set the value of ")) + EVENTLOG_BUFFER + _T("): ") + error::lookup::last_error(err); 613 return NSCAPI::returnUNKNOWN; 614 } else if (err != ERROR_HANDLE_EOF) { 615 NSC_LOG_ERROR_STD(_T("Failed to read from eventlog: ") + error::lookup::last_error(err)); 616 message = _T("Failed to read from eventlog: ") + error::lookup::last_error(err); 617 return NSCAPI::returnUNKNOWN; 618 } 596 619 CloseEventLog(hLog); 597 620 for (uniq_eventlog_map::const_iterator cit = uniq_records.begin(); cit != uniq_records.end(); ++cit) { -
modules/CheckEventLog/CheckEventLog.h
r8c7d67f ra34b229 31 31 bool debug_; 32 32 std::wstring syntax_; 33 DWORD buffer_; 33 34 34 35 public: -
modules/CheckSystem/PDHCollector.cpp
rdd02c15 ra34b229 29 29 std::wstring s = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_CPU_BUFFER_TIME, C_SYSTEM_CPU_BUFFER_TIME_DEFAULT); 30 30 unsigned int i = strEx::stoui_as_time(s, checkIntervall_*100); 31 cpu.resize(i/(checkIntervall_*100) );31 cpu.resize(i/(checkIntervall_*100)+10); 32 32 } 33 33 -
modules/NSClientListener/NSClientListener.cpp
rdc59b0e ra34b229 138 138 return false; 139 139 } 140 140 void split_to_list(std::list<std::wstring> &list, std::wstring str) { 141 strEx::splitList add = strEx::splitEx(str, _T("&")); 142 list.insert(list.begin(), add.begin(), add.end()); 143 } 141 144 std::string NSClientListener::parseRequest(std::string str_buffer) { 142 145 std::wstring buffer = strEx::string_to_wstring(str_buffer); … … 168 171 NSC_DEBUG_MSG_STD(_T("Data: ") + cmd.second); 169 172 173 std::list<std::wstring> args; 170 174 171 175 // prefix various commands … … 173 177 case REQ_CPULOAD: 174 178 cmd.first = _T("checkCPU"); 175 cmd.second += _T("&nsclient"); 179 split_to_list(args, cmd.second); 180 args.push_back(_T("nsclient")); 176 181 break; 177 182 case REQ_UPTIME: 178 183 cmd.first = _T("checkUpTime"); 179 cmd.second = _T("nsclient");184 args.push_back(_T("nsclient")); 180 185 break; 181 186 case REQ_USEDDISKSPACE: 182 187 cmd.first = _T("CheckDriveSize"); 183 cmd.second += _T("&nsclient"); 188 split_to_list(args, cmd.second); 189 args.push_back(_T("nsclient")); 184 190 break; 185 191 case REQ_CLIENTVERSION: … … 192 198 case REQ_SERVICESTATE: 193 199 cmd.first = _T("checkServiceState"); 194 cmd.second += _T("&nsclient"); 200 split_to_list(args, cmd.second); 201 args.push_back(_T("nsclient")); 195 202 break; 196 203 case REQ_PROCSTATE: 197 204 cmd.first = _T("checkProcState"); 198 cmd.second += _T("&nsclient"); 205 split_to_list(args, cmd.second); 206 args.push_back(_T("nsclient")); 199 207 break; 200 208 case REQ_MEMUSE: 201 209 cmd.first = _T("checkMem"); 202 cmd.second = _T("nsclient");210 args.push_back(_T("nsclient")); 203 211 break; 204 212 case REQ_COUNTER: 205 213 cmd.first = _T("checkCounter"); 206 cmd.second = _T("Counter=") + cmd.second + _T("&nsclient"); 214 args.push_back(_T("Counter=") + cmd.second); 215 args.push_back(_T("nsclient")); 207 216 break; 208 217 case REQ_FILEAGE: 209 218 cmd.first = _T("getFileAge"); 210 cmd.second = _T("path=") + cmd.second; 211 break; 219 args.push_back(_T("path=") + cmd.second); 220 break; 221 default: 222 split_to_list(args, cmd.second); 212 223 } 213 224 214 225 std::wstring message, perf; 215 NSCAPI::nagiosReturn ret = NSCModuleHelper::Inject SplitAndCommand(cmd.first.c_str(), cmd.second.c_str(), '&', message, perf);226 NSCAPI::nagiosReturn ret = NSCModuleHelper::InjectCommand(cmd.first.c_str(), args, message, perf); 216 227 if (!NSCHelper::isNagiosReturnCode(ret)) { 217 228 if (message.empty())
Note: See TracChangeset
for help on using the changeset viewer.








