mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
rewrite ups-apcups
This commit is contained in:
@@ -22,6 +22,7 @@ Different applications support a variety of ways collect data: by direct connect
|
|||||||
1. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent
|
1. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent
|
||||||
1. [Unbound](#unbound) - Agent
|
1. [Unbound](#unbound) - Agent
|
||||||
1. [UPS-nut](#ups-nut) - SNMP extend
|
1. [UPS-nut](#ups-nut) - SNMP extend
|
||||||
|
1. [UPS-apcups](#ups-apcups) - SNMP extend
|
||||||
1. [Agent Setup](#agent-setup)
|
1. [Agent Setup](#agent-setup)
|
||||||
|
|
||||||
|
|
||||||
@@ -323,6 +324,21 @@ extend ups-nut /etc/snmp/ups-nut.sh
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### UPS-apcups
|
||||||
|
A small shell script that exports apcacess ups status.
|
||||||
|
|
||||||
|
##### SNMP Extend
|
||||||
|
1. Copy the [ups apcups](https://github.com/librenms/librenms-agent/blob/master/snmp/ups-apcups.sh) to `/etc/snmp/` on your host.
|
||||||
|
2. Make the script executable (chmod +x /etc/snmp/ups-apcups.sh)
|
||||||
|
3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add:
|
||||||
|
```
|
||||||
|
extend ups-apcups /etc/snmp/ups-apcups.sh
|
||||||
|
```
|
||||||
|
4. Restart snmpd on your host
|
||||||
|
5. On the device page in Librenms, edit your host and check the `UPS apcups` under the Applications tab.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Agent Setup
|
Agent Setup
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@@ -91,6 +91,9 @@ function nicecase($item)
|
|||||||
case 'ups-nut':
|
case 'ups-nut':
|
||||||
return 'UPS nut';
|
return 'UPS nut';
|
||||||
|
|
||||||
|
case 'ups-apcups':
|
||||||
|
return 'UPS apcups';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ucfirst($item);
|
return ucfirst($item);
|
||||||
}
|
}
|
||||||
|
33
html/includes/graphs/application/ups-apcups_charge.inc.php
Normal file
33
html/includes/graphs/application/ups-apcups_charge.inc.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 crcro
|
||||||
|
* @author Cercel Valentin <crc@nuamchefazi.ro>
|
||||||
|
*/
|
||||||
|
require 'includes/graphs/common.inc.php';
|
||||||
|
$scale_min = 0;
|
||||||
|
$ds = 'charge';
|
||||||
|
$colour_area = 'EEEEEE';
|
||||||
|
$colour_line = 'FF3300';
|
||||||
|
$colour_area_max = 'FFEE99';
|
||||||
|
$graph_max = 0;
|
||||||
|
$unit_text = 'Percent';
|
||||||
|
$ups_apcups = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
|
||||||
|
if (rrdtool_check_rrd_exists($ups_apcups)) {
|
||||||
|
$rrd_filename = $ups_apcups;
|
||||||
|
}
|
||||||
|
require 'includes/graphs/generic_simplex.inc.php';
|
33
html/includes/graphs/application/ups-apcups_load.inc.php
Normal file
33
html/includes/graphs/application/ups-apcups_load.inc.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 crcro
|
||||||
|
* @author Cercel Valentin <crc@nuamchefazi.ro>
|
||||||
|
*/
|
||||||
|
require 'includes/graphs/common.inc.php';
|
||||||
|
$scale_min = 0;
|
||||||
|
$ds = 'load';
|
||||||
|
$colour_area = 'EEEEEE';
|
||||||
|
$colour_line = 'FF3300';
|
||||||
|
$colour_area_max = 'FFEE99';
|
||||||
|
$graph_max = 0;
|
||||||
|
$unit_text = 'Percent';
|
||||||
|
$ups_apcups = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
|
||||||
|
if (rrdtool_check_rrd_exists($ups_apcups)) {
|
||||||
|
$rrd_filename = $ups_apcups;
|
||||||
|
}
|
||||||
|
require 'includes/graphs/generic_simplex.inc.php';
|
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 crcro
|
||||||
|
* @author Cercel Valentin <crc@nuamchefazi.ro>
|
||||||
|
*/
|
||||||
|
require 'includes/graphs/common.inc.php';
|
||||||
|
$scale_min = 0;
|
||||||
|
$ds = 'time_remaining';
|
||||||
|
$colour_area = 'EEEEEE';
|
||||||
|
$colour_line = '36393D';
|
||||||
|
$colour_area_max = 'FFEE99';
|
||||||
|
$graph_max = 0;
|
||||||
|
$unit_text = 'Minutes';
|
||||||
|
$ups_apcups = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
|
||||||
|
if (rrdtool_check_rrd_exists($ups_apcups)) {
|
||||||
|
$rrd_filename = $ups_apcups;
|
||||||
|
}
|
||||||
|
require 'includes/graphs/generic_simplex.inc.php';
|
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 crcro
|
||||||
|
* @author Cercel Valentin <crc@nuamchefazi.ro>
|
||||||
|
*/
|
||||||
|
require 'includes/graphs/common.inc.php';
|
||||||
|
$scale_min = 0;
|
||||||
|
$colours = 'mixed';
|
||||||
|
$unit_text = 'Volts';
|
||||||
|
$unitlen = 10;
|
||||||
|
$bigdescrlen = 15;
|
||||||
|
$smalldescrlen = 15;
|
||||||
|
$dostack = 0;
|
||||||
|
$printtotal = 0;
|
||||||
|
$addarea = 1;
|
||||||
|
$transparency = 33;
|
||||||
|
$rrd_filename = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
|
||||||
|
$array = array(
|
||||||
|
'battery_nominal' => array('descr' => 'Nominal','colour' => '630606',),
|
||||||
|
'battery_voltage' => array('descr' => 'Current','colour' => '50C150',),
|
||||||
|
);
|
||||||
|
$i = 0;
|
||||||
|
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||||
|
foreach ($array as $ds => $vars) {
|
||||||
|
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||||
|
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||||
|
$rrd_list[$i]['ds'] = $ds;
|
||||||
|
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "file missing: $rrd_filename";
|
||||||
|
}
|
||||||
|
require 'includes/graphs/generic_v3_multiline_float.inc.php';
|
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 crcro
|
||||||
|
* @author Cercel Valentin <crc@nuamchefazi.ro>
|
||||||
|
*/
|
||||||
|
require 'includes/graphs/common.inc.php';
|
||||||
|
$scale_min = 0;
|
||||||
|
$colours = 'mixed';
|
||||||
|
$unit_text = 'Volts';
|
||||||
|
$unitlen = 10;
|
||||||
|
$bigdescrlen = 15;
|
||||||
|
$smalldescrlen = 15;
|
||||||
|
$dostack = 0;
|
||||||
|
$printtotal = 0;
|
||||||
|
$addarea = 1;
|
||||||
|
$transparency = 33;
|
||||||
|
$rrd_filename = rrd_name($device['hostname'], array('app', 'ups-apcups', $app['app_id']));
|
||||||
|
$array = array(
|
||||||
|
'input_voltage' => array('descr' => 'Input','colour' => '630606',),
|
||||||
|
'nominal_voltage' => array('descr' => 'Nominal','colour' => '50C150',),
|
||||||
|
);
|
||||||
|
$i = 0;
|
||||||
|
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||||
|
foreach ($array as $ds => $vars) {
|
||||||
|
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||||
|
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||||
|
$rrd_list[$i]['ds'] = $ds;
|
||||||
|
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "file missing: $rrd_filename";
|
||||||
|
}
|
||||||
|
require 'includes/graphs/generic_v3_multiline_float.inc.php';
|
@@ -112,6 +112,14 @@ $graphs['ups-nut'] = array(
|
|||||||
'voltage_input',
|
'voltage_input',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$graphs['ups-apcups'] = array(
|
||||||
|
'remaining',
|
||||||
|
'load',
|
||||||
|
'voltage_battery',
|
||||||
|
'charge',
|
||||||
|
'voltage_input',
|
||||||
|
);
|
||||||
|
|
||||||
print_optionbar_start();
|
print_optionbar_start();
|
||||||
|
|
||||||
echo "<span style='font-weight: bold;'>Apps</span> » ";
|
echo "<span style='font-weight: bold;'>Apps</span> » ";
|
||||||
|
47
html/pages/device/apps/ups-apcups.inc.php
Normal file
47
html/pages/device/apps/ups-apcups.inc.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 crcro
|
||||||
|
* @author Cercel Valentin <crc@nuamchefazi.ro>
|
||||||
|
*/
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$graphs = array(
|
||||||
|
'ups-apcups_remaining' => 'Remaining time:',
|
||||||
|
'ups-apcups_load' => 'Load:',
|
||||||
|
'ups-apcups_voltage_battery' => 'Battery voltage:',
|
||||||
|
'ups-apcups_charge' => 'Charge:',
|
||||||
|
'ups-apcups_voltage_input' => 'Input voltage:',
|
||||||
|
);
|
||||||
|
foreach ($graphs as $key => $text) {
|
||||||
|
$graph_type = $key;
|
||||||
|
$graph_array['height'] = '100';
|
||||||
|
$graph_array['width'] = '215';
|
||||||
|
$graph_array['to'] = $config['time']['now'];
|
||||||
|
$graph_array['id'] = $app['app_id'];
|
||||||
|
$graph_array['type'] = 'application_'.$key;
|
||||||
|
echo '<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">'.$text.'</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="row">';
|
||||||
|
include 'includes/print-graphrow.inc.php';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
Reference in New Issue
Block a user