2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 18:09:35 +08:00
if ( ! $HTTP_SESSION_VARS [ 'event_reset_time' ] )
$HTTP_SESSION_VARS [ 'event_reset_time' ] = " 2000-01-01 00:00:00 " ;
2003-07-11 17:27:56 +08:00
$db_now = strftime ( " %Y-%m-%d %H:%M:%S " );
2004-01-08 18:09:35 +08:00
$sql = " select M.*, count(E.Id) as EventCount, count(if(E.StartTime>' $HTTP_SESSION_VARS['event_reset_time'] ' && E.Archived = 0,1,NULL)) as ResetEventCount, count(if(E.StartTime>' $db_now ' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>' $db_now ' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by M.Id order by M.Id " ;
2003-07-11 17:27:56 +08:00
$result = mysql_query ( $sql );
if ( ! $result )
echo mysql_error ();
$monitors = array ();
$max_width = 0 ;
$max_height = 0 ;
$cycle_count = 0 ;
while ( $row = mysql_fetch_assoc ( $result ) )
{
2004-01-08 18:09:35 +08:00
if ( $max_width < $row [ 'Width' ] ) $max_width = $row [ 'Width' ];
if ( $max_height < $row [ 'Height' ] ) $max_height = $row [ 'Height' ];
$sql = " select count(Id) as ZoneCount, count(if(Type='Active',1,NULL)) as ActZoneCount, count(if(Type='Inclusive',1,NULL)) as IncZoneCount, count(if(Type='Exclusive',1,NULL)) as ExcZoneCount, count(if(Type='Inactive',1,NULL)) as InactZoneCount from Zones where MonitorId = ' $row['Id'] ' " ;
2003-07-11 17:27:56 +08:00
$result2 = mysql_query ( $sql );
if ( ! $result2 )
echo mysql_error ();
$row2 = mysql_fetch_assoc ( $result2 );
$monitors [] = array_merge ( $row , $row2 );
if ( $row [ 'Function' ] != 'None' ) $cycle_count ++ ;
}
$sql = " select distinct Device from Monitors order by Device " ;
$result = mysql_query ( $sql );
if ( ! $result )
echo mysql_error ();
$devices = array ();
while ( $row = mysql_fetch_assoc ( $result ) )
{
2004-01-08 18:09:35 +08:00
$ps_array = preg_split ( " / \ s+/ " , exec ( " ps -edalf | grep 'zmc $row['Device'] ' | grep -v grep " ) );
2003-07-11 17:27:56 +08:00
if ( $ps_array [ 3 ] )
{
$row [ 'zmc' ] = 1 ;
}
2004-01-08 18:09:35 +08:00
$ps_array = preg_split ( " / \ s+/ " , exec ( " ps -edalf | grep 'zma $row['Device'] ' | grep -v grep " ) );
2003-07-11 17:27:56 +08:00
if ( $ps_array [ 3 ] )
{
$row [ 'zma' ] = 1 ;
}
$devices [] = $row ;
}
?>
< wml >
2004-01-07 20:57:07 +08:00
< card id = " zmConsole " title = " ZM - <?= $zmSlangConsole ?> " ontimer = " <?= $PHP_SELF ?>?view=<?= $view ?> " >
2003-07-11 17:27:56 +08:00
< timer value = " <?= REFRESH_MAIN*10 ?> " />
2004-01-07 20:57:07 +08:00
< p mode = " nowrap " align = " center " >< strong > ZM - < ? = $zmSlangConsole ?> </strong></p>
< p mode = " nowrap " align = " center " >< ? = count ( $monitors ) ?> <?= $zmSlangMonitors ?> - <?= strftime( "%T" ) ?></p>
2004-01-08 18:09:35 +08:00
< p mode = " nowrap " align = " center " >< ? = $HTTP_SESSION_VARS [ 'event_reset_time' ] ?> </p>
2003-07-11 17:27:56 +08:00
< p align = " center " >
< table columns = " 3 " >
< tr >
2004-01-07 20:57:07 +08:00
< td >< ? = $zmSlangName ?> </td>
< td >< ? = $zmSlangFunc ?> </td>
< td >< ? = $zmSlangEvents ?> </td>
2003-07-11 17:27:56 +08:00
</ tr >
< ? php
$reset_event_count = 0 ;
foreach ( $monitors as $monitor )
{
2004-01-08 18:09:35 +08:00
$device = $devices [ $monitor [ 'Device' ]];
$reset_event_count += $monitor [ 'ResetEventCount' ];
2003-07-11 17:27:56 +08:00
?>
< tr >
2004-01-08 18:09:35 +08:00
< td >< a href = " <?= $PHP_SELF ?>?view=feed&mid=<?= $monitor['Id'] ?> " >< ? = $monitor [ 'Name' ] ?> </a></td>
< td >< a href = " <?= $PHP_SELF ?>?view=function&mid=<?= $monitor['Id'] ?> " >< ? = substr ( $monitor [ 'Function' ], 0 , 1 ) ?> </a></td>
< td >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $monitor['Id'] ?> " >< ? = $monitor [ 'ResetEventCount' ] ?> </a></td>
2003-07-11 17:27:56 +08:00
</ tr >
< ? php
}
?>
</ table >
</ p >
2004-01-07 20:57:07 +08:00
< p mode = " nowrap " align = " center " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&action=reset " >< ? = $zmSlangResetEventCounts ?> </a></p>
2003-07-11 17:27:56 +08:00
</ card >
</ wml >