head 1.6; access; symbols pkgsrc-2015Q4:1.5.0.50 pkgsrc-2015Q4-base:1.5 pkgsrc-2015Q3:1.5.0.48 pkgsrc-2015Q3-base:1.5 pkgsrc-2015Q2:1.5.0.46 pkgsrc-2015Q2-base:1.5 pkgsrc-2015Q1:1.5.0.44 pkgsrc-2015Q1-base:1.5 pkgsrc-2014Q4:1.5.0.42 pkgsrc-2014Q4-base:1.5 pkgsrc-2014Q3:1.5.0.40 pkgsrc-2014Q3-base:1.5 pkgsrc-2014Q2:1.5.0.38 pkgsrc-2014Q2-base:1.5 pkgsrc-2014Q1:1.5.0.36 pkgsrc-2014Q1-base:1.5 pkgsrc-2013Q4:1.5.0.34 pkgsrc-2013Q4-base:1.5 pkgsrc-2013Q3:1.5.0.32 pkgsrc-2013Q3-base:1.5 pkgsrc-2013Q2:1.5.0.30 pkgsrc-2013Q2-base:1.5 pkgsrc-2013Q1:1.5.0.28 pkgsrc-2013Q1-base:1.5 pkgsrc-2012Q4:1.5.0.26 pkgsrc-2012Q4-base:1.5 pkgsrc-2012Q3:1.5.0.24 pkgsrc-2012Q3-base:1.5 pkgsrc-2012Q2:1.5.0.22 pkgsrc-2012Q2-base:1.5 pkgsrc-2012Q1:1.5.0.20 pkgsrc-2012Q1-base:1.5 pkgsrc-2011Q4:1.5.0.18 pkgsrc-2011Q4-base:1.5 pkgsrc-2011Q3:1.5.0.16 pkgsrc-2011Q3-base:1.5 pkgsrc-2011Q2:1.5.0.14 pkgsrc-2011Q2-base:1.5 pkgsrc-2011Q1:1.5.0.12 pkgsrc-2011Q1-base:1.5 pkgsrc-2010Q4:1.5.0.10 pkgsrc-2010Q4-base:1.5 pkgsrc-2010Q3:1.5.0.8 pkgsrc-2010Q3-base:1.5 pkgsrc-2010Q2:1.5.0.6 pkgsrc-2010Q2-base:1.5 pkgsrc-2010Q1:1.5.0.4 pkgsrc-2010Q1-base:1.5 pkgsrc-2009Q4:1.5.0.2 pkgsrc-2009Q4-base:1.5 pkgsrc-2009Q3:1.4.0.40 pkgsrc-2009Q3-base:1.4 pkgsrc-2009Q2:1.4.0.38 pkgsrc-2009Q2-base:1.4 pkgsrc-2009Q1:1.4.0.36 pkgsrc-2009Q1-base:1.4 pkgsrc-2008Q4:1.4.0.34 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.32 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.30 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.28 pkgsrc-2008Q2-base:1.4 cwrapper:1.4.0.26 pkgsrc-2008Q1:1.4.0.24 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.22 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.20 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.18 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.16 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.14 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.12 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.10 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.8 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.6 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.4 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.2 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.2.0.2 pkgsrc-2005Q1-base:1.2 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.6 date 2016.02.16.12.48.18; author fhajny; state dead; branches; next 1.5; commitid V4SDgApFTdqZI8Vy; 1.5 date 2009.11.10.14.55.18; author brook; state Exp; branches; next 1.4; 1.4 date 2005.05.02.18.15.57; author jschauma; state Exp; branches; next 1.3; 1.3 date 2005.04.13.01.57.29; author jschauma; state Exp; branches; next 1.2; 1.2 date 2005.02.10.02.33.53; author jschauma; state Exp; branches; next 1.1; 1.1 date 2005.02.07.14.33.21; author jschauma; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2005.02.07.14.33.21; author jschauma; state Exp; branches; next ; desc @@ 1.6 log @Update parallel/ganglia-monitor-core to 3.7.2. Add SMF support. Upstream changelog follows. 3.7.2 * Fix for a memory leak if override_hostname or override_ip are used 3.7.1 * Hash table in gmetad has been reworked to support much higher metric counts and larger number of metrics * A number of GMond python modules have been rewritten and enhanced 3.7.0 * Add support for sending Ganglia metrics to Riemann * Performance improvements for gmetad * Export internal gmetad metrics 3.6.0 * Improvements - Add ability to gzip XML output in gmond - Forward Graphite metrics over UDP for increased scalability - Configurable graphite prefix - Memcached publish support - export metrics into memcached - Improve metric summarization performance under heavy load * Bug fixes - Reduce CPU utilization when running in deaf mode 3.5.0 * gmond uses a separate thread to service gmetad requests. This should improve performance * Updates to a number of core Python collection modules 3.4.0 * web - now distributed as a separate source tarball, web/ tree is not present in the ganglia-3.4.0 tarball * gmond: - setgid() and initgroups() are invoked when setuid() is invoked - gmond no longer runs in root group (there may be side-effects from this change) - new UDP RX channel parameter `buffer' to set the socket buffer size 3.3.7 * gmond - BUG100: fails to start in Solaris zones - fails to start when no address on the network interface (added retry_bind parameter) - BUG321: fails to start when Solaris CPU in state FAILED (seg fault) 3.3.6 * gmond - BUG327: memory leak when receive channel is not configured or not hearing any data 3.3.5 * General - Return to the use of autotools (make dist) for building the release - Release with a valid version number in configure.in * Gmetad - Fix for gmetad buffer overflow with metric value of DOUBLE_MAX * Gmond python modules - multi traffic module has been replaced with multi interface which correctly reports all interfaces * Gmond - Fix for issues/11 - Expose some useful functions in the public C API to assist module developers 3.3.1 * Web - Graph Zooming off when Ganglia Web server and web browser in different time zones - Metrics chooser in cluster view now provides metric drop down in addition to autocomplete - Ability to specify default size for graphs in Views Gmetad - You can now disable RRD writing - useful if you are using Ganglia only to feed Graphite - Export to graphite now handles spaces in metrics, groups - Minor code clean up and fixes * Gmond - Diskstat python module incorrect IO time reporting has been fixed. 3.3.0 * Web UI shipped with Ganglia has been upgraded to the Ganglia Web 2.0 interface. Changes to web UI from Gweb 2.2.0 are as follows - Additional Nagios integration scripts - Contributed by Etsy - stacked graph in the cluster view - Ability to hide/show events on individual graphs or whole pages - Numerous bug fixes and small enhancements * metric names are sanitized to avoid breaking gmetad/UI when characters such as <, > are supplied. Those are now replaced with underscores * gmetad supports sending metrics to graphite. Uncomment proper section of gmetad.conf to enable * Default RRD resolution changed. It affects only newly created RRDs. To change to old behavior please modify the RRA field in gmetad.conf * Number of Python modules from Ganglia gmond_python_modules repository have been included such as disk statistics, individual interface statistics, etc. Most of the modules are disabled. To enable rename the files in /etc/ganglia/conf.d. * sFlow has been enhanced to support Virtual machine pool/Java VM/Memcache/Apache/NGINX/Tomcat and node.js metrics. You can read more at sFlow blog 3.2.0 * sFlow support - more and even more * hostname/ip override - you can specify an arbitrary host name and IP to be shown in the UI. * FreeBSD patches * Python module improvements * Bugfixes and improvements over 3.1.7 3.1.7: * Fix build support for RHEL5/issue with commas in CFLAGS * multicpu module: show CPU utilization as a value between 0-100% for each core 3.1.3 - 3.1.6: * Merge commit 1966 from trunk to fix "contrib/removespikes.pl" * Bootstrapping with Debian 5.0 (lenny) versions of autotools for this and future releases. * Require user to explicitly specify sysconfdir when building from source, due to the fact that the old behavior was not consistent with the documented behavior. * Configuration files and scripts are now created during the install phase rather than during configure. This allows values such as @@sysconfdir@@ to be used in the template configuration files. * Abolish the use of release names - only release numbers will be used to distinguish versions in future * libmetrics: workaround system header conflict in DFBSD >= 2.4 (BUG245) * Use PCRE regex matching to configure metrics using the name_match directive * rrdcached support * gmetad now uses apr and the sleep intervals between polls are randomized in a way that supports shorter polling intervals * FreeBSD support: fixes for crashes and disk statistics (BUG153) * Further tweaks to Solaris build support (remove C99 hack) * Eliminate conflict with ncpus symbol name on older Solaris * AIX support: determine if the host is a virtual server (BUG226) * AIX support: setting linker flags (BUG227), add -lm * AIX support: tweaks for AIX >= v6.1 * AIX support: revised init scripts for gmond and gmetad * Check for Python.h explicitly * Include the necessary Python files in the distribution tarball, regardless of how BUILD_PYTHON is set (r2215). * Remove references to GNU toolchain in documentation * Fortify write_data_to_rrd against overflows * Web interface: minor formatting changes * mcast_if implementation tweaked so that the send channel will be bound to the IP of the outgoing interface * Documentation updates relating to the options for multihomed hosts, particularly bind, bind_hostname and mcast_if * gmond: Limit the use of APR_POLLSET_THREADSAFE to Linux >= 2.6 * gmond: improve/revert setuid behavior in configure script * gmond: Fix the allow_extra_data configuration directive (BUG199) * gmond: Ensure that a complete XML dump is delivered before closing the send socket. Submitted by: Jerry * gmond: add bind and bind_hostname parameters for udp_send_channel() * gmetad: BUG232: eliminate case-sensitive hostname bug, user can choose to maintain legacy behavior though. * gmond: BUG237: revise fix for segfault on Solaris where first CPU not in slot 0 * gmond: support for HUP signal on platforms with execve * gmond: status module: return gmond version info as string metrics * gmond: Check return status of apr_pollset_create. Use APR_POLLSET_THREADSAFE on Linux. * build: various configure options: Solaris 8 with Sun Studio 11 support, extra modules for static linking, default setuid, release number, build multicpu and status during static builds, support for SYSCONFDIR (BUG16) * RPM: include status module, allow packager to supply own gmond.conf * build: Look in lib64 rather than lib for apr, confuse and expat on x86_64 @ text @$NetBSD: patch-ab,v 1.5 2009/11/10 14:55:18 brook Exp $ --- gmetad/gmetad.conf.orig 2009-01-28 16:23:20.000000000 -0700 +++ gmetad/gmetad.conf @@@@ -110,5 +110,5 @@@@ data_source "my cluster" localhost # #------------------------------------------------------------------------------- # Where gmetad stores its round-robin databases -# default: "/var/lib/ganglia/rrds" +# default: "/var/db/ganglia/rrds" # rrd_rootdir "/some/other/place" @ 1.5 log @Update to v3.1.2. The number of changes over the intervening years is too large to list here. See the ChangeLog file or the home page for details. @ text @d1 1 a1 1 $NetBSD$ @ 1.4 log @Apply patch from Mark Davies to make this build after stafs -> statvfs (ie NetBSD-3 and -current). @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.3 2005/04/13 01:57:29 jschauma Exp $ d3 9 a11 1294 --- /dev/null 2005-04-12 21:39:02.000000000 -0400 +++ srclib/libmetrics/netbsd/metrics.c 2005-04-12 21:34:24.000000000 -0400 @@@@ -0,0 +1,1291 @@@@ +/* + * First stab at support for metrics in NetBSD + * by Jan Schaumann + * Thu Feb 3 22:33:36 EST 2005 + * + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "interface.h" +#include "libmetrics.h" + +#ifdef HAVE_SYS_STATVFS_H +#define statfs statvfs +#endif + +#define MIB_SWAPINFO_SIZE 3 + +#ifndef MIN_NET_POLL_INTERVAL +#define MIN_NET_POLL_INTERVAL 0.5 +#endif + +#ifndef MIN_CPU_POLL_INTERVAL +#define MIN_CPU_POLL_INTERVAL 0.5 +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX ULLONG_MAX +#endif + +#define timertod(tvp) \ + ((double)(tvp)->tv_sec + (double)(tvp)->tv_usec/(1000*1000)) + +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 *); + +// XXX +//static int vm_state(int); + +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 */ +static long percentages(int cnt, u_int64_t *out, register u_int64_t *new, + register u_int64_t *old, u_int64_t *diffs); + +/* + * This function is called only once by the gmond. Use to + * initialize data structures, etc or just return SYNAPSE_SUCCESS; + */ +g_val_t +metric_init(void) +{ + g_val_t val; + kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "metric_init()"); + pagesize = sysconf(_SC_PAGESIZE); + + /* Initialize some counters */ + get_netbw(NULL, NULL, NULL, NULL); + cpu_state(-1); + val.int32 = SYNAPSE_SUCCESS; + return val; +} + +g_val_t +cpu_num_func ( void ) +{ + g_val_t val; + int ncpu; + size_t len = sizeof (int); + int mib[2]; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1 || !len) + ncpu = 1; + + val.uint16 = ncpu; + return val; +} + +g_val_t +cpu_speed_func ( void ) +{ + g_val_t val; + size_t len; + long cpu_speed; + + cpu_speed = 0; + +#if (__NetBSD_Version__ > 299000000) + if (sysctlbyname("machdep.est.frequency.target", &cpu_speed, &len, NULL, 0) == -1) + val.uint16 = 0; +#endif + + val.uint16 = cpu_speed /= 1000000; + return val; +} + +g_val_t +mem_total_func ( void ) +{ + g_val_t val; + size_t len; + int total; + int mib[2]; + + mib[0] = CTL_HW; + mib[1] = HW_PHYSMEM; + len = sizeof (total); + + sysctl(mib, 2, &total, &len, NULL, 0); + total /= 1024; + val.uint32 = total; + return val; +} + +g_val_t +swap_total_func ( void ) +{ + g_val_t val; + + int mib[2]; + struct uvmexp_sysctl uvmexp; + size_t len; + int totswap; + + val.uint32 = 0; + totswap = 0; + + mib[0] = CTL_VM; + mib[1] = VM_UVMEXP2; + + len = sizeof(uvmexp); + + if((sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0) + || !len) + totswap = 0; + else + totswap = uvmexp.swpages; + + val.uint32 = totswap * (pagesize / 1024); + + return val; +} + +g_val_t +boottime_func ( void ) +{ + g_val_t val; + struct timeval boottime; + int mib[2]; + size_t size; + + mib[0] = CTL_KERN; + mib[1] = KERN_BOOTTIME; + size = sizeof(boottime); + if (sysctl(mib, 2, &boottime, &size, NULL, 0) == -1) + val.uint32 = 0; + + val.uint32 = boottime.tv_sec; + + return val; +} + +g_val_t +sys_clock_func ( void ) +{ + g_val_t val; + + val.uint32 = time(NULL); + return val; +} + +g_val_t +machine_type_func ( void ) +{ + g_val_t val; + char machine_type[MAX_G_STRING_SIZE]; + size_t len = MAX_G_STRING_SIZE; + int mib[2]; + + mib[0] = CTL_HW; + mib[1] = HW_MACHINE; + + if (sysctl(mib, 2, &machine_type, &len, NULL, 0) == -1 || !len) + strncpy( val.str, "x86", MAX_G_STRING_SIZE ); + + strncpy( val.str, machine_type, MAX_G_STRING_SIZE ); + return val; +} + +g_val_t +os_name_func ( void ) +{ + g_val_t val; + char osname[MAX_G_STRING_SIZE]; + size_t len = MAX_G_STRING_SIZE; + int mib[2]; + + mib[0] = CTL_KERN; + mib[1] = KERN_OSTYPE; + + if (sysctl(mib, 2, &osname, &len, NULL, 0) == -1 || !len) + strncpy( val.str, "NetBSD", MAX_G_STRING_SIZE ); + + strncpy( val.str, osname, MAX_G_STRING_SIZE ); + + return val; +} + +g_val_t +os_release_func ( void ) +{ + g_val_t val; + int mib[2]; + size_t len; + char *prefix, buf[1024]; + + prefix = ""; + + mib[0] = CTL_KERN; + mib[1] = KERN_OSRELEASE; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + strncpy( val.str, "Unknown", MAX_G_STRING_SIZE ); + + strncpy( val.str, buf, MAX_G_STRING_SIZE ); + + return val; +} + +int +cpu_state(int which) +{ + u_int64_t cp_time[CPUSTATES]; + u_int64_t cp_diff[CPUSTATES]; + static u_int64_t cp_old[CPUSTATES]; + static u_int64_t cpu_states[CPUSTATES]; + static struct timeval this_time, last_time; + struct timeval time_diff; + size_t len = sizeof(cp_time); + int i; + + if (which == -1) { + bzero(cp_old, sizeof(cp_old)); + bzero(&last_time, sizeof(last_time)); + return 0.0; + } + + gettimeofday(&this_time, NULL); + timersub(&this_time, &last_time, &time_diff); + if (timertod(&time_diff) < MIN_CPU_POLL_INTERVAL) { + goto output; + } + last_time = this_time; + + /* puts kern.cp_time array into cp_time */ + if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) == -1) { + warn("kern.cp_time"); + return 0.0; + } + /* Use percentages function lifted from top(1) to figure percentages */ + percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + +output: + return cpu_states[which]; + +} + +g_val_t +cpu_user_func ( void ) +{ + g_val_t val; + int res; + + static u_int64_t cp_time[CPUSTATES]; + static u_int64_t cp_old[CPUSTATES]; + static u_int64_t cp_diff[CPUSTATES]; + static u_int64_t cpu_states[CPUSTATES]; + static long tot; + size_t len = sizeof(cp_time); + int mib[2]; + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + + /* Copy the last cp_time into cp_old */ + memcpy(&cp_old, &cp_time, CPUSTATES*sizeof(long)); + /* puts kern.cp_time array into cp_time */ + if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1 || !len) + res = 0.0; + else { + /* Use percentages function lifted from top(1) to figure percentages */ + tot = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + res = cpu_states[CP_USER]; + } + val.f = (float)res/10; + return val; +} + +g_val_t +cpu_nice_func ( void ) +{ + g_val_t val; + int res; + + static u_int64_t cp_time[CPUSTATES]; + static u_int64_t cp_old[CPUSTATES]; + static u_int64_t cp_diff[CPUSTATES]; + static u_int64_t cpu_states[CPUSTATES]; + static long tot; + size_t len = sizeof(cp_time); + int mib[2]; + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + + /* Copy the last cp_time into cp_old */ + memcpy(&cp_old, &cp_time, CPUSTATES*sizeof(long)); + /* puts kern.cp_time array into cp_time */ + if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1 || !len) + res = 0.0; + else { + /* Use percentages function lifted from top(1) to figure percentages */ + tot = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + res = cpu_states[CP_NICE]; + } + val.f = (float)res/10; + return val; +} + +g_val_t +cpu_system_func ( void ) +{ + g_val_t val; + int res; + + static u_int64_t cp_time[CPUSTATES]; + static u_int64_t cp_old[CPUSTATES]; + static u_int64_t cp_diff[CPUSTATES]; + static u_int64_t cpu_states[CPUSTATES]; + static long tot; + size_t len = sizeof(cp_time); + int mib[2]; + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + + /* Copy the last cp_time into cp_old */ + memcpy(&cp_old, &cp_time, CPUSTATES*sizeof(long)); + /* puts kern.cp_time array into cp_time */ + if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1 || !len) + res = 0.0; + else { + /* Use percentages function lifted from top(1) to figure percentages */ + tot = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + res = cpu_states[CP_SYS]; + } + val.f = (float)res/10; + return val; +} + +g_val_t +cpu_idle_func ( void ) +{ + g_val_t val; + int res; + + static u_int64_t cp_time[CPUSTATES]; + static u_int64_t cp_old[CPUSTATES]; + static u_int64_t cp_diff[CPUSTATES]; + static u_int64_t cpu_states[CPUSTATES]; + static long tot; + size_t len = sizeof(cp_time); + int mib[2]; + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + + /* Copy the last cp_time into cp_old */ + memcpy(&cp_old, &cp_time, CPUSTATES*sizeof(long)); + /* puts kern.cp_time array into cp_time */ + if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1 || !len) + res = 0.0; + else { + /* Use percentages function lifted from top(1) to figure percentages */ + tot = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + res = cpu_states[CP_IDLE]; + } + val.f = (float)res/10; + return val; +} + +/* +** FIXME +*/ +g_val_t +cpu_wio_func ( void ) +{ + g_val_t val; + val.f = 0.0; + return val; +} + +g_val_t +cpu_aidle_func ( void ) +{ + g_val_t val; + + val.f = 0.0; + return val; +} + +g_val_t +cpu_intr_func ( void ) +{ + g_val_t val; + int res; + + static u_int64_t cp_time[CPUSTATES]; + static u_int64_t cp_old[CPUSTATES]; + static u_int64_t cp_diff[CPUSTATES]; + static u_int64_t cpu_states[CPUSTATES]; + static long tot; + size_t len = sizeof(cp_time); + int mib[2]; + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + + /* Copy the last cp_time into cp_old */ + memcpy(&cp_old, &cp_time, CPUSTATES*sizeof(long)); + /* puts kern.cp_time array into cp_time */ + if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1 || !len) + res = 0.0; + else { + /* Use percentages function lifted from top(1) to figure percentages */ + tot = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + res = cpu_states[CP_INTR]; + } + + val.f = (float)res/10; + return val; +} + +/* +** FIXME +*/ +g_val_t +cpu_sintr_func ( void ) +{ + g_val_t val; + val.f = 0.0; + return val; +} + +g_val_t +load_one_func ( void ) +{ + g_val_t val; + double load[3]; + + getloadavg(load, 3); + val.f = load[0]; + return val; +} + +g_val_t +load_five_func ( void ) +{ + g_val_t val; + double load[3]; + + getloadavg(load, 3); + + val.f = load[1]; + return val; +} + +g_val_t +load_fifteen_func ( void ) +{ + g_val_t val; + double load[3]; + + getloadavg(load, 3); + val.f = load[2]; + return val; +} + +g_val_t +proc_total_func ( void ) +{ + g_val_t val; + int mib[3]; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_ALL; + + sysctl(mib, 3, NULL, &len, NULL, 0); + + val.uint32 = (len / sizeof (struct kinfo_proc)); + + return val; +} + + +/* + * Don't know how to do this yet.. + */ +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; + + 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) { +#if (__NetBSD_Version__ >= 200000000) + case SACTIVE: +#else + case SRUN: + case SONPROC: +#endif + case SIDL: + val.uint32++; + break; + } + } + + if (val.uint32 > 0) + val.uint32--; + +output: + return val; +} + +g_val_t +mem_free_func ( void ) +{ + g_val_t val; + size_t len; + struct vmtotal vminfo; + int mib[2]; + + len = sizeof(vminfo); + mib[0] = CTL_VM; + mib[1] = VM_METER; + if (sysctl(mib, 2, &vminfo, &len, NULL, 0) < 0) + val.uint32 = 0; + else + val.uint32 = vminfo.t_free * (pagesize / 1024); + return val; +} + +g_val_t +mem_shared_func ( void ) +{ + g_val_t val; + size_t len; + struct vmtotal vminfo; + int mib[2]; + + len = sizeof(vminfo); + mib[0] = CTL_VM; + mib[1] = VM_METER; + if (sysctl(mib, 2, &vminfo, &len, NULL, 0) < 0) + val.uint32 = 0; + else + val.uint32 = (vminfo.t_vmshr + vminfo.t_rmshr) * (pagesize / 1024); + return val; +} + +g_val_t +mem_buffers_func ( void ) +{ + g_val_t val; + size_t len; + int buffers; + int mib[2]; + + mib[0] = CTL_VM; + mib[1] = VM_NKMEMPAGES; + + len = sizeof (buffers); + if((sysctl(mib, 2, &buffers, &len, NULL, 0) == -1) || !len) + buffers = 0; + buffers /= 1024; + + val.uint32 = buffers; + return val; +} + +g_val_t +mem_cached_func ( void ) +{ + g_val_t val; + size_t len; + int cache; + struct uvmexp_sysctl uvmexp; + int mib[2]; + + mib[0] = CTL_VM; + mib[1] = VM_UVMEXP2; + + len = sizeof(uvmexp); + + if((sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0) + || !len) + cache = 0; + else + cache = uvmexp.execpages + uvmexp.filepages; + + val.uint32 = cache * (pagesize / 1024); + return val; +} + +g_val_t +swap_free_func ( void ) +{ + g_val_t val; + + int mib[2]; + struct uvmexp_sysctl uvmexp; + size_t len; + int totswapf; + + val.uint32 = 0; + totswapf = 0; + + mib[0] = CTL_VM; + mib[1] = VM_UVMEXP2; + + len = sizeof(uvmexp); + + if((sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0) + || !len) + totswapf = 0; + else + totswapf = uvmexp.swpages - uvmexp.swpginuse; + + val.uint32 = totswapf * (pagesize / 1024); + + return val; +} + +g_val_t +mtu_func ( void ) +{ + /* We want to find the minimum MTU (Max packet size) over all UP interfaces. +*/ + g_val_t val; + val.uint32 = get_min_mtu(); + /* A val of 0 means there are no UP interfaces. Shouldn't happen. */ + return val; +} + +/* + * Function to get cpu percentages. + * Might be changed ever so slightly, but is still mostly: + * AUTHOR: Christos Zoulas + * Steven Wallace + * Wolfram Schneider + * + * $FreeBSD: src/usr.bin/top/machine.c,v 1.29.2.2 2001/07/31 20:27:05 tmm Exp $ + */ + +static long percentages(int cnt, u_int64_t *out, register u_int64_t *new, + register u_int64_t *old, u_int64_t *diffs) { + + register int i; + register u_int64_t change; + register u_int64_t total_change; + register u_int64_t *dp; + long half_total; + + /* initialization */ + total_change = 0; + dp = diffs; + + /* calculate changes for each state and the overall change */ + for (i = 0; i < cnt; i++) { + if ((change = *new - *old) < 0) { + /* this only happens when the counter wraps */ + change = (int) + ((unsigned long)*new-(unsigned long)*old); + } + total_change += (*dp++ = change); + *old++ = *new++; + } + /* avoid divide by zero potential */ + if (total_change == 0) { total_change = 1; } + + /* calculate percentages based on overall change, rounding up */ + half_total = total_change / 2l; + + /* Do not divide by 0. Causes Floating point exception */ + if(total_change) { + for (i = 0; i < cnt; i++) { + *out++ = (int)((*diffs++ * 1000 + half_total) / total_change); + } + } + + /* return the total in case the caller wants to use it */ + 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 NetBSD 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; + char *netvfslist; + 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"; + + netvfslist = makenetvfslist(); + vfslist = makevfslist(netvfslist); + free(netvfslist); + + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + mntsize = regetmntinfo(&mntbuf, mntsize, vfslist); + for (i = 0; i < mntsize; i++) { +#ifdef HAVE_SYS_STATVFS_H + if ((mntbuf[i].f_flag & MNT_IGNORE) == 0) { +#else + if ((mntbuf[i].f_flags & MNT_IGNORE) == 0) { +#endif + 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; + +#ifdef HAVE_SYS_STATVFS_H + toru = reported_units/mntbuf[i].f_frsize; +#else + toru = reported_units/mntbuf[i].f_bsize; +#endif + *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; + j = 0; + 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(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(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; + i = 0; + av[i++] = nextcp; + while ((nextcp = strchr(nextcp, ',')) != NULL) { + *nextcp++ = '\0'; + av[i++] = nextcp; + } + av[i++] = NULL; + return (av); +} + +static char * +makenetvfslist(void) +{ + char *str = NULL, *strptr, **listptr = NULL; + size_t slen; + int cnt, i; + + int mib[3], maxvfsconf; + 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"); + goto done; + } + + if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { + warnx("malloc failed"); + goto done; + } + + cnt = 0; + /* XXX: use sysctl ? */ + /* while ((ptr = getvfsent()) != NULL && cnt < maxvfsconf) { + + listptr[cnt] = strdup(ptr->vfc_name); + if (listptr[cnt] == NULL) { + warnx("malloc failed"); + goto done; + } + cnt++; + } */ + if (cnt == 0) + goto done; + /* + * Count up the string lengths, we need a extra byte to hold + * the between entries ',' or the NUL at the end. + */ + for (i = 0; i < cnt; i++) + slen = strlen(listptr[i]) + 1; + /* Add 2 for initial "no". */ + slen += 2; + + if ((str = malloc(slen)) == NULL) { + warnx("malloc failed"); + goto done; + } + + str[0] = 'n'; + str[1] = 'o'; + for (i = 0, strptr = str + 2; i < cnt; i++, strptr++) { + strcpy(strptr, listptr[i]); + strptr += strlen(listptr[i]); + *strptr = ','; + } + *strptr = '\0'; + +done: + if (listptr != NULL) { + for(i = 0; i < cnt && listptr[i] != NULL; i++) + free(listptr[i]); + 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; +} @ 1.3 log @merge some changes from the freebsd metrics code into the netbsd source file. bump pkgrevision @ text @d1 1 a1 1 $NetBSD: $ d5 1 a5 1 @@@@ -0,0 +1,1279 @@@@ d40 4 d939 3 d943 1 d951 3 d955 1 @ 1.2 log @Upgradde ganglia-monitor-core to version 3.0.0, which was released one day after the initial import of this package. @ text @d3 3 a5 3 --- /dev/null 2005-02-08 14:28:37.000000000 -0500 +++ srclib/libmetrics/netbsd/metrics.c 2005-02-08 14:34:29.000000000 -0500 @@@@ -0,0 +1,1110 @@@@ d46 4 d67 15 a81 7 + +static size_t regetmntinfo(struct statfs **, long); +static float find_disk_space(double *, double *); +static int vm_state(int); + +static kvm_t *kd = NULL; +static long pagesize; d97 4 d273 38 d914 2 d928 4 d933 1 a933 1 + mntsize = regetmntinfo(&mntbuf, mntsize); d958 1 a958 1 +regetmntinfo(struct statfs **mntbufp, long mntsize) d963 3 d968 3 a970 2 + for (i = 0; i < mntsize; i++) { + struct statfs layerbuf = mntbuf[i]; a971 7 + /* + * If the FS name changed, then new data is for + * a different layer and we don't want it. + */ + if (memcmp(layerbuf.f_mntfromname, + mntbuf[j].f_mntfromname, MNAMELEN)) + mntbuf[j] = layerbuf; d977 62 d1040 50 @ 1.1 log @Initial revision @ text @d3 3 a5 3 --- /dev/null 2005-02-06 17:33:10.000000000 -0500 +++ gmond/machines/netbsd.c 2005-02-06 17:33:11.000000000 -0500 @@@@ -0,0 +1,1006 @@@@ d21 1 d24 1 a24 1 +#include d37 2 a38 3 +#include "dnet.h" +#include "ganglia.h" +#include "metric_typedefs.h" d95 5 a99 1 + if (sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) == -1 || !len) d113 3 d118 1 d205 6 a210 1 + if (sysctlbyname("hw.machine", &machine_type, &len, NULL, 0) == -1 || !len) d223 6 a228 1 + if (sysctlbyname("kern.ostype", &osname, &len, NULL, 0) == -1 || !len) d257 5 a261 5 +/* Get the CPU state given by index, from kern.cp_time + * Use the constants in + * CP_USER=0, CP_NICE=1, CP_SYS=2, CP_INTR=3, CP_IDLE=4 + */ +int cpu_state(int which) { d278 8 a285 5 + return 0.0; + /* Use percentages function lifted from top(1) to figure percentages */ + tot = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); + + return cpu_states[which]; d289 1 a289 1 +cpu_user_func ( void ) d294 21 a314 1 + res = cpu_state(CP_USER); d319 2 a320 2 +g_val_t +cpu_nice_func ( void ) d325 21 a345 1 + res = cpu_state(CP_NICE); a346 1 + d351 1 a351 1 +cpu_system_func ( void ) d356 21 a376 1 + res = cpu_state(CP_SYS); d378 2 d381 17 d402 1 a402 1 +cpu_idle_func ( void ) d407 22 a428 1 + res = cpu_state(CP_IDLE); a429 1 + d433 3 d437 1 a437 1 +cpu_aidle_func ( void ) a439 1 + d527 1 d529 4 d588 4 d594 1 a594 1 + if((sysctlbyname("vfs.nkmempages", &buffers, &len, NULL, 0) == -1) || !len) a654 18 + +static int +find_mtu(const struct intf_entry *entry, void *arg) +{ + unsigned int mtu; + unsigned int *min = (unsigned int *) arg; + + /* Only consider interfaces that are up. */ + if (! entry->intf_flags & INTF_FLAG_UP) + return 0; + + mtu=entry->intf_mtu; + if ( !*min || *min>mtu) + *min=mtu; + + return 0; +} + a659 1 + unsigned int min=0; d661 1 a661 7 + + intf_t *intf; + intf = intf_open(); + intf_loop(intf, find_mtu, &min); + intf_close(intf); + val.uint32 = min; + a665 1 + @ 1.1.1.1 log @Initial import of ganglia-monitor-core into pkgsrc: Ganglia is a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids. It is based on a hierarchical design targeted at federations of clusters. It relies on a multicast-based listen/announce protocol to monitor state within clusters and uses a tree of point-to-point connections amongst representative cluster nodes to federate clusters and aggregate their state. It leverages widely used technologies such as XML for data representation, XDR for compact, portable data transport, and RRDtool for data storage and visualization. It uses carefully engineered data structures and algorithms to achieve very low per-node overheads and high concurrency. The implementation is robust, has been ported to an extensive set of operating systems and processor architectures, and is currently in use on over 500 clusters around the world. It has been used to link clusters across university campuses and around the world and can scale to handle clusters with 2000 nodes. http://ganglia.sourceforge.net @ text @@