Discussion:
samba profiling and pcp pmda
Alison Winters
2007-04-12 06:42:33 UTC
Permalink
CC:ed into samba-technical from personal email, this is a discussion
about the steps we could to take to enhance the existing profiling code
in Samba.
The metrics export mechanism from jpeach-xmetrics belongs in the main
samba tree.
Agreed.
The first thing you need to do to get this in is to split it into
multiple mmap'ed files. That is, each different metrics structure should
have its own mmap and backing store. Once you do this, the allocator
becomes a simple slot allocator and most of the really ugly code goes away.
Do you mean having one header file that everything mmaps and a bunch of
files for each connected client and configured share that get mmapped
separately? I'm assuming the ugly code you're referring to is the bit
where it has to keep growing the file whenever new connections join etc.
The second thing that you need os some way of gathering the stats that
is not that horrible VFS module :)
That's in the pipeline :) What i'm planning is to just add a bit of
extra magic to the existing Samba profiling macros that allow us to
split it out per-client and per-share along with the existing recording
of global counts and times. I'm pretty sure this is going to be fairly
elegant and small if i get it right.

I have a separate patch which i can't submit yet (it's copyright SGI)
that splits out all of the current profiling statistics into smaller
groups that we can turn on and off independently. This will allow us
more granular control over what to profile, and will hopefully avoid
nasty performance hits when we're only interested in isolated areas of
the code.
Once you have a stable, versioned export mechanism, then the PMDA can
simply be one of the consumers of the exported metrics. There's not real
need for it to be in the Samba tree. I'd be OK with making the client
interfaces (header file and shared library) LGPL.
I guess my real problem with this is that there's already a PMDA in the
pcp/ subdirectory in Samba. This PMDA is broken right now - it won't
compile because some definitions have been moved around. If it's not
going to be maintained then it should be removed from the tree - i can
just have a closed-source PMDA that builds independently (assuming LGPL
headers). On the other hand, since it's in the tree anyway it could be
maintained as part of Samba - in which case i think applying the
attached two patches (move, then add) would be the right thing to do.
These patches move the PMDA into the main build - they're just a subset
of your xmetrics branch.
I was going to CC samba-technical, but got lazy. Feel free to forward
this mail there if you want some more opinions ...
Done :-)

Alison

