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 : objects.php
11 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
12 ** VERSION NUMBER : $Revision: 1.6 $
14 ** DESCRIPTION : Objects Administration page.
15 ** Input parameters: action (POST) : empty, 'Create'
16 ** objname (POST) : name of the object to create or remove
21 ***************************************************************************
22 ** ADMINISTRATIVE INFORMATION *
23 ********************************
24 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
25 ** CREATION DATE : Dec 04, 2002
26 ** LAST UPDATE : Feb 14, 2003
28 **************************************************************************/
30 /*****************************
32 Revision 1.6 2003-02-21 08:46:58 arjen
33 Improved the table layout.
35 Revision 1.5 2003/02/13 09:01:29 arjen
36 All web interface pages use the page class.
38 Revision 1.4 2003/02/13 08:48:23 arjen
39 Added log, notification and parameter counters to the 'object' table.
40 Counting these things at the time a user interface needs them is
41 too slow. Other programs, like gcm_daemon en gcm_input should prepare
42 these counters for quick retrieval.
44 Revision 1.3 2003/02/10 15:42:24 arjen
45 Show the total number of Log entries, parameters and notifications
47 Revision 1.2 2003/02/05 09:48:14 arjen
48 Added display and handling of notifications
50 ******************************/
52 // RCSID = "$Id: objects.php,v 1.6 2003-02-21 08:46:58 arjen Exp $";
54 ini_set('include_path', '.:./classes:../phpclasses');
56 require_once('page.class.php');
58 function clientscripts()
62 <script language='JavaScript'>
64 function CheckCreate(f)
66 if (f.objectname.value == "")
68 alert("You must supply a name");
74 function CheckRemove(f)
76 var message = "Are you sure you want to remove object ";
77 message += f.objectname.value;
80 return confirm(message);
88 class object_page extends page
95 echo "<h1>Objects Administration</h1><hr>";
97 if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
99 pg_exec($this->database, "INSERT INTO object (objectname, log_count, parameter_count, notification_count)
100 VALUES ('" . $_POST['objectname'] . "', '0', '0', '0')");
103 if (isset($_POST['action']) && $_POST['action'] == 'Remove' && !empty($_POST['objectname']))
105 pg_exec($this->database, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
108 $res = pg_exec($this->database, "SELECT objectid,objectname, log_count, notification_count
109 FROM object ORDER BY objectname");
113 <tr><th>Object</th><th>Log entries</th>
114 <th>Parameters</th><th>Notifications</th>
120 //The counters are set to zero
122 $count_notifications = 0;
123 $count_parameters = 0;
125 while ($obj < pg_numrows($res))
127 $u = pg_fetch_object($res, $obj);
128 $nr_logs = $u->log_count;
129 $count_logs = $count_logs + $nr_logs;
131 $r = pg_exec ($this->database, "SELECT count(paramid) FROM parameter WHERE objectid=CAST('"
132 . $u->objectid . "' AS BIGINT)");
133 $r = pg_fetch_object($r, 0);
135 $nr_params = $r->count;
136 $count_parameters = $count_parameters + $nr_params;
138 $nr_notifications = $u->notification_count;
139 $count_notifications = $count_notifications + $nr_notifications;
141 <tr><td><center><img src='server.png'><br>
142 <b><?php echo $u->objectname ?></b></center>
143 </td><td class='number'>
144 <?php echo "<a href='log.php?oid=$u->objectid'> $nr_logs </a>" ?>
145 </td><td class='number'>
146 <?php echo "<a href='parameter.php?oid=$u->objectid'> $nr_params </a>" ?>
147 </td><td class='number'>
148 <?php echo "<a href='notification.php?oid=$u->objectid'> $nr_notifications </a>" ?>
150 <form action='objects.php' method='post' onSubmit='return CheckRemove(this)'>
151 <input type='hidden' name='objectname' value='<?php echo $u->objectname ?>'>
152 <input type='submit' name='action' value='Remove'>
160 echo "<tr><td><strong><B><br><br>TOTALS</B></strong></td>";
161 echo "<td class='number'>$count_logs</td>";
162 echo "<td class='number'>$count_parameters</td>";
163 echo "<td class='number'>$count_notifications</td></tr>";
168 <h2>Create new object:</h2>
171 <form action='objects.php' method='post' onSubmit='return CheckCreate(this)'>
172 Objects name (FQDN): <input name='objectname' type='text'>
174 <input type='submit' name='action' value='Create'>
182 $obj_page = new object_page("Gnucomo Objects Administration");
184 $obj_page->Showpage();