Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: sdfsinfo #6494

Merged
merged 11 commits into from Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions doc/Extensions/Applications.md
Expand Up @@ -30,6 +30,7 @@ Different applications support a variety of ways collect data: by direct connect
1. [PowerDNS Recursor](#powerdns-recursor) - Direct, Agent
1. [Proxmox](#proxmox) - SNMP extend
1. [Raspberry PI](#raspberry-pi) - SNMP extend
1. [SDFS info](#sdfs-info) - SNMP extend
1. [SMART](#smart) - SNMP extend
1. [Squid](#squid) - SNMP proxy
1. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent
Expand Down Expand Up @@ -715,3 +716,24 @@ 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.


### SDFS info
A small shell script that exportfs SDFS volume info.

###### SNMP Extend
1. Download the script onto the desired host (the host must be added to LibreNMS devices)
```
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/sdfsinfo -O /etc/snmp/sdfsinfo
```

2. Make the script executable (chmod +x /etc/snmp/sdfsinfo)

3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add:
```
extend sdfsinfo /etc/snmp/sdfsinfo
```

4. Restart snmpd on your host

5. On the device page in Librenms, edit your host and check the `SDFS info` under the Applications tab or wait for it to be auto-discovered.
3 changes: 3 additions & 0 deletions html/includes/functions.inc.php
Expand Up @@ -115,6 +115,9 @@ function nicecase($item)
case 'opengridscheduler':
return 'Open Grid Scheduler';

case 'sdfsinfo':
return 'SDFS info';

default:
return ucfirst($item);
}
Expand Down
57 changes: 57 additions & 0 deletions html/includes/graphs/application/sdfsinfo_blocks.inc.php
@@ -0,0 +1,57 @@
<?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 2017 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/

require 'includes/graphs/common.inc.php';

$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Blocks';
$unitlen = 6;
$bigdescrlen = 25;
$smalldescrlen = 25;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 33;
$rrd_filename = rrd_name($device['hostname'], array('app', $app['app_type'], $app['app_id']));

$array = array(
'dup_data' => array('descr' => 'Duplicate data wrote (GB)','colour' => '000000',),
'blocks_unique' => array('descr' => 'Unique blocks (GB)','colour' => '2A7A12',),
'blocks_compressed' => array('descr' => 'Compressed blocks (GB)','colour' => '74127A',),
'cluster_copies' => array('descr' => 'Cluster copies','colour' => 'F44842',),
);

$i = 0;

if (rrdtool_check_rrd_exists($rrd_filename)) {
foreach ($array as $ds => $var) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $var['descr'];
$rrd_list[$i]['ds'] = $ds;
$rrd_list[$i]['colour'] = $var['colour'];
$i++;
}
} else {
echo "file missing: $rrd_filename";
}

require 'includes/graphs/generic_v3_multiline_float.inc.php';
55 changes: 55 additions & 0 deletions html/includes/graphs/application/sdfsinfo_rates.inc.php
@@ -0,0 +1,55 @@
<?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 2017 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/

require 'includes/graphs/common.inc.php';

$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Rates';
$unitlen = 6;
$bigdescrlen = 20;
$smalldescrlen = 20;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 33;
$rrd_filename = rrd_name($device['hostname'], array('app', $app['app_type'], $app['app_id']));
$array = array(
'dedup_rate' => array('descr' => 'Dedup rate (%)','colour' => '000000',),
'actual_savings' => array('descr' => 'Savings (%)','colour' => '2A7A12',),
'comp_rate' => array('descr' => 'Compression (%)','colour' => '74127A',),
);

$i = 0;

if (rrdtool_check_rrd_exists($rrd_filename)) {
foreach ($array as $ds => $var) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $var['descr'];
$rrd_list[$i]['ds'] = $ds;
$rrd_list[$i]['colour'] = $var['colour'];
$i++;
}
} else {
echo "file missing: $rrd_filename";
}

require 'includes/graphs/generic_v3_multiline_float.inc.php';
56 changes: 56 additions & 0 deletions html/includes/graphs/application/sdfsinfo_volume.inc.php
@@ -0,0 +1,56 @@
<?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 2017 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/

require 'includes/graphs/common.inc.php';

$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Volume';
$unitlen = 6;
$bigdescrlen = 25;
$smalldescrlen = 25;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 33;
$rrd_filename = rrd_name($device['hostname'], array('app', $app['app_type'], $app['app_id']));
$array = array(
'files' => array('descr' => 'Files','colour' => '000000',),
'vol_capacity' => array('descr' => 'Capacity (GB)','colour' => '2A7A12',),
'vol_logic_size' => array('descr' => 'Logic capacity (GB)','colour' => '74127A',),
'vol_max_load' => array('descr' => 'Max load (%)','colour' => 'F44842',),
);

$i = 0;

if (rrdtool_check_rrd_exists($rrd_filename)) {
foreach ($array as $ds => $var) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $var['descr'];
$rrd_list[$i]['ds'] = $ds;
$rrd_list[$i]['colour'] = $var['colour'];
$i++;
}
} else {
echo "file missing: $rrd_filename";
}

require 'includes/graphs/generic_v3_multiline_float.inc.php';
6 changes: 6 additions & 0 deletions html/pages/apps.inc.php
Expand Up @@ -232,6 +232,12 @@
'id233',
);

$graphs['sdfsinfo'] = array(
'volume',
'blocks',
'rates',
);

print_optionbar_start();

echo "<span style='font-weight: bold;'>Apps</span> &#187; ";
Expand Down
48 changes: 48 additions & 0 deletions html/pages/device/apps/sdfsinfo.inc.php
@@ -0,0 +1,48 @@
<?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 2017 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/

global $config;

$graphs = array(
'sdfsinfo_volume' => 'Volume stats',
'sdfsinfo_blocks' => 'Block stats',
'sdfsinfo_rates' => 'Volume rates',
);

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>';
}
69 changes: 69 additions & 0 deletions includes/polling/applications/sdfsinfo.inc.php
@@ -0,0 +1,69 @@
<?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 2017 crcro
* @author Cercel Valentin <crc@nuamchefazi.ro>
*/

