3 /**************************************************************************
4 ** (c) Copyright 2003, Andromeda Technology & Automation
5 ** This is free software; you can redistribute it and/or modify it under the
6 ** terms of the GNU General Public License, see the file COPYING.
7 ***************************************************************************
8 ** MODULE INFORMATION *
9 ***********************
10 ** FILE NAME : log.php
11 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
12 ** VERSION NUMBER : $Revision: 1.4 $
14 ** DESCRIPTION : Logs page
19 ***************************************************************************
20 ** ADMINISTRATIVE INFORMATION *
21 ********************************
22 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
23 ** CREATION DATE : Dec 04, 2002
24 ** LAST UPDATE : Jul 15, 2003
26 **************************************************************************/
28 /*****************************
30 Revision 1.4 2003-07-15 11:03:39 arjen
31 Show the log one day at a time.
33 Revision 1.3 2003/02/21 08:50:12 arjen
34 Database optimizations.
36 Revision 1.2 2003/02/13 09:01:29 arjen
37 All web interface pages use the page class.
39 Revision 1.2 2003/02/05 09:48:14 arjen
40 Added display and handling of notifications
42 ******************************/
44 // RCSID = "$Id: log.php,v 1.4 2003-07-15 11:03:39 arjen Exp $";
46 ini_set('include_path', '.:./classes:../phpclasses');
48 require_once('page.class.php');
51 class log_page extends page
56 if (!empty($_GET['oid']))
58 $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=CAST('" . $_GET['oid']. "' AS BIGINT)");
59 $obj = pg_fetch_object($res, 0);
60 echo "<h1>Log for " . $obj->objectname . "</h1><hr>";
62 // Determine which day to display.
63 // This is either from a previous button though a _POST[] variable
64 // or the last day in the log table by default.
66 if (empty($_POST['logday']))
68 $res = pg_exec($this->database, "SELECT date_trunc('day',object_timestamp) FROM log
69 WHERE objectid='". $_GET['oid'] ."'
70 ORDER BY object_timestamp DESC LIMIT 1");
72 $last_time = pg_fetch_object($res, 0);
73 $logday = strtotime($last_time->date_trunc);
77 $logday = $_POST['logday'];
80 // Make buttons to request the previous and the next day of logs.
82 echo "<form method='POST'>";
83 echo "<input type='submit' value='<<'>";
84 echo "<input type='hidden' name='logday' value='" . ($logday - 24 * 60 * 60) . "'>";
87 echo "<h3>" . date('F d, Y', $logday) ."</h3>";
89 echo "<form method='POST'>";
90 echo "<input type='submit' value='>>'>";
91 echo "<input type='hidden' name='logday' value='" . ($logday + 24 * 60 * 60) . "'>";
94 // Show the log for one day only.
96 $res = pg_exec($this->database, "SELECT object_timestamp, servicecode, rawdata FROM log "
97 ."WHERE objectid = CAST('" . $_GET['oid'] . "' AS BIGINT)
98 AND date_trunc('day', object_timestamp)='" . date('Y-m-d', $logday) . "'
99 ORDER BY object_timestamp");
102 echo "<tr><th>Date</th><th>Service</th><th>Log</th></tr>\n";
104 while ($row < pg_numrows($res))
106 $log = pg_fetch_object($res, $row);
108 <tr><td class='time'>
109 <?php echo $log->object_timestamp?>
111 <?php echo $log->servicecode?>
113 <?php echo $log->rawdata?>
123 $page = new log_page("Gnucomo system logs");