Updated discovery to log new type + updated eventlog page to show this

This commit is contained in:
laf
2015-08-05 20:05:45 +00:00
parent 2537767f2d
commit 746c52046b
4 changed files with 29 additions and 3 deletions

View File

@@ -20,6 +20,8 @@ var grid = $("#eventlog").bootgrid({
{ {
return { return {
id: "eventlog", id: "eventlog",
device: "' .mres($vars['device']) .'",
type: "' .mres($vars['type']) .'",
}; };
}, },
url: "/ajax_table.php" url: "/ajax_table.php"

View File

@@ -7,6 +7,11 @@ if (is_numeric($_POST['device'])) {
$param[] = $_POST['device']; $param[] = $_POST['device'];
} }
if (!empty($_POST['type'])) {
$where .= ' AND `E`.`type` = ?';
$param[] = $_POST['type'];
}
if ($_POST['string']) { if ($_POST['string']) {
$where .= ' AND E.message LIKE ?'; $where .= ' AND E.message LIKE ?';
$param[] = '%'.$_POST['string'].'%'; $param[] = '%'.$_POST['string'].'%';
@@ -54,7 +59,7 @@ foreach (dbFetchRows($sql, $param) as $eventlog) {
$type = '<b>'.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).'</b>'; $type = '<b>'.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).'</b>';
} }
else { else {
$type = 'System'; $type = $eventlog['type'];;
} }
$response[] = array( $response[] = array(

View File

@@ -34,6 +34,25 @@ print_optionbar_start();
echo '>'.$hostname.'</option>'; echo '>'.$hostname.'</option>';
} }
} }
?>
</select>
</div>
<div class="form-group">
<label>
<strong>Type: </strong>
</label>
<select name="type" id="type" class="form-control input-sm">
<option value="">All types</option>
<?php
foreach (dbFetchRows("SELECT `type` FROM `eventlog` GROUP BY `type`") as $types) {
echo '<option value="'.$types['type'].'"';
if ($types['type'] === $_POST['type']) {
echo ' selected';
}
echo '>'.$types['type'].'</option>';
}
?> ?>
</select> </select>
</div> </div>

View File

@@ -67,10 +67,10 @@ function discover_new_device($hostname, $device='', $method='', $interface='') {
$extra_log = ' (port '.$int['label'].') '; $extra_log = ' (port '.$int['label'].') ';
} }
log_event('Device $'.$remote_device['hostname']." ($ip) $extra_log autodiscovered through $method on ".$device['hostname'], $remote_device_id, 'system'); log_event('Device $'.$remote_device['hostname']." ($ip) $extra_log autodiscovered through $method on ".$device['hostname'], $remote_device_id, 'discovery');
} }
else { else {
log_event("$method discovery of ".$remote_device['hostname']." ($ip) failed - check ping and SNMP access", $device['device_id'], 'system'); log_event("$method discovery of ".$remote_device['hostname']." ($ip) failed - check ping and SNMP access", $device['device_id'], 'discovery');
} }
return $remote_device_id; return $remote_device_id;