Changeset b39c1f3 in nscp


Ignore:
Timestamp:
05/17/09 21:49:38 (4 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
dcd5462
Parents:
b1ac2fa
Message:

Added debug to checkProcess and some additions to the Lua moduel and varous other things...

Files:
18 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    rb1ac2fa rb39c1f3  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,6,613 
    6 #define PRODUCTVER     0,3,6,613 
    7 #define STRFILEVER     _T("0.3.6.613") 
    8 #define STRPRODUCTVER  _T("0.3.6.613") 
    9 #define STRPRODUCTDATE  _T("2009-05-03") 
     5#define FILEVER        0,3,6,660 
     6#define PRODUCTVER     0,3,6,660 
     7#define STRFILEVER     _T("0.3.6.660") 
     8#define STRPRODUCTVER  _T("0.3.6.660") 
     9#define STRPRODUCTDATE  _T("2009-05-14") 
    1010#endif // AUTOBUILD_H 
  • Jamroot

    rb1ac2fa rb39c1f3  
    108108 
    109109make $(target).exe.manifest : NSClient++.manifest : common.copy ; 
    110 explicit $(target).manifest ; 
     110explicit $(target).exe.manifest ; 
    111111 
    112112 
     
    161161 
    162162all-scripts = 
    163     [ MATCH .*scripts/(.*)/.* : [ glob scripts/* ] ] 
     163    [ MATCH .*scripts/(.+\\..*) : [ glob scripts/* ] ] 
    164164    ; 
    165  
     165local all-scripts-lst ; 
    166166if $(toolset) = "msvc" { 
    167167  if ! ( [ bjam/lua.isEnabled ] = true ) { 
     
    194194  for local l in $(all-scripts) 
    195195  { 
    196     make scripts-$l : scripts/$l : common.copy ; 
    197     explicit script-$(l) ; 
     196    #make scripts-$(l) : scripts/$(l) : common.copy ; 
     197    #explicit scripts/$(l) ; 
     198 
     199    #alias scripts-$(l) : scripts/$(l) ; 
     200    #explicit scripts-$(l) ; 
     201 
     202    all-scripts-lst = $(all-scripts-lst) scripts/$(l) ; 
     203 
    198204    echo "Adding script: $(l)" ; 
    199205  } 
     206  echo ">>>Done with: $(all-scripts-lst)" ; 
     207  echo $(all-scripts-lst) ; 
     208  echo "<<<Done with: $(all-scripts-lst)" ; 
    200209} 
    201210 
     
    227236explicit all-helpers-targets ; 
    228237 
     238alias all-scripts-targets : $(all-scripts-lst) ; 
     239explicit all-scripts-targets ; 
     240 
    229241alias all-root-targets : $(target) $(target-config) $(target-readme) $(target-license) $(target-changelog) $(target-counters) helpers/systray_helper ; 
    230242explicit all-root-targets ; 
     243 
    231244alias all-modules-targets : $(all-modules) ; 
    232245explicit all-modules-targets ; 
     
    255268  return <location>$(BOOST_STAGE_LOCATE)/$(tag)/helpers ; 
    256269} 
     270rule generate-scripts-location ( properties * ) 
     271{ 
     272  local tag = [ get-root-prefix $(properties) ] ; 
     273  return <location>$(BOOST_STAGE_LOCATE)/$(tag)/binaries/scripts ; 
     274} 
    257275rule generate-module-location ( properties * ) 
    258276{ 
     
    270288explicit dist-helpers ; 
    271289 
    272 alias build-binaries : dist dist-modules dist-helpers ; 
     290install dist-scripts : all-scripts-targets : <conditional>@generate-scripts-location ; 
     291explicit dist-scripts ; 
     292 
     293 
     294 
     295alias build-binaries : dist dist-modules dist-helpers dist-scripts ; 
    273296explicit build-binaries ; 
    274297 
  • NSClient++.cpp

    rb1ac2fa rb39c1f3  
    570570  if (boot) { 
    571571    try { 
    572       SettingsT::sectionList list = Settings::getInstance()->getSection(_T("modules")); 
    573       for (SettingsT::sectionList::iterator it = list.begin(); it != list.end(); it++) { 
     572      settings_base::sectionList list = Settings::getInstance()->getSection(_T("modules")); 
     573      for (settings_base::sectionList::iterator it = list.begin(); it != list.end(); it++) { 
    574574        try { 
    575575          loadPlugin(getBasePath() + _T("modules\\") + (*it)); 
  • changelog

    rb1ac2fa rb39c1f3  
    44 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 
    55 * Improved socket performance (would be nice if we could be used as a "hub") 
     6 * Fixa dependonservice LanManWorkStation (old win) 
     7 * Fix RtlStringFromGUID problem on NT4 
     8  
     9 
     102009-05-17 MickeM  
     11 * Changed default buffer size for process enumeration (64K now instead of 1K should I hope work better on 64bit OS:es) 
     12 
     132009-05-10 MickeM  
     14 + Added write support for modules to installer 
    615 
    7162009-05-03 MickeM  
  • helpers/installer/Product.wxs

    rb1ac2fa rb39c1f3  
    133133              </Component> 
    134134            </Directory> 
     135            <Directory Id="INSTALLLOCATION_SCRIPTS" Name="scripts"> 
     136              <Component Id="Scripts" Guid="9B490E67-5472-4267-96DC-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     137                <File Id="scriptargs.bat" Name="args.bat" LongName="args.bat" DiskId="1" Source="$(var.Source)/scripts/args.bat" Vital="no" /> 
     138                <File Id="scriptcheck_vb.vbs" Name="check_vb.vbs" LongName="check_vb.vbs" DiskId="1" Source="$(var.Source)/scripts/check_vb.vbs" Vital="no" /> 
     139                <File Id="scriptcritical.bat" Name="critical.bat" LongName="critical.bat" DiskId="1" Source="$(var.Source)/scripts/critical.bat" Vital="no" /> 
     140                <File Id="scriptmulti_line.bat" Name="mline.bat" LongName="multi_line.bat" DiskId="1" Source="$(var.Source)/scripts/multi_line.bat" Vital="no" /> 
     141                <File Id="scriptok.bat" Name="ok.bat" LongName="ok.bat" DiskId="1" Source="$(var.Source)/scripts/ok.bat" Vital="no" /> 
     142                <File Id="scriptpowershell.ps1" Name="pwrshell.ps1" LongName="powershell.ps1" DiskId="1" Source="$(var.Source)/scripts/powershell.ps1" Vital="no" /> 
     143                <File Id="scripttest.lua" Name="test.lua" LongName="test.lua" DiskId="1" Source="$(var.Source)/scripts/test.lua" Vital="no" /> 
     144              </Component> 
     145            </Directory> 
     146          </Directory> 
     147        </Directory> 
     148        <Directory Id="ProgramMenuFolder" Name="PMenu" LongName="Programs"> 
     149          <Directory Id="ProgramMenuDir" Name='NSClient' LongName="$(var.App.StartMenuPath)" /> 
    135150        </Directory> 
    136151      </Directory> 
    137       <Directory Id="ProgramMenuFolder" Name="PMenu" LongName="Programs"> 
    138         <Directory Id="ProgramMenuDir" Name='NSClient' LongName="$(var.App.StartMenuPath)" /> 
    139       </Directory> 
    140     </Directory> 
    141     <Feature Id="ProductFeature" Title="NSClient++ $(var.PlatForm)" Description="Binaries for $(var.PlatForm)" 
    142              Display="expand"  Level="1" ConfigurableDirectory="INSTALLLOCATION" Absent="disallow"> 
    143       <Feature Id="MainProgram" Title="Program" Description="Main Service" Level="1" Absent="disallow"> 
    144         <ComponentRef Id="MainClient" /> 
     152      <Feature Id="ProductFeature" Title="NSClient++ $(var.PlatForm)" Description="Binaries for $(var.PlatForm)" 
     153               Display="expand"  Level="1" ConfigurableDirectory="INSTALLLOCATION" Absent="disallow"> 
     154        <Feature Id="MainProgram" Title="Program" Description="Main Service" Level="1" Absent="disallow"> 
     155          <ComponentRef Id="MainClient" /> 
    145156      </Feature> 
    146157      <Feature Id="Plugins" Title="Plugins" Description="Plugins" Level="1" Absent="disallow"> 
     
    156167        <Feature Id="NSCAPlugin" Title="NSCA plugin" Description="Plugin to submit passive results to an NSCA server" Level="1" Absent="disallow"> 
    157168          <ComponentRef Id="NSCA" /> 
     169        </Feature> 
     170        <Feature Id="SampleScripts" Title="Sample Scripts" Description="Some sample client-side scripts to use with NRPE" Level="1" Absent="disallow"> 
     171          <ComponentRef Id="Scripts" /> 
    158172        </Feature> 
    159173      </Feature> 
  • include/EnumProcess.cpp

    rb1ac2fa rb39c1f3  
    8585  TOKEN_PRIVILEGES token_privileges;                  
    8686  DWORD dwSize;                        
    87   ZeroMemory (&token_privileges, sizeof (token_privileges)); 
     87  ZeroMemory (&token_privileges, sizeof(token_privileges)); 
    8888  token_privileges.PrivilegeCount = 1; 
    8989  if ( !OpenProcessToken (GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken)) 
     
    123123 
    124124CEnumProcess::process_list CEnumProcess::enumerate_processes(bool expand_command_line, bool find_16bit, CEnumProcess::error_reporter *error_interface, unsigned int buffer_size) { 
    125  
     125  if (error_interface!=NULL) 
     126    error_interface->report_debug_enter(_T("enumerate_processes")); 
    126127  try { 
     128    if (error_interface!=NULL) 
     129      error_interface->report_debug_enter(_T("enable_token_privilege")); 
    127130    enable_token_privilege(SE_DEBUG_NAME); 
     131    if (error_interface!=NULL) 
     132      error_interface->report_debug_exit(_T("enable_token_privilege")); 
    128133  } catch (process_enumeration_exception &e) { 
    129134    if (error_interface!=NULL) 
     
    134139  DWORD *dwPIDs = new DWORD[buffer_size+1]; 
    135140  DWORD cbNeeded = 0; 
     141  if (error_interface!=NULL) 
     142    error_interface->report_debug_enter(_T("FEnumProcesses")); 
    136143  BOOL OK = FEnumProcesses(dwPIDs, buffer_size*sizeof(DWORD), &cbNeeded); 
     144  if (error_interface!=NULL) 
     145    error_interface->report_debug_exit(_T("FEnumProcesses")); 
    137146  if (cbNeeded >= DEFAULT_BUFFER_SIZE*sizeof(DWORD)) { 
    138147    delete [] dwPIDs; 
     148    if (error_interface!=NULL) 
     149      error_interface->report_debug(_T("Need larger buffer: ") + strEx::itos(buffer_size)); 
    139150    return enumerate_processes(expand_command_line, find_16bit, error_interface, buffer_size * 10);  
    140151  } 
     
    149160    CProcessEntry entry; 
    150161    try { 
     162      if (error_interface!=NULL) 
     163        error_interface->report_debug_enter(_T("describe_pid")); 
    151164      try { 
    152165        entry = describe_pid(dwPIDs[i], expand_command_line); 
     
    156169        entry = describe_pid(dwPIDs[i], false); 
    157170      } 
     171      if (error_interface!=NULL) 
     172        error_interface->report_debug_exit(_T("describe_pid")); 
    158173      if (VDMDBG!=NULL&&find_16bit) { 
     174        if (error_interface!=NULL) 
     175          error_interface->report_debug(_T("Looking for 16bit apps")); 
    159176        if( _wcsicmp(entry.filename.substr(0,9).c_str(), _T("NTVDM.EXE")) == 0) { 
    160177          find_16bit_container container; 
     
    174191  } 
    175192  delete [] dwPIDs; 
     193  if (error_interface!=NULL) 
     194    error_interface->report_debug_exit(_T("enumerate_processes")); 
    176195  return ret; 
    177196} 
  • include/EnumProcess.h

    rb1ac2fa rb39c1f3  
    5151#endif 
    5252 
    53 #define DEFAULT_BUFFER_SIZE 1024 
     53#define DEFAULT_BUFFER_SIZE 64*1024 
    5454 
    5555class CEnumProcess   
     
    6161    virtual void report_error(std::wstring error) = 0; 
    6262    virtual void report_warning(std::wstring error) = 0; 
     63    virtual void report_debug(std::wstring error) = 0; 
     64    virtual void report_debug_enter(std::wstring error) = 0; 
     65    virtual void report_debug_exit(std::wstring error) = 0; 
    6366  }; 
    6467  class process_enumeration_exception { 
  • include/INISettings.h

    r99e4d8f rb39c1f3  
    1616  std::wstring file_; 
    1717public: 
    18   typedef std::list<std::wstring> sectionList; 
     18  //typedef std::list<std::wstring> sectionList; 
    1919 
    2020public: 
     
    3131   * @param unsigned int bufferLength 
    3232   */ 
    33   sectionList getSections(unsigned int bufferLength = BUFF_LEN) { 
    34     sectionList ret; 
     33  settings_base::sectionList getSections(unsigned int bufferLength = BUFF_LEN) { 
     34    settings_base::sectionList ret; 
    3535    TCHAR* buffer = new TCHAR[bufferLength+1]; 
    3636    unsigned int count = ::GetPrivateProfileSectionNames(buffer, BUFF_LEN, file_.c_str()); 
     
    5656  * @return A list with all keys from the section 
    5757  */ 
    58   sectionList getSection(std::wstring section, unsigned int bufferLength = BUFF_LEN) { 
    59     sectionList ret; 
     58  settings_base::sectionList getSection(std::wstring section, unsigned int bufferLength = BUFF_LEN) { 
     59    settings_base::sectionList ret; 
    6060    TCHAR* buffer = new TCHAR[bufferLength+1]; 
    6161    unsigned int count = GetPrivateProfileSection(section.c_str(), buffer, bufferLength, file_.c_str()); 
     
    8080  } 
    8181  /** 
     82  * Get all keys from a section as a list<string> 
     83  * @param section The section to return all keys from 
     84  * @return A list with all keys from the section 
     85  */ 
     86  //void settings_base::setSection(std::wstring,settings_base::sectionList) 
     87  void setSection(std::wstring section, settings_base::sectionList data) { 
     88    unsigned int length = 0; 
     89    for (settings_base::sectionList::const_iterator cit = data.begin(); cit!=data.end();++cit) { 
     90      length += (*cit).size() + 10; 
     91    } 
     92    TCHAR* buffer = new TCHAR[length+1]; 
     93    unsigned int index = 0; 
     94    for (settings_base::sectionList::const_iterator cit = data.begin(); cit!=data.end();++cit) { 
     95      wcsncpy_s(&buffer[index], length-index-1,(*cit).c_str(), (*cit).length()+1); 
     96      index+=(*cit).length(); 
     97      buffer[index]=0; 
     98      index++; 
     99    } 
     100    buffer[index]=0; 
     101    buffer[index+1]=0; 
     102    WritePrivateProfileSection(section.c_str(), buffer, file_.c_str()); 
     103    delete [] buffer; 
     104  } 
     105  /** 
    82106  * Get a string from the settings file 
    83107  * @param section Section to read from  
     
    132156      coreFile_ = tmp; 
    133157    files_.push_front(tmp); 
    134     INIFile::sectionList lst = tmp->getSection(_T("includes")); 
    135     for(INIFile::sectionList::const_iterator cit = lst.begin(); cit != lst.end(); ++cit) { 
     158    settings_base::sectionList lst = tmp->getSection(_T("includes")); 
     159    for(settings_base::sectionList::const_iterator cit = lst.begin(); cit != lst.end(); ++cit) { 
    136160      if (!hasFile(*cit)) 
    137161        importFile(basepath, *cit); 
     
    154178  * @param unsigned int bufferLength 
    155179  */ 
    156   INIFile::sectionList getSections(unsigned int bufferLength = BUFF_LEN) { 
    157     INIFile::sectionList ret; 
    158     for (std::list<INIFile*>::const_iterator cit = files_.begin(); cit != files_.end(); ++cit) { 
    159       INIFile::sectionList tmp = (*cit)->getSections(bufferLength); 
     180  settings_base::sectionList getSections(unsigned int bufferLength = BUFF_LEN) { 
     181    settings_base::sectionList ret; 
     182    for (std::list<INIFile*>::const_iterator cit = files_.begin(); cit != files_.end(); ++cit) { 
     183      settings_base::sectionList tmp = (*cit)->getSections(bufferLength); 
    160184      ret.insert(ret.begin(), tmp.begin(), tmp.end()); 
    161185    } 
     
    168192  * @return A list with all keys from the section 
    169193  */ 
    170   INIFile::sectionList getSection(std::wstring section, unsigned int bufferLength = BUFF_LEN) { 
    171     INIFile::sectionList ret; 
    172     for (std::list<INIFile*>::const_iterator cit = files_.begin(); cit != files_.end(); ++cit) { 
    173       INIFile::sectionList tmp = (*cit)->getSection(section, bufferLength); 
     194  settings_base::sectionList getSection(std::wstring section, unsigned int bufferLength = BUFF_LEN) { 
     195    settings_base::sectionList ret; 
     196    for (std::list<INIFile*>::const_iterator cit = files_.begin(); cit != files_.end(); ++cit) { 
     197      settings_base::sectionList tmp = (*cit)->getSection(section, bufferLength); 
    174198      ret.insert(ret.begin(), tmp.begin(), tmp.end()); 
    175199    } 
     
    192216  } 
    193217 
     218  void setSection(std::wstring section, settings_base::sectionList data) { 
     219    if (coreFile_ != NULL) 
     220      coreFile_->setSection(section, data); 
     221  } 
     222     
    194223  void setString(std::wstring section, std::wstring key, std::wstring value) { 
    195224    if (coreFile_ != NULL) 
     
    218247}; 
    219248 
    220 class INISettings : public TSettings 
     249class INISettings : public settings_base 
    221250{ 
    222251private: 
     
    251280    return settingsBundle.getSections(bufferLength); 
    252281  } 
     282  void setSection(std::wstring section, settings_base::sectionList data) { 
     283    return settingsBundle.setSection(section, data); 
     284  } 
    253285 
    254286  /** 
  • include/REGSettings.h

    r1d53fe0 rb39c1f3  
    1010 
    1111#include <iostream> 
    12 class REGSettings : public TSettings 
     12class REGSettings : public settings_base 
    1313{ 
    1414public: 
     
    216216    return ret; 
    217217  } 
     218  void setSection(std::wstring section, sectionList data)  { 
     219    std::wcout << _T("Unsupported function call") << std::endl; 
     220  } 
    218221}; 
  • include/Settings.h

    rfebff5f rb39c1f3  
    3939}; 
    4040 
    41 class SettingsT 
     41class settings_core 
    4242{ 
    4343private: 
     
    5454  std::wstring basepath_; 
    5555  bool bHasInternalData; 
    56   TSettings *settingsManager; 
     56  settings_base *settingsManager; 
    5757 
    5858public: 
    5959  typedef std::list<std::wstring> sectionList; 
    60   SettingsT(void) : bHasInternalData(false), settingsManager(NULL) 
     60  settings_core(void) : bHasInternalData(false), settingsManager(NULL) 
    6161  { 
    6262  } 
    6363 
    64   virtual ~SettingsT(void) 
     64  virtual ~settings_core(void) 
    6565  { 
    6666    if (settingsManager) 
     
    103103  void read(int type = -1) { 
    104104    bool bNew = false; 
    105     TSettings *sM = settingsManager; 
     105    settings_base *sM = settingsManager; 
    106106    if (settingsManager == NULL) 
    107107      throw SettingsException(_T("No settings method specified, cannot start")); 
     
    160160    } 
    161161  } 
     162  void writeSection(std::wstring section, sectionList data) { 
     163    if (settingsManager == NULL) 
     164      throw SettingsException(_T("No settings method specified, cannot start")); 
     165    if (settingsManager->getActiveTypeID() == INISettings::getType()) 
     166      settingsManager->setSection(section, data); 
     167    else  
     168      throw SettingsException(_T("Writing modules to non-INI file is not supported")); 
     169  } 
    162170  void write(int type = -1) { 
    163171    bool bNew = false; 
    164     TSettings *sM = settingsManager; 
     172    settings_base *sM = settingsManager; 
    165173    if (settingsManager == NULL) 
    166174      throw SettingsException(_T("No settings method specified, cannot start")); 
     
    294302}; 
    295303 
    296 typedef Singleton<SettingsT> Settings;    // Implement the settings manager as a singleton 
     304typedef Singleton<settings_core> Settings;    // Implement the settings manager as a singleton 
  • include/TSettings.h

    r7e33d82 rb39c1f3  
    55#define BUFF_LEN 4096 
    66 
    7 class TSettings 
     7class settings_base 
    88{ 
    99public: 
    1010  typedef std::list<std::wstring> sectionList; 
    11   TSettings(void) 
     11  settings_base(void) 
    1212  { 
    1313  } 
    1414 
    15   virtual ~TSettings(void) 
     15  virtual ~settings_base(void) 
    1616  { 
    1717  } 
     
    2424  virtual void setInt(std::wstring section, std::wstring key, int value) = 0; 
    2525  virtual int getActiveTypeID() = 0; 
     26  virtual void setSection(std::wstring section, sectionList data) = 0; 
     27 
    2628}; 
  • include/strEx.h

    r3692371 rb39c1f3  
    214214    while (pos != std::wstring::npos) { 
    215215      string = string.substr(0,pos)+with+string.substr(pos+len); 
    216       pos = string.find(replace, pos+1); 
     216      if (with.find(replace) != std::wstring::npos) // If the replace containes the key look after the replace! 
     217        pos = string.find(replace, pos+with.length()); 
     218      else 
     219        pos = string.find(replace, pos+1); 
    217220    } 
    218221  } 
  • modules/CheckEventLog/Jamfile

    r1d53fe0 rb39c1f3  
    1313  #<user-interface>gui 
    1414  <runtime-link>static 
     15  <source>/boost//regexp 
    1516 
    1617  : # default build 
  • modules/CheckSystem/CheckSystem.cpp

    rb1ac2fa rb39c1f3  
    803803    NSC_LOG_MESSAGE(error); 
    804804  } 
     805  void report_debug(std::wstring error) { 
     806    NSC_DEBUG_MSG_STD(_T("PROC::: ") + error); 
     807  } 
     808  void report_debug_enter(std::wstring error) { 
     809    NSC_DEBUG_MSG_STD(_T("PROC>>> ") + error); 
     810  } 
     811  void report_debug_exit(std::wstring error) { 
     812    NSC_DEBUG_MSG_STD(_T("PROC<<<") + error); 
     813  } 
    805814}; 
    806815 
  • modules/CheckSystem/PDHCollector.cpp

    ra34b229 rb39c1f3  
    107107      memCb = _T("\\") + pdh.lookupIndex(4) + _T("\\") + pdh.lookupIndex(26); 
    108108    } else { 
    109       SettingsT settings; 
     109      settings_core settings; 
    110110      settings.setFile(NSCModuleHelper::getBasePath(),  _T("counters.defs"), true); 
    111111      NSC_DEBUG_MSG_STD(_T("Detected language: ") + settings.getString(section, _T("Description"), _T("Not found")) + _T(" (") + section + _T(")")); 
  • modules/LUAScript/script_wrapper.hpp

    rbc97cd8 rb39c1f3  
    120120  void push_string(lua_State *L, std::wstring s) { 
    121121    lua_pushstring(L, strEx::wstring_to_string(s).c_str()); 
     122  } 
     123  void push_array(lua_State *L, std::list<std::wstring> &arr) { 
     124    lua_createtable(L, 0, arr.size()); 
     125    int i=0; 
     126    for (std::list<std::wstring>::const_iterator cit=arr.begin(); cit != arr.end(); ++cit) { 
     127      lua_pushnumber(L,i++); 
     128      lua_pushstring(L,strEx::wstring_to_string(*cit).c_str()); 
     129      lua_settable(L,-3); 
     130    } 
    122131  } 
    123132 
     
    237246    } 
    238247    static int getSection (lua_State *L) { 
    239       NSC_DEBUG_MSG_STD(_T("LUA::setSettings")); 
    240       return 0; 
     248      int nargs = lua_gettop( L ); 
     249      if (nargs > 1) 
     250        return luaL_error(L, "Incorrect syntax: nscp.getSection([<section>]);"); 
     251      std::wstring v; 
     252      if (nargs > 0) 
     253        v = pop_string(L); 
     254      try { 
     255        std::list<std::wstring> list = NSCModuleHelper::getSettingsSection(v); 
     256        push_array(L, list); 
     257      } catch (...) { 
     258        return luaL_error(L, "Unknown exception getting section"); 
     259      } 
     260      return 1; 
    241261    } 
    242262    static int info (lua_State *L) { 
  • modules/NRPEListener/NRPEListener.cpp

    rb1ac2fa rb39c1f3  
    324324      } catch (NRPEPacket::NRPEPacketException e) { 
    325325        NSC_LOG_ERROR_STD(_T("NRPESocketException: ") + e.getMessage()); 
    326         client->close(); 
    327         return; 
     326        NRPEPacket err(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnUNKNOWN, _T("Could not construct return paket in NRPE handler check clientside (nsclient.log) logs..."), buffer_length_); 
     327        try { 
     328          block.copyFrom(out.getBuffer(), out.getBufferLength()); 
     329        } catch (NRPEPacket::NRPEPacketException e) { 
     330          NSC_LOG_ERROR_STD(_T("NRPESocketException (again): ") + e.getMessage()); 
     331          client->close(); 
     332          return; 
     333        } 
    328334      } 
    329335      int maxWait = socketTimeout_*10; 
  • scripts/test.lua

    rbc97cd8 rb39c1f3  
    1010nscp.register('lua_debug', 'debug') 
    1111nscp.register('foo', 'something') 
     12nscp.register('lua_alias', 'execute_all_alias') 
    1213 
    1314function something (command) 
     
    2021end 
    2122 
     23function execute_all_alias() 
     24  commands = nscp.getSection('External Alias') 
     25  ok = 0 
     26  err = 0 
     27  for i,key in pairs(commands) do  
     28    args = nscp.getSetting('External Alias', key) 
     29    code, msg, perf = nscp.execute(key,args) 
     30    if code == 'ok' then 
     31      ok = ok + 1 
     32    else 
     33      err = err + 1 
     34      print('[' .. i .. '] ' .. key .. ': ' .. code .. ' <' .. msg ..'>') 
     35    end 
     36  end 
     37  if err == 0 then 
     38    return 'ok', 'All ' .. ok .. ' commands were ok' 
     39  else 
     40    return 'error', 'Only ' .. ok .. ' commands of the ' .. (ok+err) .. ' were successfull' 
     41  end 
     42end 
    2243 
    2344function debug (command, args) 
Note: See TracChangeset for help on using the changeset viewer.