Hello,

I've been experimenting with using ganglios to monitor our machines, and I've run into a couple small problems.

The first is that /proc/mounts looks like this for us (debian sarge, 2.6.8-2-686-smp). I don't know why it's /dev2 instead of /dev, our /dev directory is normal, there is no /dev2 in the file system.

station17$ more /proc/mounts
rootfs / rootfs rw 0 0
/dev2/root2 / xfs rw 0 0
proc /proc proc rw,nodiratime 0 0
sysfs /sys sysfs rw 0 0
...

This change allows ganglia to report free disk correctly:

station17$ cvs diff -r ganglia-3-0-1-20051004 srclib/libmetrics/linux/metrics.c
Index: srclib/libmetrics/linux/metrics.c
===================================================================
RCS file: /cvs/ganglia/srclib/libmetrics/linux/metrics.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -r1.3 -r1.4
1188c1188,1189
<       if (strncmp(device, "/dev/", 5)) continue;
---
>       if (strncmp(device, "/dev/", 5) != 0 &&
>         strncmp(device, "/dev2/", 6) != 0) continue;


The second problem: We need daemons we run to put a pid in /var/run/whatever so they can be watched with monit, etc.

I've added this function to daemon_init.c and I call it from gmond.c and gmetad.c. I'm not familiar enough with the code to know where this should go, so I'll offer this instead of a patch:


/**
 * @fn void update_pidfile (const char *pname)
 * @param argv0 name of this program
 */

void
update_pidfile (const char *argv0)
{
  pid_t pid;
  static char pidfile[ 256 ];
  const char *myname;
  FILE *file;

  myname = strrchr (argv0, '/');
  if (! myname)
    myname = argv0;
snprintf (pidfile, sizeof (pidfile), "%s/run/%s.pid", localstatedir, myname);

  /* make sure this program isn't already running. */
  file = fopen (pidfile, "r");
  if (file)
    {
      if (fscanf(file, "%d", &pid) == 1 &&
          getpgid (pid) > -1)
        {
          fprintf (stderr, "%s is already running: pid %d\n", myname, pid);
          exit (1);
        }
      close (file);
    }

  /* write the pid of this process to the pidfile */
  umask(0112);
  unlink(pidfile);

  file = fopen (pidfile, "w");
  if (!file)
    {
      fprintf (stderr, "%s: Error writing pidfile '%s' -- %s\n",
               argv0, pidfile, strerror (errno));
      exit (1);
    }
  fprintf (file, "%d\n", (int) getpid());
  fclose (file);
}


        -seth


Reply via email to