use LibreNMS\RRD\RrdDefinition;

$name = 'sdfsinfo';
$app_id = $app['app_id'];
$options = '-O qv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.8.115.100.102.115.105.110.102.111';

d_echo($name);

$sdfsinfo = snmp_walk($device, $oid, $options);

if (is_string($sdfsinfo)) {
update_application($app, $sdfsinfo);
$rrd_name = array('app', $name, $app_id);

$rrd_def = RrdDefinition::make()
->addDataset('files', 'GAUGE', 0)
->addDataset('vol_capacity', 'GAUGE', 0)
->addDataset('vol_logic_size', 'GAUGE', 0)
->addDataset('vol_max_load', 'GAUGE', 0)
->addDataset('dup_data', 'GAUGE', 0)
->addDataset('blocks_unique', 'GAUGE', 0)
->addDataset('blocks_compressed', 'GAUGE', 0)
->addDataset('cluster_copies', 'GAUGE', 0)
->addDataset('dedup_rate', 'GAUGE', 0)
->addDataset('actual_savings', 'GAUGE', 0)
->addDataset('comp_rate', 'GAUGE', 0);

list($files, $vol_capacity, $vol_logic_size, $vol_max_load, $dup_data, $blocks_unique, $blocks_compressed, $cluster_copies, $dedup_rate, $actual_savings, $comp_rate) = explode(" ", $sdfsinfo);

$fields = array(
'files' => $files,
'vol_capacity' => $vol_capacity,
'vol_logic_size' => $vol_logic_size,
'vol_max_load' => $vol_max_load,
'dup_data' => $dup_data,
'blocks_unique' => $blocks_unique,
'blocks_compressed' => $blocks_compressed,
'cluster_copies' => $cluster_copies,
'dedup_rate' => $dedup_rate,
'actual_savings' => $actual_savings,
'comp_rate' => $comp_rate,
);

$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name);
data_update($device, 'app', $tags, $fields);
unset($sdfsinfo, $rrd_name, $rrd_def, $data, $fields, $tags);
}