/[monit]/monit/validate.c
ViewVC logotype

Diff of /monit/validate.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.143 by martinp, Thu Sep 1 01:10:27 2005 UTC revision 1.144 by martinp, Mon Sep 5 09:51:38 2005 UTC
# Line 178  int check_process(Service_T s) { Line 178  int check_process(Service_T s) {
178    if(!(pid= Util_isProcessRunning(s))) {    if(!(pid= Util_isProcessRunning(s))) {
179      /* Reset the service info object to prevent false data in the first run */      /* Reset the service info object to prevent false data in the first run */
180      Util_resetInfo(s);      Util_resetInfo(s);
181      Event_post(s, EVENT_NONEXIST, TRUE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_FAILED, s->action_NONEXIST,
182        "'%s' process is not running", s->name);        "'%s' process is not running", s->name);
183      return FALSE;      return FALSE;
184    } else {    } else {
185      Event_post(s, EVENT_NONEXIST, FALSE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_PASSED, s->action_NONEXIST,
186        "'%s' process is running with pid %d", s->name, (int)pid);        "'%s' process is running with pid %d", s->name, (int)pid);
187    }    }
188    
# Line 224  int check_device(Service_T s) { Line 224  int check_device(Service_T s) {
224    ASSERT(s);    ASSERT(s);
225    
226    if(stat(s->path, &stat_buf) != 0) {    if(stat(s->path, &stat_buf) != 0) {
227      Event_post(s, EVENT_NONEXIST, TRUE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_FAILED, s->action_NONEXIST,
228        "'%s' device doesn't exist", s->name);        "'%s' device doesn't exist", s->name);
229      return FALSE;      return FALSE;
230    } else {    } else {
231      s->inf->st_mode= stat_buf.st_mode;      s->inf->st_mode= stat_buf.st_mode;
232      s->inf->st_uid= stat_buf.st_uid;      s->inf->st_uid= stat_buf.st_uid;
233      s->inf->st_gid= stat_buf.st_gid;      s->inf->st_gid= stat_buf.st_gid;
234      Event_post(s, EVENT_NONEXIST, FALSE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_PASSED, s->action_NONEXIST,
235        "'%s' device exist", s->name);        "'%s' device exist", s->name);
236    }    }
237    
238    if(!device_usage(s->inf, s->path)) {    if(!device_usage(s->inf, s->path)) {
239      Event_post(s, EVENT_DATA, TRUE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_FAILED, s->action_DATA,
240        "'%s' unable to read device %s state", s->name, s->path);        "'%s' unable to read device %s state", s->name, s->path);
241      return FALSE;      return FALSE;
242    } else {    } else {
# Line 248  int check_device(Service_T s) { Line 248  int check_device(Service_T s) {
248              (float)s->inf->f_blocks);              (float)s->inf->f_blocks);
249      s->inf->inode_total= s->inf->f_files - s->inf->f_filesfree;      s->inf->inode_total= s->inf->f_files - s->inf->f_filesfree;
250      s->inf->space_total= s->inf->f_blocks - s->inf->f_blocksfreetotal;      s->inf->space_total= s->inf->f_blocks - s->inf->f_blocksfreetotal;
251      Event_post(s, EVENT_DATA, FALSE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_PASSED, s->action_DATA,
252        "'%s' succeeded getting device statistic for %s", s->name, s->path);        "'%s' succeeded getting device statistic for %s", s->name, s->path);
253    }    }
254    
# Line 281  int check_file(Service_T s) { Line 281  int check_file(Service_T s) {
281    ASSERT(s);    ASSERT(s);
282    
283    if(stat(s->path, &stat_buf) != 0) {    if(stat(s->path, &stat_buf) != 0) {
284      Event_post(s, EVENT_NONEXIST, TRUE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_FAILED, s->action_NONEXIST,
285        "'%s' file doesn't exist", s->name);        "'%s' file doesn't exist", s->name);
286      return FALSE;      return FALSE;
287    } else {    } else {
# Line 298  int check_file(Service_T s) { Line 298  int check_file(Service_T s) {
298      s->inf->st_size= stat_buf.st_size;      s->inf->st_size= stat_buf.st_size;
299      s->inf->timestamp= MAX(stat_buf.st_mtime, stat_buf.st_ctime);      s->inf->timestamp= MAX(stat_buf.st_mtime, stat_buf.st_ctime);
300      DEBUG("'%s' file existence check passed\n", s->name);      DEBUG("'%s' file existence check passed\n", s->name);
301      Event_post(s, EVENT_NONEXIST, FALSE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_PASSED, s->action_NONEXIST,
302        "'%s' file exist", s->name);        "'%s' file exist", s->name);
303    }    }
304    
305    if(!S_ISREG(s->inf->st_mode)) {    if(!S_ISREG(s->inf->st_mode)) {
306      Event_post(s, EVENT_INVALID, TRUE, s->action_INVALID,      Event_post(s, EVENT_INVALID, STATE_FAILED, s->action_INVALID,
307        "'%s' is not regular file", s->name);        "'%s' is not regular file", s->name);
308      return FALSE;      return FALSE;
309    } else {    } else {
310      DEBUG("'%s' is regular file\n", s->name);      DEBUG("'%s' is regular file\n", s->name);
311      Event_post(s, EVENT_INVALID, FALSE, s->action_INVALID,      Event_post(s, EVENT_INVALID, STATE_PASSED, s->action_INVALID,
312        "'%s' is regular file", s->name);        "'%s' is regular file", s->name);
313    }    }
314    
# Line 349  int check_directory(Service_T s) { Line 349  int check_directory(Service_T s) {
349    ASSERT(s);    ASSERT(s);
350    
351    if(stat(s->path, &stat_buf) != 0) {    if(stat(s->path, &stat_buf) != 0) {
352      Event_post(s, EVENT_NONEXIST, TRUE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_FAILED, s->action_NONEXIST,
353        "'%s' directory doesn't exist", s->name);        "'%s' directory doesn't exist", s->name);
354      return FALSE;      return FALSE;
355    } else {    } else {
# Line 358  int check_directory(Service_T s) { Line 358  int check_directory(Service_T s) {
358      s->inf->st_gid= stat_buf.st_gid;      s->inf->st_gid= stat_buf.st_gid;
359      s->inf->timestamp= MAX(stat_buf.st_mtime, stat_buf.st_ctime);      s->inf->timestamp= MAX(stat_buf.st_mtime, stat_buf.st_ctime);
360      DEBUG("'%s' directory existence check passed\n", s->name);      DEBUG("'%s' directory existence check passed\n", s->name);
361      Event_post(s, EVENT_NONEXIST, FALSE, s->action_NONEXIST,      Event_post(s, EVENT_NONEXIST, STATE_PASSED, s->action_NONEXIST,
362        "'%s' directory exist", s->name);        "'%s' directory exist", s->name);
363    }    }
364    
365    if(!S_ISDIR(s->inf->st_mode)) {    if(!S_ISDIR(s->inf->st_mode)) {
366      Event_post(s, EVENT_INVALID, TRUE, s->action_INVALID,      Event_post(s, EVENT_INVALID, STATE_FAILED, s->action_INVALID,
367        "'%s' is not directory", s->name);        "'%s' is not directory", s->name);
368      return FALSE;      return FALSE;
369    } else {    } else {
370      DEBUG("'%s' is directory\n", s->name);      DEBUG("'%s' is directory\n", s->name);
371      Event_post(s, EVENT_INVALID, FALSE, s->action_INVALID,      Event_post(s, EVENT_INVALID, STATE_PASSED, s->action_INVALID,
372        "'%s' is directory", s->name);        "'%s' is directory", s->name);
373    }    }
374    
# Line 413  int check_remote_host(Service_T s) { Line 413  int check_remote_host(Service_T s) {
413          if(icmp->response < 0) {          if(icmp->response < 0) {
414            icmp->is_available= FALSE;            icmp->is_available= FALSE;
415            DEBUG("'%s' icmp ping failed\n", s->name);            DEBUG("'%s' icmp ping failed\n", s->name);
416            Event_post(s, EVENT_ICMP, TRUE, icmp->action,            Event_post(s, EVENT_ICMP, STATE_FAILED, icmp->action,
417              "'%s' failed ICMP test [%s]", s->name, icmpnames[icmp->type]);              "'%s' failed ICMP test [%s]", s->name, icmpnames[icmp->type]);
418          } else {          } else {
419            icmp->is_available= TRUE;            icmp->is_available= TRUE;
420            DEBUG("'%s' icmp ping succeeded [response time %.3fs]\n",            DEBUG("'%s' icmp ping succeeded [response time %.3fs]\n",
421              s->name, icmp->response);              s->name, icmp->response);
422            Event_post(s, EVENT_ICMP, FALSE, icmp->action,            Event_post(s, EVENT_ICMP, STATE_PASSED, icmp->action,
423              "'%s' passed ICMP test [%s]", s->name, icmpnames[icmp->type]);              "'%s' passed ICMP test [%s]", s->name, icmpnames[icmp->type]);
424          }          }
425          break;          break;
# Line 509  static void check_connection(Service_T s Line 509  static void check_connection(Service_T s
509    
510    if(!rv) {    if(!rv) {
511      p->is_available= FALSE;      p->is_available= FALSE;
512      Event_post(s, EVENT_CONNECTION, TRUE, p->action, report);      Event_post(s, EVENT_CONNECTION, STATE_FAILED, p->action, report);
513    } else {    } else {
514      p->is_available= TRUE;      p->is_available= TRUE;
515      Event_post(s, EVENT_CONNECTION, FALSE, p->action,      Event_post(s, EVENT_CONNECTION, STATE_PASSED, p->action,
516        "'%s' connection passed", s->name);        "'%s' connection passed", s->name);
517    }    }
518                
# Line 530  static void check_process_state(Service_ Line 530  static void check_process_state(Service_
530      /* We do not check the process anymore if it's a zombie      /* We do not check the process anymore if it's a zombie
531         since such a process is (usually) unmanageable */         since such a process is (usually) unmanageable */
532      Util_monitorUnset(s);      Util_monitorUnset(s);
533      Event_post(s, EVENT_DATA, TRUE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_FAILED, s->action_DATA,
534        "'%s' process with pid %d is a zombie", s->name, s->inf->pid);        "'%s' process with pid %d is a zombie", s->name, s->inf->pid);
535    } else {    } else {
536      DEBUG("'%s' zombie check passed [status_flag=%04x]\n",      DEBUG("'%s' zombie check passed [status_flag=%04x]\n",
537        s->name,  s->inf->status_flag);        s->name,  s->inf->status_flag);
538      Event_post(s, EVENT_DATA, FALSE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_PASSED, s->action_DATA,
539        "'%s' check process state passed", s->name);        "'%s' check process state passed", s->name);
540    }    }
541    
# Line 554  static void check_process_pid(Service_T Line 554  static void check_process_pid(Service_T
554      return;      return;
555    
556    if(s->inf->_pid != s->inf->pid) {    if(s->inf->_pid != s->inf->pid) {
557      Event_post(s, EVENT_CHANGED, TRUE, s->action_PID,      Event_post(s, EVENT_CHANGED, STATE_FAILED, s->action_PID,
558        "'%s' process PID changed to %d", s->name, s->inf->pid);        "'%s' process PID changed to %d", s->name, s->inf->pid);
559    } else {    } else {
560      DEBUG("'%s' PID has not changed since last cycle\n", s->name);      DEBUG("'%s' PID has not changed since last cycle\n", s->name);
561      Event_post(s, EVENT_CHANGED, FALSE, s->action_PID,      Event_post(s, EVENT_CHANGED, STATE_PASSED, s->action_PID,
562        "'%s' PID has not changed", s->name);        "'%s' PID has not changed", s->name);
563    }    }
564  }  }
# Line 576  static void check_process_ppid(Service_T Line 576  static void check_process_ppid(Service_T
576      return;      return;
577    
578    if(s->inf->_ppid != s->inf->ppid) {    if(s->inf->_ppid != s->inf->ppid) {
579      Event_post(s, EVENT_CHANGED, TRUE, s->action_PPID,      Event_post(s, EVENT_CHANGED, STATE_FAILED, s->action_PPID,
580        "'%s' process PPID changed to %d", s->name, s->inf->ppid);        "'%s' process PPID changed to %d", s->name, s->inf->ppid);
581    } else {    } else {
582      DEBUG("'%s' PPID has not changed since last cycle\n", s->name);      DEBUG("'%s' PPID has not changed since last cycle\n", s->name);
583      Event_post(s, EVENT_CHANGED, FALSE, s->action_PPID,      Event_post(s, EVENT_CHANGED, STATE_PASSED, s->action_PPID,
584        "'%s' PPID has not changed", s->name);        "'%s' PPID has not changed", s->name);
585    }    }
586  }  }
# Line 726  static void check_process_resources(Serv Line 726  static void check_process_resources(Serv
726      return;      return;
727    }    }
728    
729    if(okay && pr->cycle > 0) {    if(! okay) {
730      pr->cycle--;      Event_post(s, EVENT_RESOURCE, STATE_FAILED, pr->action, report);
   } else if(! okay) {  
     pr->cycle++;  
   }  
   
   if(pr->cycle >= pr->max_cycle) {  
     pr->cycle=0;  
     Event_post(s, EVENT_RESOURCE, TRUE, pr->action, report);  
731    } else {    } else {
732      Event_post(s, EVENT_RESOURCE, FALSE, pr->action,      Event_post(s, EVENT_RESOURCE, STATE_PASSED, pr->action,
733        "'%s' resource passed", s->name);        "'%s' resource passed", s->name);
734    }    }
735        
# Line 760  static void check_checksum(Service_T s) Line 753  static void check_checksum(Service_T s)
753    
754    if(s->inf->cs_sum) {    if(s->inf->cs_sum) {
755    
756      Event_post(s, EVENT_DATA, FALSE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_PASSED, s->action_DATA,
757        "'%s' checksum computed for %s", s->name, s->path);        "'%s' checksum computed for %s", s->name, s->path);
758    
759      switch(cs->type) {      switch(cs->type) {
# Line 780  static void check_checksum(Service_T s) Line 773  static void check_checksum(Service_T s)
773    
774        /* if we are testing for changes only, the value is variable */        /* if we are testing for changes only, the value is variable */
775        if(cs->test_changes) {        if(cs->test_changes) {
776            Event_post(s, EVENT_CHANGED, STATE_FAILED, cs->action,
777              "'%s' checksum was changed for %s", s->name, s->path);
778          /* reset expected value for next cycle */          /* reset expected value for next cycle */
779          FREE(cs->hash);          FREE(cs->hash);
780          cs->hash= xstrdup(s->inf->cs_sum);          cs->hash= xstrdup(s->inf->cs_sum);
         Event_post(s, EVENT_CHANGED, TRUE, cs->action,  
           "'%s' checksum was changed for %s", s->name, s->path);  
781        } else {        } else {
782          /* we are testing constant value for failed or passed state */          /* we are testing constant value for failed or passed state */
783          Event_post(s, EVENT_CHECKSUM, TRUE, cs->action,          Event_post(s, EVENT_CHECKSUM, STATE_FAILED, cs->action,
784            "'%s' checksum test failed for %s", s->name, s->path);            "'%s' checksum test failed for %s", s->name, s->path);
785        }        }
786    
787      } else if(cs->test_changes) {      } else if(cs->test_changes) {
788    
789        DEBUG("'%s' checksum has not changed\n", s->name);        DEBUG("'%s' checksum has not changed\n", s->name);
790        Event_post(s, EVENT_CHANGED, FALSE, cs->action,        Event_post(s, EVENT_CHANGED, STATE_PASSED, cs->action,
791          "'%s' checksum has not changed", s->name);          "'%s' checksum has not changed", s->name);
792    
793      } else {      } else {
794    
795        DEBUG("'%s' has valid checksums\n", s->name);        DEBUG("'%s' has valid checksums\n", s->name);
796        Event_post(s, EVENT_CHECKSUM, FALSE, cs->action,        Event_post(s, EVENT_CHECKSUM, STATE_PASSED, cs->action,
797          "'%s' checksum passed", s->name);          "'%s' checksum passed", s->name);
798    
799      }      }
# Line 809  static void check_checksum(Service_T s) Line 802  static void check_checksum(Service_T s)
802    
803    }    }
804    
805    Event_post(s, EVENT_DATA, TRUE, s->action_DATA,    Event_post(s, EVENT_DATA, STATE_FAILED, s->action_DATA,
806      "'%s' cannot compute checksum for %s", s->name, s->path);      "'%s' cannot compute checksum for %s", s->name, s->path);
807    
808  }  }
# Line 823  static void check_perm(Service_T s) { Line 816  static void check_perm(Service_T s) {
816    ASSERT(s && s->perm);    ASSERT(s && s->perm);
817    
818    if((s->inf->st_mode & 07777) != s->perm->perm) {    if((s->inf->st_mode & 07777) != s->perm->perm) {
819      Event_post(s, EVENT_PERMISSION, TRUE, s->perm->action,      Event_post(s, EVENT_PERMISSION, STATE_FAILED, s->perm->action,
820        "'%s' permission test failed for %s -- current permission is %o",        "'%s' permission test failed for %s -- current permission is %o",
821        s->name, s->path, s->inf->st_mode&07777);        s->name, s->path, s->inf->st_mode&07777);
822    } else {    } else {
823      DEBUG("'%s' permission check passed [current permission=%o]\n",      DEBUG("'%s' permission check passed [current permission=%o]\n",
824        s->name, s->inf->st_mode&07777);        s->name, s->inf->st_mode&07777);
825      Event_post(s, EVENT_PERMISSION, FALSE, s->perm->action,      Event_post(s, EVENT_PERMISSION, STATE_PASSED, s->perm->action,
826        "'%s' permission passed", s->name);        "'%s' permission passed", s->name);
827    }    }
828  }  }
# Line 843  static void check_uid(Service_T s) { Line 836  static void check_uid(Service_T s) {
836    ASSERT(s && s->uid);    ASSERT(s && s->uid);
837    
838    if(s->inf->st_uid != s->uid->uid) {    if(s->inf->st_uid != s->uid->uid) {
839      Event_post(s, EVENT_UID, TRUE, s->uid->action,      Event_post(s, EVENT_UID, STATE_FAILED, s->uid->action,
840        "'%s' uid test failed for %s -- current uid is %d",        "'%s' uid test failed for %s -- current uid is %d",
841        s->name, s->path, (int)s->inf->st_uid);        s->name, s->path, (int)s->inf->st_uid);
842    } else {    } else {
843      DEBUG("'%s' uid check passed [current uid=%d]\n", s->name,      DEBUG("'%s' uid check passed [current uid=%d]\n", s->name,
844            (int)s->inf->st_uid);            (int)s->inf->st_uid);
845      Event_post(s, EVENT_UID, FALSE, s->uid->action, "'%s' uid passed", s->name);      Event_post(s, EVENT_UID, STATE_PASSED, s->uid->action, "'%s' uid passed", s->name);
846    }    }
847    
848  }  }
# Line 863  static void check_gid(Service_T s) { Line 856  static void check_gid(Service_T s) {
856    ASSERT(s && s->gid);    ASSERT(s && s->gid);
857    
858    if(s->inf->st_gid != s->gid->gid ) {    if(s->inf->st_gid != s->gid->gid ) {
859      Event_post(s, EVENT_GID, TRUE, s->gid->action,      Event_post(s, EVENT_GID, STATE_FAILED, s->gid->action,
860        "'%s' gid test failed for %s -- current gid is %d",        "'%s' gid test failed for %s -- current gid is %d",
861        s->name, s->path, (int)s->inf->st_gid);        s->name, s->path, (int)s->inf->st_gid);
862    } else {    } else {
863      DEBUG("'%s' gid check passed [current gid=%d]\n", s->name,      DEBUG("'%s' gid check passed [current gid=%d]\n", s->name,
864            (int)s->inf->st_gid);            (int)s->inf->st_gid);
865      Event_post(s, EVENT_GID, FALSE, s->gid->action, "'%s' gid passed", s->name);      Event_post(s, EVENT_GID, STATE_PASSED, s->gid->action, "'%s' gid passed", s->name);
866    }    }
867    
868  }  }
# Line 887  static void check_timestamp(Service_T s) Line 880  static void check_timestamp(Service_T s)
880    
881    
882    if((int)time(&now) == -1) {    if((int)time(&now) == -1) {
883      Event_post(s, EVENT_DATA, TRUE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_FAILED, s->action_DATA,
884        "'%s' can't obtain actual system time", s->name);        "'%s' can't obtain actual system time", s->name);
885      return;      return;
886    } else {    } else {
887      Event_post(s, EVENT_DATA, FALSE, s->action_DATA,      Event_post(s, EVENT_DATA, STATE_PASSED, s->action_DATA,
888        "'%s' actual system time obtained", s->name);        "'%s' actual system time obtained", s->name);
889    }    }
890    
# Line 899  static void check_timestamp(Service_T s) Line 892  static void check_timestamp(Service_T s)
892      if(t->test_changes) {      if(t->test_changes) {
893      /* if we are testing for changes only, the value is variable */      /* if we are testing for changes only, the value is variable */
894        if(t->timestamp != s->inf->timestamp) {        if(t->timestamp != s->inf->timestamp) {
895          Event_post(s, EVENT_CHANGED, TRUE, t->action,          Event_post(s, EVENT_CHANGED, STATE_FAILED, t->action,
896            "'%s' timestamp was changed for %s", s->name, s->path);            "'%s' timestamp was changed for %s", s->name, s->path);
897          /* reset expected value for next cycle */          /* reset expected value for next cycle */
898          t->timestamp= s->inf->timestamp;          t->timestamp= s->inf->timestamp;
899        } else {        } else {
900          DEBUG("'%s' timestamp was not changed for %s\n", s->name, s->path);          DEBUG("'%s' timestamp was not changed for %s\n", s->name, s->path);
901          Event_post(s, EVENT_CHANGED, FALSE, t->action,          Event_post(s, EVENT_CHANGED, STATE_PASSED, t->action,
902            "'%s' timestamp was not changed for %s", s->name, s->path);            "'%s' timestamp was not changed for %s", s->name, s->path);
903        }        }
904        break;        break;
905      } else {      } else {
906      /* we are testing constant value for failed or passed state */      /* we are testing constant value for failed or passed state */
907        if(Util_evalQExpression(t->operator, (int)(now - s->inf->timestamp), t->time)) {        if(Util_evalQExpression(t->operator, (int)(now - s->inf->timestamp), t->time)) {
908          Event_post(s, EVENT_TIMESTAMP, TRUE, t->action,          Event_post(s, EVENT_TIMESTAMP, STATE_FAILED, t->action,
909            "'%s' timestamp test failed for %s", s->name, s->path);            "'%s' timestamp test failed for %s", s->name, s->path);
910        } else {        } else {
911          DEBUG("'%s' timestamp test passed for %s\n", s->name, s->path);          DEBUG("'%s' timestamp test passed for %s\n", s->name, s->path);
912          Event_post(s, EVENT_TIMESTAMP, FALSE, t->action,          Event_post(s, EVENT_TIMESTAMP, STATE_PASSED, t->action,
913            "'%s' timestamp passed", s->name);            "'%s' timestamp passed", s->name);
914        }        }
915      }      }
# Line 938  static void check_size(Service_T s) { Line 931  static void check_size(Service_T s) {
931      /* if we are testing for changes only, the value is variable */      /* if we are testing for changes only, the value is variable */
932      if(sl->test_changes) {      if(sl->test_changes) {
933        if(sl->size != s->inf->st_size) {        if(sl->size != s->inf->st_size) {
934          Event_post(s, EVENT_CHANGED, TRUE, sl->action,          Event_post(s, EVENT_CHANGED, STATE_FAILED, sl->action,
935            "'%s' size was changed for %s", s->name, s->path);            "'%s' size was changed for %s", s->name, s->path);
936          /* reset expected value for next cycle */          /* reset expected value for next cycle */
937          sl->size= s->inf->st_size;          sl->size= s->inf->st_size;
938        } else {        } else {
939          DEBUG("'%s' size has not changed [current size=%lu B]\n", s->name,          DEBUG("'%s' size has not changed [current size=%lu B]\n", s->name,
940                s->inf->st_size);                s->inf->st_size);
941          Event_post(s, EVENT_CHANGED, FALSE, sl->action,          Event_post(s, EVENT_CHANGED, STATE_PASSED, sl->action,
942            "'%s' size was not changed", s->name, s->path);            "'%s' size was not changed", s->name, s->path);
943        }        }
944        break;        break;
# Line 953  static void check_size(Service_T s) { Line 946  static void check_size(Service_T s) {
946    
947      /* we are testing constant value for failed or passed state */      /* we are testing constant value for failed or passed state */
948      if(Util_evalQExpression(sl->operator, s->inf->st_size, sl->size)) {      if(Util_evalQExpression(sl->operator, s->inf->st_size, sl->size)) {
949        Event_post(s, EVENT_SIZE, TRUE, sl->action,        Event_post(s, EVENT_SIZE, STATE_FAILED, sl->action,
950          "'%s' size test failed for %s -- current size is %lu B",          "'%s' size test failed for %s -- current size is %lu B",
951          s->name, s->path, s->inf->st_size);          s->name, s->path, s->inf->st_size);
952      } else {      } else {
953        DEBUG("'%s' file size check passed [current size=%lu B]\n", s->name,        DEBUG("'%s' file size check passed [current size=%lu B]\n", s->name,
954              s->inf->st_size);              s->inf->st_size);
955        Event_post(s, EVENT_SIZE, FALSE, sl->action, "'%s' size passed", s->name);        Event_post(s, EVENT_SIZE, STATE_PASSED, sl->action, "'%s' size passed", s->name);
956      }      }
957    }    }
958  }  }
# Line 1152  static void check_size(Service_T s) { Line 1145  static void check_size(Service_T s) {
1145            return;            return;
1146          }          }
1147                    
1148          Event_post(s, EVENT_MATCH, TRUE, ml->action,          Event_post(s, EVENT_MATCH, STATE_FAILED, ml->action,
1149                     "'%s' content match "                     "'%s' content match "
1150                     "[%s]",                     "[%s]",
1151                     s->name, line);                     s->name, line);
# Line 1194  static void check_device_resources(Servi Line 1187  static void check_device_resources(Servi
1187    
1188        if(td->limit_percent >= 0) {        if(td->limit_percent >= 0) {
1189          if(Util_evalQExpression( td->operator, s->inf->inode_percent, td->limit_percent)) {          if(Util_evalQExpression( td->operator, s->inf->inode_percent, td->limit_percent)) {
1190            Event_post(s, EVENT_RESOURCE, TRUE, td->action,            Event_post(s, EVENT_RESOURCE, STATE_FAILED, td->action,
1191              "'%s' inode usage %.1f%% matches resource limit [inode usage%s%.1f%%]",              "'%s' inode usage %.1f%% matches resource limit [inode usage%s%.1f%%]",
1192              s->name,              s->name,
1193              s->inf->inode_percent/10.,              s->inf->inode_percent/10.,
# Line 1204  static void check_device_resources(Servi Line 1197  static void check_device_resources(Servi
1197          }          }
1198        } else {        } else {
1199          if(Util_evalQExpression(td->operator, s->inf->inode_total, td->limit_absolute)) {          if(Util_evalQExpression(td->operator, s->inf->inode_total, td->limit_absolute)) {
1200            Event_post(s, EVENT_RESOURCE, TRUE, td->action,            Event_post(s, EVENT_RESOURCE, STATE_FAILED, td->action,
1201              "'%s' inode usage %ld matches resource limit [inode usage%s%ld]",              "'%s' inode usage %ld matches resource limit [inode usage%s%ld]",
1202              s->name,              s->name,
1203              s->inf->inode_total,              s->inf->inode_total,
# Line 1215  static void check_device_resources(Servi Line 1208  static void check_device_resources(Servi
1208        }        }
1209        DEBUG("'%s' inode usage check passed [current inode usage=%.1f%%]\n",        DEBUG("'%s' inode usage check passed [current inode usage=%.1f%%]\n",
1210              s->name, s->inf->inode_percent/10.);              s->name, s->inf->inode_percent/10.);
1211        Event_post(s, EVENT_RESOURCE, FALSE, td->action,        Event_post(s, EVENT_RESOURCE, STATE_PASSED, td->action,
1212          "'%s' device resources passed", s->name);          "'%s' device resources passed", s->name);
1213        return;        return;
1214    
1215    case RESOURCE_ID_SPACE:    case RESOURCE_ID_SPACE:
1216        if(td->limit_percent >= 0) {        if(td->limit_percent >= 0) {
1217          if(Util_evalQExpression( td->operator, s->inf->space_percent, td->limit_percent)) {          if(Util_evalQExpression( td->operator, s->inf->space_percent, td->limit_percent)) {
1218            Event_post(s, EVENT_RESOURCE, TRUE, td->action,            Event_post(s, EVENT_RESOURCE, STATE_FAILED, td->action,
1219              "'%s' space usage %.1f%% matches resource limit [space usage%s%.1f%%]",              "'%s' space usage %.1f%% matches resource limit [space usage%s%.1f%%]",
1220              s->name,              s->name,
1221              s->inf->space_percent/10.,              s->inf->space_percent/10.,
# Line 1232  static void check_device_resources(Servi Line 1225  static void check_device_resources(Servi
1225          }          }
1226        } else {        } else {
1227          if(Util_evalQExpression(td->operator, s->inf->space_total, td->limit_absolute)) {          if(Util_evalQExpression(td->operator, s->inf->space_total, td->limit_absolute)) {
1228            Event_post(s, EVENT_RESOURCE, TRUE, td->action,            Event_post(s, EVENT_RESOURCE, STATE_FAILED, td->action,
1229              "'%s' space usage %ld blocks matches resource limit "              "'%s' space usage %ld blocks matches resource limit "
1230              "[space usage%s%ld blocks]",              "[space usage%s%ld blocks]",
1231              s->name,              s->name,
# Line 1244  static void check_device_resources(Servi Line 1237  static void check_device_resources(Servi
1237        }        }
1238        DEBUG("'%s' space usage check passed [current space usage=%.1f%%]\n",        DEBUG("'%s' space usage check passed [current space usage=%.1f%%]\n",
1239              s->name, s->inf->space_percent/10.);              s->name, s->inf->space_percent/10.);
1240        Event_post(s, EVENT_RESOURCE, FALSE, td->action,        Event_post(s, EVENT_RESOURCE, STATE_PASSED, td->action,
1241          "'%s' device resources passed", s->name);          "'%s' device resources passed", s->name);
1242        return;        return;
1243                
# Line 1276  static int check_timeout(Service_T s) { Line 1269  static int check_timeout(Service_T s) {
1269     * Check timeout     * Check timeout
1270     */     */
1271    if(s->nstart >= s->to_start && s->ncycle <= s->to_cycle) {    if(s->nstart >= s->to_start && s->ncycle <= s->to_cycle) {
1272      Event_post(s, EVENT_TIMEOUT, TRUE, s->action_TIMEOUT,      Event_post(s, EVENT_TIMEOUT, STATE_FAILED, s->action_TIMEOUT,
1273                "'%s' service timed out and will not be checked anymore",                "'%s' service timed out and will not be checked anymore",
1274                s->name);                s->name);
1275      return TRUE;      return TRUE;

Legend:
Removed from v.1.143  
changed lines
  Added in v.1.144

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26