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

Diff of /monit/process.c

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

revision 1.25 by martinp, Sat Nov 5 14:09:01 2005 UTC revision 1.26 by martinp, Fri Nov 18 22:52:39 2005 UTC
# Line 78  char operatornames[][STRLEN]= {"greater Line 78  char operatornames[][STRLEN]= {"greater
78  char operatorshortnames[][3]= {">", "<", "=", "!="};  char operatorshortnames[][3]= {">", "<", "=", "!="};
79  char monitornames[][STRLEN]=  {"not monitored", "monitored", "initializing"};  char monitornames[][STRLEN]=  {"not monitored", "monitored", "initializing"};
80  char statusnames[][STRLEN]=   {"accessible", "accessible", "accessible",  char statusnames[][STRLEN]=   {"accessible", "accessible", "accessible",
81                                 "running", "online with all services"};                                 "running", "online with all services",
82                                   "running"};
83  char servicetypes[][STRLEN]=  {"Device", "Directory", "File", "Process",  char servicetypes[][STRLEN]=  {"Device", "Directory", "File", "Process",
84                                 "Remote Host", "System"};                                 "Remote Host", "System"};
85  char pathnames[][STRLEN]=     {"Path", "Path", "Path", "Pid file", "Path"};  char pathnames[][STRLEN]=     {"Path", "Path", "Path", "Pid file", "Path", ""};
86  char icmpnames[][STRLEN]=     {"Echo Reply", "", "", "Destination Unreachable",  char icmpnames[][STRLEN]=     {"Echo Reply", "", "", "Destination Unreachable",
87                                 "Source Quench", "Redirect", "", "",                                 "Source Quench", "Redirect", "", "",
88                                 "Echo Request", "", "", "Time Exceeded",                                 "Echo Request", "", "", "Time Exceeded",
# Line 197  int update_system_load(ProcessTree_T *pt Line 198  int update_system_load(ProcessTree_T *pt
198      /** Get load average triplet */      /** Get load average triplet */
199      if(-1 == getloadavg_sysdep(systeminfo.loadavg, 3))      if(-1 == getloadavg_sysdep(systeminfo.loadavg, 3))
200      {      {
201        log("'system' statistic error -- load average gathering failed\n");        log("'%s' statistic error -- load average gathering failed\n",
202            Run.system->name);
203        goto error1;        goto error1;
204      }      }
     DEBUG("'system' load average [%.2f][%.2f][%.2f]\n",  
       systeminfo.loadavg[0],  
       systeminfo.loadavg[1],  
       systeminfo.loadavg[2]);  
205    
206      /** Get real memory usage statistic */      /** Get real memory usage statistic */
207      if(!used_system_memory_sysdep(&systeminfo))      if(!used_system_memory_sysdep(&systeminfo))
208      {      {
209        DEBUG("'system' statistic -- memory usage gathering method fallback\n");        DEBUG("'%s' statistic -- memory usage gathering method fallback\n",
210            Run.system->name);
211        /* Update the total real memory usage by monitoring process with PID 1 */        /* Update the total real memory usage by monitoring process with PID 1 */
212        if((leaf = findprocess(1, pt, treesize)) && leaf->mem_kbyte_sum > 0)        if((leaf = findprocess(1, pt, treesize)) && leaf->mem_kbyte_sum > 0)
213        {        {
# Line 216  int update_system_load(ProcessTree_T *pt Line 215  int update_system_load(ProcessTree_T *pt
215        }        }
216        else        else
217        {        {
218          log("'system' statistic error -- memory usage gathering failed\n");          log("'%s' statistic error -- memory usage gathering failed\n",
219              Run.system->name);
220          goto error2;          goto error2;
221        }        }
222      }      }
223      systeminfo.total_mem_percent = (int)(1000 *      systeminfo.total_mem_percent = (int)(1000 *
224        (double)systeminfo.total_mem_kbyte / (double)systeminfo.mem_kbyte_max);        (double)systeminfo.total_mem_kbyte / (double)systeminfo.mem_kbyte_max);
     DEBUG("'system' memory usage %.1f%% [%ld kB]\n",  
       systeminfo.total_mem_percent / 10.,  
       systeminfo.total_mem_kbyte);  
225    
226      /** Get CPU usage statistic */      /** Get CPU usage statistic */
227      if(!used_system_cpu_sysdep(&systeminfo))      if(!used_system_cpu_sysdep(&systeminfo))
228      {      {
229        DEBUG("'system' statistic -- cpu usage gathering method fallback\n");        DEBUG("'%s' statistic -- cpu usage gathering method fallback\n",
230            Run.system->name);
231        /* Update the total CPU load by monitoring process with PID 1 */        /* Update the total CPU load by monitoring process with PID 1 */
232        if((leaf = findprocess(1, pt, treesize)))        if((leaf = findprocess(1, pt, treesize)))
233        {        {
# Line 239  int update_system_load(ProcessTree_T *pt Line 237  int update_system_load(ProcessTree_T *pt
237        }        }
238        else        else
239        {        {
240          log("'system' statistic error -- cpu usage gathering failed\n");          log("'%s' statistic error -- cpu usage gathering failed\n",
241              Run.system->name);
242          goto error3;          goto error3;
243        }        }
244      }      }
     DEBUG("'system' cpu usage %.1f%%us %.1f%%sy %.1f%%wa\n",  
       systeminfo.total_cpu_user_percent / 10.,  
       systeminfo.total_cpu_syst_percent / 10.,  
       systeminfo.total_cpu_wait_percent / 10.);  
245    
246      return TRUE;      return TRUE;
247    }    }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

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