diff options
Diffstat (limited to 'sysutils')
14 files changed, 862 insertions, 207 deletions
diff --git a/sysutils/ganglia-monitor-core/Makefile b/sysutils/ganglia-monitor-core/Makefile index c1d97ce7348b..52e4d38ec6c6 100644 --- a/sysutils/ganglia-monitor-core/Makefile +++ b/sysutils/ganglia-monitor-core/Makefile @@ -6,7 +6,7 @@ # PORTNAME= ganglia-monitor-core -PORTVERSION= 2.5.3 +PORTVERSION= 2.5.4 CATEGORIES= sysutils net parallel MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ganglia @@ -24,7 +24,6 @@ LIB_DEPENDS= rrd.0:${PORTSDIR}/net/rrdtool GNU_CONFIGURE= yes CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ LIBS="-L${LOCALBASE}/lib" -CONFIGURE_ARGS+= --includedir=${PREFIX}/include/ganglia .if !defined (WITHOUT_GMETAD) CONFIGURE_ARGS+= --with-gmetad .endif diff --git a/sysutils/ganglia-monitor-core/distinfo b/sysutils/ganglia-monitor-core/distinfo index 7286b7766047..263b4f4a515f 100644 --- a/sysutils/ganglia-monitor-core/distinfo +++ b/sysutils/ganglia-monitor-core/distinfo @@ -1 +1 @@ -MD5 (ganglia-monitor-core-2.5.3.tar.gz) = c6bd5f5d21b3b84286d474f7e57f5101 +MD5 (ganglia-monitor-core-2.5.4.tar.gz) = 354b18077ba33738af5bcb9539ae854d diff --git a/sysutils/ganglia-monitor-core/files/patch-config.h.in b/sysutils/ganglia-monitor-core/files/patch-config.h.in new file mode 100644 index 000000000000..f094dc027b6b --- /dev/null +++ b/sysutils/ganglia-monitor-core/files/patch-config.h.in @@ -0,0 +1,16 @@ + +$FreeBSD$ + +--- config.h.in.orig Tue Oct 28 14:41:30 2003 ++++ config.h.in Tue Oct 28 14:41:41 2003 +@@ -3,8 +3,8 @@ + /* AIX */ + #undef AIX + +-/* BSD */ +-#undef BSD ++/* FREEBSD */ ++#undef FREEBSD + + /* CPU_VENDOR_OS */ + #undef CPU_VENDOR_OS diff --git a/sysutils/ganglia-monitor-core/files/patch-configure b/sysutils/ganglia-monitor-core/files/patch-configure new file mode 100644 index 000000000000..6e977ba1b3ce --- /dev/null +++ b/sysutils/ganglia-monitor-core/files/patch-configure @@ -0,0 +1,14 @@ + +$FreeBSD$ + +--- configure.orig Mon Oct 27 16:51:34 2003 ++++ configure Mon Oct 27 16:52:23 2003 +@@ -11458,7 +11458,7 @@ + + + cat >>confdefs.h <<\_ACEOF +-#define BSD 1 ++#define FREEBSD 1 + _ACEOF + ;; + *cygwin*) metric_source="cygwin.c" diff --git a/sysutils/ganglia-monitor-core/files/patch-gmetad_conf.c b/sysutils/ganglia-monitor-core/files/patch-gmetad_conf.c new file mode 100644 index 000000000000..7ca61393c51d --- /dev/null +++ b/sysutils/ganglia-monitor-core/files/patch-gmetad_conf.c @@ -0,0 +1,14 @@ + +$FreeBSD$ + +--- gmetad/conf.c.orig Tue May 27 11:02:49 2003 ++++ gmetad/conf.c Tue Oct 28 11:10:08 2003 +@@ -251,7 +251,7 @@ + config->trusted_hosts = NULL; + config->debug_level = 0; + config->should_setuid = 1; +- config->setuid_username = "nobody"; ++ config->setuid_username = "ganglia"; + config->rrd_rootdir = "/var/lib/ganglia/rrds"; + config->scalable_mode = 1; + config->all_trusted = 0; diff --git a/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.c b/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.c deleted file mode 100644 index 76fdd5276cb1..000000000000 --- a/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.c +++ /dev/null @@ -1,14 +0,0 @@ - -$FreeBSD$ - ---- gmetad/gmetad.c.orig Mon Dec 9 14:43:23 2002 -+++ gmetad/gmetad.c Fri Feb 21 11:52:24 2003 -@@ -40,7 +40,7 @@ - pthread_mutex_t server_socket_mutex = PTHREAD_MUTEX_INITIALIZER; - int server_threads = 2; - char *rrd_rootdir = "/var/lib/ganglia/rrds"; --char *setuid_username = "nobody"; -+char *setuid_username = "ganglia"; - int should_setuid = 1; - unsigned int source_index = 0; - diff --git a/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.conf b/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.conf index 9ed21c5722cf..8d0b13d54724 100644 --- a/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.conf +++ b/sysutils/ganglia-monitor-core/files/patch-gmetad_gmetad.conf @@ -1,12 +1,12 @@ $FreeBSD$ ---- gmetad/gmetad.conf.orig Wed Jan 29 10:17:02 2003 -+++ gmetad/gmetad.conf Fri Feb 21 11:52:58 2003 -@@ -55,9 +55,9 @@ - # default: on +--- gmetad/gmetad.conf.orig Mon May 12 14:58:40 2003 ++++ gmetad/gmetad.conf Tue Oct 28 11:11:03 2003 +@@ -80,9 +80,9 @@ # setuid off # + #------------------------------------------------------------------------------- -# User gmetad will setuid to (defaults to "nobody") -# default: "nobody" -# setuid_username "nobody" @@ -14,5 +14,5 @@ $FreeBSD$ +# default: "ganglia" +# setuid_username "ganglia" # + #------------------------------------------------------------------------------- # The port gmetad will answer requests for XML - # default: 8651 diff --git a/sysutils/ganglia-monitor-core/files/patch-gmond_gmond.c b/sysutils/ganglia-monitor-core/files/patch-gmond_gmond.c deleted file mode 100644 index c3dfe5b94738..000000000000 --- a/sysutils/ganglia-monitor-core/files/patch-gmond_gmond.c +++ /dev/null @@ -1,33 +0,0 @@ - -$FreeBSD$ - ---- gmond/gmond.c.orig Tue Jan 7 09:05:04 2003 -+++ gmond/gmond.c Thu Apr 3 16:40:22 2003 -@@ -163,6 +163,13 @@ - print_gmond_config(); - */ - -+ /* in machine.c */ -+ initval = metric_init(); -+ if ( initval.int32 <0) -+ { -+ err_quit("metric_init() returned an error"); -+ } -+ - if(!gmond_config.no_setuid) - become_a_nobody(gmond_config.setuid); - -@@ -266,13 +273,6 @@ - return -1; - } - debug_msg("multicasting on channel %s %d", gmond_config.mcast_channel, gmond_config.mcast_port); -- -- /* in machine.c */ -- initval = metric_init(); -- if ( initval.int32 <0) -- { -- err_quit("monitor_init() returned an error"); -- } - - pthread_create(&tid, &attr, monitor_thread, NULL); - debug_msg("created monitor thread"); diff --git a/sysutils/ganglia-monitor-core/files/patch-gmond_key__metrics.h b/sysutils/ganglia-monitor-core/files/patch-gmond_key__metrics.h new file mode 100644 index 000000000000..ad0b44ce7289 --- /dev/null +++ b/sysutils/ganglia-monitor-core/files/patch-gmond_key__metrics.h @@ -0,0 +1,21 @@ + +$FreeBSD$ + +--- gmond/key_metrics.h.orig Mon Oct 27 16:47:42 2003 ++++ gmond/key_metrics.h Mon Oct 27 16:48:12 2003 +@@ -69,6 +69,15 @@ + cpu_avm, + cpu_vm, + #endif ++#ifdef FREEBSD ++ bytes_in, ++ bytes_out, ++ pkts_in, ++ pkts_out, ++ disk_total, ++ disk_free, ++ part_max_used, ++#endif + num_key_metrics + } key_metrics; + #endif diff --git a/sysutils/ganglia-monitor-core/files/patch-gmond_machines_freebsd.c b/sysutils/ganglia-monitor-core/files/patch-gmond_machines_freebsd.c index 6f73c8d24160..3916982f2644 100644 --- a/sysutils/ganglia-monitor-core/files/patch-gmond_machines_freebsd.c +++ b/sysutils/ganglia-monitor-core/files/patch-gmond_machines_freebsd.c @@ -1,176 +1,748 @@ $FreeBSD$ ---- gmond/machines/freebsd.c.orig Thu Aug 15 10:17:25 2002 -+++ gmond/machines/freebsd.c Wed May 28 12:51:18 2003 -@@ -10,11 +10,36 @@ +--- gmond/machines/freebsd.c.orig Tue Jul 29 10:56:38 2003 ++++ gmond/machines/freebsd.c Mon Oct 27 17:02:26 2003 +@@ -9,9 +9,11 @@ + */ + + #include <kvm.h> +-#include <fcntl.h> ++ #include <sys/param.h> ++#include <sys/mount.h> #include <sys/sysctl.h> ++#include <sys/time.h> #include <sys/user.h> -+#if __FreeBSD_version < 500101 + #if __FreeBSD_version < 500101 #include <sys/dkstat.h> -+#else -+#include <sys/resource.h> -+#endif -+#include <sys/stat.h> -+#include <vm/vm_param.h> +@@ -20,12 +22,35 @@ + #endif + #include <sys/stat.h> + #include <vm/vm_param.h> ++ ++#include <sys/socket.h> ++#include <net/if.h> ++#include <net/if_dl.h> ++#include <net/route.h> ++ #include <unistd.h> ++#include <err.h> ++#include <fcntl.h> ++#include <limits.h> ++#include <paths.h> ++ ++#include "dnet.h" #include "ganglia.h" #include "metric_typedefs.h" -+#define MIB_SWAPINFO_SIZE 3 -+ -+#ifndef XSWDEV_VERSION -+#define XSWDEV_VERSION 1 -+struct xswdev { -+ u_int xsw_version; -+ udev_t xsw_dev; -+ int xsw_flags; -+ int xsw_nblks; -+ int xsw_used; -+}; + #define MIB_SWAPINFO_SIZE 3 + ++#ifndef MIN_NET_POLL_INTERVAL ++#define MIN_NET_POLL_INTERVAL 0.5 +#endif + -+static int use_vm_swap_info = 0; -+static int mibswap[MIB_SWAPINFO_SIZE]; -+static size_t mibswap_size; -+static kvm_t *kd = NULL; -+static int pagesize; ++#ifndef UINT64_MAX ++#define UINT64_MAX ULLONG_MAX ++#endif ++ ++#define timertod(tvp) \ ++ ((double)(tvp)->tv_sec + (double)(tvp)->tv_usec/(1000*1000)) ++ + #ifndef XSWDEV_VERSION + #define XSWDEV_VERSION 1 + struct xswdev { +@@ -37,14 +62,32 @@ + }; + #endif + ++struct traffic { ++ uint64_t in_bytes; ++ uint64_t out_bytes; ++ uint64_t in_pkts; ++ uint64_t out_pkts; ++}; ++ ++static void get_netbw(double *, double *, double *, double *); ++static uint64_t counterdiff(uint64_t, uint64_t, uint64_t, uint64_t); ++ ++ ++static char *makenetvfslist(void); ++static size_t regetmntinfo(struct statfs **, long, const char **); ++static int checkvfsname(const char *, const char **); ++static const char **makevfslist(char *); ++static float find_disk_space(double *, double *); + + static int use_vm_swap_info = 0; + static int mibswap[MIB_SWAPINFO_SIZE]; + static size_t mibswap_size; + static kvm_t *kd = NULL; + static int pagesize; ++static int skipvfs; + /* Function prototypes */ - long percentages(int cnt, int *out, register long *new, +-long percentages(int cnt, int *out, register long *new, ++static long percentages(int cnt, int *out, register long *new, register long *old, long *diffs); -@@ -27,6 +52,19 @@ - metric_init(void) - { - g_val_t val; -+ + + /* +@@ -64,10 +107,25 @@ + if (sysctlnametomib("vm.swap_info", mibswap, &mibswap_size) == -1) { + kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "metric_init()"); + } else { ++ /* ++ * Versions of FreeBSD with the swap mib generally have a version ++ * of libkvm that doesn't need root for simple proc access so we ++ * just open /dev/null to give us a working handle here. This is ++ * bogus, but only a few pre-release versions of 5.0 are ++ * affected by the bogosity and people running those should ++ * upgrade. ++ */ ++ kd = kvm_open(_PATH_DEVNULL, NULL, NULL, O_RDONLY, "metric_init()"); + use_vm_swap_info = 1; + } + pagesize = getpagesize(); + + /* -+ * Try to use the vm.swap_info sysctl to gather swap data. If it -+ * isn't implemented, fall back to trying to old kvm based interface. ++ * Call get_netbw once to initalize the counters. + */ -+ mibswap_size = MIB_SWAPINFO_SIZE; -+ if (sysctlnametomib("vm.swap_info", mibswap, &mibswap_size) == -1) { -+ kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "metric_init()"); -+ } else { -+ use_vm_swap_info = 1; -+ } -+ pagesize = getpagesize(); ++ ++ get_netbw(NULL, NULL, NULL, NULL); + val.int32 = SYNAPSE_SUCCESS; return val; } -@@ -81,21 +119,33 @@ - swap_total_func ( void ) - { +@@ -124,7 +182,7 @@ g_val_t val; -- struct kvm_swap swap[1]; -- kvm_t *kd; -+ struct xswdev xsw; -+ size_t mibsize, size; + struct xswdev xsw; +- size_t mibsize, size; ++ size_t size; int totswap, n; + val.uint32 = 0; + totswap = 0; +@@ -366,9 +424,41 @@ + g_val_t + proc_run_func( void ) + { ++ struct kinfo_proc *kp; ++ int i; ++ int state; ++ int nentries; ++ int what = KERN_PROC_ALL; + g_val_t val; -- kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open"); -- n = kvm_getswapinfo(kd, swap, 1, 0); -- if (n < 0 || swap[0].ksw_total == 0) { -- val.uint32 = 0; -+ val.uint32 = 0; -+ totswap = 0; -+ -+ if (use_vm_swap_info) { -+ for (n = 0; ; ++n) { -+ mibswap[mibswap_size] = n; -+ size = sizeof(xsw); -+ if (sysctl(mibswap, mibswap_size + 1, &xsw, &size, NULL, NULL) == -1) -+ break; -+ if (xsw.xsw_version != XSWDEV_VERSION) -+ return val; -+ totswap += xsw.xsw_nblks; -+ } -+ } else if(kd != NULL) { -+ n = kvm_getswapinfo(kd, swap, 1, 0); -+ if (n < 0 || swap[0].ksw_total == 0) { -+ val.uint32 = 0; + val.uint32 = 0; ++ ++ if (kd == NULL) ++ goto output; ++#ifdef KERN_PROC_NOTHREADS ++ what |= KERN_PROC_NOTHREADS ++#endif ++ if ((kp = kvm_getprocs(kd, what, 0, &nentries)) == 0 || nentries < 0) ++ goto output; ++ ++ for (i = 0; i < nentries; kp++, i++) { ++#ifdef KINFO_PROC_SIZE ++ state = kp->ki_stat; ++#else ++ state = kp->kp_proc.p_stat; ++#endif ++ switch(state) { ++ case SRUN: ++ case SIDL: ++ val.uint32++; ++ break; + } -+ totswap = swap[0].ksw_total; - } -- totswap = swap[0].ksw_total; -- totswap *= getpagesize() / 1024; -- val.uint32 = totswap; -- kvm_close(kd); - -+ val.uint32 = totswap * (pagesize / 1024); ++ } ++ ++ if (val.uint32 > 0) ++ val.uint32--; ++ ++output: return val; } -@@ -330,9 +380,8 @@ - len = sizeof (free_pages); - if((sysctlbyname("vm.stats.vm.v_free_count", &free_pages, &len, NULL, 0) - == -1) || !len) free_pages = 0; -- free_pages *= getpagesize() / 1024; - -- val.uint32 = free_pages; -+ val.uint32 = free_pages * (pagesize / 1024); +@@ -461,7 +551,6 @@ return val; } -@@ -373,9 +422,7 @@ - || !len) - cache = 0; +-#include "dnet.h" -- cache *= getpagesize() / 1024; -- -- val.uint32 = cache; -+ val.uint32 = cache * (pagesize / 1024); - return val; - } + static int + find_mtu(const struct intf_entry *entry, void *arg) +@@ -509,8 +598,8 @@ + * $FreeBSD$ + */ -@@ -383,23 +430,35 @@ - swap_free_func ( void ) - { - g_val_t val; -+ - struct kvm_swap swap[1]; -- kvm_t *kd; -+ struct xswdev xsw; -+ size_t size; - int totswap, usedswap, freeswap, n; +-long percentages(int cnt, int *out, register long *new, +- register long *old, long *diffs) { ++static long percentages(int cnt, int *out, register long *new, ++ register long *old, long *diffs) { -- kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open"); -- n = kvm_getswapinfo(kd, swap, 1, 0); -- if (n < 0 || swap[0].ksw_total == 0) { -- val.uint32 = 0; -- } -- totswap = swap[0].ksw_total; -- usedswap = swap[0].ksw_used; -- kvm_close(kd); -+ val.uint32 = 0; -+ totswap = 0; -+ usedswap = 0; - -- freeswap = totswap-usedswap; -- freeswap *= getpagesize() / 1024; -+ if (use_vm_swap_info) { -+ for (n = 0; ; ++n) { -+ mibswap[mibswap_size] = n; -+ size = sizeof(xsw); -+ if (sysctl(mibswap, mibswap_size + 1, &xsw, &size, NULL, NULL) == -1) -+ break; -+ if (xsw.xsw_version != XSWDEV_VERSION) -+ return val; -+ totswap += xsw.xsw_nblks; -+ usedswap += xsw.xsw_used; -+ } -+ } else if(kd != NULL) { -+ n = kvm_getswapinfo(kd, swap, 1, 0); -+ totswap = swap[0].ksw_total; -+ usedswap = swap[0].ksw_used; -+ } -+ freeswap = totswap - usedswap; - -- val.uint32 = freeswap; -+ val.uint32 = freeswap * (pagesize / 1024); - return val; + register int i; + register long change; +@@ -549,3 +638,563 @@ + return(total_change); } ++g_val_t ++pkts_in_func ( void ) ++{ ++ double in_pkts; ++ g_val_t val; ++ ++ get_netbw(NULL, NULL, &in_pkts, NULL); ++ ++ val.f = (float)in_pkts; ++ return val; ++} ++ ++g_val_t ++pkts_out_func ( void ) ++{ ++ double out_pkts; ++ g_val_t val; ++ ++ get_netbw(NULL, NULL, NULL, &out_pkts); ++ ++ val.f = (float)out_pkts; ++ return val; ++} ++ ++g_val_t ++bytes_out_func ( void ) ++{ ++ double out_bytes; ++ g_val_t val; ++ ++ get_netbw(NULL, &out_bytes, NULL, NULL); ++ ++ val.f = (float)out_bytes; ++ return val; ++} ++ ++g_val_t ++bytes_in_func ( void ) ++{ ++ double in_bytes; ++ g_val_t val; ++ ++ get_netbw(&in_bytes, NULL, NULL, NULL); ++ ++ val.f = (float)in_bytes; ++ return val; ++} ++ ++/* ++ * Disk space reporting functions from Linux code. find_disk_space() ++ * body derived from FreeBSD df and mount code. ++ */ ++ ++g_val_t ++disk_free_func( void ) ++{ ++ double total_free=0.0; ++ double total_size=0.0; ++ g_val_t val; ++ ++ find_disk_space(&total_size, &total_free); ++ ++ val.d = total_free; ++ return val; ++} ++ ++g_val_t ++disk_total_func( void ) ++{ ++ double total_free=0.0; ++ double total_size=0.0; ++ g_val_t val; ++ ++ find_disk_space(&total_size, &total_free); ++ ++ val.d = total_size; ++ return val; ++} ++ ++g_val_t ++part_max_used_func( void ) ++{ ++ double total_free=0.0; ++ double total_size=0.0; ++ float most_full; ++ g_val_t val; ++ ++ most_full = find_disk_space(&total_size, &total_free); ++ ++ val.f = most_full; ++ return val; ++} ++ ++ ++/* ++ * Copyright (c) 1980, 1983, 1990, 1993, 1994, 1995 ++ * The Regents of the University of California. All rights reserved. ++ * (c) UNIX System Laboratories, Inc. ++ * All or some portions of this file are derived from material licensed ++ * to the University of California by American Telephone and Telegraph ++ * Co. or Unix System Laboratories, Inc. and are reproduced herein with ++ * the permission of UNIX System Laboratories, Inc. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. All advertising materials mentioning features or use of this software ++ * must display the following acknowledgement: ++ * This product includes software developed by the University of ++ * California, Berkeley and its contributors. ++ * 4. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ * ++ * NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ++ * ("BSD") source has been updated. The copyright addendum may be found ++ * at ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change. ++ */ ++ ++ ++ ++static float ++find_disk_space(double *total, double *tot_avail) ++{ ++ struct statfs *mntbuf; ++ const char *fstype; ++ const char **vfslist; ++ size_t i, mntsize; ++ size_t used, availblks; ++ const double reported_units = 1e9; ++ double toru; ++ float pct; ++ float most_full = 0.0; ++ ++ *total = 0.0; ++ *tot_avail = 0.0; ++ ++ fstype = "ufs"; ++ ++ vfslist = makevfslist(makenetvfslist()); ++ ++ mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); ++ mntsize = regetmntinfo(&mntbuf, mntsize, vfslist); ++ for (i = 0; i < mntsize; i++) { ++ if ((mntbuf[i].f_flags & MNT_IGNORE) == 0) { ++ used = mntbuf[i].f_blocks - mntbuf[i].f_bfree; ++ availblks = mntbuf[i].f_bavail + used; ++ pct = (availblks == 0 ? 100.0 : ++ (double)used / (double)availblks * 100.0); ++ if (pct > most_full) ++ most_full = pct; ++ ++ toru = reported_units/mntbuf[i].f_bsize; ++ *total += mntbuf[i].f_blocks / toru; ++ *tot_avail += mntbuf[i].f_bavail / toru; ++ } ++ } ++ ++ return most_full; ++} ++ ++/* ++ * Make a pass over the file system info in ``mntbuf'' filtering out ++ * file system types not in vfslist and possibly re-stating to get ++ * current (not cached) info. Returns the new count of valid statfs bufs. ++ */ ++static size_t ++regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist) ++{ ++ int i, j; ++ struct statfs *mntbuf; ++ ++ if (vfslist == NULL) ++ return (getmntinfo(mntbufp, MNT_WAIT)); ++ ++ mntbuf = *mntbufp; ++ for (j = 0, i = 0; i < mntsize; i++) { ++ if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) ++ continue; ++ (void)statfs(mntbuf[i].f_mntonname,&mntbuf[j]); ++ j++; ++ } ++ return (j); ++} ++ ++static int ++checkvfsname(vfsname, vfslist) ++ const char *vfsname; ++ const char **vfslist; ++{ ++ ++ if (vfslist == NULL) ++ return (0); ++ while (*vfslist != NULL) { ++ if (strcmp(vfsname, *vfslist) == 0) ++ return (skipvfs); ++ ++vfslist; ++ } ++ return (!skipvfs); ++} ++ ++static const char ** ++makevfslist(fslist) ++ char *fslist; ++{ ++ const char **av; ++ int i; ++ char *nextcp; ++ ++ if (fslist == NULL) ++ return (NULL); ++ if (fslist[0] == 'n' && fslist[1] == 'o') { ++ fslist += 2; ++ skipvfs = 1; ++ } ++ for (i = 0, nextcp = fslist; *nextcp; nextcp++) ++ if (*nextcp == ',') ++ i++; ++ if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { ++ warnx("malloc failed"); ++ return (NULL); ++ } ++ nextcp = fslist; ++ i = 0; ++ av[i++] = nextcp; ++ while ((nextcp = strchr(nextcp, ',')) != NULL) { ++ *nextcp++ = '\0'; ++ av[i++] = nextcp; ++ } ++ av[i++] = NULL; ++ return (av); ++} ++ ++static char * ++makenetvfslist(void) ++{ ++#if __FreeBSD_version > 500000 ++ char *str, *strptr, **listptr; ++ struct xvfsconf *xvfsp, *keep_xvfsp; ++ size_t buflen; ++ int cnt, i, maxvfsconf; ++ ++ if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) { ++ warn("sysctl(vfs.conflist)"); ++ return (NULL); ++ } ++ xvfsp = malloc(buflen); ++ if (xvfsp == NULL) { ++ warnx("malloc failed"); ++ return (NULL); ++ } ++ keep_xvfsp = xvfsp; ++ if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) { ++ warn("sysctl(vfs.conflist)"); ++ free(keep_xvfsp); ++ return (NULL); ++ } ++ maxvfsconf = buflen / sizeof(struct xvfsconf); ++ ++ if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { ++ warnx("malloc failed"); ++ free(keep_xvfsp); ++ return (NULL); ++ } ++ ++ for (cnt = 0, i = 0; i < maxvfsconf; i++) { ++ if (xvfsp->vfc_flags & (VFCF_NETWORK|VFCF_SYNTHETIC|VFCF_LOOPBACK)) { ++ listptr[cnt++] = strdup(xvfsp->vfc_name); ++ if (listptr[cnt-1] == NULL) { ++ warnx("malloc failed"); ++ free(listptr); ++ free(keep_xvfsp); ++ return (NULL); ++ } ++ } ++ xvfsp++; ++ } ++ ++ if (cnt == 0 || ++ (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { ++ if (cnt > 0) ++ warnx("malloc failed"); ++ free(listptr); ++ free(keep_xvfsp); ++ return (NULL); ++ } ++ ++ *str = 'n'; *(str + 1) = 'o'; ++ for (i = 0, strptr = str + 2; i < cnt; i++, strptr++) { ++ strncpy(strptr, listptr[i], 32); ++ strptr += strlen(listptr[i]); ++ *strptr = ','; ++ free(listptr[i]); ++ } ++ *(--strptr) = NULL; ++ ++ free(keep_xvfsp); ++#else ++ char *str, *strptr, **listptr; ++ int mib[3], maxvfsconf, cnt=0, i; ++ size_t miblen; ++ struct ovfsconf *ptr; ++ ++ mib[0] = CTL_VFS; mib[1] = VFS_GENERIC; mib[2] = VFS_MAXTYPENUM; ++ miblen=sizeof(maxvfsconf); ++ if (sysctl(mib, (unsigned int)(sizeof(mib) / sizeof(mib[0])), ++ &maxvfsconf, &miblen, NULL, 0)) { ++ warnx("sysctl failed"); ++ return (NULL); ++ } ++ ++ if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { ++ warnx("malloc failed"); ++ return (NULL); ++ } ++ ++ for (ptr = getvfsent(); ptr; ptr = getvfsent()) ++ if (ptr->vfc_flags & (VFCF_NETWORK|VFCF_SYNTHETIC|VFCF_LOOPBACK)) { ++ listptr[cnt++] = strdup(ptr->vfc_name); ++ if (listptr[cnt-1] == NULL) { ++ warnx("malloc failed"); ++ return (NULL); ++ } ++ } ++ ++ if (cnt == 0 || ++ (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { ++ if (cnt > 0) ++ warnx("malloc failed"); ++ free(listptr); ++ return (NULL); ++ } ++ ++ *str = 'n'; *(str + 1) = 'o'; ++ for (i = 0, strptr = str + 2; i < cnt; i++, strptr++) { ++ strncpy(strptr, listptr[i], 32); ++ strptr += strlen(listptr[i]); ++ *strptr = ','; ++ free(listptr[i]); ++ } ++ *(--strptr) = NULL; ++ ++#endif ++ free(listptr); ++ return (str); ++ ++} ++ ++static void ++get_netbw(double *in_bytes, double *out_bytes, ++ double *in_pkts, double *out_pkts) ++{ ++#ifdef NETBW_DEBUG ++ char name[IFNAMSIZ]; ++#endif ++ struct if_msghdr *ifm, *nextifm; ++ struct sockaddr_dl *sdl; ++ char *buf, *lim, *next; ++ size_t needed; ++ int mib[6]; ++ int i; ++ int index; ++ static double ibytes, obytes, ipkts, opkts; ++ struct timeval this_time; ++ struct timeval time_diff; ++ struct traffic traffic; ++ static struct timeval last_time = {0,0}; ++ static int indexes = 0; ++ static int *seen = NULL; ++ static struct traffic *lastcount = NULL; ++ static double o_ibytes, o_obytes, o_ipkts, o_opkts; ++ ++ ibytes = obytes = ipkts = opkts = 0.0; ++ ++ mib[0] = CTL_NET; ++ mib[1] = PF_ROUTE; ++ mib[2] = 0; ++ mib[3] = 0; /* address family */ ++ mib[4] = NET_RT_IFLIST; ++ mib[5] = 0; /* interface index */ ++ ++ gettimeofday(&this_time, NULL); ++ timersub(&this_time, &last_time, &time_diff); ++ if (timertod(&time_diff) < MIN_NET_POLL_INTERVAL) { ++ goto output; ++ } ++ ++ ++ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) ++ errx(1, "iflist-sysctl-estimate"); ++ if ((buf = malloc(needed)) == NULL) ++ errx(1, "malloc"); ++ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) ++ errx(1, "actual retrieval of interface table"); ++ lim = buf + needed; ++ ++ next = buf; ++ while (next < lim) { ++ ++ ifm = (struct if_msghdr *)next; ++ ++ if (ifm->ifm_type == RTM_IFINFO) { ++ sdl = (struct sockaddr_dl *)(ifm + 1); ++ } else { ++ fprintf(stderr, "out of sync parsing NET_RT_IFLIST\n"); ++ fprintf(stderr, "expected %d, got %d\n", RTM_IFINFO, ++ ifm->ifm_type); ++ fprintf(stderr, "msglen = %d\n", ifm->ifm_msglen); ++ fprintf(stderr, "buf:%p, next:%p, lim:%p\n", buf, next, ++ lim); ++ exit (1); ++ } ++ ++ next += ifm->ifm_msglen; ++ while (next < lim) { ++ nextifm = (struct if_msghdr *)next; ++ ++ if (nextifm->ifm_type != RTM_NEWADDR) ++ break; ++ ++ next += nextifm->ifm_msglen; ++ } ++ ++ if ((ifm->ifm_flags & IFF_LOOPBACK) || ++ !(ifm->ifm_flags & IFF_UP)) ++ continue; ++ ++ index = ifm->ifm_index; ++ ++ /* If we don't have a previous value yet, make a slot. */ ++ if (index >= indexes) { ++ seen = realloc(seen, sizeof(*seen)*(index+1)); ++ lastcount = realloc(lastcount, ++ sizeof(*lastcount)*(index+1)); ++ ++ /* Initalize the new slots */ ++ for (i = indexes; i <= index; i++) { ++ seen[i] = 0; ++ } ++ indexes = index+1; ++ } ++ ++ /* ++ * If this is the first time we've seen this interface, ++ * set the last values to the current ones. That causes ++ * us to see no bandwidth on the interface the first ++ * time, but that's OK. ++ */ ++ if (!seen[index]) { ++ seen[index] = 1; ++ lastcount[index].in_bytes = ifm->ifm_data.ifi_ibytes; ++ lastcount[index].out_bytes = ifm->ifm_data.ifi_obytes; ++ lastcount[index].in_pkts = ifm->ifm_data.ifi_ipackets; ++ lastcount[index].out_pkts = ifm->ifm_data.ifi_opackets; ++ } ++ ++ traffic.in_bytes = counterdiff(lastcount[index].in_bytes, ++ ifm->ifm_data.ifi_ibytes, ULONG_MAX, 0); ++ traffic.out_bytes = counterdiff(lastcount[index].out_bytes, ++ ifm->ifm_data.ifi_obytes, ULONG_MAX, 0); ++ traffic.in_pkts = counterdiff(lastcount[index].in_pkts, ++ ifm->ifm_data.ifi_ipackets, ULONG_MAX, 0); ++ traffic.out_pkts = counterdiff(lastcount[index].out_pkts, ++ ifm->ifm_data.ifi_opackets, ULONG_MAX, 0); ++ ++ lastcount[index].in_bytes = ifm->ifm_data.ifi_ibytes; ++ lastcount[index].out_bytes = ifm->ifm_data.ifi_obytes; ++ lastcount[index].in_pkts = ifm->ifm_data.ifi_ipackets; ++ lastcount[index].out_pkts = ifm->ifm_data.ifi_opackets; ++ ++#ifdef NETBW_DEBUG ++ if_indextoname(index, name); ++ printf("%s: \n", name); ++ printf("\topackets=%llu ipackets=%llu\n", ++ traffic.out_pkts, traffic.in_pkts); ++ printf("\tobytes=%llu ibytes=%llu\n", ++ traffic.out_bytes, traffic.in_bytes); ++#endif ++ ++ if (timerisset(&last_time)) { ++ ibytes += (double)traffic.in_bytes / timertod(&time_diff); ++ obytes += (double)traffic.out_bytes / timertod(&time_diff); ++ ipkts += (double)traffic.in_pkts / timertod(&time_diff); ++ opkts += (double)traffic.out_pkts / timertod(&time_diff); ++ } ++ } ++ free(buf); ++ ++ /* Save the values from this time */ ++ last_time = this_time; ++ o_ibytes = ibytes; ++ o_obytes = obytes; ++ o_ipkts = ipkts; ++ o_opkts = opkts; ++ ++output: ++ if (in_bytes != NULL) ++ *in_bytes = o_ibytes; ++ if (out_bytes != NULL) ++ *out_bytes = o_obytes; ++ if (in_pkts != NULL) ++ *in_pkts = o_ipkts; ++ if (out_pkts != NULL) ++ *out_pkts = o_opkts; ++} ++ ++static uint64_t ++counterdiff(uint64_t oldval, uint64_t newval, uint64_t maxval, uint64_t maxdiff) ++{ ++ uint64_t diff; ++ ++ if (maxdiff == 0) ++ maxdiff = maxval; ++ ++ /* Paranoia */ ++ if (oldval > maxval || newval > maxval) ++ return 0; ++ ++ /* ++ * Tackle the easy case. Don't worry about maxdiff here because ++ * we're SOL if it happens (i.e. assuming a reset just makes ++ * matters worse). ++ */ ++ if (oldval <= newval) ++ return (newval - oldval); ++ ++ /* ++ * Now the tricky part. If we assume counters never get reset, ++ * this is easy. Unfortunaly, they do get reset on some ++ * systems, so we need to try and deal with that. Our huristic ++ * is that if out difference is greater then maxdiff and newval ++ * is less or equal to maxdiff, then we've probably been reset ++ * rather then actually wrapping. Obviously, you need to be ++ * careful to poll often enough that you won't exceed maxdiff or ++ * you will get undersized numbers when you do wrap. ++ */ ++ diff = maxval - oldval + newval; ++ if (diff > maxdiff && newval <= maxdiff) ++ return newval; ++ ++ return diff; ++} diff --git a/sysutils/ganglia-monitor-core/files/patch-gmond_metric.h b/sysutils/ganglia-monitor-core/files/patch-gmond_metric.h new file mode 100644 index 000000000000..7c7d8eeb06bc --- /dev/null +++ b/sysutils/ganglia-monitor-core/files/patch-gmond_metric.h @@ -0,0 +1,65 @@ + +$FreeBSD$ + +--- gmond/metric.h.orig Mon Oct 27 16:47:53 2003 ++++ gmond/metric.h Mon Oct 27 16:48:15 2003 +@@ -88,6 +88,18 @@ + + #endif + ++#ifdef FREEBSD ++ ++extern g_val_t bytes_in_func(void); ++extern g_val_t bytes_out_func(void); ++extern g_val_t pkts_in_func(void); ++extern g_val_t pkts_out_func(void); ++extern g_val_t disk_total_func(void); ++extern g_val_t disk_free_func(void); ++extern g_val_t part_max_used_func(void); ++ ++#endif ++ + #define INIT 0, 0, {0}, {0} + #define KEY(NAME) { #NAME, NAME ##_func, INIT + +@@ -182,7 +194,8 @@ + KEY(pkts_in), 256, 30, 40, 200, 300, g_float, "packets/sec", "%.2f" }, + KEY(pkts_out), 256, 30, 40, 200, 300, g_float, "packets/sec", "%.2f" }, + +-/* The amount of disk space could change - hot-swap, mounts, etc. check: 30-60min. */ ++/* ++ * The amount of disk space could change - hot-swap, mounts, etc. check: 30-60min. */ + KEY(disk_total), 1, 1800, 3600, 900, 1200, g_double, "GB", "%.3f" }, + KEY(disk_free), 1, 30, 40, 120, 180, g_double, "GB", "%.3f" }, + KEY(part_max_used), 1, 30, 40, 120, 180, g_float, "%", "%.1f" } +@@ -198,6 +211,30 @@ + KEY(mem_rm), 1024, 30, 40, 120, 180, g_uint32, "KB", "%u" }, + KEY(mem_avm), 1024, 30, 40, 120, 180, g_uint32, "KB", "%u" }, + KEY(mem_vm), 1024, 30, 40, 120, 180, g_uint32, "KB", "%u" } ++ ++#endif ++ ++#ifdef FREEBSD ++ ++, ++/* ++ * (sacerdoti) Experiments have shown gmon resting bandwidth is around ++ * 2KB/s for a 128-node cluster. We set the value thresh of these ++ * metrics to double that. ++ * ++ */ ++KEY(bytes_out), 4096, 30, 40, 200, 300, g_float, "bytes/sec", "%.2f" }, ++KEY(bytes_in), 4096, 30, 40, 200, 300, g_float, "bytes/sec", "%.2f" }, ++KEY(pkts_in), 256, 30, 40, 200, 300, g_float, "packets/sec", "%.2f" }, ++KEY(pkts_out), 256, 30, 40, 200, 300, g_float, "packets/sec", "%.2f" }, ++ ++/* ++ * The amount of disk space could change - hot-swap, mounts, etc. ++ * check: 30-60min. ++ */ ++KEY(disk_total), 1, 1800, 3600, 900, 1200, g_double, "GB", "%.3f" }, ++KEY(disk_free), 1, 30, 40, 120, 180, g_double, "GB", "%.3f" }, ++KEY(part_max_used), 1, 30, 40, 120, 180, g_float, "%", "%.1f" } + + #endif + }; diff --git a/sysutils/ganglia-monitor-core/files/patch-lib_Makefile.in b/sysutils/ganglia-monitor-core/files/patch-lib_Makefile.in deleted file mode 100644 index 11d8a323fc92..000000000000 --- a/sysutils/ganglia-monitor-core/files/patch-lib_Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ - -$FreeBSD$ - ---- lib/Makefile.in.orig Wed May 28 12:59:41 2003 -+++ lib/Makefile.in Wed May 28 13:00:03 2003 -@@ -471,7 +471,6 @@ - - install-exec-am: install-libLTLIBRARIES - @$(NORMAL_INSTALL) -- $(MAKE) $(AM_MAKEFLAGS) install-exec-hook - - install-info: install-info-am - diff --git a/sysutils/ganglia-monitor-core/files/patch-lib_ganglia_net.h b/sysutils/ganglia-monitor-core/files/patch-lib_ganglia_net.h new file mode 100644 index 000000000000..0ca2ad99970d --- /dev/null +++ b/sysutils/ganglia-monitor-core/files/patch-lib_ganglia_net.h @@ -0,0 +1,14 @@ + +$FreeBSD$ + +--- lib/ganglia/net.h.orig Mon Oct 27 16:53:00 2003 ++++ lib/ganglia/net.h Mon Oct 27 16:53:07 2003 +@@ -12,7 +12,7 @@ + #include <netdb.h> + #include <ganglia/llist.h> + #include <ganglia/net.h> +-#ifdef BSD ++#ifdef FREEBSD + #include <sys/types.h> + #endif + #include <netinet/in.h> diff --git a/sysutils/ganglia-monitor-core/pkg-plist b/sysutils/ganglia-monitor-core/pkg-plist index 903beb055db2..4144d046aa47 100644 --- a/sysutils/ganglia-monitor-core/pkg-plist +++ b/sysutils/ganglia-monitor-core/pkg-plist @@ -5,7 +5,7 @@ etc/gmond.conf.sample %%GMETAD%%etc/gmetad.conf.sample etc/rc.d/gmond.sh.sample %%GMETAD%%etc/rc.d/gmetad.sh.sample -include/ganglia/ganglia.h +include/ganglia.h include/ganglia/ascii.h include/ganglia/asciitab.h include/ganglia/daemon_inetd.h |