mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
storage poller redux
git-svn-id: http://www.observium.org/svn/observer/trunk@938 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
19
includes/polling/storage-hrstorage.inc.php
Executable file
19
includes/polling/storage-hrstorage.inc.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/// HOST-RESOURCES-MIB - Storage Objects
|
||||
|
||||
if(!is_array($storage_cache['hrstorage'])) {
|
||||
$storage_cache['hrstorage'] = snmp_cache_oid("hrStorageEntry", $device, array(), "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
|
||||
print_r($storage_cache);
|
||||
}
|
||||
|
||||
$entry = $storage_cache['hrstorage'][$device[device_id]][$storage[storage_index]];
|
||||
|
||||
print_r($entry);
|
||||
|
||||
$storage['units'] = $entry['hrStorageAllocationUnits'];
|
||||
$storage['used'] = $entry['hrStorageUsed'] * $storage['units'];
|
||||
$storage['size'] = $entry['hrStorageSize'] * $storage['units'];
|
||||
$storage['free'] = $storage['size'] - $storage['used'];
|
||||
|
||||
?>
|
57
includes/polling/storage.inc.php
Executable file
57
includes/polling/storage.inc.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
$storage_cache = array();
|
||||
|
||||
$query = "SELECT * FROM storage WHERE device_id = '" . $device['device_id'] . "'";
|
||||
$storage_data = mysql_query($query);
|
||||
while($storage = mysql_fetch_array($storage_data)) {
|
||||
|
||||
echo($storage['storage_descr'] . ": ");
|
||||
|
||||
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("storage-" . $storage['storage_mib'] . "-" . $storage['storage_index'] . ".rrd");
|
||||
|
||||
if (!is_file($storage_rrd)) {
|
||||
rrdtool_create($storage_rrd, "--step 300 \
|
||||
DS:used:GAUGE:600:-273:100000000000 \
|
||||
DS:free:GAUGE:600:-273:100000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
$file = $config['install_dir']."/includes/polling/storage-".$storage['storage_mib'].".inc.php";
|
||||
if(is_file($file)) {
|
||||
include($file);
|
||||
} else {
|
||||
### FIXME GENERIC
|
||||
}
|
||||
|
||||
if($debug) {print_r($storage);}
|
||||
|
||||
$percent = round($storage['used'] / $storage['size'] * 100);
|
||||
|
||||
echo($percent."% ");
|
||||
|
||||
rrdtool_update($storage_rrd,"N:".$storage['used'].":".$storage['free']);
|
||||
|
||||
$update_query = "UPDATE `storage` SET `storage_used` = '".$storage['used']."'";
|
||||
$update_query .= ", `storage_free` = '".$storage['free']."', `storage_size` = '".$storage['size']."'";
|
||||
$update_query .= ", `storage_units` = '".$storage['units']."', `storage_perc` = '".$percent."'";
|
||||
$update_query .= " WHERE `storage_id` = '".$storage['storage_id']."'";
|
||||
if($debug) { echo("$update_query\n"); }
|
||||
mysql_query($update_query);
|
||||
|
||||
}
|
||||
|
||||
unset($storage_cache, $storage);
|
||||
|
||||
?>
|
Reference in New Issue
Block a user