Viewing only overnight events from console

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Viewing only overnight events from console

Post by kevin_robson »

I have created a patch to add an extra line into the console, which lists events from all monitors that occurred overnight only. This works for weeks and months also, not just 'last night'

I figure that most critical things will happen overnight so it can be a pain having to trawl through a whole day/week/months innocent events from through the day. Of course the full events are also available.

Unfortunately I cannot add a screenshot but hopefully you understand what I mean.

Two patch files are needed. Be careful with ensuring long lines dont go in as multiple short lines.

Copy the following to a file called zm_html_styles.css.patch inside your htdocs dir:

--- zm_html_styles.css.orig 2007-06-24 09:34:13.000000000 +0100
+++ zm_html_styles.css 2007-06-24 09:39:34.000000000 +0100
@@ -54,6 +54,11 @@
color: #688E23;
font-weight: bold;
}
+.blutext {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10px;
+ color: #7F7Fb2;
+}
.redtextem {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
@@ -98,6 +103,7 @@
color: #7F7FB2;
text-decoration: none;
}
+}
a:visited {
color: #7F7FB2;
text-decoration: none;

and the following into zm_html_view_console.php.patch:
--- zm_html_view_console.php.orig 2007-06-24 09:33:27.000000000 +0100
+++ zm_html_view_console.php 2007-06-24 09:32:42.000000000 +0100
@@ -399,6 +399,44 @@
<?php
}
?>
+
+
+<tr>
+<td align="center" class="blutext">&nbsp</td>
+<td align="left" class="blutext">Night</td>
+<td align="center" class="blutext">&nbsp</td>
+<td align="center" class="blutext">&nbsp</td>
+<?php>
+
+$query = "select count(if(StartTime>date_add(NOW(), INTERVAL -1 MONTH),1,NULL)) as monthcount,count(if(StartTime>date_add(NOW(), INTERVAL -1 WEEK),1,NULL)) as weekcount,count(if(StartTime>date_add(NOW(), INTERVAL -1 DAY),1,NULL)) as daycount, count(*) as allcount from Events where ((extract(HOUR_MINUTE from StartTime) >= '2100') and (extract(HOUR_MINUTE from StartTime) <= '2359')) or ((extract(HOUR_MINUTE from StartTime) >= '0000') and (extract(HOUR_MINUTE from StartTime) < '0800'))";
+
+$result = mysql_query($query);
+ $row = mysql_fetch_assoc( result, MYSQL_NUM );
+
+while($row = mysql_fetch_array($result, MYSQL_NUM))
+{
+ $countnightmonth = $row[0];
+ $countnightweek = $row[1];
+ $countnightday = $row[2];
+ $countnightall = $row[3];
+}
+?>
+
+<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&trms=4&obr1=1&attr1=Time&op1=%3C=&val1=0800&cnj2=and&attr2=Time&op2=%3E=&val2=0000&cbr2=1&cnj3=or&obr3=1&attr3=Time&op3=%3C=&val3=2359&cnj4=and&attr4=Time&op4=%3E=&val4=2100&cbr4=1', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $countnightall, canView( 'Events' ) ) ?></td>
+
+<td align="center" class="blutext">&nbsp</td>
+
+<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&trms=7&obr1=1&attr1=DateTime&op1=%3E%3D&val1=-1day&cnj2=and&attr2=Time&op2=%3C=&val2=0800&cnj3=and&attr3=Time&op3=%3E=&val3=0000&cbr3=1&cnj4=or&obr4=1&attr4=DateTime&op4=%3E=&val4=-1%20day&%20cnj5=and&attr5=DateTime&op5=%3C=&val5=-0%20day&cnj6=and&attr6=Time&op6=%3C=&val6=2359&cnj7=and&attr7=Time&op7=%3E=&val7=2100&cbr7=1', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $countnightday, canView( 'Events' ) ) ?></td>
+
+<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&trms=7&obr1=1&attr1=DateTime&op1=%3E%3D&val1=-1week&cnj2=and&attr2=Time&op2=%3C=&val2=0800&cnj3=and&attr3=Time&op3=%3E=&val3=0000&cbr3=1&cnj4=or&obr4=1&attr4=DateTime&op4=%3E=&val4=-1%20week&%20cnj5=and&attr5=DateTime&op5=%3C=&val5=-0%20week&cnj6=and&attr6=Time&op6=%3C=&val6=2359&cnj7=and&attr7=Time&op7=%3E=&val7=2100&cbr7=1', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $countnightweek, canView( 'Events' ) ) ?></td>
+
+<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&trms=7&obr1=1&attr1=DateTime&op1=%3E%3D&val1=-1month&cnj2=and&attr2=Time&op2=%3C=&val2=0800&cnj3=and&attr3=Time&op3=%3E=&val3=0000&cbr3=1&cnj4=or&obr4=1&attr4=DateTime&op4=%3E=&val4=-1%20month&%20cnj5=and&attr5=DateTime&op5=%3C=&val5=-0%20month&cnj6=and&attr6=Time&op6=%3C=&val6=2359&cnj7=and&attr7=Time&op7=%3E=&val7=2100&cbr7=1', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $countnightmonth, canView( 'Events' ) ) ?></td>
+
+</tr>
+
+
+
+
<tr>
<td colspan="4" align="center">
<table align="center" border="0" cellspacing="0" cellpadding="0" width="100%">

Of course you should change all the times to when you find suitable.

You should then be able to cd into htdocs and run:
patch -p0 < zm_html_view_console.php.patch
patch -p0 < zm_html_styles.css.patch

Could this be added in to a future version, as I find it quite convenient? Obviously it could be done better, with the ability to switch it on/off and change times in the ZM options page.

Apologies for any shoddy coding in there!
Hope someone finds it useful anyway.
P.S. Thanks to Cordel for his help with the original time queries
Post Reply