Changeset b0ae738 in nscp for include


Ignore:
Timestamp:
11/14/07 21:41:36 (6 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
23c63eb
Parents:
5782414
Message:

2007-11-14 MickeM

+ Added multi-line output support ( issue #91 )

  • Improved error handling for external commands
  • Fixed an issue with NRPE/NSClient socket-reading (introduced by the socket_timeout)

(and added the scripts folder to the SVN, and hopefully the build as well :)

Location:
include
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • include/NSCHelper.cpp

    receb8c7 rb0ae738  
    610610    return NSCAPI::returnIgnored; 
    611611  NSCAPI::nagiosReturn ret = NSCHelper::wrapReturnString(returnBufferMessage, returnBufferMessageLen, retMessage, retResult); 
     612  if (!NSCHelper::isMyNagiosReturn(ret)) { 
     613    NSC_LOG_ERROR("A module returned an invalid return code"); 
     614  } 
    612615  return NSCHelper::wrapReturnString(returnBufferPerf, returnBufferPerfLen, retPerformance, ret); 
    613616} 
     617 
    614618/** 
    615619 * Wrap the NSLoadModule call 
  • include/NSCHelper.h

    r30bfe74 rb0ae738  
    4646      return true; 
    4747    return false; 
     48  } 
     49  inline bool isMyNagiosReturn(NSCAPI::nagiosReturn code) { 
     50    return code == NSCAPI::returnCRIT || code == NSCAPI::returnOK || code == NSCAPI::returnWARN || code == NSCAPI::returnUNKNOWN  
     51      || code == NSCAPI::returnInvalidBufferLen || code == NSCAPI::returnIgnored; 
    4852  } 
    4953 
  • include/PDHCounter.h

    rb749b8d rb0ae738  
    201201    } 
    202202    virtual ~PDHQuery(void) { 
    203       if (hQuery_) 
    204         close(); 
    205       for (CounterList::iterator it = counters_.begin(); it != counters_.end(); it++) { 
    206         delete (*it); 
    207       } 
    208       counters_.clear(); 
     203      removeAllCounters(); 
    209204    } 
    210205 
     
    220215      return counter; 
    221216    } 
     217    void removeAllCounters() { 
     218      if (hQuery_) 
     219        close(); 
     220      for (CounterList::iterator it = counters_.begin(); it != counters_.end(); it++) { 
     221        delete (*it); 
     222      } 
     223      counters_.clear(); 
     224    } 
    222225 
    223226    void open() { 
     
    233236    void close() { 
    234237      assert(hQuery_ != NULL); 
    235       DWORD x = PDH_INVALID_HANDLE; 
    236238      PDH_STATUS status; 
    237239      for (CounterList::iterator it = counters_.begin(); it != counters_.end(); it++) { 
  • include/SSLSocket.cpp

    r30bfe74 rb0ae738  
    6868 
    6969 
    70 void simpleSSL::sSSL::readAll(simpleSocket::DataBuffer &buffer, unsigned int tmpBufferLength /* = 1024*/) { 
     70bool simpleSSL::sSSL::readAll(simpleSocket::DataBuffer &buffer, unsigned int tmpBufferLength /* = 1024*/) { 
    7171  // @todo this could be optimized a bit if we want to 
    7272  // If only one buffer is needed we could "reuse" the buffer instead of copying it. 
     
    9393  */ 
    9494  delete [] tmpBuffer; 
     95  return n >= 0; 
    9596  /* 
    9697  if (n <= 0) { 
  • include/SSLSocket.h

    r30bfe74 rb0ae738  
    227227      context_ = context; 
    228228    } 
    229     void readAll (simpleSocket::DataBuffer &buffer, unsigned int tmpBufferLength = 1024); 
     229    bool readAll (simpleSocket::DataBuffer &buffer, unsigned int tmpBufferLength = 1024); 
    230230    void send(const char * buf, unsigned int len); 
    231231  }; 
     
    257257      } 
    258258    } 
    259     virtual void readAll (simpleSocket::DataBuffer &buffer, unsigned int tmpBufferLength = 1024) { 
     259    virtual bool readAll (simpleSocket::DataBuffer &buffer, unsigned int tmpBufferLength = 1024) { 
    260260      try { 
    261         ssl.readAll(buffer, tmpBufferLength); 
     261        return ssl.readAll(buffer, tmpBufferLength); 
    262262      } catch (simpleSSL::SSLException e) { 
    263263        throw simpleSocket::SocketException(e.getMessage()); 
  • include/Socket.cpp

    r478588b rb0ae738  
    3737 * @param tmpBufferLength Length of temporary buffer to use (generally larger then expected data) 
    3838 */ 
    39 void simpleSocket::Socket::readAll(DataBuffer& buffer, unsigned int tmpBufferLength /* = 1024*/) { 
     39bool simpleSocket::Socket::readAll(DataBuffer& buffer, unsigned int tmpBufferLength /* = 1024*/) { 
    4040  // @todo this could be optimized a bit if we want to 
    4141  // If only one buffer is needed we could "reuse" the buffer instead of copying it. 
     
    5555  } 
    5656  delete [] tmpBuffer; 
     57  return n!=SOCKET_ERROR; 
    5758} 
    5859 
  • include/Socket.h

    r30bfe74 rb0ae738  
    226226      return ret; 
    227227    } 
    228     virtual void readAll(DataBuffer &buffer, unsigned int tmpBufferLength = 1024); 
     228    virtual bool readAll(DataBuffer &buffer, unsigned int tmpBufferLength = 1024); 
    229229 
    230230    virtual void socket(int af, int type, int protocol ) { 
Note: See TracChangeset for help on using the changeset viewer.