monit_process.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C), 2000-2002 by Contributors to the monit codebase. 
00003  * All Rights Reserved.
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018  */
00019 
00020 #include "config.h"
00021 
00022 #ifdef HAVE_SYS_TYPES_H
00023 #include <sys/types.h>
00024 #endif
00025 
00026 #ifdef HAVE_SYS_STAT_H
00027 #include <sys/stat.h>
00028 #endif
00029 
00030 #ifdef HAVE_FCNTL_H
00031 #include <fcntl.h>
00032 #endif
00033 
00034 #ifdef HAVE_STDLIB_H
00035 #include <stdlib.h>
00036 #endif
00037 
00038 #ifdef TIME_WITH_SYS_TIME
00039 #include <time.h>
00040 
00041 #ifdef HAVE_SYS_TIME
00042 #include <sys/time.h>
00043 #endif
00044 #else
00045 #include <time.h>
00046 #endif
00047 
00048 #ifdef HAVE_SYS_LOADAVG_H
00049 #include <sys/loadavg.h>
00050 #endif
00051 
00052 #ifdef HAVE_STRING_H
00053 #include <string.h>
00054 #endif
00055 
00056 #include <stdio.h>
00057 
00058 #include "monitor.h"
00059 #include "monit_process.h"
00060 #include "process/process.h"
00061 
00074 /* ------------------------------------------------------------------ Public */
00075 
00076 char actionnames[][STRLEN]=   {"ignore", "alert", "restart", "stop"};
00077 char modenames[][STRLEN]=     {"active", "passive", "manual"};
00078 char operatorshortnames[][3]= {">", "<", "=", "!="};
00079 char operatornames[][STRLEN]= {"greater than", "less than", "equal to",
00080                                "not equal to"};
00081 
00082 int  include_children= TRUE;
00083 int  num_cpus=1;
00084 
00085 
00090 int init_process_info(void) {
00091 
00092   return (init_process_info_sysdep());
00093 
00094 }
00095 
00096 
00104 int update_process_data(Process_T p, pid_t pid) {
00105 
00106   ProcInfo_T pi;
00107 
00108   ASSERT(p);
00109   
00110   pi= p->procinfo;
00111   pi->pid=pid;
00112 
00113   if (! get_process_info(pi)) {
00114 
00115     return FALSE;
00116     
00117   } 
00118 
00119   return TRUE;
00120 }
00121 
00122 
00127 int update_loadavg(void) {
00128 
00129   if ( -1 == getloadavg( Run.loadavg, 3) ) {
00130 
00131     return FALSE;
00132 
00133   }
00134 
00135   return TRUE;
00136 }