Improve behaviour and reduce extra logging when db goes away
This commit is contained in:
parent
aaeb30a72f
commit
95a6d0666a
|
@ -546,9 +546,11 @@ class Event {
|
||||||
}
|
}
|
||||||
$filters = array();
|
$filters = array();
|
||||||
$result = dbQuery($sql, $values);
|
$result = dbQuery($sql, $values);
|
||||||
$results = $result->fetchALL();
|
if ( $result ) {
|
||||||
foreach ( $results as $row ) {
|
$results = $result->fetchALL();
|
||||||
$filters[] = new Event($row);
|
foreach ( $results as $row ) {
|
||||||
|
$filters[] = new Event($row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $filters;
|
return $filters;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1909,23 +1909,24 @@ function logState() {
|
||||||
|
|
||||||
# This is an expensive request, as it has to hit every row of the Logs Table
|
# This is an expensive request, as it has to hit every row of the Logs Table
|
||||||
$sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC';
|
$sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC';
|
||||||
$counts = dbFetchAll( $sql );
|
$counts = dbFetchAll($sql);
|
||||||
|
if ( $counts ) {
|
||||||
foreach ( $counts as $count ) {
|
foreach ( $counts as $count ) {
|
||||||
if ( $count['Level'] <= Logger::PANIC )
|
if ( $count['Level'] <= Logger::PANIC )
|
||||||
$count['Level'] = Logger::FATAL;
|
$count['Level'] = Logger::FATAL;
|
||||||
if ( !($levelCount = $levelCounts[$count['Level']]) ) {
|
if ( !($levelCount = $levelCounts[$count['Level']]) ) {
|
||||||
Error( "Unexpected Log level ".$count['Level'] );
|
Error('Unexpected Log level '.$count['Level']);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ( $levelCount[1] && $count['LevelCount'] >= $levelCount[1] ) {
|
if ( $levelCount[1] && $count['LevelCount'] >= $levelCount[1] ) {
|
||||||
$state = 'alarm';
|
$state = 'alarm';
|
||||||
break;
|
break;
|
||||||
} elseif ( $levelCount[0] && $count['LevelCount'] >= $levelCount[0] ) {
|
} elseif ( $levelCount[0] && $count['LevelCount'] >= $levelCount[0] ) {
|
||||||
$state = 'alert';
|
$state = 'alert';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return( $state );
|
return $state;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVector ( &$array ) {
|
function isVector ( &$array ) {
|
||||||
|
|
|
@ -345,7 +345,7 @@ if ($reload == 'reload') ob_start();
|
||||||
<?php
|
<?php
|
||||||
$connections = dbFetchOne( "SHOW status WHERE variable_name='threads_connected'", 'Value' );
|
$connections = dbFetchOne( "SHOW status WHERE variable_name='threads_connected'", 'Value' );
|
||||||
$max_connections = dbFetchOne( "SHOW variables WHERE variable_name='max_connections'", 'Value' );
|
$max_connections = dbFetchOne( "SHOW variables WHERE variable_name='max_connections'", 'Value' );
|
||||||
$percent_used = 100 * $connections / $max_connections;
|
$percent_used = $max_connections ? 100 * $connections / $max_connections : 100;
|
||||||
echo '<li'. ( $percent_used > 90 ? ' class="warning"' : '' ).'>'.translate('DB').':'.$connections.'/'.$max_connections.'</li>';
|
echo '<li'. ( $percent_used > 90 ? ' class="warning"' : '' ).'>'.translate('DB').':'.$connections.'/'.$max_connections.'</li>';
|
||||||
?>
|
?>
|
||||||
<li><?php echo translate('Storage') ?>:
|
<li><?php echo translate('Storage') ?>:
|
||||||
|
|
Loading…
Reference in New Issue