diff --git a/data-pick.php b/data-pick.php
index b995691d..55d27180 100755
--- a/data-pick.php
+++ b/data-pick.php
@@ -7,105 +7,105 @@
$weathermap_config = array (
- 'show_interfaces' => 'all',
- 'sort_if_by' => 'ifAlias',
+ 'show_interfaces' => 'all',
+ 'sort_if_by' => 'ifAlias',
);
$valid_sort_if_by = array (
- 'ifAlias',
- 'ifDescr',
- 'ifIndex',
- 'ifName',
+ 'ifAlias',
+ 'ifDescr',
+ 'ifIndex',
+ 'ifName',
);
$valid_show_interfaces = array (
- 'all' => -1,
- 'any' => -1,
- '-1' => -1,
- #
- 'none' => 0,
- '0' => 0,
+ 'all' => -1,
+ 'any' => -1,
+ '-1' => -1,
+ #
+ 'none' => 0,
+ '0' => 0,
);
- /*
- * Include the LibreNMS config, so we know about the database.
- *
- * Include config first to get install dir, then load defaults and config
- * again to get full set of config values.
- */
- /* Load Weathermap config defaults, see file for description. */
+ /*
+ * Include the LibreNMS config, so we know about the database.
+ *
+ * Include config first to get install dir, then load defaults and config
+ * again to get full set of config values.
+ */
+ /* Load Weathermap config defaults, see file for description. */
$init_modules = ['web', 'auth'];
require $librenms_base . '/includes/init.php';
- if (!Auth::check()) {
- header('Location: /');
- exit;
- }
+ if (!Auth::check()) {
+ header('Location: /');
+ exit;
+ }
- chdir($librenms_base . '/plugins/Weathermap');
- $librenms_found = true;
+ chdir($librenms_base . '/plugins/Weathermap');
+ $librenms_found = true;
- /* Validate configuration, see defaults.inc.php for explaination */
- if (in_array ($config['plugins']['Weathermap']['sort_if_by'], $valid_sort_if_by))
- $weathermap_config['sort_if_by'] = $config['plugins']['Weathermap']['sort_if_by'];
+ /* Validate configuration, see defaults.inc.php for explaination */
+ if (in_array ($config['plugins']['Weathermap']['sort_if_by'], $valid_sort_if_by))
+ $weathermap_config['sort_if_by'] = $config['plugins']['Weathermap']['sort_if_by'];
- if (in_array ($config['plugins']['Weathermap']['show_interfaces'], $valid_show_interfaces))
- $weathermap_config['show_interfaces'] = $valid_show_interfaces[$config['plugins']['Weathermap']['show_interfaces']];
- elseif (validate_device_id ($config['plugins']['Weathermap']['show_interfaces']))
- $weathermap_config['show_interfaces'] = $config['plugins']['Weathermap']['show_interfaces'];
+ if (in_array ($config['plugins']['Weathermap']['show_interfaces'], $valid_show_interfaces))
+ $weathermap_config['show_interfaces'] = $valid_show_interfaces[$config['plugins']['Weathermap']['show_interfaces']];
+ elseif (validate_device_id ($config['plugins']['Weathermap']['show_interfaces']))
+ $weathermap_config['show_interfaces'] = $config['plugins']['Weathermap']['show_interfaces'];
// ******************************************
function js_escape($str)
{
- $str = str_replace('\\', '\\\\', $str);
- $str = str_replace("'", "\\\'", $str);
+ $str = str_replace('\\', '\\\\', $str);
+ $str = str_replace("'", "\\\'", $str);
- $str = "'".$str."'";
+ $str = "'".$str."'";
- return($str);
+ return($str);
}
if(isset($_REQUEST['command']) && $_REQUEST["command"]=='link_step2')
{
- $dataid = intval($_REQUEST['dataid']);
+ $dataid = intval($_REQUEST['dataid']);
?>
-
+
This window should disappear in a moment.
-
-
+
+
+
Pick a data source
value('device_id');
- if ($node1_id)
- $host_id = $node1_id;
- }
-
- // Link query
- $hosts = \App\Models\Device::orderBy('hostname')->get(['device_id', 'hostname']);
+ $host_id = $weathermap_config['show_interfaces'];
+
+ $overlib = true;
+ $aggregate = false;
+
+ if(isset($_REQUEST['aggregate'])) $aggregate = ( $_REQUEST['aggregate']==0 ? false : true);
+ if(isset($_REQUEST['overlib'])) $overlib= ( $_REQUEST['overlib']==0 ? false : true);
+
+ /* Explicit device_id given? */
+ if (isset ($_REQUEST['host_id']) and !empty ($_REQUEST['host_id']))
+ {
+ $host_id = intval ($_REQUEST['host_id']);
+ }
+
+ /* If the editor gave us the links source node name, try to find the device_id
+ * so we can present the user with the interfaces of this particular device. */
+ if (isset ($_REQUEST['node1']) and !empty ($_REQUEST['node1']))
+ {
+ $node1 = strtolower ($_REQUEST['node1']);
+ $node1_id = \App\Models\Device::where('hostname', 'like', "%$node1%")->value('device_id');
+ if ($node1_id)
+ $host_id = $node1_id;
+ }
+
+ // Link query
+ $hosts = \App\Models\Device::orderBy('hostname')->get(['device_id', 'hostname', 'sysname']);
?>
Pick a data source:
';
+ print '';
- /*
- * Query interfaces (if we should)...
- */
- $result = Null;
- if ($host_id != 0) {
- $devices = \App\Models\Device::when($host_id > 0, function ($query) use ($host_id) {
- $query->where('device_id', $host_id);
+ /*
+ * Query interfaces (if we should)...
+ */
+ $result = Null;
+ if ($host_id != 0) {
+ $devices = \App\Models\Device::when($host_id > 0, function ($query) use ($host_id) {
+ $query->where('device_id', $host_id);
})
->with(['ports' => function ($query) use ($weathermap_config) {
$query->orderBy($weathermap_config['sort_if_by']);
}])
->orderBy('hostname')
->get();
- }
+ }
- $i=0;
+ $i=0;
if ($devices->isNotEmpty()) {
foreach ($devices as $device) {
if (!is_null($device->ports)) {
foreach ($device->ports as $port) {
echo "- ";
- $key = $device->device_id . "','" . $device->hostname . "','" . $port->port_id . "','" . addslashes($port->ifAlias) . "','" . addslashes($port->ifDescr) . "','" . (int)$port->ifIndex;
+ $key = $device->device_id . "','" . $device->hostname . "','" . $port->port_id . "','" . addslashes($port->ifAlias) . "','" . addslashes($port->ifDescr) . "','" . (int)$port->ifIndex . "','" . $port->ifSpeed;
- echo "" . $device->displayName() . "/$port->ifDescr Desc: $port->ifAlias";
+ echo "" . $device->displayName() . "
".strtoupper($port->ifDescr)."
Desc: ".strtoupper($port->ifAlias)."
Speed: $port->ifSpeed";
echo " \n";
}
$i++;
@@ -341,8 +342,8 @@ function applyDSFilterChange(objForm) {
}
} else {
- print "- No results...
";
- }
+ print "- No results...
";
+ }
?>
@@ -354,22 +355,22 @@ function applyDSFilterChange(objForm) {
if(isset($_REQUEST['command']) && $_REQUEST["command"]=='node_step1')
{
- $host_id = -1;
-
-
- $overlib = true;
- $aggregate = false;
-
- if(isset($_REQUEST['aggregate'])) $aggregate = ( $_REQUEST['aggregate']==0 ? false : true);
- if(isset($_REQUEST['overlib'])) $overlib= ( $_REQUEST['overlib']==0 ? false : true);
-
-
- if(isset($_REQUEST['host_id']))
- {
- $host_id = intval($_REQUEST['host_id']);
- }
-
- $hosts = \App\Models\Device::orderBy('hostname')->get(['device_id AS id', 'hostname AS name']);
+ $host_id = -1;
+
+
+ $overlib = true;
+ $aggregate = false;
+
+ if(isset($_REQUEST['aggregate'])) $aggregate = ( $_REQUEST['aggregate']==0 ? false : true);
+ if(isset($_REQUEST['overlib'])) $overlib= ( $_REQUEST['overlib']==0 ? false : true);
+
+
+ if(isset($_REQUEST['host_id']))
+ {
+ $host_id = intval($_REQUEST['host_id']);
+ }
+
+ $hosts = \App\Models\Device::orderBy('hostname')->get(['device_id AS id', 'hostname AS name', 'sysname AS sysname']);
?>
@@ -377,89 +378,90 @@ function applyDSFilterChange(objForm) {
-
+
+
+
Pick a graph
@@ -468,42 +470,43 @@ function update_source_step1(graphid,name)
Pick a graph: