Index: html/includes/graphs/application/dhcpkit_msgtypes.inc.php
===================================================================
--- html/includes/graphs/application/dhcpkit_msgtypes.inc.php (revision 0)
+++ html/includes/graphs/application/dhcpkit_msgtypes.inc.php (working copy)
@@ -0,0 +1,53 @@
+
+ * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$colours = "mixed";
+$nototal = (($width<224) ? 1 : 0);
+$unit_text = "Count";
+$rrd_filename = str_replace('%index%', $app['app_id'], $config['rrd_types']['dhcpkit-stats']['file']);
+$rrd_filename = get_rrd_path($device, $rrd_filename);
+$simple_rrd = TRUE;
+
+$array = array(
+ 'msg_in_solicit' => array('descr' => 'Solicit', 'invert' => FALSE),
+ 'msg_in_request' => array('descr' => 'Request', 'invert' => FALSE),
+ 'msg_in_confirm' => array('descr' => 'Confirm', 'invert' => FALSE),
+ 'msg_in_renew' => array('descr' => 'Renew', 'invert' => FALSE),
+ 'msg_in_rebind' => array('descr' => 'Rebind', 'invert' => FALSE),
+ 'msg_in_release' => array('descr' => 'Release', 'invert' => FALSE),
+ 'msg_in_decline' => array('descr' => 'Decline', 'invert' => FALSE),
+ 'msg_in_inf_req' => array('descr' => 'Inform. Request', 'invert' => FALSE),
+ 'msg_out_advertise' => array('descr' => 'Advertise', 'invert' => TRUE),
+ 'msg_out_reply' => array('descr' => 'Reply', 'invert' => TRUE),
+ 'msg_out_reconfigure' => array('descr' => 'Reconfigure', 'invert' => TRUE),
+);
+$i = 0;
+
+if (is_file($rrd_filename))
+{
+ foreach ($array as $ds => $data)
+ {
+ $rrd_list[$i]['filename'] = $rrd_filename;
+ $rrd_list[$i]['descr'] = $data['descr'];
+ $rrd_list[$i]['ds'] = $ds;
+ $rrd_list[$i]['invert'] = $data['invert'];
+ $i++;
+ }
+} else {
+ echo("file missing: $file");
+}
+
+include($config['html_dir']."/includes/graphs/generic_multi.inc.php");
+
+/* End of file dhcpkit_msgtypes.inc.php */
Index: html/includes/graphs/application/dhcpkit_packets.inc.php
===================================================================
--- html/includes/graphs/application/dhcpkit_packets.inc.php (revision 0)
+++ html/includes/graphs/application/dhcpkit_packets.inc.php (working copy)
@@ -0,0 +1,49 @@
+
+ * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$colours = "mixed";
+$nototal = (($width<224) ? 1 : 0);
+$unit_text = "Count";
+$rrd_filename = str_replace('%index%', $app['app_id'], $config['rrd_types']['dhcpkit-stats']['file']);
+$rrd_filename = get_rrd_path($device, $rrd_filename);
+$simple_rrd = TRUE;
+
+$array = array(
+ 'incoming_packets' => array('descr' => 'Incoming', 'invert' => FALSE),
+ 'outgoing_packets' => array('descr' => 'Outgoing', 'invert' => TRUE),
+ 'unparsable_packets' => array('descr' => 'Unparsable', 'invert' => TRUE),
+ 'handling_errors' => array('descr' => 'Handling error', 'invert' => TRUE),
+ 'for_other_server' => array('descr' => 'For other server', 'invert' => TRUE),
+ 'do_not_respond' => array('descr' => 'Ignored', 'invert' => TRUE),
+ 'use_multicast' => array('descr' => 'Use multicast', 'invert' => TRUE),
+);
+$i = 0;
+
+if (is_file($rrd_filename))
+{
+ foreach ($array as $ds => $data)
+ {
+ $rrd_list[$i]['filename'] = $rrd_filename;
+ $rrd_list[$i]['descr'] = $data['descr'];
+ $rrd_list[$i]['ds'] = $ds;
+ $rrd_list[$i]['invert'] = $data['invert'];
+ $i++;
+ }
+} else {
+ echo("file missing: $file");
+}
+
+include($config['html_dir']."/includes/graphs/generic_multi.inc.php");
+
+/* End of file dhcpkit_packets.inc.php */
Index: html/pages/device/apps/dhcpkit.inc.php
===================================================================
--- html/pages/device/apps/dhcpkit.inc.php (revision 0)
+++ html/pages/device/apps/dhcpkit.inc.php (working copy)
@@ -0,0 +1,18 @@
+
+ * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+$app_graphs['default'] = array(
+ 'dhcpkit_packets' => "Packets",
+ 'dhcpkit_msgtypes' => "Message types",
+);
+
+/* End of file dhcpkit.inc.php */
Index: includes/definitions/apps.inc.php
===================================================================
--- includes/definitions/apps.inc.php (revision 8013)
+++ includes/definitions/apps.inc.php (working copy)
@@ -25,6 +25,7 @@
$config['app']['mysql']['top'] = array('network_traffic', 'connections', 'command_counters', 'select_types');
$config['app']['postgresql']['top'] = array('xact', 'blks', 'tuples', 'tuples_query');
$config['app']['memcached']['top'] = array('bits', 'commands', 'data', 'items');
+$config['app']['dhcpkit']['top'] = array('packets', 'msgtypes');
$config['app']['drbd']['top'] = array('disk_bits', 'network_bits', 'queue', 'unsynced');
$config['app']['ntpd']['top'] = array('stats', 'freq', 'stratum', 'bits');
$config['app']['nfs']['top'] = array('nfs2','nfs3', 'nfs4');
Index: includes/definitions/rrdtypes.inc.php
===================================================================
--- includes/definitions/rrdtypes.inc.php (revision 8013)
+++ includes/definitions/rrdtypes.inc.php (working copy)
@@ -662,6 +662,32 @@
),
);
+// DHCPKit
+
+$config['rrd_types']['dhcpkit-stats'] = array(
+ 'file' => 'app-dhcpkit-%index%-stats.rrd',
+ 'ds' => array(
+ 'incoming_packets' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'outgoing_packets' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'unparsable_packets' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'handling_errors' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'for_other_server' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'do_not_respond' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'use_multicast' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_solicit' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_request' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_confirm' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_renew' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_rebind' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_release' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_decline' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_in_inf_req' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_out_advertise' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_out_reply' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ 'msg_out_reconfigure' => array('type' => 'DERIVE', 'min' => 0, 'max' => 7500000),
+ ),
+);
+
// Exchange
$config['rrd_types']['exchange-as'] = array(
Index: includes/polling/applications/dhcpkit.inc.php
===================================================================
--- includes/polling/applications/dhcpkit.inc.php (revision 0)
+++ includes/polling/applications/dhcpkit.inc.php (working copy)
@@ -0,0 +1,37 @@
+
+ * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+foreach ($agent_data['app']['dhcpkit'] as $collection => $collection_data)
+{
+ $lines = explode("\n", $agent_data['app']['dhcpkit'][$collection]);
+ $data = array();
+
+ foreach ($lines as $line)
+ {
+ // Line format is "key:value"
+ list ($key, $value) = explode(':', $line, 2);
+
+ // Adjust naming
+ $key = preg_replace('/\\.information_request$/', '.inf_req', $key);
+ $key = preg_replace('/^messages_(in|out)\\./', 'msg_$1_', $key);
+
+ $data[$key] = intval($value);
+ }
+
+ $app_id = discover_app($device, 'dhcpkit', $collection);
+ rrdtool_update_ng($device, 'dhcpkit-stats', $data, $app_id);
+
+ unset($lines);
+ unset($data);
+}
+
+/* End of file dhcpkit.inc.php */
Index: scripts/agent-local/dhcpkit
===================================================================
--- scripts/agent-local/dhcpkit (revision 0)
+++ scripts/agent-local/dhcpkit (working copy)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+import json
+from collections import OrderedDict
+
+from dhcpkit.ipv6.server.dhcpctl import DHCPKitControlClient
+from typing import Any, Dict
+
+# Change this if you change the default
+socket_path = '/var/run/ipv6-dhcpd.sock'
+
+
+# Output a section
+def print_section(data: Dict[str, Any], prefix: str = ''):
+ """
+ Output the data in Observium app format
+
+ :param data: A dictionary with data
+ :param prefix: The current prefix up to this point
+ """
+ # First see if this item has its own data
+ own_data = False
+ if prefix:
+ # We don't support own data in the root, so only check when there is a prefix
+ for value in data.values():
+ if not isinstance(value, dict):
+ own_data = True
+ break
+
+ if own_data:
+ # Print this item
+ print("<<>>".format(prefix))
+ for key, value in data.items():
+ print_values(key, value)
+
+ else:
+ # Print sub-items
+ for key, value in data.items():
+ if isinstance(value, dict):
+ print_section(value, prefix="{}-{}".format(prefix, key).strip('-'))
+
+
+# Output key/value pairs
+def print_values(key: str, value: Any):
+ """
+ Output key/value pairs
+
+ :param key: The key
+ :param value: The value(s)
+ """
+ if isinstance(value, dict):
+ # The value is a dictionary, recurse
+ for sub_key, sub_value in value.items():
+ print_values("{}.{}".format(key, sub_key), sub_value)
+ else:
+ print("{}:{}".format(key, value))
+
+
+# Open connection
+conn = DHCPKitControlClient(socket_path)
+output = conn.execute_command('stats-json')
+
+# Decode json
+json_data = '\n'.join(output)
+data = json.loads(json_data, object_pairs_hook=OrderedDict)
+
+# Done: disconnect (and process output to empty the buffers)
+output = conn.execute_command('quit')
+list(output)
+
+# Show the stats
+print_section(data)
Property changes on: scripts/agent-local/dhcpkit
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property