Create separate notifications for different objects in service_check().
authorarjen <arjen>
Wed, 29 Oct 2003 09:58:29 +0000 (09:58 +0000)
committerarjen <arjen>
Wed, 29 Oct 2003 09:58:29 +0000 (09:58 +0000)
src/gcm_daemon/gcm_daemon.php

index 12ccdde..bd65a72 100755 (executable)
    Gnucomo-0.0.8: September 4th 2003
 
  $Log: gcm_daemon.php,v $
- Revision 1.16  2003-09-03 12:48:48  arjen
+ Revision 1.17  2003-10-29 09:58:29  arjen
+ Create separate notifications for different objects in service_check().
+
+ Revision 1.16  2003/09/03 12:48:48  arjen
  Check the log table against the servies running on an object and
  create notifications if a service is not supposed to be available
  or is not known at all.
@@ -56,7 +59,7 @@
 
 */
 
-// $Id: gcm_daemon.php,v 1.16 2003-09-03 12:48:48 arjen Exp $
+// $Id: gcm_daemon.php,v 1.17 2003-10-29 09:58:29 arjen Exp $
 
 ini_set('include_path', '.:./classes:../phpclasses');
 ini_set('html_errors', 'false');
@@ -453,8 +456,8 @@ function service_check()
 {
    global  $dbms;
 
-   $unknown_notification = 0;
-   $unused_notification  = 0;
+   $unknown_notification = array();
+   $unused_notification  = array();
    $last_log             = 0;
 
    //  How far did we get last time ?
@@ -501,30 +504,32 @@ function service_check()
 
          if ($dbms->num_rows($dbms->query($qry)) == 0)
          {
-            if ($unknown_notification == 0)
+            if (!isset($unknown_notification[$log_entry->objectid]))
             {
                $remark = "One or more log entries from a service that is not in the database";
-               $unknown_notification = $dbms->new_notification($log_entry->objectid, 'service unknown', $remark);
+               $unknown_notification[$log_entry->objectid] =
+                         $dbms->new_notification($log_entry->objectid, 'service unknown', $remark);
             }
-            if ($unknown_notification != 0)
+            if (isset($unknown_notification[$log_entry->objectid]))
             {
                $insertion = "INSERT INTO log_notification (notificationid, logid) VALUES ('";
-               $insertion .= $unknown_notification . "', '";
+               $insertion .= $unknown_notification[$log_entry->objectid] . "', '";
                $insertion .= $log_entry->logid . "')";
                $dbms->query($insertion);
             }
          }
          else
          {
-            if ($unused_notification == 0)
+            if (!isset($unused_notification[$log_entry->objectid]))
             {
                $remark = "One or more log entries from a service not running on this object";
-               $unused_notification = $dbms->new_notification($log_entry->objectid, 'service not used', $remark);
+               $unused_notification[$log_entry->objectid] =
+                         $dbms->new_notification($log_entry->objectid, 'service not used', $remark);
             }
-            if ($unused_notification != 0)
+            if (isset($unused_notification[$log_entry->objectid]))
             {
                $insertion = "INSERT INTO log_notification (notificationid, logid) VALUES ('";
-               $insertion .= $unused_notification . "', '";
+               $insertion .= $unused_notification[$log_entry->objectid] . "', '";
                $insertion .= $log_entry->logid . "')";
                $dbms->query($insertion);
             }