pcp
[Top] [All Lists]

[PATCH 07/12] Fix distro reporting on Debian

To: Michael Newton <kimbrr@xxxxxxx>, Mark Goodwin <markgw@xxxxxxx>
Subject: [PATCH 07/12] Fix distro reporting on Debian
From: Nathan Scott <nscott@xxxxxxxxxx>
Date: Mon, 20 Nov 2006 16:10:34 +1100
Cc: pcp@xxxxxxxxxxx
Organization: Aconex
Reply-to: nscott@xxxxxxxxxx
Sender: pcp-bounce@xxxxxxxxxxx
This patch adds support for the Debian distribution into the Linux PMDA,
alongside the existing RH/SuSE values.

-- 
Nathan

Index: devel-pcp-2.5.99/src/pmdas/linux/pmda.c
===================================================================
--- devel-pcp-2.5.99.orig/src/pmdas/linux/pmda.c 2006-11-20
11:28:56.653481750 +1100
+++ devel-pcp-2.5.99/src/pmdas/linux/pmda.c 2006-11-20
11:40:33.657041750 +1100
@@ -3896,8 +3896,10 @@ linux_fetchCallBack(pmdaMetric *mdesc, u
* more
*/
struct stat sbuf;
- int r, fd = -1;
+ int r, fd = -1, len = 0;
+ char prefix[16];
char *rfiles[] = {
+ "/etc/debian_version",
"/etc/fedora-release",
"/etc/redhat-release",
"/etc/SuSE-release",
@@ -3909,14 +3911,19 @@ linux_fetchCallBack(pmdaMetric *mdesc, u
    }
}
if (fd != -1) {
+     if (r == 0) { /* Debian, needs prefix */
+ strncpy(prefix, "Debian ", sizeof(prefix));
+ len = 7;
+     }
    /*
     * at this point, assume sbuf is good and file contains
     * the string we want, probably with a \n terminator
     */
-     distro_name = (char *)malloc((int)sbuf.st_size+1);
-
+     distro_name = (char *)malloc(len + (int)sbuf.st_size + 1);
    if (distro_name != NULL) {
- r = read(fd, distro_name, (int)sbuf.st_size);
+ if (len)
+     strncpy(distro_name, prefix, len);
+ r = read(fd, distro_name + len, (int)sbuf.st_size);
close(fd);
if (r <= 0) {
    free (distro_name);



<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 07/12] Fix distro reporting on Debian, Nathan Scott <=