diff options
author | jschauma <jschauma> | 2005-04-13 01:57:29 +0000 |
---|---|---|
committer | jschauma <jschauma> | 2005-04-13 01:57:29 +0000 |
commit | aaa12dddb1834d580e5f82ca22a75ba5bf3bbc10 (patch) | |
tree | c66855e98e27489638f9dc35aab7769494597f75 /parallel | |
parent | 44a05a59f1330248719b3dddd36a96aaadcc45da (diff) | |
download | pkgsrc-aaa12dddb1834d580e5f82ca22a75ba5bf3bbc10.tar.gz |
merge some changes from the freebsd metrics code into the netbsd source
file. bump pkgrevision
Diffstat (limited to 'parallel')
-rw-r--r-- | parallel/ganglia-monitor-core/Makefile | 3 | ||||
-rw-r--r-- | parallel/ganglia-monitor-core/distinfo | 4 | ||||
-rw-r--r-- | parallel/ganglia-monitor-core/patches/patch-ab | 209 |
3 files changed, 193 insertions, 23 deletions
diff --git a/parallel/ganglia-monitor-core/Makefile b/parallel/ganglia-monitor-core/Makefile index ad28628a6d3..a91537adc3f 100644 --- a/parallel/ganglia-monitor-core/Makefile +++ b/parallel/ganglia-monitor-core/Makefile @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.4 2005/04/11 21:47:04 tv Exp $ +# $NetBSD: Makefile,v 1.5 2005/04/13 01:57:29 jschauma Exp $ # DISTNAME= ganglia-3.0.1 PKGNAME= ganglia-monitor-core-3.0.1 +PKGREVISION= 1 CATEGORIES= net parallel MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=ganglia/} EXTRACT_SUFX= .tar.bz2 diff --git a/parallel/ganglia-monitor-core/distinfo b/parallel/ganglia-monitor-core/distinfo index 3e81e97ac7a..408a59725a8 100644 --- a/parallel/ganglia-monitor-core/distinfo +++ b/parallel/ganglia-monitor-core/distinfo @@ -1,10 +1,10 @@ -$NetBSD: distinfo,v 1.4 2005/04/03 19:13:50 jschauma Exp $ +$NetBSD: distinfo,v 1.5 2005/04/13 01:57:29 jschauma Exp $ SHA1 (ganglia-3.0.1.tar.bz2) = 3e5c4ec4a509713974dd1e8d516127f6aa2c5a20 RMD160 (ganglia-3.0.1.tar.bz2) = 1f0ecc7388f1058d64df9ab98734810a983e6d26 Size (ganglia-3.0.1.tar.bz2) = 2649342 bytes SHA1 (patch-aa) = 88972d2268ebc76d72d8f2197bb272c6553f7098 -SHA1 (patch-ab) = 21cae050a12d8b63aa313a327b6358fd6b9e397e +SHA1 (patch-ab) = a8b766000f725ed1785c4b3d2baecfa2cbe66da1 SHA1 (patch-ac) = 23ad60ea06080a6763b21256e20549868110cf54 SHA1 (patch-ad) = 4f03c665800827e1d89d7d76b81b667f0cf82ca6 SHA1 (patch-ae) = 417a7ed552583fc61f8c3e095e9233c68311caf9 diff --git a/parallel/ganglia-monitor-core/patches/patch-ab b/parallel/ganglia-monitor-core/patches/patch-ab index da764620542..5685d6a487e 100644 --- a/parallel/ganglia-monitor-core/patches/patch-ab +++ b/parallel/ganglia-monitor-core/patches/patch-ab @@ -1,8 +1,8 @@ -$NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ +$NetBSD: patch-ab,v 1.3 2005/04/13 01:57:29 jschauma Exp $ ---- /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 @@ +--- /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,1279 @@ +/* + * First stab at support for metrics in NetBSD + * by Jan Schaumann <jschauma@netbsd.org> @@ -43,6 +43,10 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ +#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 @@ -60,13 +64,21 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ +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 size_t regetmntinfo(struct statfs **, long); -+static float find_disk_space(double *, double *); -+static int vm_state(int); ++// XXX ++//static int vm_state(int); + -+static kvm_t *kd = NULL; -+static long pagesize; ++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, @@ -82,6 +94,10 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ + 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; +} @@ -254,6 +270,44 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ + 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 ) +{ @@ -857,6 +911,8 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ +{ + struct statfs *mntbuf; + const char *fstype; ++ const char **vfslist; ++ char *netvfslist; + size_t i, mntsize; + size_t used, availblks; + const double reported_units = 1e9; @@ -869,8 +925,12 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ + + fstype = "ufs"; + ++ netvfslist = makenetvfslist(); ++ vfslist = makevfslist(netvfslist); ++ free(netvfslist); ++ + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); -+ mntsize = regetmntinfo(&mntbuf, mntsize); ++ 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; @@ -895,29 +955,138 @@ $NetBSD: patch-ab,v 1.2 2005/02/10 02:33:53 jschauma Exp $ + * current (not cached) info. Returns the new count of valid statfs bufs. + */ +static size_t -+regetmntinfo(struct statfs **mntbufp, long mntsize) ++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 (i = 0; i < mntsize; i++) { -+ struct statfs layerbuf = mntbuf[i]; ++ for (j = 0, i = 0; i < mntsize; i++) { ++ if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) ++ continue; + (void)statfs(mntbuf[i].f_mntonname, &mntbuf[j]); -+ /* -+ * 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; + 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, |