pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/net-snmp - don't use getfsstat, use getvfsstat.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9557b2faa694
branches:  trunk
changeset: 514731:9557b2faa694
user:      christos <christos%pkgsrc.org@localhost>
date:      Sat Jun 17 17:20:56 2006 +0000

description:
- don't use getfsstat, use getvfsstat.
- add code to do disk i/o statistics for NetBSD and enable it.

diffstat:

 net/net-snmp/Makefile         |    8 +-
 net/net-snmp/distinfo         |    4 +-
 net/net-snmp/patches/patch-aa |   12 +++
 net/net-snmp/patches/patch-ab |  155 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 176 insertions(+), 3 deletions(-)

diffs (215 lines):

diff -r feea66e6dfbf -r 9557b2faa694 net/net-snmp/Makefile
--- a/net/net-snmp/Makefile     Sat Jun 17 17:17:00 2006 +0000
+++ b/net/net-snmp/Makefile     Sat Jun 17 17:20:56 2006 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.48 2006/03/19 22:03:29 joerg Exp $
+# $NetBSD: Makefile,v 1.49 2006/06/17 17:20:56 christos Exp $
 
 DISTNAME=      net-snmp-5.3.0.1
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    net
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE:=net-snmp/} \
                ftp://ftp.net-smnp.org/pub/sourceforge/net-snmp/
@@ -56,7 +56,11 @@
 .if !empty(NET_SNMP_MIBDIRS)
 CONFIGURE_ARGS+=       --with-mibdirs=${NET_SNMP_MIBDIRS:Q}
 .endif
+.if ${OPSYS} == "NetBSD"
+CONFIGURE_ARGS+=       --with-mib-modules="smux host ucd-snmp/diskio"
+.else
 CONFIGURE_ARGS+=       --with-mib-modules="smux host"
+.endif
 .if !empty(MACHINE_PLATFORM:MDarwin-[567].*)
 CONFIGURE_ARGS+=       --with-out-mib-modules="ucd-snmp/diskio mibII"
 .endif
diff -r feea66e6dfbf -r 9557b2faa694 net/net-snmp/distinfo
--- a/net/net-snmp/distinfo     Sat Jun 17 17:17:00 2006 +0000
+++ b/net/net-snmp/distinfo     Sat Jun 17 17:20:56 2006 +0000
@@ -1,8 +1,10 @@
-$NetBSD: distinfo,v 1.22 2006/03/19 22:03:29 joerg Exp $
+$NetBSD: distinfo,v 1.23 2006/06/17 17:20:56 christos Exp $
 
 SHA1 (net-snmp-5.3.0.1.tar.gz) = c58ddabe4281c3681a268bd48de6865e812f2ec5
 RMD160 (net-snmp-5.3.0.1.tar.gz) = 86b7e56b512faf73d2a08ac3df2def4560b62945
 Size (net-snmp-5.3.0.1.tar.gz) = 4183370 bytes
+SHA1 (patch-aa) = 30a4d1546fe7022a0578d01004fc3f284e45c392
+SHA1 (patch-ab) = e274e0a440e760a6c25b7c5311089e4138098ec6
 SHA1 (patch-ae) = 750412088b9ccd5fb50bd6e7fc049903f6113a39
 SHA1 (patch-af) = f7c95d2276ccd8332e7dc39f2bf88c857bdfde9f
 SHA1 (patch-ag) = 9bad3789cfb12bb68c2b306e82600d866467471a
