From: arjen Date: Tue, 2 Sep 2003 12:47:41 +0000 (+0000) Subject: BUGFIX: Secondary indices on log_notification were unique. X-Git-Tag: V0_0_8~11 X-Git-Url: http://www.andromeda.nl/gitweb/?p=gnucomo.git;a=commitdiff_plain;h=c33e4aa82d44900523d65c55ee795cb6db236f61 BUGFIX: Secondary indices on log_notification were unique. Additional information in the 'usr' table: 'display_name' and 'email'. Added new issues and services. --- diff --git a/src/database/create.sql b/src/database/create.sql index 3ce7098..e497a25 100644 --- a/src/database/create.sql +++ b/src/database/create.sql @@ -12,7 +12,12 @@ -- DBA create the database and give access permissions. -- -- $Log: create.sql,v $ --- Revision 1.16 2003-08-16 14:29:02 arjen +-- Revision 1.17 2003-09-02 12:49:47 arjen +-- BUGFIX: Secondary indices on log_notification were unique. +-- Additional information in the 'usr' table: 'display_name' and 'email'. +-- Added new issues and services. +-- +-- Revision 1.16 2003/08/16 14:29:02 arjen -- Fixed a few typos. -- -- Revision 1.15 2003/08/05 07:43:24 arjen @@ -102,7 +107,7 @@ CREATE UNIQUE INDEX act_actionname ON "action" USING btree (actionname); CREATE INDEX act_statuscode ON "action" USING btree (statuscode); -SELECT setval ('"action_actionid_seq"', 19, true); +SELECT setval ('"action_actionid_seq"', 21, true); -- -- @@ -146,7 +151,7 @@ CREATE TABLE "db_value" COPY "db_value" FROM stdin; -db_version 41 +db_version 43 gcm_daemon_version 5 log_processing 0 last_notification 0 @@ -321,9 +326,9 @@ CREATE TABLE "log_notification" CREATE UNIQUE INDEX lon_pk ON log_notification USING btree (notificationid, logid); -CREATE UNIQUE INDEX lon_notificationid ON log_notification USING btree (notificationid); +CREATE INDEX lon_notificationid ON log_notification USING btree (notificationid); -CREATE UNIQUE INDEX lon_logid ON log_notification USING btree (logid); +CREATE INDEX lon_logid ON log_notification USING btree (logid); -- -- @@ -669,6 +674,18 @@ kernel kernel 1 5 sshd sshd 1 5 su su 1 5 syslogd syslogd 1 5 +CROND Cron Daemon 1 5 +gnucomo Gnucomo Daemon 1 5 +sendmail Mail Transport Agent 1 5 +dhcpd DHCP Daemon 1 5 +rpc NFS Services 1 5 +named DNS Services 1 5 +xinetd Internet Daemon 1 5 +ipop Post Office Protocol 1 5 +mgetty Serial port login and fax 1 5 +login User login 1 5 +pam Authentication modules 1 5 +modprobe Kernel modules 1 5 \. CREATE UNIQUE INDEX ser_pk ON service USING btree (servicecode); @@ -738,6 +755,8 @@ COPY "type_of_issue" FROM stdin; 2 parameter created 3 A new parameter was created t 3 property modified 3 The STATIC property of a parameter was modified t 4 parameter removed 3 A parameter was removed t +5 service unknown 5 Service in log entry is unknown t +6 service not used 5 Service in log entry is not used t \. CREATE UNIQUE INDEX type_of_issue_type_of_issue_key ON type_of_issue USING btree (type_of_issueid); @@ -746,7 +765,7 @@ CREATE UNIQUE INDEX toi_name ON type_of_issue USING btree (name); CREATE INDEX toi_active ON type_of_issue USING btree (active); -SELECT setval ('"type_of_issue_type_of_issue_seq"', 4, true); +SELECT setval ('"type_of_issue_type_of_issue_seq"', 6, true); -- -- @@ -756,7 +775,9 @@ CREATE TABLE "usr" "username" text NOT NULL, "active_sessionid" bigint, "account_active" boolean, - "security_level" integer + "security_level" integer, + display_name text, + email text ); CREATE UNIQUE INDEX usr_username ON usr USING btree (username); diff --git a/src/gcm_daemon/classes/gnucomo_db_version.php b/src/gcm_daemon/classes/gnucomo_db_version.php index caea052..a83930a 100644 --- a/src/gcm_daemon/classes/gnucomo_db_version.php +++ b/src/gcm_daemon/classes/gnucomo_db_version.php @@ -15,7 +15,7 @@ case 1: //DROP the rule that prohibits updates (change of spec). $local_sql = "DROP RULE log_update"; -// $dbms->query($local_sql); DISABLED FOR NEW ROLE LOG-tABLE + $dbms->query($local_sql); //DISABLED FOR NEW ROLE LOG-tABLE ??? case 2: //In the log table processed should be false by default @@ -168,21 +168,21 @@ $dbms->query($local_sql); case 18: - $local_sql = "UPDATE action SET actionname = 'Investigation completed', statuscode = 'PEN', description = 'Investigation has been done.' "; + $local_sql = "UPDATE action SET actionname = 'Investigation completed', statuscode = 'PEN', description = 'Investigation has been done. Information is available to fix the problem.' "; $local_sql .= "WHERE actionid = '9'"; $dbms->query($local_sql); case 19: - $local_sql = "insert into type_of_issue (name, suggested_priority, description)"; - $local_sql .= " values ('parameter created',3,'A new parameter was created')"; + $local_sql = "insert into type_of_issue (name, suggested_priority, description, active)"; + $local_sql .= " values ('parameter created',3,'A new parameter was created', true)"; $dbms->query($local_sql); - $local_sql = "insert into type_of_issue (name, suggested_priority, description)"; - $local_sql .= " values ('property modified',3,'The STATIC property of a parameter was modified')"; + $local_sql = "insert into type_of_issue (name, suggested_priority, description, active)"; + $local_sql .= " values ('property modified',3,'The STATIC property of a parameter was modified', true)"; $dbms->query($local_sql); - $local_sql = "insert into type_of_issue (name, suggested_priority, description)"; - $local_sql .= " values ('parameter removed',3,'A parameter was removed') "; + $local_sql = "insert into type_of_issue (name, suggested_priority, description, active)"; + $local_sql .= " values ('parameter removed',3,'A parameter was removed', true) "; $dbms->query($local_sql); case 20: @@ -360,7 +360,7 @@ case 37: $local_sql = "ALTER TABLE notification_check ADD COLUMN type_of_issueid BIGINT"; $dbms->query($local_sql); - $local_sql = "ALTER TABLE notification_check ALTER COLUMN decreasinglist SET DEFAULT 'FALSE'"; + $local_sql = "ALTER TABLE notification_check ALTER COLUMN decreasinglist SET DEFAULT false"; $dbms->query($local_sql); $local_sql = "CREATE SEQUENCE checklineid_seq"; @@ -376,10 +376,10 @@ case 37: $local_sql = "ALTER TABLE notification_check_line ALTER COLUMN historicboundary SET DEFAULT '0'"; $dbms->query($local_sql); - $local_sql = "ALTER TABLE notification_check_line ALTER COLUMN use_logid SET DEFAULT 'FALSE'"; + $local_sql = "ALTER TABLE notification_check_line ALTER COLUMN use_logid SET DEFAULT false"; $dbms->query($local_sql); - $local_sql = "ALTER TABLE notification_check_line ALTER COLUMN last_logid SET DEFAULT '0'"; + $local_sql = "ALTER TABLE notification_check_line ALTER COLUMN last_logid SET DEFAULT 0"; $dbms->query($local_sql); case 38: @@ -429,6 +429,63 @@ case 41: $local_sql = "CREATE INDEX history_pid_mod ON history(paramid, modified)"; $dbms->query($local_sql); +case 42: + + // The secondary indices on log_notification should not be unique + + $local_sql = "DROP INDEX lon_notificationid"; + $dbms->query($local_sql); + $local_sql = "CREATE INDEX lon_notificationid ON log_notification USING btree (notificationid)"; + $dbms->query($local_sql); + + $local_sql = "DROP INDEX lon_logid"; + $dbms->query($local_sql); + $local_sql = "CREATE INDEX lon_logid ON log_notification USING btree (logid)"; + $dbms->query($local_sql); + + // Additional information for the users + + $local_sql = "ALTER TABLE usr ADD COLUMN display_name text"; + $dbms->query($local_sql); + $local_sql = "ALTER TABLE usr ADD COLUMN email text"; + $dbms->query($local_sql); + + // Add issues for the services check + + $local_sql = "INSERT INTO type_of_issue (name, suggested_priority, description, active)"; + $local_sql .= " VALUES ('service unknown',5,'Service in log entry is unknown', true) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO type_of_issue (name, suggested_priority, description, active)"; + $local_sql .= " VALUES ('service not used',5,'Service in log entry is not used', true) "; + $dbms->query($local_sql); + + // Add a few more services + + $local_sql = "INSERT INTO service VALUES ('CROND','Cron Daemon', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('gnucomo','Gnucomo Daemon', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('sendmail','Mail Transport Agent', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('dhcpd','DHCP Daemon', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('rpc','NFS Services', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('named','DNS Services', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('xinetd','Internet Daemon', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('ipop','Post Office Protocol', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('mgetty','Serial port login and fax', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('login','User login', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('pam','Authentication modules', 1, 5) "; + $dbms->query($local_sql); + $local_sql = "INSERT INTO service VALUES ('modprobe','Kernel modules', 1, 5) "; + $dbms->query($local_sql); + //These columns have to be removed when a new version of PGSQL has become mainstream that supportsa DROP COLUMN /* diff --git a/src/gcm_daemon/gcm_daemon.php b/src/gcm_daemon/gcm_daemon.php index 958895a..7a38aba 100755 --- a/src/gcm_daemon/gcm_daemon.php +++ b/src/gcm_daemon/gcm_daemon.php @@ -19,7 +19,12 @@ Gnucomo-0.0.3: December 6th 2002 $Log: gcm_daemon.php,v $ - Revision 1.14 2003-09-01 06:51:07 arjen + Revision 1.15 2003-09-02 12:48:09 arjen + BUGFIX: Secondary indices on log_notification were unique. + Additional information in the 'usr' table: 'display_name' and 'email'. + Added new issues and services. + + Revision 1.14 2003/09/01 06:51:07 arjen Accept command argument '-c config' to use an alternate gnucomo configuration. @@ -45,7 +50,7 @@ */ -// $Id: gcm_daemon.php,v 1.14 2003-09-01 06:51:07 arjen Exp $ +// $Id: gcm_daemon.php,v 1.15 2003-09-02 12:48:09 arjen Exp $ ini_set('include_path', '.:./classes:../phpclasses'); ini_set('html_errors', 'false'); @@ -62,7 +67,7 @@ require_once "gnucomo.process_log.php"; $project_name = "gnucomo"; // name of the entire project $app_name = "gcm_daemon"; // name of the application running $developrelease = "FALSE"; // Indicates if special debug settings are needed -$db_version = 42; // The db_version indicates what the level of +$db_version = 43; // The db_version indicates what the level of // the database should be. If the database is // old an update will be generated. $gcmd_version = 5; // This value indicates the active version of @@ -196,6 +201,7 @@ do //At this place we start processing new log-lines process_log (); + //service_check(); find_notifications(); $keep_running = false; @@ -430,8 +436,55 @@ function GatherStatistics($objectid) UpdateStatistic($objectid, 'logs', $cnt->count); } +/* + * Service_check - Check the log entries if there are any unknown + * services. + */ + +function service_check() +{ + global $dbms; + + $log_res = $dbms->query("SELECT objectid, servicecode,rawdata FROM log"); + + for ($log_row = 0; $log_row < $dbms->num_rows($log_res); $log_row++) + { + $log_entry = $dbms->fetch_object($log_res, $log_row); + + // Check if the service is used on the object. + + $qry = "SELECT * FROM object_service WHERE objectid='"; + $qry .= $log_entry->objectid . "' AND servicecode='"; + $qry .= $log_entry->servicecode . "'"; + + $os_res = $dbms->query($qry); + if ($dbms->num_rows($os_res) == 0) + { + // Service is not found for the object, check if the service + // exists at all. -function find_notifications () { + $qry = "SELECT * FROM service WHERE servicecode='"; + $qry .= $log_entry->servicecode . "'"; + + if ($dbms->num_rows($dbms->query($qry)) == 0) + { + echo "Service " . $log_entry->servicecode . " does not exist.\n"; + } + else + { + $qry = "SELECT objectname FROM object WHERE objectid='"; + $qry .= $log_entry->objectid . "'"; + $object = $dbms->fetch_object($dbms->query($qry), 0); + echo "Service " . $log_entry->servicecode . " is not used on "; + echo $object->objectname . ".\n"; + } + echo $log_entry->rawdata . "\n"; + } + } +} + +function find_notifications () +{ /* * Do something with notification checks.