Commit ecb7e49b authored by ueli heuer's avatar ueli heuer 👾
Browse files

Add support for #/path for the probe 'Disk usage (linux)'

parent cb59dd3a
......@@ -1561,6 +1561,9 @@ sub device2params($$$$$$) # {{{
} elsif ( $value =~ /^#/i && $probe_name =~ /^iostat/ ) {
$value = DVG_tool::get_iodevice_byname($HOSTS{$host_id}{'session'},
$host_id,$device_id,$target,$value);
} elsif ( $value =~ /^#/i && $probe_name =~ /^Disk usage/ ) {
$value = DVG_tool::get_mountpath_byname($HOSTS{$host_id}{'session'},
$host_id,$device_id,$target,$value);
} elsif ( $value eq '@IP' ) { # hack for the lucent pips
$value = 0;
# search the IP Addresse ...
......
......@@ -375,6 +375,50 @@ sub get_iodevice_byname ($$$$$) {
return $result_id;
}
#}}}
# {{{ sub get_mountpath_byname ($session,host_id,$device_id,$host,$path)
sub get_mountpath_byname ($$$$$) {
my ($session,$host_id,$device_id,$host,$path) = @_;
my ($mountpath, $mountid, $result_id, $vars, $cache_id, $value);
$path =~ s/^#//; # drop '#'
$mountpath = $mountid = undef;
Unix::Syslog::syslog(LOG_DEBUG, 'get_mountpath_byname: SNMP START (%s:%s)',$host_id,$path);
$vars = new SNMP::VarList(['hrStorageDescr'],['hrStorageIndex']);
($mountpath, $mountid) = $session->getnext($vars);
if ( $session->{ErrorStr} ) {
Unix::Syslog::syslog(LOG_DEBUG,
"get_mountpath_byname getnext_error %s (host_id=%d, path=%s)",
$session->{ErrorStr}, $host_id, $path);
}
while (!$session->{ErrorStr} and $$vars[0]->tag eq 'hrStorageDescr') {
if ($mountpath eq $path) {
$result_id = $mountid;
}
($mountpath, $mountid) = $session->getnext($vars);
}
Unix::Syslog::syslog(LOG_DEBUG, 'get_mountpath_byname: SNMP DONE (%s)',$host_id);
Unix::Syslog::syslog(LOG_DEBUG, 'path(%s)=%d',$path,$result_id);
$get_host_cache_h->execute($host_id,$device_id);
if ($get_host_cache_h->rows == 1) {
($cache_id, $value) = $get_host_cache_h->fetchrow;
}
if ( defined($cache_id) ) {
if ($value != $result_id) {
$update_host_cache_h->execute($result_id,$path,$cache_id);
}
} else {
$insert_host_cache_h->execute($host_id,$device_id,$result_id,$path);
}
return $result_id;
}
#}}}
# {{{ sub get_intnum_byip ($host_id,$host,$community,$ip)
sub get_intnum_byip ($$$$$) {
my ($session,$host_id,$device_id,$host,$ip) = @_;
......
......@@ -436,6 +436,12 @@ public function device_edit($device_id,$error = null) // {{{
exit;
}
$select_cache_sql = 'SELECT `value`, `name`
FROM dvg_host_cache
WHERE host_id = ?
AND device_id = ?';
$select_cache_r = $CONFIG->DB->prepare($select_cache_sql);
$error_msg = null;
if (!is_array($error)) {
$error_msg = $error;
......@@ -555,8 +561,15 @@ public function device_edit($device_id,$error = null) // {{{
$param_value)), DVG_table::WHOLE_ROW,'value');
break;
case 'snmp':
$table->add_cell(DVG_snmp::get_paraminfo($device_id,$ppid),
DVG_table::WHOLE_ROW,'value');
$select_cache_h = $select_cache_r->execute(array($host_id,$device_id));
DVG_error::check($select_cache_r);
list ($v_id,$value) = $select_cache_r->fetch();
if ( isset($value) ) {
$table->add_cell($value,DVG_table::WHOLE_ROW,'value');
} else {
$table->add_cell(DVG_snmp::get_paraminfo($device_id,$ppid),
DVG_table::WHOLE_ROW,'value');
}
break;
case 'module':
DVG_module::load($param_value,'probe',TRUE);
......@@ -1011,7 +1024,6 @@ public function device_detail($device_id,$action) // {{{
$table->add_cell(sprintf('%s:',$param_name),1,'description');
$select_cache_h = $select_cache_r->execute(array($host_id,$device_id));
DVG_error::check($select_cache_r);
print $select_cache_r->rowCount();
list ($v_id,$value) = $select_cache_r->fetch();
if ( isset($value) ) {
$table->add_cell($value,DVG_table::WHOLE_ROW,'value');
......@@ -1531,7 +1543,7 @@ public function device_hostdraw($tab,$cols,$img_type = 'sh') // {{{
$graph_sql = sprintf('
SELECT gp.id, gp.definition, gp.definition_peak,
gp.definition_abs, gp.params, gu.subst
gp.definition_abs, gp.params, gu.subst, dd.host_id
FROM dvg_device dd,
dvg_probe dp,
dvg_graph g, dvg_graph_uses gu,
......@@ -1552,7 +1564,7 @@ public function device_hostdraw($tab,$cols,$img_type = 'sh') // {{{
}
DVG_image::errorimage('paramter');
}
list ($graph_id,$opts,$opts_peak,$opts_abs,$params,$subst) =
list ($graph_id,$opts,$opts_peak,$opts_abs,$params,$subst,$host_id) =
$graph_r->fetch();
if ( $with_peak ) {
......@@ -1615,6 +1627,13 @@ public function device_hostdraw($tab,$cols,$img_type = 'sh') // {{{
$opts = str_replace ('#MAX8#',$speed8,$opts);
}
$select_cache_sql = 'SELECT `value`, `name`
FROM dvg_host_cache
WHERE host_id = ?
AND device_id = ?';
$select_cache_r = $CONFIG->DB->prepare($select_cache_sql);
$get_params_sql = sprintf('SELECT pp.id, pp.param, pp.type, ddp.value
FROM dvg_device_param ddp, dvg_probe_param pp, dvg_probe_args pa
where pa.probe_id = pp.probe_id
......@@ -1644,8 +1663,15 @@ public function device_hostdraw($tab,$cols,$img_type = 'sh') // {{{
$opts = str_replace('#MAX#',$value,$opts);
}
if ( $param_type == 'snmp' && (! $small_graph) ) {
require_once 'DVG_snmp.php';
$value=DVG_snmp::get_paraminfo($device_id,$param_id);
$select_cache_h = $select_cache_r->execute(array($host_id,$device_id));
DVG_error::check($select_cache_r);
list ($v_id,$value) = $select_cache_r->fetch();
if ( isset($value)) {
// every thing is fine :)
} else {
require_once 'DVG_snmp.php';
$value=DVG_snmp::get_paraminfo($device_id,$param_id);
}
# escape : for the rrd-graph
$value = str_replace(':','\:', $value);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment