newdevice: APC in-row coolers

This commit is contained in:
Neil Lathwood
2017-01-07 00:09:41 +00:00
committed by Søren Rosiak
parent 0db5a7caa4
commit 5e349685b3
16 changed files with 388 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

View File

@@ -0,0 +1,44 @@
<?php
/**
* airflow.inc.php
*
* LibreNMS airflow graph for WebUI
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
$scale_min = '0';
$scale_max = '10';
require 'includes/graphs/common.inc.php';
$rrd_options .= " COMMENT:' Min Max Last\\n'";
$rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE";
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 21)."'";
$rrd_options .= ' GPRINT:sensor:MIN:%4.1lf';
$rrd_options .= ' GPRINT:sensor:MAX:%4.1lf';
$rrd_options .= ' GPRINT:sensor:LAST:%4.1lf\l';
if (is_numeric($sensor['sensor_limit'])) {
$rrd_options .= ' HRULE:'.$sensor['sensor_limit'].'#999999::dashes';
}
if (is_numeric($sensor['sensor_limit_low'])) {
$rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes';
}

View File

@@ -18,6 +18,7 @@ $dBm = dbFetchCell("select count(*) from sensors WHERE sensor_class='dB
$states = dbFetchCell("select count(*) from sensors WHERE sensor_class='state' AND device_id = ?", array($device['device_id']));
$load = dbFetchCell("select count(*) from sensors WHERE sensor_class='load' AND device_id = ?", array($device['device_id']));
$signal = dbFetchCell("select count(*) from sensors WHERE sensor_class='signal' AND device_id = ?", array($device['device_id']));
$airflow = dbFetchCell("select count(*) from sensors WHERE sensor_class='airflow' AND device_id = ?", array($device['device_id']));
unset($datas);
$datas[] = 'overview';
@@ -89,6 +90,10 @@ if ($signal) {
$datas[] = 'signal';
}
if ($airflow) {
$datas[] = 'airflow';
}
$type_text['overview'] = 'Overview';
$type_text['charge'] = 'Battery Charge';
$type_text['temperature'] = 'Temperature';
@@ -107,6 +112,7 @@ $type_text['dbm'] = 'dBm';
$type_text['state'] = 'State';
$type_text['load'] = 'Load';
$type_text['signal'] = 'Signal';
$type_text['airflow'] = 'Airflow';
$link_array = array(
'page' => 'device',

View File

@@ -0,0 +1,30 @@
<?php
/**
* airflow.inc.php
*
* LibreNMS airflow health page for WebUI
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
$class = 'airflow';
$unit = 'CFM';
$graph_type = 'sensor_airflow';
require 'sensors.inc.php';

View File

@@ -68,6 +68,7 @@ require 'overview/sensors/frequencies.inc.php';
require 'overview/sensors/load.inc.php';
require 'overview/sensors/state.inc.php';
require 'overview/sensors/signal.inc.php';
require 'overview/sensors/airflow.inc.php';
require 'overview/eventlog.inc.php';
require 'overview/services.inc.php';
require 'overview/syslog.inc.php';

View File

@@ -0,0 +1,31 @@
<?php
/**
* airflow.inc.php
*
* LibreNMS airflow overview for WebUI
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
$graph_type = 'sensor_airflow';
$sensor_class = 'airflow';
$sensor_unit = 'cfm';
$sensor_type = 'Airflow';
require 'pages/device/overview/generic/sensor.inc.php';

View File

@@ -30,3 +30,4 @@ require 'includes/discovery/sensors/load.inc.php';
require 'includes/discovery/sensors/states.inc.php';
require 'includes/discovery/sensors/dbm.inc.php';
require 'includes/discovery/sensors/signal.inc.php';
require 'includes/discovery/sensors/airflow.inc.php';

View File

@@ -0,0 +1,36 @@
<?php
/**
* airflow.inc.php
*
* LibreNMS airflow module for discovery
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
echo 'Airflow: ';
// Include all discovery modules
$include_dir = 'includes/discovery/sensors/airflow';
require 'includes/include-dir.inc.php';
d_echo($valid['sensor']['airflow']);
check_valid_sensors($device, 'airflow', $valid['sensor']);
echo "\n";

View File

@@ -0,0 +1,34 @@
<?php
/**
* apc.inc.php
*
* LibreNMS os sensor airflow module for APC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
foreach ($cooling_unit_analog as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index;
$descr = $data['coolingUnitStatusAnalogDescription'];
$scale = $data['coolingUnitStatusAnalogScale'];
$value = $data['coolingUnitStatusAnalogValue'];
if (preg_match('/Airflow/', $descr) && $data['coolingUnitStatusAnalogUnits'] == 'CFM' && $value >= 0) {
discover_sensor($valid['sensor'], 'airflow', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* apc.inc.php
*
* LibreNMS os sensor fanspeeds module for APC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
foreach ($cooling_unit_analog as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index;
$descr = $data['coolingUnitStatusAnalogDescription'];
$scale = $data['coolingUnitStatusAnalogScale'];
$value = $data['coolingUnitStatusAnalogValue'];
if (preg_match('/Fan Speed/', $descr) && $data['coolingUnitStatusAnalogUnits'] == '%' && $value >= 0) {
discover_sensor($valid['sensor'], 'fanspeed', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* apc.inc.php
*
* LibreNMS os sensor power module for APC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
foreach ($cooling_unit_analog as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index;
$descr = $data['coolingUnitStatusAnalogDescription'];
$scale = $data['coolingUnitStatusAnalogScale'];
$value = $data['coolingUnitStatusAnalogValue'];
if (preg_match('/Cool/', $descr) && $data['coolingUnitStatusAnalogUnits'] == 'kW' && $value >= 0) {
discover_sensor($valid['sensor'], 'power', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value);
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* apc.inc.php
*
* LibreNMS os sensor pre-cache module for APC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
$cooling_unit_analog = snmpwalk_cache_oid($device, 'coolingUnitStatusAnalogEntry', array(), 'PowerNet-MIB');

View File

@@ -45,4 +45,66 @@ if ($device['os'] == 'apc') {
//Create Sensor To State Index
create_sensor_to_state_index($device, $state_name, $index);
}
$cooling_status = snmpwalk_cache_oid($device, 'coolingUnitStatusDiscreteEntry', array(), 'PowerNet-MIB');
foreach ($cooling_status as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.2.2.1.4.' . $index;
$state_name = $data['coolingUnitStatusDiscreteDescription'];
$state_index_id = create_state_index($state_name);
if ($state_index_id !== null) {
$tmp_states = explode(',', $data['coolingUnitStatusDiscreteIntegerReferenceKey']);
$states = array();
foreach ($tmp_states as $k => $ref) {
preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches);
$nagios_state = get_nagios_state($matches[1]);
$states[] = array($state_index_id, $matches[1], 0, $matches[2], $nagios_state);
}
foreach ($states as $value) {
$insert = array(
'state_index_id' => $value[0],
'state_descr' => $value[1],
'state_draw_graph' => $value[2],
'state_value' => $value[3],
'state_generic_value' => $value[4]
);
dbInsert($insert, 'state_translations');
}
}
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, '1', '1', null, null, null, null, $data['coolingUnitStatusDiscreteValueAsInteger']);
create_sensor_to_state_index($device, $state_name, $index);
}
unset($cooling_status);
$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedDiscreteEntry', array(), 'PowerNet-MIB');
foreach ($cooling_unit as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.6.2.2.1.4.' . $index;
$state_name = $data['coolingUnitExtendedDiscreteDescription'];
$state_index_id = create_state_index($state_name);
if ($state_index_id !== null) {
$tmp_states = explode(',', $data['coolingUnitExtendedDiscreteIntegerReferenceKey']);
$states = array();
foreach ($tmp_states as $k => $ref) {
preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches);
$nagios_state = get_nagios_state($matches[1]);
$states[] = array($state_index_id, $matches[1], 0, $matches[2], $nagios_state);
}
foreach ($states as $value) {
$insert = array(
'state_index_id' => $value[0],
'state_descr' => $value[1],
'state_draw_graph' => $value[2],
'state_value' => $value[3],
'state_generic_value' => $value[4]
);
dbInsert($insert, 'state_translations');
}
}
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, '1', '1', null, null, null, null, $data['coolingUnitExtendedDiscreteValueAsInteger']);
create_sensor_to_state_index($device, $state_name, $index);
}
unset($cooling_unit);
}

View File

@@ -137,4 +137,25 @@ if ($device['os'] == 'apc') {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, $precision, '1', null, null, null, null, $current);
}
$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedAnalogEntry', array(), 'PowerNet-MIB');
foreach ($cooling_unit as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.6.1.2.1.3.' . $index;
$descr = $data['coolingUnitExtendedAnalogDescription'];
$scale = $data['coolingUnitExtendedAnalogScale'];
$value = $data['coolingUnitExtendedAnalogValue'];
if (preg_match('/Temperature/', $descr) && $data['coolingUnitExtendedAnalogUnits'] == 'C' && $value >= 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value);
}
}
foreach ($cooling_unit_analog as $index => $data) {
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index;
$descr = $data['coolingUnitStatusAnalogDescription'];
$scale = $data['coolingUnitStatusAnalogScale'];
$value = $data['coolingUnitStatusAnalogValue'];
if (preg_match('/Temperature/', $descr) && $data['coolingUnitStatusAnalogUnits'] == 'C' && $value >= 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value);
}
}
}//end if

View File

@@ -1,5 +1,4 @@
<?php
/*
* LibreNMS Network Management and Monitoring System
* Copyright (C) 2006-2011, Observium Developers - http://www.observium.org
@@ -27,6 +26,7 @@ $supported_sensors = array(
'load' => '%',
'state' => '#',
'signal' => 'dBm',
'airflow' => 'cfm',
);
foreach ($supported_sensors as $sensor_type => $sensor_unit) {

View File

@@ -1419,3 +1419,30 @@ function rewrite_ceraos_hardware($ceragon_type, $device)
}
return $hardware;
};
/**
* @param $descr
* @return int
*/
function get_nagios_state($descr)
{
switch ($descr) {
case 'On':
case 'Okay':
case 'Ok':
return 0;
break;
case 'Standby':
case 'Idle':
case 'Maintenance':
return 1;
break;
case 'Under':
case 'Over':
return 2;
break;
default:
return 3;
break;
}
}