~ubuntu-branches/ubuntu/trusty/monit/trusty-proposed

« back to all changes in this revision

Viewing changes to src/process/sysdep_SOLARIS.c

  • Committer: Package Import Robot
  • Author(s): Sergey B Kirpichev
  • Date: 2013-09-05 17:03:07 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20130905170307-ae94md1vagm60e41
Tags: 1:5.6-1
ImportedĀ UpstreamĀ versionĀ 5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
#include <sys/sysinfo.h>
93
93
#endif
94
94
 
 
95
#ifdef HAVE_ZONE_H
 
96
#include <zone.h>
 
97
#endif
 
98
 
95
99
#include "monit.h"
96
100
#include "process.h"
97
101
#include "process_sysdep.h"
204
208
    pt[i].mem_kbyte = psinfo->pr_rssize;
205
209
 
206
210
    pt[i].cmdline  = Str_dup(psinfo->pr_psargs);
207
 
    if (! pt[i].cmdline || ! *pt[i].cmdline)
 
211
    if (! pt[i].cmdline || ! *pt[i].cmdline) {
 
212
      FREE(pt[i].cmdline);
208
213
      pt[i].cmdline = Str_dup(psinfo->pr_fname);
 
214
    }
209
215
 
210
216
    if (! read_proc_file(buf, sizeof(buf), "status", pt[i].pid, NULL)) {
211
217
      pt[i].cputime     = 0;
253
259
 
254
260
  /* Memory */
255
261
  kctl  = kstat_open();
256
 
  kstat = kstat_lookup(kctl, "unix", 0, "system_pages");
257
 
  if (kstat_read(kctl, kstat, 0) == -1) {
258
 
    LogError("system statistic error -- memory usage gathering failed\n");
259
 
    kstat_close(kctl);
260
 
    return FALSE;
 
262
  if (getzoneid() != GLOBAL_ZONEID && (kstat = kstat_lookup(kctl, "memory_cap", -1, NULL))) {
 
263
    /* Joyent SmartOS zone: reports wrong unix::system_pages:freemem in the zone - shows global zone freemem, witch to SmartOS specific memory_cap kstat */
 
264
    if (kstat_read(kctl, kstat, NULL) == -1) {
 
265
      LogError("system statistic error -- memory_cap usage gathering failed\n");
 
266
      kstat_close(kctl);
 
267
      return FALSE;
 
268
    }
 
269
    kstat_named_t *rss;
 
270
    if ((rss = (kstat_named_t *)kstat_data_lookup(kstat, "rss")))
 
271
      si->total_mem_kbyte = rss->value.i64 / 1024;
 
272
  } else {
 
273
    kstat = kstat_lookup(kctl, "unix", 0, "system_pages");
 
274
    if (kstat_read(kctl, kstat, 0) == -1) {
 
275
      LogError("system statistic error -- memory usage gathering failed\n");
 
276
      kstat_close(kctl);
 
277
      return FALSE;
 
278
    }
 
279
    knamed = kstat_data_lookup(kstat, "freemem");
 
280
    if (knamed)
 
281
      si->total_mem_kbyte = systeminfo.mem_kbyte_max - pagetok(knamed->value.ul);
261
282
  }
262
 
  knamed = kstat_data_lookup(kstat, "freemem");
263
 
  if (knamed)
264
 
    si->total_mem_kbyte = systeminfo.mem_kbyte_max-pagetok(knamed->value.ul);
265
283
  kstat_close(kctl);
266
284
 
267
285
 /* Swap */