weathermap |
Subversion Repositories: |
Rev 1 | Rev 85 | |
---|---|---|
Line 36... | Line 36... | |
} |
} | |
|
| |
function ReadData($targetstring, &$map, &$item) |
function ReadData($targetstring, &$map, &$item) | |
{ |
{ | |
|
| |
$inbw = -1; |
$data[IN] = NULL; | |
$outbw = -1; |
$data[OUT] = NULL; | |
$data_time = 0; |
$data_time = 0; | |
|
| |
if(preg_match("/^cactihost:(\d+)$/",$targetstring,$matches)) |
if(preg_match("/^cactihost:(\d+)$/",$targetstring,$matches)) | |
{ |
{ | |
$cacti_id = intval($matches[1]); |
$cacti_id = intval($matches[1]); | |
|
| |
$SQL = "select status, disabled from host where id=$cacti_id"; |
$SQL = "select * from host where id=$cacti_id"; | |
// 0=disabled |
// 0=disabled | |
// 1=down |
// 1=down | |
// 2=recovering |
// 2=recovering | |
// 3=up |
// 3=up | |
|
| |
Line 60... | Line 60... | |
if($result['status'] == 1) { $state = 1; $statename = 'down'; } |
if($result['status'] == 1) { $state = 1; $statename = 'down'; } | |
if($result['status'] == 2) { $state = 2; $statename = 'recovering'; } |
if($result['status'] == 2) { $state = 2; $statename = 'recovering'; } | |
if($result['status'] == 3) { $state = 3; $statename = 'up'; } |
if($result['status'] == 3) { $state = 3; $statename = 'up'; } | |
if($result['disabled']) { $state = 0; $statename = 'disabled'; } |
if($result['disabled']) { $state = 0; $statename = 'disabled'; } | |
|
| |
$inbw = $state; |
$data[IN] = $state; | |
$outbw = $state; |
$data[OUT] = $state; | |
$item->add_note("state",$statename); |
$item->add_note("state",$statename); | |
$item->add_note("cacti_description",$result['description']); | ||
| ||
$item->add_note("cacti_hostname",$result['hostname']); | ||
$item->add_note("cacti_curtime",$result['cur_time']); | ||
$item->add_note("cacti_avgtime",$result['avg_time']); | ||
$item->add_note("cacti_mintime",$result['min_time']); | ||
$item->add_note("cacti_maxtime",$result['max_time']); | ||
$item->add_note("cacti_availability",$result['availability']); | ||
| ||
$item->add_note("cacti_faildate",$result['status_fail_date']); | ||
$item->add_note("cacti_recdate",$result['status_rec_date']); | ||
} |
} | |
} |
} | |
|
| |
debug ("CactiHost ReadData: Returning ($inbw,$outbw,$data_time)\n"); |
debug ("CactiHost ReadData: Returning (".($data[IN]===NULL?'NULL':$data[IN]).",".($data[OUT]===NULL?'NULL':$data[OUT]).",$data_time)\n"); | |
|
| |
return( array($inbw, $outbw, $data_time) ); |
return( array($data[IN], $data[OUT], $data_time) ); | |
} |
} | |
} |
} | |
|
| |
|
| |
// vim:ts=4:sw=4: |
// vim:ts=4:sw=4: |