Module: check_mk
Branch: master
Commit: e3bb09bb6384ebbc50f486fb9b0b40459f258c98
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e3bb09bb6384eb…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jan 21 15:13:15 2016 +0100
Refactoring: Improved naming.
---
livestatus/src/InputBuffer.cc | 54 ++++++++++++++++++++---------------------
livestatus/src/InputBuffer.h | 6 ++---
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/livestatus/src/InputBuffer.cc b/livestatus/src/InputBuffer.cc
index c0c8ec1..a79bb95 100644
--- a/livestatus/src/InputBuffer.cc
+++ b/livestatus/src/InputBuffer.cc
@@ -70,9 +70,9 @@ pair<list<string>, InputBuffer::Result> failure(InputBuffer::Result r)
InputBuffer::InputBuffer(int fd, int *termination_flag)
: _fd(fd), _termination_flag(termination_flag)
{
- _read_pointer = 0; // points to data not yet processed
- _write_pointer = 0; // points to end of data in buffer
- _end_pointer = buffer_size; // points ot end of buffer
+ _read_index = 0; // points to data not yet processed
+ _write_index = 0; // points to end of data in buffer
+ _end_index = buffer_size; // points ot end of buffer
}
// read in data enough for one complete request (and maybe more).
@@ -90,28 +90,28 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
// queries.
bool query_started = false;
- // _read_pointer points to the place in the buffer, where the
- // next valid data begins. This data ends at _write_pointer.
+ // _read_index points to the place in the buffer, where the
+ // next valid data begins. This data ends at _write_index.
// That data might have been read while reading the previous
// request.
// r is used to find the end of the line
- size_t r = _read_pointer;
+ size_t r = _read_index;
while (true)
{
// Try to find end of the current line in buffer
- while (r < _write_pointer && _readahead_buffer[r] != '\n')
+ while (r < _write_index && _readahead_buffer[r] != '\n')
r++; // now r is at end of data or at '\n'
// If we cannot find the end of line in the data
// already read, then we need to read new data from
// the client.
- if (r == _write_pointer)
+ if (r == _write_index)
{
// Is there still space left in the buffer => read in
// further data into the buffer.
- if (_write_pointer < _end_pointer)
+ if (_write_index < _end_index)
{
Result rd = readData(); // tries to read in further data into buffer
if (rd == Result::timeout) {
@@ -130,7 +130,7 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
// read an incomplete line. If the last thing we read was
// a linefeed, then we consider the current request to
// be valid, if it is not empty.
- else if (rd == Result::eof && r == _read_pointer /* currently at beginning of a line */)
+ else if (rd == Result::eof && r == _read_index /* currently at beginning of a line */)
{
if (request_lines.empty()) {
return failure(Result::eof); // empty request -> no request
@@ -139,7 +139,7 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
// socket has been closed but request is complete
return make_pair(request_lines, Result::request_read);
// the current state is now:
- // _read_pointer == r == _write_pointer => buffer is empty
+ // _read_index == r == _write_index => buffer is empty
// that way, if the main program tries to read the
// next request, it will get an IB_UNEXPECTED_EOF
}
@@ -155,15 +155,15 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
}
// OK. So no space is left in the buffer. But maybe at the
// *beginning* of the buffer is space left again. This is
- // very probable if _write_pointer == _end_pointer. Most
+ // very probable if _write_index == _end_index. Most
// of the buffer's content is already processed. So we simply
// shift the yet unprocessed data to the very left of the buffer.
- else if (_read_pointer > 0) {
- int shift_by = _read_pointer; // distance to beginning of buffer
- int size = _write_pointer - _read_pointer; // amount of data to shift
- memmove(&_readahead_buffer[0], &_readahead_buffer[_read_pointer], size);
- _read_pointer = 0; // unread data is now at the beginning
- _write_pointer -= shift_by; // write pointer shifted to the left
+ else if (_read_index > 0) {
+ int shift_by = _read_index; // distance to beginning of buffer
+ int size = _write_index - _read_index; // amount of data to shift
+ memmove(&_readahead_buffer[0], &_readahead_buffer[_read_index], size);
+ _read_index = 0; // unread data is now at the beginning
+ _write_index -= shift_by; // write pointer shifted to the left
r -= shift_by; // current scan position also shift left
// continue -> still no data in buffer, but it will
// be read, as now is space
@@ -176,8 +176,8 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
}
else // end of line found
{
- if (_read_pointer == r) { // empty line found => end of request
- _read_pointer = r + 1;
+ if (_read_index == r) { // empty line found => end of request
+ _read_index = r + 1;
// Was ist, wenn noch keine korrekte Zeile gelesen wurde?
if (request_lines.empty()) {
return failure(Result::empty_request);
@@ -186,16 +186,16 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
return make_pair(request_lines, Result::request_read);
}
else { // non-empty line: belongs to current request
- int length = r - _read_pointer;
- for (size_t end = r; end > _read_pointer && isspace(_readahead_buffer[--end]);)
+ int length = r - _read_index;
+ for (size_t end = r; end > _read_index && isspace(_readahead_buffer[--end]);)
length--;
if (length > 0)
- request_lines.push_back(string(&_readahead_buffer[_read_pointer], length));
+ request_lines.push_back(string(&_readahead_buffer[_read_index], length));
else
logger(LG_INFO, "Warning ignoring line containing only whitespace");
query_started = true;
- _read_pointer = r + 1;
- r = _read_pointer;
+ _read_index = r + 1;
+ r = _read_index;
}
}
}
@@ -224,7 +224,7 @@ InputBuffer::Result InputBuffer::readData()
int retval = select(_fd + 1, &fds, NULL, NULL, &tv);
if (retval > 0 && FD_ISSET(_fd, &fds)) {
- ssize_t r = read(_fd, &_readahead_buffer[_write_pointer], _end_pointer - _write_pointer);
+ ssize_t r = read(_fd, &_readahead_buffer[_write_index], _end_index - _write_index);
if (r < 0) {
return Result::eof;
}
@@ -232,7 +232,7 @@ InputBuffer::Result InputBuffer::readData()
return Result::eof;
}
else {
- _write_pointer += r;
+ _write_index += r;
return Result::data_read;
}
}
diff --git a/livestatus/src/InputBuffer.h b/livestatus/src/InputBuffer.h
index 5457e2b..9a5ffe7 100644
--- a/livestatus/src/InputBuffer.h
+++ b/livestatus/src/InputBuffer.h
@@ -53,9 +53,9 @@ private:
int _fd;
int *_termination_flag;
char _readahead_buffer[buffer_size];
- size_t _read_pointer;
- size_t _write_pointer;
- size_t _end_pointer;
+ size_t _read_index;
+ size_t _write_index;
+ size_t _end_index;
Result readData();
};
Module: check_mk
Branch: master
Commit: 38394981ae2a85d1e1f2ae68dd18191e5e4e8cab
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=38394981ae2a85…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jan 21 15:10:20 2016 +0100
Refactoring only: Use indices instead of pointers.
This will enable us to use a resizable vector more easily.
---
livestatus/src/InputBuffer.cc | 25 ++++++++++++-------------
livestatus/src/InputBuffer.h | 6 +++---
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/livestatus/src/InputBuffer.cc b/livestatus/src/InputBuffer.cc
index 6bababb..c0c8ec1 100644
--- a/livestatus/src/InputBuffer.cc
+++ b/livestatus/src/InputBuffer.cc
@@ -70,9 +70,9 @@ pair<list<string>, InputBuffer::Result> failure(InputBuffer::Result r)
InputBuffer::InputBuffer(int fd, int *termination_flag)
: _fd(fd), _termination_flag(termination_flag)
{
- _read_pointer = &_readahead_buffer[0]; // points to data not yet processed
- _write_pointer = _read_pointer; // points to end of data in buffer
- _end_pointer = _read_pointer + buffer_size; // points ot end of buffer
+ _read_pointer = 0; // points to data not yet processed
+ _write_pointer = 0; // points to end of data in buffer
+ _end_pointer = buffer_size; // points ot end of buffer
}
// read in data enough for one complete request (and maybe more).
@@ -96,12 +96,12 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
// request.
// r is used to find the end of the line
- char *r = _read_pointer;
+ size_t r = _read_pointer;
while (true)
{
// Try to find end of the current line in buffer
- while (r < _write_pointer && r[0] != '\n')
+ while (r < _write_pointer && _readahead_buffer[r] != '\n')
r++; // now r is at end of data or at '\n'
// If we cannot find the end of line in the data
@@ -158,11 +158,11 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
// very probable if _write_pointer == _end_pointer. Most
// of the buffer's content is already processed. So we simply
// shift the yet unprocessed data to the very left of the buffer.
- else if (_read_pointer > _readahead_buffer) {
- int shift_by = _read_pointer - _readahead_buffer; // distance to beginning of buffer
+ else if (_read_pointer > 0) {
+ int shift_by = _read_pointer; // distance to beginning of buffer
int size = _write_pointer - _read_pointer; // amount of data to shift
- memmove(_readahead_buffer, _read_pointer, size);
- _read_pointer = _readahead_buffer; // unread data is now at the beginning
+ memmove(&_readahead_buffer[0], &_readahead_buffer[_read_pointer], size);
+ _read_pointer = 0; // unread data is now at the beginning
_write_pointer -= shift_by; // write pointer shifted to the left
r -= shift_by; // current scan position also shift left
// continue -> still no data in buffer, but it will
@@ -186,12 +186,11 @@ pair<list<string>, InputBuffer::Result> InputBuffer::readRequest()
return make_pair(request_lines, Result::request_read);
}
else { // non-empty line: belongs to current request
- // storeRequestLine(_read_pointer, r - _read_pointer);
int length = r - _read_pointer;
- for (char *end = r; end > _read_pointer && isspace(*--end);)
+ for (size_t end = r; end > _read_pointer && isspace(_readahead_buffer[--end]);)
length--;
if (length > 0)
- request_lines.push_back(string(_read_pointer, length));
+ request_lines.push_back(string(&_readahead_buffer[_read_pointer], length));
else
logger(LG_INFO, "Warning ignoring line containing only whitespace");
query_started = true;
@@ -225,7 +224,7 @@ InputBuffer::Result InputBuffer::readData()
int retval = select(_fd + 1, &fds, NULL, NULL, &tv);
if (retval > 0 && FD_ISSET(_fd, &fds)) {
- ssize_t r = read(_fd, _write_pointer, _end_pointer - _write_pointer);
+ ssize_t r = read(_fd, &_readahead_buffer[_write_pointer], _end_pointer - _write_pointer);
if (r < 0) {
return Result::eof;
}
diff --git a/livestatus/src/InputBuffer.h b/livestatus/src/InputBuffer.h
index 2e7626f..5457e2b 100644
--- a/livestatus/src/InputBuffer.h
+++ b/livestatus/src/InputBuffer.h
@@ -53,9 +53,9 @@ private:
int _fd;
int *_termination_flag;
char _readahead_buffer[buffer_size];
- char *_read_pointer;
- char *_write_pointer;
- char *_end_pointer;
+ size_t _read_pointer;
+ size_t _write_pointer;
+ size_t _end_pointer;
Result readData();
};
Module: check_mk
Branch: master
Commit: 5c62b03a28fadb41c01858e2754b715d68bc0e70
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c62b03a28fadb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jan 21 14:38:03 2016 +0100
#2944 FIX Fixed exception during config activation having clusters with unresolvable node IP addresses
---
.werks/2944 | 9 +++++++++
ChangeLog | 1 +
modules/check_mk.py | 24 +++++++++++++++++++-----
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/.werks/2944 b/.werks/2944
new file mode 100644
index 0000000..af4723d
--- /dev/null
+++ b/.werks/2944
@@ -0,0 +1,9 @@
+Title: Fixed exception during config activation having clusters with unresolvable node IP addresses
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453383432
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 6dd77ed..7b675ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
* 2848 FIX: Fixed cleanup of old autocheck files of cluster hosts...
* 2894 FIX: Fixed broken cluster checks when using Nagios core...
* 2926 FIX: Fix exception in WATO when a check man page has not catalog entry
+ * 2944 FIX: Fixed exception during config activation having clusters with unresolvable node IP addresses
Checks & Agents:
* 2434 NetApp monitoring: Cluster-Mode is now supported, changes in existing 7Mode checks...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index e453a55..5a1d584 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2020,7 +2020,11 @@ def lookup_ipv4_address(hostname):
def lookup_ipv6_address(hostname):
return lookup_ip_address(hostname, 6)
-# Determine the IP address of a host
+# Determine the IP address of a host. It returns either an IP address,
+# or raise an exception when a hostname can not be resolved on the first
+# try to resolve a hostname. On later tries to resolve a hostname it
+# returns None instead of raising an exception.
+# FIXME: This different handling is bad. Clean this up!
def lookup_ip_address(hostname, family=None):
if family == None: # choose primary family
family = is_ipv6_primary(hostname) and 6 or 4
@@ -3280,11 +3284,21 @@ def get_cluster_attributes(hostname, nodes):
attrs = {}
node_ips_4 = []
if is_ipv4_host(hostname):
- node_ips_4 = [ ip_address_of(h, 4) for h in nodes ]
+ for h in nodes:
+ addr = ip_address_of(h, 4)
+ if addr != None:
+ node_ips_4.append(addr)
+ else:
+ node_ips_4.append(fallback_ip_for(hostname, 4))
node_ips_6 = []
if is_ipv6_host(hostname):
- node_ips_6 = [ ip_address_of(h, 6) for h in nodes ]
+ for h in nodes:
+ addr = ip_address_of(h, 6)
+ if addr != None:
+ node_ips_6.append(addr)
+ else:
+ node_ips_6.append(fallback_ip_for(hostname, 6))
if is_ipv6_primary(hostname):
node_ips = node_ips_6
@@ -3307,8 +3321,8 @@ def ip_address_of(hostname, family=None):
g_failed_ip_lookups.append(hostname)
addr = fallback_ip_for(hostname, family)
if not ignore_ip_lookup_failures:
- configuration_warning("Cannot lookup IP address of '%s': %s, using "
- "address %s instead" % (hostname, e, addr))
+ configuration_warning("Cannot lookup IP address of '%s' (%s). Using "
+ "address %s instead." % (hostname, e, addr))
return addr
Module: check_mk
Branch: master
Commit: 6120b59d90353139320c091c13a8a5da53f1a176
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6120b59d903531…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Jan 21 14:15:37 2016 +0100
#1323 win_printers: Warning and Critical levels can now be set
The change can be found in commit #67c90d81ee34114db1b12d2e0867bbd146a90716
---
.werks/1323 | 10 ++++++++++
ChangeLog | 1 +
2 files changed, 11 insertions(+)
diff --git a/.werks/1323 b/.werks/1323
new file mode 100644
index 0000000..9aa0051
--- /dev/null
+++ b/.werks/1323
@@ -0,0 +1,10 @@
+Title: win_printers: Warning and Critical levels can now be set
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453382032
+Class: feature
+
+The change can be found in commit #67c90d81ee34114db1b12d2e0867bbd146a90716
+
diff --git a/ChangeLog b/ChangeLog
index de09450..1e1852d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -83,6 +83,7 @@
* 2919 hp_webmgmt_status: New check for health status of various Hewlett-Packard devices...
* 2920 hr_cpu: this check can now also supports per-core features...
* 1322 solaris_prtdiag: New Check for Solaris Hardware State based on prtdiag
+ * 1323 win_printers: Warning and Critical levels can now be set...
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...