Added log, notification and parameter counters to the 'object' table.
authorarjen <arjen>
Thu, 13 Feb 2003 08:46:54 +0000 (08:46 +0000)
committerarjen <arjen>
Thu, 13 Feb 2003 08:46:54 +0000 (08:46 +0000)
Counting these things at the time a user interface needs them is
too slow. Other programs, like gcm_daemon en gcm_input should prepare
these counters for quick retrieval.

src/database/create.sql
src/web/objects.php

index 38fa870..b2105ae 100644 (file)
 -- DBA create the database and give access permissions.
 --
 --  $Log: create.sql,v $
---  Revision 1.8  2003-02-08 07:36:41  arjen
+--  Revision 1.9  2003-02-13 08:46:54  arjen
+--  Added log, notification and parameter counters to the 'object' table.
+--  Counting these things at the time a user interface needs them is
+--  too slow. Other programs, like gcm_daemon en gcm_input should prepare
+--  these counters for quick retrieval.
+--
+--  Revision 1.8  2003/02/08 07:36:41  arjen
 --  Added new table to the database : log_adv_daemon
 --
 --  Revision 1.7  2003/02/05 09:29:08  arjen
@@ -112,9 +118,10 @@ CREATE TABLE "db_value"
 
 
 COPY "db_value" FROM stdin;
-db_version     21
+db_version     28
 gcm_daemon_version     1
 log_processing 0
+last_notification      0
 \.
 
 --
@@ -324,7 +331,10 @@ CREATE TABLE "object"
        "timezone" text,
        "remark" text,
         "os"     text,
-        "os_version"   text
+        "os_version"   text,
+        "log_count"    bigint,
+        "notification_count"   bigint,
+        "parameter_count"      bigint
 );
 
 CREATE UNIQUE INDEX object_objectid_key ON object USING btree (objectid);
@@ -588,7 +598,7 @@ CREATE TABLE "type_of_issue"
 COPY "type_of_issue" FROM stdin;
 1      manual entry    4       A manual entry of a notification        t
 2      parameter created       3       A new parameter was created     t
-3      property modified       3       The STATIC property of a parameter was modified t
+3      property modified       3       The STATIC property of a parameter was modified t
 4      parameter removed       3       A parameter was removed t
 \.
 
index e322a04..6c7120b 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : objects.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.3 $
+**      VERSION NUMBER : $Revision: 1.4 $
 **
 **  DESCRIPTION      : Objects Administration page.
 **                     Input parameters: action (POST) : empty, 'Create'
 
 /*****************************
    $Log: objects.php,v $
-   Revision 1.3  2003-02-10 15:42:24  arjen
+   Revision 1.4  2003-02-13 08:48:23  arjen
+   Added log, notification and parameter counters to the 'object' table.
+   Counting these things at the time a user interface needs them is
+   too slow. Other programs, like gcm_daemon en gcm_input should prepare
+   these counters for quick retrieval.
+
+   Revision 1.3  2003/02/10 15:42:24  arjen
    Show the total number of Log entries, parameters and notifications
 
    Revision 1.2  2003/02/05 09:48:14  arjen
@@ -37,7 +43,7 @@
 
 ******************************/
 
-// RCSID = "$Id: objects.php,v 1.3 2003-02-10 15:42:24 arjen Exp $";
+// RCSID = "$Id: objects.php,v 1.4 2003-02-13 08:48:23 arjen Exp $";
 
 session_start();
 require_once('classes/gnucomo_config.php');
@@ -93,8 +99,8 @@ else
 
    if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
    {
-      pg_exec($conn, "INSERT INTO object (objectname) VALUES ('"
-                     . $_POST['objectname'] . "')");
+      pg_exec($conn, "INSERT INTO object (objectname, log_count, parameter_count, notification_count) VALUES ('"
+                     . $_POST['objectname'] . "', '0', '0', '0')");
    }
 
    if (isset($_POST['action']) && $_POST['action'] == 'Remove' && !empty($_POST['objectname']))
@@ -102,7 +108,7 @@ else
       pg_exec($conn, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
    }
 
-   $res = pg_exec($conn, "SELECT objectid,objectname FROM object");
+   $res = pg_exec($conn, "SELECT objectid,objectname, log_count, notification_count FROM object ORDER BY objectname");
 
    echo "<table>";
    $obj = 0;
@@ -115,11 +121,7 @@ else
    while ($obj < pg_numrows($res))
    {
       $u = pg_fetch_object($res, $obj);
-      $r = pg_exec($conn, "SELECT count(logid) FROM log WHERE objectid='"
-                           . $u->objectid . "'");
-      $r = pg_fetch_object($r, 0);
-
-      $nr_logs = $r->count;
+      $nr_logs = $u->log_count;
       $count_logs = $count_logs + $nr_logs; 
 
       $r = pg_exec ($conn, "SELECT count(paramid) FROM parameter WHERE objectid='"
@@ -129,16 +131,12 @@ else
       $nr_params = $r->count;
       $count_parameters = $count_parameters + $nr_params;
 
-      $r = pg_exec ($conn, "SELECT count(notificationid) FROM notification WHERE objectid='"
-                           . $u->objectid . "'");
-      $r = pg_fetch_object($r, 0);
-
-      $nr_notifications = $r->count;
+      $nr_notifications = $u->notification_count;
       $count_notifications = $count_notifications + $nr_notifications;
       ?>
       <tr><td align='center'><img src='server.png'><br>
              <b><?php echo $u->objectname ?></b>
-      </td><td>
+      </td><td align='right'>
           <?php echo $nr_logs?> <a href='log.php?oid=<?php echo $u->objectid?>'>Log entries</a>
       </td><td>
           <?php echo $nr_params?> <a href='parameter.php?oid=<?php echo $u->objectid?>'>Parameters</a>