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

add SMART app support #6181

Merged
merged 7 commits into from Mar 22, 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
43 changes: 43 additions & 0 deletions doc/Extensions/Applications.md
Expand Up @@ -29,6 +29,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. [SMART](#smart) - SNMP extend
1. [Squid](#squid) - SNMP proxy
1. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent
1. [Unbound](#unbound) - Agent
Expand Down Expand Up @@ -508,6 +509,48 @@ snmp ALL=(ALL) NOPASSWD: /etc/snmp/raspberry.sh, /usr/bin/vcgencmd*
```
5. Restart snmpd on PI host

### SMART

#### SNMP Extend

1: Copy the Perl script, smart, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/smart -O /etc/snmp/smart)

2: Make the script executable (chmod +x /etc/snmp/smart)

3: Edit your snmpd.conf file and add:
```
extend smart /etc/snmp/smart
```

4: You will also need to create the config file, which defaults to the same path as the script, but with .config appended. So if the script is located at /etc/snmp/smart, the config file will be /etc/snmp/smart.config. Alternatively you can also specific a config via -c.

Anything starting with a # is comment. The format for variables is $variable=$value. Empty lines are ignored. Spaces and tabes at either the start or end of a line are ignored. Any line with out a = or # are treated as a disk.
```
#This is a comment
cache=/var/cache/smart
smartctl=/usr/bin/env smartctl
ada0
ada1
```

The variables are as below.
```
cache = The path to the cache file to use. Default: /var/cache/smart
smartctl = The path to use for smartctl. Default: /usr/bin/env smartctl
```

If you want to guess at the configuration, call it with -g and it will print out what it thinks
it should be. This will result in a usable config, but may miss some less common disk devices.

5: Restart snmpd on your host

6: On the device page in Librenms, edit your host and check `SMART` under the Applications tab.

If you have a large number of more than one or two disks on a system, you should consider adding this to cron. Also make sure the cache file is some place it can be written to.
```
*/3 * * * * /etc/snmp/smart -u
```

### Squid

#### SNMP Proxy
Expand Down
17 changes: 17 additions & 0 deletions html/includes/functions.inc.php
Expand Up @@ -1484,3 +1484,20 @@ function get_disks($device)
{
return dbFetchRows('SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr', array($device));
}

// takes the device array and app_id
function get_disks_with_smart($device, $app_id)
{
$all_disks=get_disks($device['device_id']);
$disks=array();
$all_disks_int=0;
while (isset($all_disks[$all_disks_int])) {
$disk=$all_disks[$all_disks_int]['diskio_descr'];
$rrd_filename = rrd_name($device['hostname'], array('app', 'smart', $app_id, $disk));
if (rrdtool_check_rrd_exists($rrd_filename)) {
$disks[]=$disk;
}
$all_disks_int++;
}
return $disks;
}
31 changes: 31 additions & 0 deletions html/includes/graphs/application/smart-common.inc.php
@@ -0,0 +1,31 @@
<?php
$name = 'smart';
$app_id = $app['app_id'];
$colours = 'mega';
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;

if (isset($vars['disk'])) {
$disks=array($vars['disk']);
} else {
$disks=get_disks_with_smart($device, $app['app_id']);
}

$int=0;
while (isset($disks[$int])) {
$disk=$disks[$int];
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id, $disk));

if (rrdtool_check_rrd_exists($rrd_filename)) {
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => $disk,
'ds' => $rrdVar,
);
}
$int++;
}

require 'includes/graphs/generic_multi_line_exact_numbers.inc.php';
46 changes: 46 additions & 0 deletions html/includes/graphs/application/smart_big5.inc.php
@@ -0,0 +1,46 @@
<?php
$name = 'smart';
$app_id = $app['app_id'];
$unit_text = '';
$unitlen = 10;
$bigdescrlen = 10;
$smalldescrlen = 10;
$colours = 'mega';
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;

$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id, $vars['disk']));

if (rrdtool_check_rrd_exists($rrd_filename)) {
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 5',
'ds' => 'id5',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 187',
'ds' => 'id187',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 188',
'ds' => 'id188',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 197',
'ds' => 'id197',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 198',
'ds' => 'id198',
);
}



require 'includes/graphs/generic_multi_line_exact_numbers.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id10.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Spin Retry Cnt';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id10';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id173.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'SSD Wear Lvl';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id173';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id183.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Dctcd Uncor Bad';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id183';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id184.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'End-to-End err';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id184';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id187.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Rprtd Uncr Err';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id187';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id188.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Cmd Timeout';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id188';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id190.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Air Temp (C)';
$unitlen = 12;
$bigdescrlen = 12;
$smalldescrlen = 12;

$rrdVar='id190';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id194.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Temp (C)';
$unitlen = 10;
$bigdescrlen = 10;
$smalldescrlen = 10;

$rrdVar='id194';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id196.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Reall Evnt Cnt';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id196';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id197.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Crnt Pnd Sct Cnt';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id197';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id198.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Uncr Sct Cnt';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id198';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id199.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'CRC Err Cnt';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id199';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id231.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'SDD Life Left';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id231';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id233.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Media Wear Indi';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id233';

require 'smart-common.inc.php';
9 changes: 9 additions & 0 deletions html/includes/graphs/application/smart_id5.inc.php
@@ -0,0 +1,9 @@
<?php
$unit_text = 'Reall Sect Ct';
$unitlen = 20;
$bigdescrlen = 5;
$smalldescrlen = 5;

$rrdVar='id5';

require 'smart-common.inc.php';
44 changes: 44 additions & 0 deletions html/includes/graphs/application/smart_other.inc.php
@@ -0,0 +1,44 @@
<?php
$name = 'smart';
$app_id = $app['app_id'];
$unit_text = '';
$unitlen = 10;
$bigdescrlen = 10;
$smalldescrlen = 10;
$colours = 'mega';
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;

$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id, $vars['disk']));

if (rrdtool_check_rrd_exists($rrd_filename)) {
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 10',
'ds' => 'id10',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 183',
'ds' => 'id183',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 184',
'ds' => 'id184',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 196',
'ds' => 'id197',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 199',
'ds' => 'id199',
);
}

require 'includes/graphs/generic_multi_line_exact_numbers.inc.php';
36 changes: 36 additions & 0 deletions html/includes/graphs/application/smart_ssd.inc.php
@@ -0,0 +1,36 @@
<?php
$name = 'smart';
$app_id = $app['app_id'];
$unit_text = '';
$unitlen = 10;
$bigdescrlen = 10;
$smalldescrlen = 10;
$colours = 'mega';
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;

$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id, $vars['disk']));

if (rrdtool_check_rrd_exists($rrd_filename)) {
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 173',
'ds' => 'id173',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 231',
'ds' => 'id231',
);
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'ID# 233',
'ds' => 'id233',
);
}



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