Permalink
Browse files

Livestatus backend: You can now disable KeepAlive header

You can now set the "keepalive" backend option to 0 to disable
sending the keepalive livestatus header
  • Loading branch information...
LarsMichelsen committed Nov 9, 2017
1 parent 565cf97 commit ea6542a34d2998a0daaa198e285874f08e6a0292
View
@@ -1,4 +1,6 @@
1.9.5
* Livestatus backend: You can now set the "keepalive" backend option to 0 to
disable sending the keepalive livestatus header
1.9.4
Core:
@@ -27,7 +27,8 @@ <h1>MKLivestatus backend</h1>
<td>socket</td>
<td>unix:/usr/local/nagios/var/rw/live</td>
<td><p>The socket to connect to can be a local unix socket or a tcp socket. You have to define the type at the beginning of the string. Set &quot;unix:&quot; for unix sockets or &quot;tcp:&quot; for tcp sockets.</p> <p>In case of the unix socket you need to specify the path of the livestatus unix socket to connect to.</p> <p>When using a tcp socket you have to enter a host address and a tcp port using the following scheme: &lt;host>:&lt;port>. The host address can be an IP address or an FQDN.</p></td>
</tr><tr>
</tr>
<tr>
<td>timeout</td>
<td>5</td>
<td>
@@ -36,6 +37,15 @@ <h1>MKLivestatus backend</h1>
For details take a look at the general backend parameters documented in the <a href="nagvis_config_format_description.html#backend">backend section</a>
of the main configuration format description.</a></td>
</tr>
<tr>
<td>keepalive</td>
<td>1</td>
<td>
<font color="#f00">New in 1.9.5</font>: In case you need to connect to a livestatus source which does not
support the <tt>KeepAlive</tt> header (like LMD), or you simply don't want to use keepalive mode, you can
set this option to 0.
</td>
</tr>
</table>
<p>There are also some general parameters. You can read about them in <a href="nagvis_config_format_description.html#backend">main configuration format description</a>.</p>
</body>
@@ -399,6 +399,12 @@ backendtype="mklivestatus"
; "<backend_id>:<hostname>" -> e.g. "live_2:nagios"
;statushost=""
;socket="unix:/usr/local/nagios/var/rw/live"
; You can use this option to customize the TCP connect timeout
;timeout=5
; In case you need to connect to a livestatus source which does not support the
; KeepAlive header, or you simply don't want to use keepalive mode, you can
; set this option to 0
;keepalive=1
; Example definition for a MySQL backend
; in this example the ID of the Backend is "ndomy_1" you can define another ID.
@@ -58,6 +58,13 @@ class GlobalBackendmklivestatus implements GlobalBackendInterface {
'default' => 5,
'match' => MATCH_INTEGER,
),
'keepalive' => Array(
'must' => 0,
'editable' => 1,
'default' => 1,
'field_type' => 'boolean',
'match' => MATCH_BOOLEAN
),
);
/**
@@ -241,8 +248,13 @@ private function queryLivestatus($query, $response = true) {
// Query to get a json formated array back
// Use KeepAlive with fixed16 header
if($response)
$query .= "OutputFormat: json\nKeepAlive: on\nResponseHeader: fixed16\n\n";
if($response) {
$query .= "OutputFormat: json\n";
if ((bool)cfg('backend_'.$this->backendId, 'keepalive'))
$query .= "KeepAlive: on\n";
$query .= "ResponseHeader: fixed16\n\n";
}
// Disable regular error reporting to suppress php error messages
$oldLevel = error_reporting(0);
$write = fwrite($this->SOCKET, $query);

0 comments on commit ea6542a

Please sign in to comment.