-------------- next part --------------
Index: samba-3.0.24.vanilla/source/profile/pmda/root
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/root 2007-04-11 14:02:06.791875499 +1000
@@ -0,0 +1,10 @@
+/*
+ * fake "root" for validating the local PMNS subtree
+ */
+
+#include "/var/pcp/pmns/stdpmid"
+
+root { samba }
+
+#include "pmns"
+
Index: samba-3.0.24.vanilla/source/profile/pmda/samba.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/samba.c 2007-04-11 14:02:06.795874974 +1000
@@ -0,0 +1,390 @@
+/*
+ * Samba, configurable PMDA
+ *
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA 94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+
+typedef int BOOL;
+
+#define IRIX 1
+
+#include <stdio.h>
+#include <sys/shm.h>
+#include <pcp/pmapi.h>
+#ifdef IRIX
+#include <pcp/impl.h>
+#endif
+#include <pcp/pmda.h>
+#include "domain.h"
+#include "profile.h"
+#include "metrics.h"
+
+static pmdaInstid *counttime = NULL;
+static pmdaInstid *bytes = NULL;
+
+/*
+ * List of instance domains
+ */
+
+static pmdaIndom indomtab[] = {
+ {COUNT_TIME_INDOM,0,NULL},
+ {BYTE_INDOM,0,NULL}
+};
+/*
+ * all metrics supported in this PMDA - one table entry for each
+ */
+
+static pmdaMetric metrictab[] = {
+/* smbd.smb_count */
+ { NULL, { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* smbd.uid_changes */
+ { NULL, { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* statcache.lookups */
+ { NULL, { PMDA_PMID(1,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* statcache.misses */
+ { NULL, { PMDA_PMID(1,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* statcache.hits */
+ { NULL, { PMDA_PMID(1,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.num_caches */
+ { NULL, { PMDA_PMID(2,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.allocated_caches */
+ { NULL, { PMDA_PMID(2,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.read_hits */
+ { NULL, { PMDA_PMID(2,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.total_writes */
+ { NULL, { PMDA_PMID(2,3), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.init_writes */
+ { NULL, { PMDA_PMID(2,4), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.abutted_writes */
+ { NULL, { PMDA_PMID(2,5), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.perfect_writes */
+ { NULL, { PMDA_PMID(2,6), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.direct_writes */
+ { NULL, { PMDA_PMID(2,7), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.non_oplock_writes */
+ { NULL, { PMDA_PMID(2,8), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.seek_flush */
+ { NULL, { PMDA_PMID(2,9), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.read_flush */
+ { NULL, { PMDA_PMID(2,10), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.write_flush */
+ { NULL, { PMDA_PMID(2,11), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.readraw_flush */
+ { NULL, { PMDA_PMID(2,12), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.oplock_rel_flush */
+ { NULL, { PMDA_PMID(2,13), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.close_flush */
+ { NULL, { PMDA_PMID(2,14), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.sync_flush */
+ { NULL, { PMDA_PMID(2,15), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* writecache.size_change_flush */
+ { NULL, { PMDA_PMID(2,16), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* counts instance domain */
+ { NULL, { PMDA_PMID(3,0), PM_TYPE_U32, COUNT_TIME_INDOM, PM_SEM_COUNTER,
+ { 0,0,1,0,0,PM_COUNT_ONE} }, },
+/* times instance domain */
+ { NULL, { PMDA_PMID(4,0), PM_TYPE_U32, COUNT_TIME_INDOM, PM_SEM_COUNTER,
+ { 0,1,0,0,PM_TIME_USEC,0} }, },
+/* bytes instance domain */
+ { NULL, { PMDA_PMID(5,0), PM_TYPE_U32, BYTE_INDOM, PM_SEM_COUNTER,
+ { 1,0,0,PM_SPACE_BYTE,0,0} }, }
+
+};
+
+extern int errno;
+struct profile_stats *stats;
+struct profile_header *shmheader;
+int shmid = -1;
+
+
+int
+samba_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
+{
+ __pmID_int *idp = (__pmID_int *)&(mdesc->m_desc.pmid);
+
+
+ if (inst != PM_IN_NULL && mdesc->m_desc.indom == PM_INDOM_NULL)
+ return PM_ERR_INST;
+
+ if (idp->cluster == 0) {
+ switch (idp->item) {
+ case 0: /* smbd.smb_count */
+ atom->ul = stats->smb_count;
+ break;
+ case 1: /* smb.uid_changes */
+ atom->ul = stats->uid_changes;
+ break;
+ default:
+ return PM_ERR_PMID;
+ }
+ }
+ else if (idp->cluster == 1) { /* statcache */
+ switch (idp->item) {
+ case 0: /* statcache.lookups */
+ atom->ul = stats->statcache_lookups;
+ break;
+ case 1: /* statcache.misses */
+ atom->ul = stats->statcache_misses;
+ break;
+ case 2: /* statcache.hits */
+ atom->ul = stats->statcache_hits;
+ break;
+ default:
+ return PM_ERR_PMID;
+ }
+ }
+ else if (idp->cluster == 2) { /* writecache */
+ switch (idp->item) {
+ case 0: /* writecache.num_caches */
+ atom->ul = stats->writecache_num_write_caches;
+ break;
+ case 1: /* writecache.allocated_caches */
+ atom->ul = stats->writecache_allocated_write_caches;
+ break;
+ case 2: /* writecache.read_hits */
+ atom->ul = stats->writecache_read_hits;
+ break;
+ case 3: /* writecache.total_writes */
+ atom->ul = stats->writecache_total_writes;
+ break;
+ case 4: /* writecache.init_writes */
+ atom->ul = stats->writecache_init_writes;
+ break;
+ case 5: /* writecache.abutted_writes */
+ atom->ul = stats->writecache_abutted_writes;
+ break;
+ case 6: /* writecache.perfect_writes */
+ atom->ul = stats->writecache_num_perfect_writes;
+ break;
+ case 7: /* writecache.direct_writes */
+ atom->ul = stats->writecache_direct_writes;
+ break;
+ case 8: /* writecache.non_oplock_writes */
+ atom->ul = stats->writecache_non_oplock_writes;
+ break;
+ case 9: /* writecache.seek_flush */
+ atom->ul = stats->writecache_flushed_writes[SEEK_FLUSH];
+ break;
+ case 10: /* writecache.read_flush */
+ atom->ul = stats->writecache_flushed_writes[READ_FLUSH];
+ break;
+ case 11: /* writecache.write_flush */
+ atom->ul = stats->writecache_flushed_writes[WRITE_FLUSH];
+ break;
+ case 12: /* writecache.readraw_flush */
+ atom->ul = stats->writecache_flushed_writes[READRAW_FLUSH];
+ break;
+ case 13: /* writecache.oplock_rel_flush */
+ atom->ul = stats->writecache_flushed_writes[OPLOCK_RELEASE_FLUSH];
+ break;
+ case 14: /* writecache.close_flush */
+ atom->ul = stats->writecache_flushed_writes[CLOSE_FLUSH];
+ break;
+ case 15: /* writecache.sync_flush */
+ atom->ul = stats->writecache_flushed_writes[SYNC_FLUSH];
+ break;
+ case 16: /* writecache.size_change_flush */
+ atom->ul = stats->writecache_flushed_writes[SIZECHANGE_FLUSH];
+ break;
+ default:
+ return PM_ERR_PMID;
+ }
+ }
+ else if (idp->cluster == 3) { /* counts */
+ if (idp->item == 0) {
+ if (inst < indomtab[COUNT_TIME_INDOM].it_numinst) {
+ unsigned *p;
+
+ p = (unsigned *)((unsigned)stats + samba_counts[inst].offset);
+ atom->ul = *p;
+ }
+ else
+ return PM_ERR_INST;
+ }
+ else
+ return PM_ERR_PMID;
+ }
+ else if (idp->cluster == 4) { /* times */
+ if (idp->item == 0) {
+ if (inst < indomtab[COUNT_TIME_INDOM].it_numinst) {
+ unsigned *p;
+
+ p = (unsigned *)((unsigned)stats + samba_times[inst].offset);
+ atom->ul = *p;
+ }
+ else
+ return PM_ERR_INST;
+ }
+ else
+ return PM_ERR_PMID;
+ }
+ else if (idp->cluster == 5) { /* bytes */
+ if (idp->item == 0) {
+ if (inst < indomtab[BYTE_INDOM].it_numinst) {
+ unsigned *p;
+
+ p = (unsigned *)((unsigned)stats + samba_bytes[inst].offset);
+ atom->ul = *p;
+ }
+ else
+ return PM_ERR_INST;
+ }
+ else
+ return PM_ERR_PMID;
+ }
+ else
+ return PM_ERR_PMID;
+ return 0;
+}
+
+
+void
+samba_init(pmdaInterface *dp)
+{
+ int inst_count, i;
+
+ if (dp->status != 0)
+ return;
+
+ if ((shmid = shmget(PROF_SHMEM_KEY, 0, 0)) == -1) {
+ fprintf(stderr, "shmid: %s\n", strerror(errno));
+ fprintf(stderr, "samba not compiled with profile support or not running\n");
+ exit(1);
+ }
+ shmheader = (struct profile_header *)shmat(shmid, NULL, SHM_RDONLY);
+ if ((int)shmheader == -1) {
+ fprintf(stderr, "shmat: %s\n", strerror(errno));
+ exit(1);
+ }
+
+/*
+ * Initialize lists of instances
+ */
+
+ inst_count = sizeof(samba_counts)/sizeof(samba_counts[0]);
+ counttime = (pmdaInstid *)malloc(inst_count * sizeof(pmdaInstid));
+ if (counttime == NULL) {
+ __pmNoMem("count&time",inst_count * sizeof(pmdaInstid),PM_FATAL_ERR);
+ /* NOTREACHED*/
+ }
+ for (i = 0; i < inst_count; i++) {
+ counttime[i].i_inst = i;
+ counttime[i].i_name = samba_counts[i].name;
+ }
+ indomtab[COUNT_TIME_INDOM].it_numinst = inst_count;
+ indomtab[COUNT_TIME_INDOM].it_set = counttime;
+
+ inst_count = sizeof(samba_bytes)/sizeof(samba_bytes[0]);
+ bytes = (pmdaInstid *)malloc(inst_count * sizeof(pmdaInstid));
+ if (bytes == NULL) {
+ __pmNoMem("bytes",inst_count * sizeof(pmdaInstid),PM_FATAL_ERR);
+ /* NOTREACHED*/
+ }
+ for (i = 0; i < inst_count; i++) {
+ bytes[i].i_inst = i;
+ bytes[i].i_name = samba_bytes[i].name;
+ }
+ indomtab[BYTE_INDOM].it_numinst = inst_count;
+ indomtab[BYTE_INDOM].it_set = bytes;
+
+
+ pmdaSetFetchCallBack(dp, samba_fetchCallBack);
+ pmdaInit(dp, indomtab, sizeof(indomtab)/sizeof(indomtab[0]),
+ metrictab, sizeof(metrictab)/sizeof(metrictab[0]));
+
+ /* validate the data */
+ if (!shmheader) /* not mapped yet */
+ fprintf(stderr, "samba_init: shmem not mapped\n");
+ else if (shmheader->prof_shm_magic != PROF_SHM_MAGIC)
+ fprintf(stderr, "samba_init: bad magic\n");
+ else if (shmheader->prof_shm_version != PROF_SHM_VERSION)
+ fprintf(stderr, "samba_init: bad version %X\n",
+ shmheader->prof_shm_version);
+ else {
+ stats = &shmheader->stats;
+ return; /* looks OK */
+ }
+ exit(1);
+}
+
+
+int
+main(int argc, char **argv)
+{
+ int err = 0;
+ char *p;
+ pmdaInterface dispatch;
+
+ for (p = pmProgname = argv[0]; *p; p++)
+ if (*p == '/') pmProgname = p+1;
+
+ pmdaDaemon(&dispatch, PMDA_INTERFACE_2, pmProgname, SAMBA,
+ "samba.log", "/var/pcp/pmdas/samba/help");
+
+ if (pmdaGetOpt(argc, argv, "D:d:l:?", &dispatch, &err) != EOF) {
+ fprintf(stderr, "Usage: %s [options]\n\n\
+Options:\n\
+ -d domain use domain (numeric) for metrics domain of PMDA\n\
+ -l logfile write log into logfile rather than using default log name\n",
+ pmProgname);
+ exit(1);
+ }
+
+ pmdaOpenLog(&dispatch);
+ samba_init(&dispatch);
+ pmdaConnect(&dispatch);
+ pmdaMain(&dispatch);
+
+ exit(0);
+ /*NOTREACHED*/
+}
Index: samba-3.0.24.vanilla/source/profile/pmda/Install
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/Install 2007-04-11 14:02:06.795874974 +1000
@@ -0,0 +1,64 @@
+#! /bin/sh
+#
+# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Further, this software is distributed without any warranty that it is
+# free of the rightful claim of any third person regarding infringement
+# or the like. Any license provided herein, whether implied or
+# otherwise, applies only to this software file. Patent licenses, if
+# any, provided herein do not apply to combinations of this program with
+# other software, or any other product whatsoever.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+# Mountain View, CA 94043, or:
+#
+# http://www.sgi.com
+#
+# For further information regarding this notice, see:
+#
+# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+#
+# Install the samba PMDA and/or PMNS
+#
+
+# source the PCP configuration environment variables
+. /etc/pcp.env
+
+# Get the common procedures and variable assignments
+#
+. $PCP_SHARE_DIR/lib/pmdaproc.sh
+
+# The name of the PMDA
+#
+iam=samba
+
+# override interactive dialog from pmdaproc.sh
+#
+__choose_mode()
+{
+ echo "Installing the \"$iam\" Performance Metrics Domain Agent (PMDA) ..."
+ echo
+}
+
+# Using libpcp_pmda.so.2 and PMDA_INTERFACE_2
+#
+pmda_interface=2
+
+# Do it
+#
+pmdaSetup
+pmdaInstall
+
+exit 0
Index: samba-3.0.24.vanilla/source/profile/pmda/help
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/help 2007-04-11 14:02:04.608162119 +1000
@@ -0,0 +1,77 @@
+#
+# samba PMDA help file in the ASCII format
+#
+# lines beginning with a # are ignored
+# lines beginning @ introduce a new entry of the form
+# @ metric_name oneline-text
+# help test goes
+# here over multiple lines
+# ...
+#
+# the metric_name is decoded against the default PMNS -- as a special case,
+# a name of the form NNN.MM (for numeric NNN and MM) is interpreted as an
+# instance domain identification, and the text describes the instance domain
+#
+# blank lines before the @ line are ignored
+#
+
+@ SAMBA.0 Count and Time Instance Domain
+Contains count and time information for system calls and smb transactions.
+Counts shows the number of times each transaction was called. Times
+indicates the time spent in each transaction.
+
+@ SAMBA.1 Byte Instance Domain
+This domain contains instances for the number of bytes transferred
+using the read and write system call.
+
+@ samba.counts Count of calls to this function
+
+@ samba.times Time required to complete call
+
+@ samba.bytes Number of bytes processed by this call
+
+@ samba.smbd.smb_count Count of SMB packets processed
+
+@ samba.smbd.uid_changes Count of times effective uid changed
+
+@ samba.statcache.lookups Number of lookups in stat cache
+
+@ samba.statcache.misses Number of times stat cache lookup missed
+
+@ samba.statcache.hits Number of times stat cache lookup hit
+
+@ samba.writecache.num_caches Number of write caches available
+
+@ samba.writecache.allocated_caches Number of write caches allocated
+
+@ samba.writecache.read_hits Number of times read request found in write cache
+
+@ samba.writecache.total_writes Number of writes to write cache
+
+@ samba.writecache.init_writes Number of initial writes to write cache
+
+@ samba.writecache.abutted_writes
+
+@ samba.writecache.perfect_writes
+
+@ samba.writecache.direct_writes
+
+@ samba.writecache.non_oplock_writes
+
+@ samba.writecache.seek_flush
+
+@ samba.writecache.read_flush
+
+@ samba.writecache.write_flush
+
+@ samba.writecache.readraw_flush
+
+@ samba.writecache.oplock_rel_flush
+
+@ samba.writecache.close_flush
+
+@ samba.writecache.sync_flush
+
+@ samba.writecache.size_change_flush
+
+@ samba.bytes cumulative number of bytes read or written
Index: samba-3.0.24.vanilla/source/profile/pmda/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/Makefile 2007-04-11 14:02:06.795874974 +1000
@@ -0,0 +1,74 @@
+#!make
+#
+# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Further, this software is distributed without any warranty that it is
+# free of the rightful claim of any third person regarding infringement
+# or the like. Any license provided herein, whether implied or
+# otherwise, applies only to this software file. Patent licenses, if
+# any, provided herein do not apply to combinations of this program with
+# other software, or any other product whatsoever.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+# Mountain View, CA 94043, or:
+#
+# http://www.sgi.com
+#
+# For further information regarding this notice, see:
+#
+# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+#
+
+SHELL = sh
+
+include /etc/pcp.conf
+
+IAM = samba
+CFILES = $(IAM).c
+
+LIBTARGET = pmda_$(IAM).so
+CMDTARGET = pmda$(IAM)
+TARGETS = $(LIBTARGET) $(CMDTARGET)
+
+DEBUG = -DDEBUG
+CFLAGS = $(DEBUG)
+LDOPTS =
+LDLIBS = -lpcp_pmda -lpcp
+DSOOPTS = -shared
+LDIRT = profile.h metrics.h so_locations *.log help.dir help.pag *.pmda_$(IAM).so
+
+PROFILEHEADER = ../source/include/smbprofile.h
+
+INSTALL = install
+CC = cc
+
+default: $(TARGETS)
+
+install: default
+
+$(CMDTARGET): profile.h metrics.h $(CFILES)
+ $(CC) $(CFLAGS) $(CFILES) $(LDOPTS) $(LDLIBS) -o $@
+
+$(LIBTARGET): profile.h metrics.h $(CFILES)
+ $(CC) $(CFLAGS) $(DSOOPTS) $(LDOPTS) $(CFILES) $(LDLIBS) -o $@
+
+metrics.h: profile.h mkheader.pl
+ ./mkheader.pl
+
+profile.h: $(PROFILEHEADER)
+ ln -s $(PROFILEHEADER) $@
+
+clobber clean:
+ rm -f $(LDIRT) $(TARGETS)
Index: samba-3.0.24.vanilla/source/profile/pmda/README
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/README 2007-04-11 14:02:04.612161594 +1000
@@ -0,0 +1,94 @@
+samba PMDA
+===========
+
+This PMDA is a sample that illustrates how a simple samba monitor
+PMDA might be constructed, using a shared memory segment to transfer
+information about transaction activity from the smb daemon.
+
+Note:
+ This PMDA may be remade from source and hence requires
+ a C compiler and Perl to be installed.
+
+ Uses of make(1) may fail (without removing or clobbering files)
+ if the C compiler cannot be found. This is most likely to
+ happen when running the PMDA ./Install script.
+
+ The only remedial action is to install the C compiler, or
+ hand-craft changes to the Makefile.
+
+Metrics
+=======
+
+The file ./help contains descriptions for all of the metrics exported
+by this PMDA.
+
+Once the PMDA has been installed, the following command will list all
+the available metrics and their explanatory "help" text:
+
+ $ pminfo -fT samba
+
+Installation
+============
+
+ + # mkdir /var/pcp/pmdas/samba
+ + # cp * /var/pcp/pmdas/samba
+ + # cp ../source/include/profile.h /var/pcp/pmdas/samba
+ + # cd /var/pcp/pmdas/samba
+
+ + Check that there is no clash in the Performance Metrics Domain
+ defined in ./domain.h and the other PMDAs currently in use
+ (/etc/pmcd.conf). If there is, edit ./domain.h to choose another
+ domain number.
+
+ + If you are not installing on an IRIX system, edit samba.c and
+ comment out the
+
+ #define IRIX 1
+
+ + Then simply use
+
+ # ./Install
+
+ + Alternatively, to install just the Performance Metrics Name Space
+ for the samba metrics on the local system, but not the samba PMDA
+ (presumably because the local system is running PCP 1.x and you
+ wish to connect to a remote system where PCP 2.0 and the samba PMDA
+ is running), make sure the Performance Metrics Domain defined in
+ ./domain.h matches the domain chosen for the samba PMDA on the
+ remote system (check the second field in the corresponding line of
+ the pmcd.conf file on the remote system - located in /etc on IRIX
+ and /var/pcp/config/pmcd on Linux), then
+
+ # ./Install -N
+
+De-installation
+===============
+
+ + Simply use
+
+ # cd /var/pcp/pmdas/samba
+ # ./Remove
+
+ + If you also want to remove the sources use
+
+ # cd /
+ # rm -rf /var/pcp/pmdas/samba
+
+Making something happen
+=======================
+
+The application "smbd" updates the shared memory segment to add
+profile information about smbd. By default updating is disabled.
+To start updating of the shared memory segment you need to run the
+smbcontrol command to turn on profiling for one or more smbd processes
+(see the man page for smbcontrol).
+
+
+
+Troubleshooting
+===============
+
+ + After installing or restarting the agent, the PMCD log file
+ (pmcd.log) and the PMDA log file (samba.log) should be checked
+ for any warnings or errors. These logs are located in
+ /var/log/pcp/pmcd on Linux and /var/adm/pcplog on IRIX.
Index: samba-3.0.24.vanilla/source/profile/pmda/Remove
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/Remove 2007-04-11 14:02:06.799874449 +1000
@@ -0,0 +1,52 @@
+#! /bin/sh
+#
+# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Further, this software is distributed without any warranty that it is
+# free of the rightful claim of any third person regarding infringement
+# or the like. Any license provided herein, whether implied or
+# otherwise, applies only to this software file. Patent licenses, if
+# any, provided herein do not apply to combinations of this program with
+# other software, or any other product whatsoever.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+# Mountain View, CA 94043, or:
+#
+# http://www.sgi.com
+#
+# For further information regarding this notice, see:
+#
+# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+#
+# Remove the samba PMDA
+#
+
+# source the PCP configuration environment variables
+. /etc/pcp.env
+
+# Get the common procedures and variable assignments
+#
+. $PCP_SHARE_DIR/lib/pmdaproc.sh
+
+# The name of the PMDA
+#
+iam=samba
+
+# Do it
+#
+pmdaSetup
+pmdaRemove
+
+exit 0
Index: samba-3.0.24.vanilla/source/profile/pmda/domain.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/domain.h 2007-04-11 14:02:06.799874449 +1000
@@ -0,0 +1,4 @@
+/*
+ * built from /var/pcp/pmns/stdpmid
+ */
+#define SAMBA 123
Index: samba-3.0.24.vanilla/source/profile/pmda/pmns
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/profile/pmda/pmns 2007-04-11 14:02:06.799874449 +1000
@@ -0,0 +1,45 @@
+/*
+ * Metrics for samba PMDA
+ *
+ */
+
+samba {
+ smbd
+ statcache
+ writecache
+ counts SAMBA:3:0
+ times SAMBA:4:0
+ bytes SAMBA:5:0
+}
+
+samba.smbd {
+ smb_count SAMBA:0:0
+ uid_changes SAMBA:0:1
+}
+
+samba.statcache {
+ lookups SAMBA:1:0
+ misses SAMBA:1:1
+ hits SAMBA:1:2
+}
+
+samba.writecache {
+ num_caches SAMBA:2:0
+ allocated_caches SAMBA:2:1
+ read_hits SAMBA:2:2
+ total_writes SAMBA:2:3
+ init_writes SAMBA:2:4
+ abutted_writes SAMBA:2:5
+ perfect_writes SAMBA:2:6
+ direct_writes SAMBA:2:7
+ non_oplock_writes SAMBA:2:8
+ seek_flush SAMBA:2:9
+ read_flush SAMBA:2:10
+ write_flush SAMBA:2:11
+ readraw_flush SAMBA:2:12
+ oplock_rel_flush SAMBA:2:13
+ close_flush SAMBA:2:14
+ sync_flush SAMBA:2:15
+ size_change_flush SAMBA:2:16
+}
+
Index: samba-3.0.24.vanilla/source/script/mkmetricsheader.pl
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.24.vanilla/source/script/mkmetricsheader.pl 2007-04-11 14:02:06.799874449 +1000
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+
+open(PROFILE,"profile.h") || die "Unable to open profile.h\n";
+@profile = <PROFILE>;
+close PROFILE;
+
+open(METRICS,"> metrics.h") || die "Unable to open metrics.h for output\n";
+
+print METRICS "#define COUNT_TIME_INDOM 0\n";
+print METRICS "#define BYTE_INDOM 1\n\n";
+print METRICS "#define FIELD_OFF(x) (unsigned)\&(((struct profile_stats *)NULL)->x)\n\n";
+print METRICS "typedef struct {\n";
+print METRICS "\tchar *name;\n";
+print METRICS "\tunsigned offset;\n";
+print METRICS "} samba_instance;\n\n";
+
+@instnames = grep(/unsigned .*_time;/,@profile);
+foreach $instnames (@instnames) {
+ chomp $instnames;
+ $instnames =~ s/^.*unsigned (.*)_time.*$/$1/;
+}
+
+print METRICS "static samba_instance samba_counts[] = {";
+$first = 1;
+foreach $1 (@instnames) {
+ if ($first == 1) {
+ $first = 0;
+ print METRICS "\n";
+ } else {
+ print METRICS ",\n";
+ }
+ print METRICS "\t{\"$1\", FIELD_OFF($1_count)}";
+}
+print METRICS "\n};\n\n";
+print METRICS "static samba_instance samba_times[] = {";
+$first = 1;
+foreach $1 (@instnames) {
+ if ($first == 1) {
+ $first = 0;
+ print METRICS "\n";
+ } else {
+ print METRICS ",\n";
+ }
+ print METRICS "\t{\"$1\", FIELD_OFF($1_time)}";
+}
+print METRICS "\n};\n\n";
+print METRICS "static samba_instance samba_bytes[] = {";
+@instnames = grep(/unsigned .*_bytes;/,@profile);
+$first = 1;
+foreach $_ (@instnames) {
+ if ($first == 1) {
+ $first = 0;
+ print METRICS "\n";
+ } else {
+ print METRICS ",\n";
+ }
+ /^.*unsigned (.*)_bytes.*$/;
+ print METRICS "\t{\"$1\", FIELD_OFF($1_bytes)}";
+}
+print METRICS "\n};\n";
+
+close METRICS
Index: samba-3.0.24.vanilla/pcp/root
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/root 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,10 +0,0 @@
-/*
- * fake "root" for validating the local PMNS subtree
- */
-
-#include "/var/pcp/pmns/stdpmid"
-
-root { samba }
-
-#include "pmns"
-
Index: samba-3.0.24.vanilla/pcp/samba.c
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/samba.c 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,390 +0,0 @@
-/*
- * Samba, configurable PMDA
- *
- * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-typedef int BOOL;
-
-#define IRIX 1
-
-#include <stdio.h>
-#include <sys/shm.h>
-#include <pcp/pmapi.h>
-#ifdef IRIX
-#include <pcp/impl.h>
-#endif
-#include <pcp/pmda.h>
-#include "domain.h"
-#include "profile.h"
-#include "metrics.h"
-
-static pmdaInstid *counttime = NULL;
-static pmdaInstid *bytes = NULL;
-
-/*
- * List of instance domains
- */
-
-static pmdaIndom indomtab[] = {
- {COUNT_TIME_INDOM,0,NULL},
- {BYTE_INDOM,0,NULL}
-};
-/*
- * all metrics supported in this PMDA - one table entry for each
- */
-
-static pmdaMetric metrictab[] = {
-/* smbd.smb_count */
- { NULL, { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* smbd.uid_changes */
- { NULL, { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* statcache.lookups */
- { NULL, { PMDA_PMID(1,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* statcache.misses */
- { NULL, { PMDA_PMID(1,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* statcache.hits */
- { NULL, { PMDA_PMID(1,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.num_caches */
- { NULL, { PMDA_PMID(2,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.allocated_caches */
- { NULL, { PMDA_PMID(2,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.read_hits */
- { NULL, { PMDA_PMID(2,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.total_writes */
- { NULL, { PMDA_PMID(2,3), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.init_writes */
- { NULL, { PMDA_PMID(2,4), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.abutted_writes */
- { NULL, { PMDA_PMID(2,5), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.perfect_writes */
- { NULL, { PMDA_PMID(2,6), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.direct_writes */
- { NULL, { PMDA_PMID(2,7), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.non_oplock_writes */
- { NULL, { PMDA_PMID(2,8), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.seek_flush */
- { NULL, { PMDA_PMID(2,9), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.read_flush */
- { NULL, { PMDA_PMID(2,10), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.write_flush */
- { NULL, { PMDA_PMID(2,11), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.readraw_flush */
- { NULL, { PMDA_PMID(2,12), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.oplock_rel_flush */
- { NULL, { PMDA_PMID(2,13), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.close_flush */
- { NULL, { PMDA_PMID(2,14), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.sync_flush */
- { NULL, { PMDA_PMID(2,15), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* writecache.size_change_flush */
- { NULL, { PMDA_PMID(2,16), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* counts instance domain */
- { NULL, { PMDA_PMID(3,0), PM_TYPE_U32, COUNT_TIME_INDOM, PM_SEM_COUNTER,
- { 0,0,1,0,0,PM_COUNT_ONE} }, },
-/* times instance domain */
- { NULL, { PMDA_PMID(4,0), PM_TYPE_U32, COUNT_TIME_INDOM, PM_SEM_COUNTER,
- { 0,1,0,0,PM_TIME_USEC,0} }, },
-/* bytes instance domain */
- { NULL, { PMDA_PMID(5,0), PM_TYPE_U32, BYTE_INDOM, PM_SEM_COUNTER,
- { 1,0,0,PM_SPACE_BYTE,0,0} }, }
-
-};
-
-extern int errno;
-struct profile_stats *stats;
-struct profile_header *shmheader;
-int shmid = -1;
-
-
-int
-samba_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
-{
- __pmID_int *idp = (__pmID_int *)&(mdesc->m_desc.pmid);
-
-
- if (inst != PM_IN_NULL && mdesc->m_desc.indom == PM_INDOM_NULL)
- return PM_ERR_INST;
-
- if (idp->cluster == 0) {
- switch (idp->item) {
- case 0: /* smbd.smb_count */
- atom->ul = stats->smb_count;
- break;
- case 1: /* smb.uid_changes */
- atom->ul = stats->uid_changes;
- break;
- default:
- return PM_ERR_PMID;
- }
- }
- else if (idp->cluster == 1) { /* statcache */
- switch (idp->item) {
- case 0: /* statcache.lookups */
- atom->ul = stats->statcache_lookups;
- break;
- case 1: /* statcache.misses */
- atom->ul = stats->statcache_misses;
- break;
- case 2: /* statcache.hits */
- atom->ul = stats->statcache_hits;
- break;
- default:
- return PM_ERR_PMID;
- }
- }
- else if (idp->cluster == 2) { /* writecache */
- switch (idp->item) {
- case 0: /* writecache.num_caches */
- atom->ul = stats->writecache_num_write_caches;
- break;
- case 1: /* writecache.allocated_caches */
- atom->ul = stats->writecache_allocated_write_caches;
- break;
- case 2: /* writecache.read_hits */
- atom->ul = stats->writecache_read_hits;
- break;
- case 3: /* writecache.total_writes */
- atom->ul = stats->writecache_total_writes;
- break;
- case 4: /* writecache.init_writes */
- atom->ul = stats->writecache_init_writes;
- break;
- case 5: /* writecache.abutted_writes */
- atom->ul = stats->writecache_abutted_writes;
- break;
- case 6: /* writecache.perfect_writes */
- atom->ul = stats->writecache_num_perfect_writes;
- break;
- case 7: /* writecache.direct_writes */
- atom->ul = stats->writecache_direct_writes;
- break;
- case 8: /* writecache.non_oplock_writes */
- atom->ul = stats->writecache_non_oplock_writes;
- break;
- case 9: /* writecache.seek_flush */
- atom->ul = stats->writecache_flushed_writes[SEEK_FLUSH];
- break;
- case 10: /* writecache.read_flush */
- atom->ul = stats->writecache_flushed_writes[READ_FLUSH];
- break;
- case 11: /* writecache.write_flush */
- atom->ul = stats->writecache_flushed_writes[WRITE_FLUSH];
- break;
- case 12: /* writecache.readraw_flush */
- atom->ul = stats->writecache_flushed_writes[READRAW_FLUSH];
- break;
- case 13: /* writecache.oplock_rel_flush */
- atom->ul = stats->writecache_flushed_writes[OPLOCK_RELEASE_FLUSH];
- break;
- case 14: /* writecache.close_flush */
- atom->ul = stats->writecache_flushed_writes[CLOSE_FLUSH];
- break;
- case 15: /* writecache.sync_flush */
- atom->ul = stats->writecache_flushed_writes[SYNC_FLUSH];
- break;
- case 16: /* writecache.size_change_flush */
- atom->ul = stats->writecache_flushed_writes[SIZECHANGE_FLUSH];
- break;
- default:
- return PM_ERR_PMID;
- }
- }
- else if (idp->cluster == 3) { /* counts */
- if (idp->item == 0) {
- if (inst < indomtab[COUNT_TIME_INDOM].it_numinst) {
- unsigned *p;
-
- p = (unsigned *)((unsigned)stats + samba_counts[inst].offset);
- atom->ul = *p;
- }
- else
- return PM_ERR_INST;
- }
- else
- return PM_ERR_PMID;
- }
- else if (idp->cluster == 4) { /* times */
- if (idp->item == 0) {
- if (inst < indomtab[COUNT_TIME_INDOM].it_numinst) {
- unsigned *p;
-
- p = (unsigned *)((unsigned)stats + samba_times[inst].offset);
- atom->ul = *p;
- }
- else
- return PM_ERR_INST;
- }
- else
- return PM_ERR_PMID;
- }
- else if (idp->cluster == 5) { /* bytes */
- if (idp->item == 0) {
- if (inst < indomtab[BYTE_INDOM].it_numinst) {
- unsigned *p;
-
- p = (unsigned *)((unsigned)stats + samba_bytes[inst].offset);
- atom->ul = *p;
- }
- else
- return PM_ERR_INST;
- }
- else
- return PM_ERR_PMID;
- }
- else
- return PM_ERR_PMID;
- return 0;
-}
-
-
-void
-samba_init(pmdaInterface *dp)
-{
- int inst_count, i;
-
- if (dp->status != 0)
- return;
-
- if ((shmid = shmget(PROF_SHMEM_KEY, 0, 0)) == -1) {
- fprintf(stderr, "shmid: %s\n", strerror(errno));
- fprintf(stderr, "samba not compiled with profile support or not running\n");
- exit(1);
- }
- shmheader = (struct profile_header *)shmat(shmid, NULL, SHM_RDONLY);
- if ((int)shmheader == -1) {
- fprintf(stderr, "shmat: %s\n", strerror(errno));
- exit(1);
- }
-
-/*
- * Initialize lists of instances
- */
-
- inst_count = sizeof(samba_counts)/sizeof(samba_counts[0]);
- counttime = (pmdaInstid *)malloc(inst_count * sizeof(pmdaInstid));
- if (counttime == NULL) {
- __pmNoMem("count&time",inst_count * sizeof(pmdaInstid),PM_FATAL_ERR);
- /* NOTREACHED*/
- }
- for (i = 0; i < inst_count; i++) {
- counttime[i].i_inst = i;
- counttime[i].i_name = samba_counts[i].name;
- }
- indomtab[COUNT_TIME_INDOM].it_numinst = inst_count;
- indomtab[COUNT_TIME_INDOM].it_set = counttime;
-
- inst_count = sizeof(samba_bytes)/sizeof(samba_bytes[0]);
- bytes = (pmdaInstid *)malloc(inst_count * sizeof(pmdaInstid));
- if (bytes == NULL) {
- __pmNoMem("bytes",inst_count * sizeof(pmdaInstid),PM_FATAL_ERR);
- /* NOTREACHED*/
- }
- for (i = 0; i < inst_count; i++) {
- bytes[i].i_inst = i;
- bytes[i].i_name = samba_bytes[i].name;
- }
- indomtab[BYTE_INDOM].it_numinst = inst_count;
- indomtab[BYTE_INDOM].it_set = bytes;
-
-
- pmdaSetFetchCallBack(dp, samba_fetchCallBack);
- pmdaInit(dp, indomtab, sizeof(indomtab)/sizeof(indomtab[0]),
- metrictab, sizeof(metrictab)/sizeof(metrictab[0]));
-
- /* validate the data */
- if (!shmheader) /* not mapped yet */
- fprintf(stderr, "samba_init: shmem not mapped\n");
- else if (shmheader->prof_shm_magic != PROF_SHM_MAGIC)
- fprintf(stderr, "samba_init: bad magic\n");
- else if (shmheader->prof_shm_version != PROF_SHM_VERSION)
- fprintf(stderr, "samba_init: bad version %X\n",
- shmheader->prof_shm_version);
- else {
- stats = &shmheader->stats;
- return; /* looks OK */
- }
- exit(1);
-}
-
-
-int
-main(int argc, char **argv)
-{
- int err = 0;
- char *p;
- pmdaInterface dispatch;
-
- for (p = pmProgname = argv[0]; *p; p++)
- if (*p == '/') pmProgname = p+1;
-
- pmdaDaemon(&dispatch, PMDA_INTERFACE_2, pmProgname, SAMBA,
- "samba.log", "/var/pcp/pmdas/samba/help");
-
- if (pmdaGetOpt(argc, argv, "D:d:l:?", &dispatch, &err) != EOF) {
- fprintf(stderr, "Usage: %s [options]\n\n\
-Options:\n\
- -d domain use domain (numeric) for metrics domain of PMDA\n\
- -l logfile write log into logfile rather than using default log name\n",
- pmProgname);
- exit(1);
- }
-
- pmdaOpenLog(&dispatch);
- samba_init(&dispatch);
- pmdaConnect(&dispatch);
- pmdaMain(&dispatch);
-
- exit(0);
- /*NOTREACHED*/
-}
Index: samba-3.0.24.vanilla/pcp/Install
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/Install 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,64 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
-#
-# Install the samba PMDA and/or PMNS
-#
-
-# source the PCP configuration environment variables
-. /etc/pcp.env
-
-# Get the common procedures and variable assignments
-#
-. $PCP_SHARE_DIR/lib/pmdaproc.sh
-
-# The name of the PMDA
-#
-iam=samba
-
-# override interactive dialog from pmdaproc.sh
-#
-__choose_mode()
-{
- echo "Installing the \"$iam\" Performance Metrics Domain Agent (PMDA) ..."
- echo
-}
-
-# Using libpcp_pmda.so.2 and PMDA_INTERFACE_2
-#
-pmda_interface=2
-
-# Do it
-#
-pmdaSetup
-pmdaInstall
-
-exit 0
Index: samba-3.0.24.vanilla/pcp/help
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/help 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,77 +0,0 @@
-#
-# samba PMDA help file in the ASCII format
-#
-# lines beginning with a # are ignored
-# lines beginning @ introduce a new entry of the form
-# @ metric_name oneline-text
-# help test goes
-# here over multiple lines
-# ...
-#
-# the metric_name is decoded against the default PMNS -- as a special case,
-# a name of the form NNN.MM (for numeric NNN and MM) is interpreted as an
-# instance domain identification, and the text describes the instance domain
-#
-# blank lines before the @ line are ignored
-#
-
-@ SAMBA.0 Count and Time Instance Domain
-Contains count and time information for system calls and smb transactions.
-Counts shows the number of times each transaction was called. Times
-indicates the time spent in each transaction.
-
-@ SAMBA.1 Byte Instance Domain
-This domain contains instances for the number of bytes transferred
-using the read and write system call.
-
-@ samba.counts Count of calls to this function
-
-@ samba.times Time required to complete call
-
-@ samba.bytes Number of bytes processed by this call
-
-@ samba.smbd.smb_count Count of SMB packets processed
-
-@ samba.smbd.uid_changes Count of times effective uid changed
-
-@ samba.statcache.lookups Number of lookups in stat cache
-
-@ samba.statcache.misses Number of times stat cache lookup missed
-
-@ samba.statcache.hits Number of times stat cache lookup hit
-
-@ samba.writecache.num_caches Number of write caches available
-
-@ samba.writecache.allocated_caches Number of write caches allocated
-
-@ samba.writecache.read_hits Number of times read request found in write cache
-
-@ samba.writecache.total_writes Number of writes to write cache
-
-@ samba.writecache.init_writes Number of initial writes to write cache
-
-@ samba.writecache.abutted_writes
-
-@ samba.writecache.perfect_writes
-
-@ samba.writecache.direct_writes
-
-@ samba.writecache.non_oplock_writes
-
-@ samba.writecache.seek_flush
-
-@ samba.writecache.read_flush
-
-@ samba.writecache.write_flush
-
-@ samba.writecache.readraw_flush
-
-@ samba.writecache.oplock_rel_flush
-
-@ samba.writecache.close_flush
-
-@ samba.writecache.sync_flush
-
-@ samba.writecache.size_change_flush
-
-@ samba.bytes cumulative number of bytes read or written
Index: samba-3.0.24.vanilla/pcp/mkheader.pl
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/mkheader.pl 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,63 +0,0 @@
-#!/usr/bin/perl
-
-
-open(PROFILE,"profile.h") || die "Unable to open profile.h\n";
-@profile = <PROFILE>;
-close PROFILE;
-
-open(METRICS,"> metrics.h") || die "Unable to open metrics.h for output\n";
-
-print METRICS "#define COUNT_TIME_INDOM 0\n";
-print METRICS "#define BYTE_INDOM 1\n\n";
-print METRICS "#define FIELD_OFF(x) (unsigned)\&(((struct profile_stats *)NULL)->x)\n\n";
-print METRICS "typedef struct {\n";
-print METRICS "\tchar *name;\n";
-print METRICS "\tunsigned offset;\n";
-print METRICS "} samba_instance;\n\n";
-
-@instnames = grep(/unsigned .*_time;/,@profile);
-foreach $instnames (@instnames) {
- chomp $instnames;
- $instnames =~ s/^.*unsigned (.*)_time.*$/$1/;
-}
-
-print METRICS "static samba_instance samba_counts[] = {";
-$first = 1;
-foreach $1 (@instnames) {
- if ($first == 1) {
- $first = 0;
- print METRICS "\n";
- } else {
- print METRICS ",\n";
- }
- print METRICS "\t{\"$1\", FIELD_OFF($1_count)}";
-}
-print METRICS "\n};\n\n";
-print METRICS "static samba_instance samba_times[] = {";
-$first = 1;
-foreach $1 (@instnames) {
- if ($first == 1) {
- $first = 0;
- print METRICS "\n";
- } else {
- print METRICS ",\n";
- }
- print METRICS "\t{\"$1\", FIELD_OFF($1_time)}";
-}
-print METRICS "\n};\n\n";
-print METRICS "static samba_instance samba_bytes[] = {";
-@instnames = grep(/unsigned .*_bytes;/,@profile);
-$first = 1;
-foreach $_ (@instnames) {
- if ($first == 1) {
- $first = 0;
- print METRICS "\n";
- } else {
- print METRICS ",\n";
- }
- /^.*unsigned (.*)_bytes.*$/;
- print METRICS "\t{\"$1\", FIELD_OFF($1_bytes)}";
-}
-print METRICS "\n};\n";
-
-close METRICS
Index: samba-3.0.24.vanilla/pcp/Makefile
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/Makefile 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,74 +0,0 @@
-#!make
-#
-# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
-#
-
-SHELL = sh
-
-include /etc/pcp.conf
-
-IAM = samba
-CFILES = $(IAM).c
-
-LIBTARGET = pmda_$(IAM).so
-CMDTARGET = pmda$(IAM)
-TARGETS = $(LIBTARGET) $(CMDTARGET)
-
-DEBUG = -DDEBUG
-CFLAGS = $(DEBUG)
-LDOPTS =
-LDLIBS = -lpcp_pmda -lpcp
-DSOOPTS = -shared
-LDIRT = profile.h metrics.h so_locations *.log help.dir help.pag *.pmda_$(IAM).so
-
-PROFILEHEADER = ../source/include/smbprofile.h
-
-INSTALL = install
-CC = cc
-
-default: $(TARGETS)
-
-install: default
-
-$(CMDTARGET): profile.h metrics.h $(CFILES)
- $(CC) $(CFLAGS) $(CFILES) $(LDOPTS) $(LDLIBS) -o $@
-
-$(LIBTARGET): profile.h metrics.h $(CFILES)
- $(CC) $(CFLAGS) $(DSOOPTS) $(LDOPTS) $(CFILES) $(LDLIBS) -o $@
-
-metrics.h: profile.h mkheader.pl
- ./mkheader.pl
-
-profile.h: $(PROFILEHEADER)
- ln -s $(PROFILEHEADER) $@
-
-clobber clean:
- rm -f $(LDIRT) $(TARGETS)
Index: samba-3.0.24.vanilla/pcp/README
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/README 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,94 +0,0 @@
-samba PMDA
-===========
-
-This PMDA is a sample that illustrates how a simple samba monitor
-PMDA might be constructed, using a shared memory segment to transfer
-information about transaction activity from the smb daemon.
-
-Note:
- This PMDA may be remade from source and hence requires
- a C compiler and Perl to be installed.
-
- Uses of make(1) may fail (without removing or clobbering files)
- if the C compiler cannot be found. This is most likely to
- happen when running the PMDA ./Install script.
-
- The only remedial action is to install the C compiler, or
- hand-craft changes to the Makefile.
-
-Metrics
-=======
-
-The file ./help contains descriptions for all of the metrics exported
-by this PMDA.
-
-Once the PMDA has been installed, the following command will list all
-the available metrics and their explanatory "help" text:
-
- $ pminfo -fT samba
-
-Installation
-============
-
- + # mkdir /var/pcp/pmdas/samba
- + # cp * /var/pcp/pmdas/samba
- + # cp ../source/include/profile.h /var/pcp/pmdas/samba
- + # cd /var/pcp/pmdas/samba
-
- + Check that there is no clash in the Performance Metrics Domain
- defined in ./domain.h and the other PMDAs currently in use
- (/etc/pmcd.conf). If there is, edit ./domain.h to choose another
- domain number.
-
- + If you are not installing on an IRIX system, edit samba.c and
- comment out the
-
- #define IRIX 1
-
- + Then simply use
-
- # ./Install
-
- + Alternatively, to install just the Performance Metrics Name Space
- for the samba metrics on the local system, but not the samba PMDA
- (presumably because the local system is running PCP 1.x and you
- wish to connect to a remote system where PCP 2.0 and the samba PMDA
- is running), make sure the Performance Metrics Domain defined in
- ./domain.h matches the domain chosen for the samba PMDA on the
- remote system (check the second field in the corresponding line of
- the pmcd.conf file on the remote system - located in /etc on IRIX
- and /var/pcp/config/pmcd on Linux), then
-
- # ./Install -N
-
-De-installation
-===============
-
- + Simply use
-
- # cd /var/pcp/pmdas/samba
- # ./Remove
-
- + If you also want to remove the sources use
-
- # cd /
- # rm -rf /var/pcp/pmdas/samba
-
-Making something happen
-=======================
-
-The application "smbd" updates the shared memory segment to add
-profile information about smbd. By default updating is disabled.
-To start updating of the shared memory segment you need to run the
-smbcontrol command to turn on profiling for one or more smbd processes
-(see the man page for smbcontrol).
-
-
-
-Troubleshooting
-===============
-
- + After installing or restarting the agent, the PMCD log file
- (pmcd.log) and the PMDA log file (samba.log) should be checked
- for any warnings or errors. These logs are located in
- /var/log/pcp/pmcd on Linux and /var/adm/pcplog on IRIX.
Index: samba-3.0.24.vanilla/pcp/Remove
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/Remove 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
-#
-# Remove the samba PMDA
-#
-
-# source the PCP configuration environment variables
-. /etc/pcp.env
-
-# Get the common procedures and variable assignments
-#
-. $PCP_SHARE_DIR/lib/pmdaproc.sh
-
-# The name of the PMDA
-#
-iam=samba
-
-# Do it
-#
-pmdaSetup
-pmdaRemove
-
-exit 0
Index: samba-3.0.24.vanilla/pcp/domain.h
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/domain.h 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,4 +0,0 @@
-/*
- * built from /var/pcp/pmns/stdpmid
- */
-#define SAMBA 123
Index: samba-3.0.24.vanilla/pcp/pmns
===================================================================
--- samba-3.0.24.vanilla.orig/pcp/pmns 2007-04-11 14:01:52.233786310 +1000
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,45 +0,0 @@
-/*
- * Metrics for samba PMDA
- *
- */
-
-samba {
- smbd
- statcache
- writecache
- counts SAMBA:3:0
- times SAMBA:4:0
- bytes SAMBA:5:0
-}
-
-samba.smbd {
- smb_count SAMBA:0:0
- uid_changes SAMBA:0:1
-}
-
-samba.statcache {
- lookups SAMBA:1:0
- misses SAMBA:1:1
- hits SAMBA:1:2
-}
-
-samba.writecache {
- num_caches SAMBA:2:0
- allocated_caches SAMBA:2:1
- read_hits SAMBA:2:2
- total_writes SAMBA:2:3
- init_writes SAMBA:2:4
- abutted_writes SAMBA:2:5
- perfect_writes SAMBA:2:6
- direct_writes SAMBA:2:7
- non_oplock_writes SAMBA:2:8
- seek_flush SAMBA:2:9
- read_flush SAMBA:2:10
- write_flush SAMBA:2:11
- readraw_flush SAMBA:2:12
- oplock_rel_flush SAMBA:2:13
- close_flush SAMBA:2:14
- sync_flush SAMBA:2:15
- size_change_flush SAMBA:2:16
-}
-
-------------- next part --------------
Index: SAMBA_3_0/source/Makefile.in
===================================================================
--- SAMBA_3_0.orig/source/Makefile.in 2007-04-10 15:23:32.000000000 +1000
+++ SAMBA_3_0/source/Makefile.in 2007-04-12 10:57:45.964971615 +1000
@@ -53,6 +53,13 @@ INSTALLLIBCMD_A=@INSTALLLIBCMD_A@
UNINSTALLLIBCMD_SH=@UNINSTALLLIBCMD_SH@
UNINSTALLLIBCMD_A=@UNINSTALLLIBCMD_A@

+PCP_LDFLAGS=@PCP_LDFLAGS@
+PCP_CPPFLAGS=@PCP_CPPFLAGS@
+
+@***@PMDA_LIBS=-lpcp -lpcp_pmda
+@***@PMDA_DIRT=profile/pmda/*.o profile/pmda/pmda_profile.inc
+@***@PMDA_INSTALLDIR=@PMDA_INSTALLDIR@
+
VPATH=@srcdir@
srcdir=@abs_srcdir@
builddir=@abs_builddir@
@@ -168,6 +175,8 @@ TORTURE_PROGS = bin/***@EXEEXT@ b

BIN_PROGS = $(BIN_PROGS1) $(BIN_PROGS2) $(BIN_PROGS3) $(BIN_PROGS4) @EXTRA_BIN_PROGS@ @SMBMOUNT_PROGS@

+@***@PMDA_PROGS = bin/***@EXEEXT@
+
EVERYTHING_PROGS = bin/***@EXEEXT@ bin/***@EXEEXT@ \
bin/***@EXEEXT@ bin/***@EXEEXT@ \
bin/***@EXEEXT@ bin/***@EXEEXT@ bin/***@EXEEXT@
@@ -901,6 +910,10 @@ NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBS
$(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ) \
$(LDB_OBJ) libsmb/errormap.o

+@***@PMDA_OBJ = profile/pmda/samba.o \
+@ifPMDA@ $(LIB_NONSMBD_OBJ) $(PARAM_OBJ) $(SECRETS_OBJ) \
+@ifPMDA@ $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LIBSAMBA_OBJ)
+
######################################################################
# now the rules...
######################################################################
@@ -974,7 +987,7 @@ idl:


everything: all libsmbclient debug2html smbfilter talloctort replacetort modules torture \
- $(EVERYTHING_PROGS)
+ $(EVERYTHING_PROGS) $(PMDA_PROGS)

.SUFFIXES:
.SUFFIXES: .c .o .lo
@@ -1686,8 +1699,21 @@ bin/***@EXEEXT@: script/tests/time
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(DYNEXP) script/tests/timelimit.o

-install: installservers installbin @INSTALL_CIFSMOUNT@ installman installscripts installdat installswat installmodules @INSTALL_LIBSMBCLIENT@ @INSTALL_LIBMSRPC@ @INSTALL_PAM_MODULES@ @INSTALL_LIBSMBSHAREMODES@
+@***@profile/pmda/pmda_profile.inc: include/smbprofile.h script/mkmetricsheader.pl
+@ifPMDA@ $(PERL) script/mkmetricsheader.pl < include/smbprofile.h > $@
+@***@profile/pmda/samba.c: profile/pmda/pmda_profile.inc
+@***@profile/pmda/samba.o: profile/pmda/samba.c
+@ifPMDA@ @echo Compiling $*.c
+@ifPMDA@ @$(CC) -I. -I$(srcdir) $(FLAGS) $(PCP_CPPFLAGS) -c -o $@ profile/pmda/samba.c
+
+@***@bin/***@EXEEXT@: $(PMDA_OBJ)
+@ifPMDA@ @echo Linking $@
+@ifPMDA@ @$(CC) $(FLAGS) -o $@ $(PMDA_OBJ) $(LDFLAGS) $(PMDA_LDFLAGS) \
+@ifPMDA@ $(PMDA_LIBS) $(LIBS)
+
+@***@pmda: $(PMDA_PROGS)

+install: installservers installbin @INSTALL_CIFSMOUNT@ installman installscripts installdat installswat installmodules @INSTALL_LIBSMBCLIENT@ @INSTALL_LIBMSRPC@ @INSTALL_PAM_MODULES@ @INSTALL_LIBSMBSHAREMODES@ @INSTALL_PMDA@

install-everything: install installmodules

@@ -1771,6 +1797,20 @@ installpammodules: $(PAM_MODULES)
"$(DESTDIR)/$(PAMMODULESDIR)"; \
done

+@***@installpmda: installdirs pmda
+@ifPMDA@ $(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS) $(DESTDIR) $(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/Install $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/Remove $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/Makefile $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/domain.h $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/pmns $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/root $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/profile/pmda/help $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ $(INSTALLCMD) $(srcdir)/bin/***@EXEEXT@ $(DESTDIR)$(PMDA_INSTALLDIR)
+@ifPMDA@ chmod 644 $(DESTDIR)$(PMDA_INSTALLDIR)/Makefile \
+@ifPMDA@ $(DESTDIR)$(PMDA_INSTALLDIR)/domain.h \
+@ifPMDA@ $(DESTDIR)$(PMDA_INSTALLDIR)/pmns
+
# Python extensions

PYTHON_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) \
@@ -1893,7 +1933,7 @@ clean: delheaders python_clean
$(TOPFILES) $(BIN_PROGS) $(SBIN_PROGS) $(ROOT_SBIN_PROGS) \
$(MODULES) $(TORTURE_PROGS) $(LIBSMBCLIENT) $(LIBADDNS) \
$(LIBSMBSHAREMODES) $(EVERYTHING_PROGS) $(LIBMSRPC) \
- .headers.stamp */src/*.o proto_exists
+ $(PMDA_DIRT) .headers.stamp */src/*.o proto_exists
-rm -rf t_dir

# Making this target will just make sure that the prototype files
Index: SAMBA_3_0/source/configure.in
===================================================================
--- SAMBA_3_0.orig/source/configure.in 2007-04-10 15:23:32.000000000 +1000
+++ SAMBA_3_0/source/configure.in 2007-04-12 10:54:53.363547137 +1000
@@ -5972,6 +5972,35 @@ AC_ARG_WITH(python,
esac ])
AC_SUBST(PYTHON)

+#################################################
+# Check for PCP support (http://oss.sgi.com/projects/pcp/). The PCP
+# configuration is driven from /etc/pcp.conf which contains a bunch of
+# site-customisable shell variables to tell us where header files and
+# libraries live and the filesystem paths to various PCP bits.
+ifPMDA="#"
+if test x"$samba_cv_WITH_PROFILE" = x"yes" ; then
+ AC_PROG_PCP(2.5,
+ [
+ if test x"$pcp_can_compile_programs" = x"yes" ; then
+ EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS pmda"
+ INSTALL_PMDA=installpmda
+ PMDA_INSTALLDIR=$PCP_PMDAS_DIR/samba
+ ifPMDA=
+ fi
+ ],
+ [
+ AC_MSG_NOTICE(Disabling PCP support)
+ ])
+
+ AC_SUBST(INSTALL_PMDA)
+ AC_SUBST(PMDA_INSTALLDIR)
+ AC_SUBST(PMDA_PROGS)
+fi
+
+AC_SUBST(ifPMDA)
+
+#################################################
+
for i in `echo $default_static_modules | sed -e 's/,/ /g'`
do
eval MODULE_DEFAULT_$i=STATIC
Index: SAMBA_3_0/source/profile/pmda/root
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/root 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/root 2007-04-12 10:54:53.371546091 +1000
@@ -2,9 +2,10 @@
* fake "root" for validating the local PMNS subtree
*/

-#include "/var/pcp/pmns/stdpmid"
+#include <stdpmid>

root { samba }

+#include "domain.h"
#include "pmns"

Index: SAMBA_3_0/source/profile/pmda/Install
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/Install 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/Install 2007-04-12 10:54:53.371546091 +1000
@@ -1,34 +1,21 @@
#! /bin/sh
#
-# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+# Copyright (C) James Peach 2000,2004
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
#
# Install the samba PMDA and/or PMNS
#
@@ -36,6 +23,9 @@
# source the PCP configuration environment variables
. /etc/pcp.env

+# Make sure we are in the PMDA directory
+cd `dirname $0`
+
# Get the common procedures and variable assignments
#
. $PCP_SHARE_DIR/lib/pmdaproc.sh
Index: SAMBA_3_0/source/profile/pmda/Makefile
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/Makefile 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/Makefile 2007-04-12 10:54:53.371546091 +1000
@@ -1,74 +1,25 @@
#!make
#
-# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+# Copyright (C) James Peach 2006
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
-#
-
-SHELL = sh
-
-include /etc/pcp.conf
-
-IAM = samba
-CFILES = $(IAM).c
-
-LIBTARGET = pmda_$(IAM).so
-CMDTARGET = pmda$(IAM)
-TARGETS = $(LIBTARGET) $(CMDTARGET)
-
-DEBUG = -DDEBUG
-CFLAGS = $(DEBUG)
-LDOPTS =
-LDLIBS = -lpcp_pmda -lpcp
-DSOOPTS = -shared
-LDIRT = profile.h metrics.h so_locations *.log help.dir help.pag *.pmda_$(IAM).so
-
-PROFILEHEADER = ../source/include/smbprofile.h
-
-INSTALL = install
-CC = cc
-
-default: $(TARGETS)
-
-install: default
-
-$(CMDTARGET): profile.h metrics.h $(CFILES)
- $(CC) $(CFLAGS) $(CFILES) $(LDOPTS) $(LDLIBS) -o $@
-
-$(LIBTARGET): profile.h metrics.h $(CFILES)
- $(CC) $(CFLAGS) $(DSOOPTS) $(LDOPTS) $(CFILES) $(LDLIBS) -o $@
-
-metrics.h: profile.h mkheader.pl
- ./mkheader.pl
-
-profile.h: $(PROFILEHEADER)
- ln -s $(PROFILEHEADER) $@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+SHELL = /bin/sh
+IAM = samba
+
+default:
+install: default
+clobber:

-clobber clean:
- rm -f $(LDIRT) $(TARGETS)
Index: SAMBA_3_0/source/profile/pmda/README
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/README 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/README 2007-04-12 10:54:53.371546091 +1000
@@ -1,20 +1,8 @@
-samba PMDA
+Samba PMDA
===========

-This PMDA is a sample that illustrates how a simple samba monitor
-PMDA might be constructed, using a shared memory segment to transfer
-information about transaction activity from the smb daemon.
-
-Note:
- This PMDA may be remade from source and hence requires
- a C compiler and Perl to be installed.
-
- Uses of make(1) may fail (without removing or clobbering files)
- if the C compiler cannot be found. This is most likely to
- happen when running the PMDA ./Install script.
-
- The only remedial action is to install the C compiler, or
- hand-craft changes to the Makefile.
+This PMDA publishes information about transaction activity from the
+Samba daemons.

Metrics
=======
@@ -30,25 +18,20 @@ the available metrics and their explanat
Installation
============

- + # mkdir /var/pcp/pmdas/samba
- + # cp * /var/pcp/pmdas/samba
- + # cp ../source/include/profile.h /var/pcp/pmdas/samba
- + # cd /var/pcp/pmdas/samba
+ + # cd $PCP_PMDAS_DIR/samba

+ Check that there is no clash in the Performance Metrics Domain
defined in ./domain.h and the other PMDAs currently in use
(/etc/pmcd.conf). If there is, edit ./domain.h to choose another
domain number.

- + If you are not installing on an IRIX system, edit samba.c and
- comment out the
-
- #define IRIX 1
-
+ Then simply use

# ./Install

+ and choose both the "collector" and "monitor" installation configuration
+ options.
+
+ Alternatively, to install just the Performance Metrics Name Space
for the samba metrics on the local system, but not the samba PMDA
(presumably because the local system is running PCP 1.x and you
@@ -66,13 +49,13 @@ De-installation

+ Simply use

- # cd /var/pcp/pmdas/samba
+ # cd $PCP_PMDA_DIR/samba
# ./Remove

+ If you also want to remove the sources use

# cd /
- # rm -rf /var/pcp/pmdas/samba
+ # rm -rf $PCP_PMDA_DIR/samba

Making something happen
=======================
@@ -83,8 +66,6 @@ To start updating of the shared memory s
smbcontrol command to turn on profiling for one or more smbd processes
(see the man page for smbcontrol).

-
-
Troubleshooting
===============

Index: SAMBA_3_0/source/profile/pmda/Remove
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/Remove 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/Remove 2007-04-12 10:54:53.371546091 +1000
@@ -1,34 +1,21 @@
#! /bin/sh
#
-# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+# Copyright (C) James Peach 2000,2004
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
#
# Remove the samba PMDA
#
@@ -36,6 +23,9 @@
# source the PCP configuration environment variables
. /etc/pcp.env

+# Make sure we are in the PMDA directory
+cd `dirname $0`
+
# Get the common procedures and variable assignments
#
. $PCP_SHARE_DIR/lib/pmdaproc.sh
Index: SAMBA_3_0/source/profile/pmda/domain.h
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/domain.h 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/domain.h 2007-04-12 10:54:53.371546091 +1000
@@ -1,4 +1,6 @@
-/*
- * built from /var/pcp/pmns/stdpmid
+/* This is the official domain number for the Samba PMDA. It is
+ * allocated upstream with oss.sgi.com/projects/pcp. Change it only
+ * if necessary to avoid clashes with a local PMDA.
+ *
*/
-#define SAMBA 123
+#define SAMBA 76
Index: SAMBA_3_0/source/aclocal.m4
===================================================================
--- SAMBA_3_0.orig/source/aclocal.m4 2007-03-15 16:20:44.000000000 +1100
+++ SAMBA_3_0/source/aclocal.m4 2007-04-12 11:00:13.321641871 +1000
@@ -793,4 +793,230 @@ int main(void)
])
])

+dnl AC_PROG_PCP([version], [ActionsIfTrue], [ActionsIfFalse])
+dnl
+dnl This macro searches for PCP, <http://oss.sgi.com/projects/pcp>.
+dnl
+dnl The argument of --with-pcp specifies the full pathname of the
+dnl pcp.conf file. This file contains all the configuration info
+dnl for a gived PCP installation. By default, this is /etc/pcp.conf.
+dnl
+dnl If the version argument is given, AC_PROG_PCP checks that the
+dnl PCP version is this version number or higher.
+dnl
+dnl If the ActionsIfTrue argument is given, it is a list of commands to run
+dnl when the PCP environment is successfully detected.
+dnl
+dnl If the ActionsIfFalse argument is given, it is a list of commands to run
+dnl when the PCP environment is found to be deficient or missing. The default
+dnl action in this case is to call AC_MSG_ERROR.
+dnl
+dnl @category InstalledPackages
+dnl @author Ivan Rayner <***@sgi.com>
+dnl @author James Peach <***@sgi.com>
+dnl @version 2005-02-14
+dnl @license GPLWithACException
+dnl
+dnl 2006-06: James Peach <***@sgi.com>
+dnl Added alternate actions arguments.
+dnl 2005-06: James Peach <***@sgi.com>
+dnl Changed the PATH in --with-pcp=PATH from the path to the pcp
+dnl program to the path to the /etc/pcp.conf file.
+dnl
+dnl 2005-02: Based on AC_PROG_APACHE by Loic Dachary <***@senga.org>
+
+AC_DEFUN([AC_PROG_PCP],
+[
+ AC_ARG_WITH(pcp,
+ [ --with-pcp=PATH Absolute path to pcp.conf (default is /etc/pcp.conf)],
+ [
+ #
+ # Run this if -with or -without was specified
+ #
+ case $withval in
+ no)
+ pcp_wanted=no
+ ;;
+ yes)
+ pcp_wanted=yes
+ PCP_CONF=/etc/pcp.conf
+ ;;
+ *)
+ pcp_wanted=yes
+ PCP_CONF=$withval
+ ;;
+ esac
+ ],
+ [
+ #
+ # Run this if nothing was said
+ #
+ PCP_CONF=/etc/pcp.conf
+ pcp_wanted=auto
+ ])
+
+#
+# Now we know if we want PCP or not, only go further if
+# it's wanted. If pcp_wanted is yes, then PCP_CONF is
+# also set.
+#
+pcp_continue_test=yes
+if test x"$pcp_wanted" != x"no"
+then
+
+ if test x"$pcp_continue_test" = x"yes" -a -f "$PCP_CONF"
+ then
+ :
+ else
+ ifelse($3, [],
+ [
+ if test x"$pcp_wanted" = x"yes" ; then
+ AC_MSG_ERROR($PCP_CONF missing (is PCP installed?))
+ fi
+ ],
+ [
+ $3
+ ])
+ pcp_continue_test=no
+ fi
+
+ if test x"$pcp_continue_test" = x"yes"
+ then
+
+ # This file is sh compatible, although we need to be careful
+ # of configure variable pollution.
+ . "$PCP_CONF"
+
+ #
+ # Collect pcp version number.
+ #
+ AC_MSG_CHECKING(PCP version)
+ if test -z "$PCP_VERSION" ; then
+ AC_MSG_RESULT(unknown)
+ ifelse($3, [],
+ [
+ if test x"$pcp_wanted" = x"yes" ; then
+ AC_MSG_ERROR($PCP_CONF did not set the PCP_VERSION variable)
+ fi
+ ],
+ [
+ $3
+ ])
+ pcp_continue_test=no
+ else
+ # Convert version of the form 2.4.1 into the form 241
+ PCP_MAJOR_VERS=`echo $PCP_VERSION | cut -d. -f1`
+ PCP_MINOR_VERS=`echo $PCP_VERSION | cut -d. -f2`
+ PCP_MICRO_VERS=`echo $PCP_VERSION | cut -d. -f3`
+ pcp_vers_avail="${PCP_MAJOR_VERS:=0}${PCP_MINOR_VERS:=0}${PCP_MICRO_VERS:=0}"
+ AC_MSG_RESULT($PCP_VERSION)
+ fi
+
+ fi
+
+ if test x"$pcp_continue_test" = x"yes"
+ then
+
+ #
+ # Check that pcp version matches requested version or above
+ #
+ if test -n "$1"
+ then
+ AC_MSG_CHECKING(PCP version >= $1)
+ PCP_MAJOR_REQ=`echo $1 | cut -d. -f1`
+ PCP_MINOR_REQ=`echo $1 | cut -d. -f2`
+ PCP_MICRO_REQ=`echo $1 | cut -d. -f3`
+ pcp_vers_req="${PCP_MAJOR_REQ:=0}${PCP_MINOR_REQ:=0}${PCP_MICRO_REQ:=0}"
+ if test $pcp_vers_avail -lt $pcp_vers_req
+ then
+ AC_MSG_RESULT(no)
+ ifelse($3, [],
+ [
+ if test x"$pcp_wanted" = x"yes" ; then
+ AC_MSG_ERROR(Available PCP version is $PCP_VERSION)
+ fi
+ ],
+ [
+ AC_MSG_WARN(Available PCP version is $PCP_VERSION)
+ $3
+ ])
+ pcp_continue_test=no
+ else
+ AC_MSG_RESULT(yes)
+ fi
+ fi
+
+ fi
+
+ if test x"$pcp_continue_test" = x"yes"
+ then
+
+ # Export PCP preprocessor and linker flags. PCP headers should be in
+ # /PREFIX/include/pcp and pcp.conf gives the full path. We reduce this to
+ # merely /PREFIX/include so that <pcp/header.h> includes can be used. This
+ # is less ambigious that just using <header.h> and knowing it's from PCP.
+ PCP_CPPFLAGS="-I$PCP_INC_DIR"
+ PCP_CPPFLAGS=`echo $PCP_CPPFLAGS | sed 's/\/pcp\$//'`
+ PCP_LDFLAGS="-L$PCP_LIB_DIR"
+
+ CFLAGS_REMOVE_USR_INCLUDE([PCP_CPPFLAGS])
+ LIB_REMOVE_USR_LIB([PCP_LDFLAGS])
+
+ # Make sure we can compile a PCP program
+ pcp_saved_libs="$LIBS"
+ pcp_saved_ldflags="$LDFLAGS"
+ pcp_saved_cppflags="$CPPFLAGS"
+
+ LIBS="-lpcp -lpcp_pmda"
+ LDFLAGS=$PCP_LDFLAGS
+ CPPFLAGS=$PCP_CPPFLAGS
+ AC_MSG_CHECKING(whether PCP programs can be compiled)
+
+ AC_TRY_COMPILE([#include <pcp/pmapi.h>
+ #include <pcp/impl.h>
+ #include <pcp/pmda.h>],
+ [ pmdaInterface dispatch;
+ pmdaInit(0, 0, 0, 0, 0); pmErrStr(PM_ERR_GENERIC); ],
+ [ pcp_can_compile_programs=yes],
+ [ pcp_can_compile_programs=no])
+
+ LIBS="$pcp_saved_libs"
+ LDFLAGS="$pcp_saved_ldflags"
+ CPPFLAGS="$pcp_saved_cppflags"
+
+ AC_MSG_RESULT($pcp_can_compile_programs)
+
+ fi
+
+ if test x"$pcp_continue_test" = x"yes"
+ then
+
+ AC_SUBST(PCP_LDFLAGS)
+ AC_SUBST(PCP_CPPFLAGS)
+
+ AC_SUBST(PCP_MAJOR_VERS)
+ AC_SUBST(PCP_MINOR_VERS)
+ AC_SUBST(PCP_MICRO_VERS)
+ AC_SUBST(PCP_VERSION)
+ AC_SUBST(PCP_LOG_DIR)
+ AC_SUBST(PCP_BIN_DIR)
+ AC_SUBST(PCP_PMDAS_DIR)
+ AC_SUBST(PCP_CPPFLAGS)
+ AC_SUBST(PCP_LDFLAGS)
+ AC_SUBST(PCP_CONF)
+
+ $2
+ fi
+
+else
+# PCP explicitly not wanted
+true
+$3
+fi
+
+unset pcp_continue_test
+unset pcp_wanted
+
+])
+
m4_include(lib/replace/libreplace.m4)
Index: SAMBA_3_0/source/script/mkmetricsheader.pl
===================================================================
--- SAMBA_3_0.orig/source/script/mkmetricsheader.pl 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/script/mkmetricsheader.pl 2007-04-12 10:54:53.379545044 +1000
@@ -1,63 +1,64 @@
-#!/usr/bin/perl
+#! /usr/bin/perl

+# mkmetricsheader.pl: Convert the Samba profile header to the equivalent
+# PCP metric structure definitions.

-open(PROFILE,"profile.h") || die "Unable to open profile.h\n";
-@profile = <PROFILE>;
-close PROFILE;
-
-open(METRICS,"> metrics.h") || die "Unable to open metrics.h for output\n";
-
-print METRICS "#define COUNT_TIME_INDOM 0\n";
-print METRICS "#define BYTE_INDOM 1\n\n";
-print METRICS "#define FIELD_OFF(x) (unsigned)\&(((struct profile_stats *)NULL)->x)\n\n";
-print METRICS "typedef struct {\n";
-print METRICS "\tchar *name;\n";
-print METRICS "\tunsigned offset;\n";
-print METRICS "} samba_instance;\n\n";
-
-@instnames = grep(/unsigned .*_time;/,@profile);
-foreach $instnames (@instnames) {
- chomp $instnames;
- $instnames =~ s/^.*unsigned (.*)_time.*$/$1/;
+# Copyright (C) James Peach 2000,2004-2006
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+
+
+my $pstruct = "struct profile_stats";
+my @instnames;
+
+my $fname = shift;
+
+my @profile = <STDIN>;
+
+print STDOUT <<"EOF";
+typedef struct {
+ const char *name;
+ unsigned offset;
+} samba_instance;
+EOF
+
+@instnames = grep(/unsigned .*_time;/, @profile);
+foreach my $name (@instnames) {
+ chomp $name;
+ $name =~ s/^.*unsigned (.*)_time.*$/$1/;
}

-print METRICS "static samba_instance samba_counts[] = {";
-$first = 1;
-foreach $1 (@instnames) {
- if ($first == 1) {
- $first = 0;
- print METRICS "\n";
- } else {
- print METRICS ",\n";
- }
- print METRICS "\t{\"$1\", FIELD_OFF($1_count)}";
+print STDOUT "static samba_instance samba_counts[] = {";
+foreach my $name (@instnames) {
+ print STDOUT "\t{\"$name\", offsetof($pstruct, ${name}_count)},\n";
}
-print METRICS "\n};\n\n";
-print METRICS "static samba_instance samba_times[] = {";
-$first = 1;
-foreach $1 (@instnames) {
- if ($first == 1) {
- $first = 0;
- print METRICS "\n";
- } else {
- print METRICS ",\n";
- }
- print METRICS "\t{\"$1\", FIELD_OFF($1_time)}";
+print STDOUT "\n};\n\n";
+
+print STDOUT "static samba_instance samba_times[] = {";
+foreach my $name (@instnames) {
+ print STDOUT "\t{\"$name\", offsetof($pstruct, ${name}_time)},\n";
}
-print METRICS "\n};\n\n";
-print METRICS "static samba_instance samba_bytes[] = {";
+print STDOUT "\n};\n\n";
+
+print STDOUT "static samba_instance samba_bytes[] = {";
@instnames = grep(/unsigned .*_bytes;/,@profile);
-$first = 1;
-foreach $_ (@instnames) {
- if ($first == 1) {
- $first = 0;
- print METRICS "\n";
- } else {
- print METRICS ",\n";
- }
- /^.*unsigned (.*)_bytes.*$/;
- print METRICS "\t{\"$1\", FIELD_OFF($1_bytes)}";
+foreach my $name (@instnames) {
+ my ($pfx) = ($name =~ m/(\w*)_bytes.*$/);
+ print STDOUT "\t{\"$pfx\", offsetof($pstruct, ${pfx}_bytes)},\n";
}
-print METRICS "\n};\n";
+print STDOUT "\n};\n";

-close METRICS
Index: SAMBA_3_0/source/profile/pmda/samba.c
===================================================================
--- SAMBA_3_0.orig/source/profile/pmda/samba.c 2007-04-12 10:54:30.000000000 +1000
+++ SAMBA_3_0/source/profile/pmda/samba.c 2007-04-12 10:54:53.379545044 +1000
@@ -1,56 +1,57 @@
/*
- * Samba, configurable PMDA
+ * Samba PMDA
*
- * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (C) James Peach 2000,2004-2006
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

-typedef int BOOL;
+#include "includes.h"
+#include <assert.h>

-#define IRIX 1
+/* We don't want to link with large globs of Samba library code, so use libc
+ * malloc directly.
+ */
+#undef malloc
+#undef realloc

-#include <stdio.h>
-#include <sys/shm.h>
#include <pcp/pmapi.h>
-#ifdef IRIX
+
+/* Convince PCP that we don't really have NDBM. The NDBM datum typedef
+ * conflicts with some other headers that includes.h might drag in.
+ */
+#undef HAVE_NDBM_H
+#define DBM void
#include <pcp/impl.h>
-#endif
#include <pcp/pmda.h>
+#undef DBM
+
+/* Global Samba performance counters. */
+#include "smbprofile.h"
+#include "pmda_profile.inc"
+
+/* PCP ID tags. */
#include "domain.h"
-#include "profile.h"
-#include "metrics.h"

static pmdaInstid *counttime = NULL;
static pmdaInstid *bytes = NULL;

-/*
+#define COUNT_TIME_INDOM 0
+#define BYTE_INDOM 1
+
+/*
* List of instance domains
*/

@@ -243,10 +244,7 @@ samba_fetchCallBack(pmdaMetric *mdesc, u
else if (idp->cluster == 3) { /* counts */
if (idp->item == 0) {
if (inst < indomtab[COUNT_TIME_INDOM].it_numinst) {
- unsigned *p;
-
- p = (unsigned *)((unsigned)stats + samba_counts[inst].offset);
- atom->ul = *p;
+ atom->ul = *(uint32_t *) ((uint8_t *) stats + samba_counts[inst].offset);
}
else
return PM_ERR_INST;
@@ -257,10 +255,7 @@ samba_fetchCallBack(pmdaMetric *mdesc, u
else if (idp->cluster == 4) { /* times */
if (idp->item == 0) {
if (inst < indomtab[COUNT_TIME_INDOM].it_numinst) {
- unsigned *p;
-
- p = (unsigned *)((unsigned)stats + samba_times[inst].offset);
- atom->ul = *p;
+ atom->ul = *(uint32_t *) ((uint8_t *) stats + samba_times[inst].offset);
}
else
return PM_ERR_INST;
@@ -271,10 +266,7 @@ samba_fetchCallBack(pmdaMetric *mdesc, u
else if (idp->cluster == 5) { /* bytes */
if (idp->item == 0) {
if (inst < indomtab[BYTE_INDOM].it_numinst) {
- unsigned *p;
-
- p = (unsigned *)((unsigned)stats + samba_bytes[inst].offset);
- atom->ul = *p;
+ atom->ul = *(uint32_t *) ((uint8_t *) stats + samba_bytes[inst].offset);
}
else
return PM_ERR_INST;
Jeremy Allison
2007-04-12 07:13:38 UTC
Permalink
Post by Alison Winters
I was going to CC samba-technical, but got lazy. Feel free to forward
this mail there if you want some more opinions ...
Done :-)
2 things - as you mentioned, this code needs to be
individual copyright, not SGI. Secondly, this
code is currently GPLv2 *only*. We need "GPLv2 or
any later version" headers for Samba, as we're
planning to go to v3.

Jeremy.
Alison Winters
2007-04-12 08:37:53 UTC
Permalink
Post by Jeremy Allison
2 things - as you mentioned, this code needs to be
individual copyright, not SGI. Secondly, this
code is currently GPLv2 *only*. We need "GPLv2 or
any later version" headers for Samba, as we're
planning to go to v3.
The patch i posted is actually all James Peach's stuff, so i'm guessing
he can reassign copyright however he chooses (and in fact, one of the
patches appears to do just that). That said, if we do move the Samba
PMDA out of Samba and into PCP then this will be much less of a problem :-)

Alison
James Peach
2007-04-12 08:31:51 UTC
Permalink
Post by Alison Winters
CC:ed into samba-technical from personal email, this is a discussion
about the steps we could to take to enhance the existing profiling code
in Samba.
The metrics export mechanism from jpeach-xmetrics belongs in the main
samba tree.
Agreed.
The first thing you need to do to get this in is to split it into
multiple mmap'ed files. That is, each different metrics structure should
have its own mmap and backing store. Once you do this, the allocator
becomes a simple slot allocator and most of the really ugly code goes away.
Do you mean having one header file that everything mmaps and a
bunch of
files for each connected client and configured share that get mmapped
separately?
I mean to use one mmap per record type. The current scheme is ugly
because it really doesn't want to be a proper allocator but it has to
deal with 2 different sizes of records in the mmap. If you have a
separate mmap for each record type, the allocator goes back to being
nice and simple.
Post by Alison Winters
I'm assuming the ugly code you're referring to is the bit
where it has to keep growing the file whenever new connections join etc.
No, I'm referring to the allocation of metric records inside the mmap.
Post by Alison Winters
The second thing that you need os some way of gathering the stats that
is not that horrible VFS module :)
That's in the pipeline :) What i'm planning is to just add a bit of
extra magic to the existing Samba profiling macros that allow us to
split it out per-client and per-share along with the existing
recording
of global counts and times. I'm pretty sure this is going to be fairly
elegant and small if i get it right.
That sounds neat. It would be great if you had some code to reconcile
the existing profiling stats with these metrics.
Post by Alison Winters
I have a separate patch which i can't submit yet (it's copyright SGI)
that splits out all of the current profiling statistics into smaller
groups that we can turn on and off independently.
Do you mean the stats that currently live in the sysv shared memory
segment?
Post by Alison Winters
This will allow us
more granular control over what to profile, and will hopefully avoid
nasty performance hits when we're only interested in isolated areas of
the code.
IIRC you only get a big performance hit when you are timing
operations. You can probably avoid this (to some degree) by using
platform-specific timers.
Post by Alison Winters
Once you have a stable, versioned export mechanism, then the PMDA can
simply be one of the consumers of the exported metrics. There's not real
need for it to be in the Samba tree. I'd be OK with making the client
interfaces (header file and shared library) LGPL.
I guess my real problem with this is that there's already a PMDA in the
pcp/ subdirectory in Samba. This PMDA is broken right now - it won't
compile because some definitions have been moved around. If it's not
going to be maintained then it should be removed from the tree - i can
just have a closed-source PMDA that builds independently (assuming LGPL
headers). On the other hand, since it's in the tree anyway it
could be
maintained as part of Samba - in which case i think applying the
attached two patches (move, then add) would be the right thing to do.
These patches move the PMDA into the main build - they're just a subset
of your xmetrics branch.
IMHO, the Samba PMDA belongs in the PCP tree, not in the Samba tree.
Since you are going to be the one maintaining it, it's easier all
round if it lives there. We can simply remove the existing PMDA from
the Samba tree.

--
James Peach | ***@samba.org
Alison Winters
2007-04-12 13:16:06 UTC
Permalink
Post by James Peach
I mean to use one mmap per record type. The current scheme is ugly
because it really doesn't want to be a proper allocator but it has to
deal with 2 different sizes of records in the mmap. If you have a
separate mmap for each record type, the allocator goes back to being
nice and simple.
Surely the only benefit of splitting out record types per-file (i.e.
client and share) is that you can step through the allocated records as
an array rather than a linked list? Is there really much performance
gain there? I imagine the code to step through the list and add/remove
records will stay pretty much the same.
Post by James Peach
Post by Alison Winters
That's in the pipeline :) What i'm planning is to just add a bit of
extra magic to the existing Samba profiling macros that allow us to
split it out per-client and per-share along with the existing recording
of global counts and times. I'm pretty sure this is going to be fairly
elegant and small if i get it right.
That sounds neat. It would be great if you had some code to reconcile
the existing profiling stats with these metrics.
That's pretty much the plan. Each class of extended stats when summed
together should equal the existing profiling stats (in theory).
Post by James Peach
Post by Alison Winters
I have a separate patch which i can't submit yet (it's copyright SGI)
that splits out all of the current profiling statistics into smaller
groups that we can turn on and off independently.
Do you mean the stats that currently live in the sysv shared memory
segment?
Yep.
Post by James Peach
IIRC you only get a big performance hit when you are timing operations.
You can probably avoid this (to some degree) by using platform-specific
timers.
I'll look into it, thanks :) Right now there's just the regular
GetTimeOfDay calls.
Post by James Peach
IMHO, the Samba PMDA belongs in the PCP tree, not in the Samba tree.
Since you are going to be the one maintaining it, it's easier all round
if it lives there. We can simply remove the existing PMDA from the Samba
tree.
Sure that makes sense. So, with that in mind, what's the best way to
export a Samba header file for consumer apps? For instance, in the case
of the smbprofile.h header, it uses stuff like enum flush_reason_enum
and typedef BOOL which are defined elsewhere that third-party apps can't
see. Is the correct approach to write a script that munges the header
into something that could potentially stand alone in a "devel" package?

Alison
James Peach
2007-04-12 20:41:43 UTC
Permalink
Post by Alison Winters
Post by James Peach
I mean to use one mmap per record type. The current scheme is ugly
because it really doesn't want to be a proper allocator but it has to
deal with 2 different sizes of records in the mmap. If you have a
separate mmap for each record type, the allocator goes back to being
nice and simple.
Surely the only benefit of splitting out record types per-file (i.e.
client and share) is that you can step through the allocated records as
an array rather than a linked list? Is there really much performance
gain there? I imagine the code to step through the list and add/
remove
records will stay pretty much the same.
No the benefit is in reducing the complexity of allocation. As you
allocate more different types of object, the code moves closer to
being a general purpose allocator. That's not something I want to
write or maintain, and as it becomes more complex it is harder to grow
the mmap.
Post by Alison Winters
Post by James Peach
Post by Alison Winters
That's in the pipeline :) What i'm planning is to just add a bit of
extra magic to the existing Samba profiling macros that allow us to
split it out per-client and per-share along with the existing recording
of global counts and times. I'm pretty sure this is going to be fairly
elegant and small if i get it right.
That sounds neat. It would be great if you had some code to reconcile
the existing profiling stats with these metrics.
That's pretty much the plan. Each class of extended stats when summed
together should equal the existing profiling stats (in theory).
Post by James Peach
Post by Alison Winters
I have a separate patch which i can't submit yet (it's copyright SGI)
that splits out all of the current profiling statistics into smaller
groups that we can turn on and off independently.
Do you mean the stats that currently live in the sysv shared memory
segment?
Yep.
Post by James Peach
IIRC you only get a big performance hit when you are timing
operations.
You can probably avoid this (to some degree) by using platform-
specific
timers.
I'll look into it, thanks :) Right now there's just the regular
GetTimeOfDay calls.
Post by James Peach
IMHO, the Samba PMDA belongs in the PCP tree, not in the Samba tree.
Since you are going to be the one maintaining it, it's easier all round
if it lives there. We can simply remove the existing PMDA from the Samba
tree.
Sure that makes sense. So, with that in mind, what's the best way to
export a Samba header file for consumer apps?
That depends on exactly what you want.
Post by Alison Winters
For instance, in the case
of the smbprofile.h header, it uses stuff like enum flush_reason_enum
and typedef BOOL which are defined elsewhere that third-party apps can't
see.
If you think that smbprofile.h is OK for client apps, then it should
be standalone. IMHO smbprofile.h is not the right solution for this,
and from the sounds of the above, you have some changes.

--
James Peach | ***@samba.org

Loading...