diff -r feea66e6dfbf -r 9557b2faa694 net/net-snmp/patches/patch-aa
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/net-snmp/patches/patch-aa     Sat Jun 17 17:20:56 2006 +0000
@@ -0,0 +1,12 @@
+$NetBSD: patch-aa,v 1.5 2006/06/17 17:20:56 christos Exp $
+
+--- agent/mibgroup/host/hr_filesys.c.orig      2005-02-28 07:52:58.000000000 -0500
++++ agent/mibgroup/host/hr_filesys.c   2006-06-17 12:21:40.000000000 -0400
+@@ -88,6 +88,7 @@
+ 
+ #elif defined(HAVE_STATVFS) && defined(__NetBSD__)
+ 
++#define getfsstat getvfsstat
+ static struct statvfs *fsstats = NULL;
+ struct statvfs                *HRFS_entry;
+ static int            fscount;
diff -r feea66e6dfbf -r 9557b2faa694 net/net-snmp/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/net-snmp/patches/patch-ab     Sat Jun 17 17:20:56 2006 +0000
@@ -0,0 +1,155 @@
+$NetBSD: patch-ab,v 1.7 2006/06/17 17:20:56 christos Exp $
+
+--- agent/mibgroup/ucd-snmp/diskio.c.orig      2005-12-04 09:25:54.000000000 -0500
++++ agent/mibgroup/ucd-snmp/diskio.c   2006-06-17 13:09:51.000000000 -0400
+@@ -419,6 +419,150 @@
+ }
+ #endif                          /* bsdi */
+ 
++#ifdef __NetBSD__
++#include <sys/sysctl.h>
++static int      ndisk;
++static int nmib[2] = {CTL_HW, HW_DISKNAMES};
++#ifdef HW_DISKSTATS
++static int dmib[3] = {CTL_HW, HW_DISKSTATS, sizeof(struct disk_sysctl)};
++static struct disk_sysctl *dk;
++#endif
++#ifdef HW_IOSTATS
++#include <sys/iostat.h>
++static int dmib[3] = {CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)};
++static struct io_sysctl *dk;
++#endif
++static char   **dkname;
++
++static int
++getstats(void)
++{
++    time_t          now;
++    char           *t, *tp;
++    int             size, dkn_size, i;
++
++    now = time(NULL);
++    if (cache_time + CACHE_TIMEOUT > now) {
++        return 1;
++    }
++    size = 0;
++    if (sysctl(dmib, 3, NULL, &size, NULL, 0) < 0) {
++        perror("Can't get size of HW_DISKSTATS/HW_IOSTATS mib");
++        return 0;
++    }
++    if (ndisk != size / dmib[2]) {
++        if (dk)
++            free(dk);
++        if (dkname) {
++            for (i = 0; i < ndisk; i++)
++                if (dkname[i])
++                    free(dkname[i]);
++            free(dkname);
++        }
++        ndisk = size / dmib[2];
++        if (ndisk == 0)
++            return 0;
++        dkname = malloc(ndisk * sizeof(char *));
++        if (sysctl(nmib, 2, NULL, &dkn_size, NULL, 0) < 0) {
++            perror("Can't get size of HW_DISKNAMES mib");
++            return 0;
++        }
++        t = malloc(dkn_size);
++        if (sysctl(nmib, 2, t, &dkn_size, NULL, 0) < 0) {
++            perror("Can't get size of HW_DISKNAMES mib");
++            return 0;
++        }
++        for (i = 0, tp = strtok(t, " "); tp && i < ndisk; i++,
++          tp = strtok(NULL, " ")) {
++            dkname[i] = strdup(tp);
++        }
++        free(t);
++        dk = malloc(ndisk * sizeof(*dk));
++    }
++    if (sysctl(dmib, 3, dk, &size, NULL, 0) < 0) {
++        perror("Can't get HW_DISKSTATS/HW_IOSTATS mib");
++        return 0;
++    }
++    cache_time = now;
++    return 1;
++}
++
++u_char *
++var_diskio(struct variable * vp,
++           oid * name,
++           size_t * length,
++           int exact, size_t * var_len, WriteMethod ** write_method)
++{
++    static long     long_ret;
++    unsigned int    indx;
++
++    if (getstats() == 0)
++        return 0;
++
++    if (header_simple_table
++        (vp, name, length, exact, var_len, write_method, ndisk))
++        return NULL;
++
++    indx = (unsigned int) (name[*length - 1] - 1);
++    if (indx >= ndisk)
++        return NULL;
++
++    switch (vp->magic) {
++    case DISKIO_INDEX:
++        long_ret = (long) indx + 1;
++        return (u_char *) & long_ret;
++
++    case DISKIO_DEVICE:
++        *var_len = strlen(dkname[indx]);
++        return (u_char *) dkname[indx];
++
++    case DISKIO_NREAD:
++#ifdef HW_DISKSTATS
++      long_ret = dk[indx].dk_rbytes;
++#endif
++#ifdef HW_IOSTATS
++      if (dk[indx].type == IOSTAT_DISK)
++          long_ret = dk[indx].rbytes;
++#endif
++        return (u_char *) & long_ret;
++
++    case DISKIO_NWRITTEN:
++#ifdef HW_DISKSTATS
++      long_ret = dk[indx].dk_wbytes;
++#endif
++#ifdef HW_IOSTATS
++      if (dk[indx].type == IOSTAT_DISK)
++          long_ret = dk[indx].wbytes;
++#endif
++        return (u_char *) & long_ret;
++
++    case DISKIO_READS:
++#ifdef HW_DISKSTATS
++      long_ret = dk[indx].dk_rxfer;
++#endif
++#ifdef HW_IOSTATS
++      if (dk[indx].type == IOSTAT_DISK)
++          long_ret = dk[indx].rxfer;
++#endif
++        return (u_char *) & long_ret;
++
++    case DISKIO_WRITES:
++#ifdef HW_DISKSTATS
++      long_ret = dk[indx].dk_wxfer;
++#endif
++#ifdef HW_IOSTATS
++      if (dk[indx].type == IOSTAT_DISK)
++          long_ret = dk[indx].wxfer;
++#endif
++        return (u_char *) & long_ret;
++
++    default:
++        ERROR_MSG("diskio.c: don't know how to handle this request.");
++    }
++    return NULL;
++}
++#endif /* __NetBSD__ */
++
+ #if defined(freebsd4) || defined(freebsd5)
+ 
+ /* disk load average patch by Rojer */



Home | Main Index | Thread Index | Old Index