コード例 #1
0
ファイル: proc_partitions.c プロジェクト: aeppert/pcp
int
is_partitions_metric(pmID full_pmid)
{
    int			i;
    static pmID		*p = NULL;
    __pmID_int          *idp = (__pmID_int *)&(full_pmid);
    pmID		pmid = PMDA_PMID(idp->cluster, idp->item);
    int			n = sizeof(disk_metric_table) / sizeof(disk_metric_table[0]);

    if (p && *p == PMDA_PMID(idp->cluster, idp->item))
    	return 1;
    for (p = disk_metric_table, i=0; i < n; i++, p++) {
    	if (*p == pmid)
	    return 1;
    }
    return 0;
}
コード例 #2
0
ファイル: cvalue.c プロジェクト: Aconex/pcp
void
ids(void)
{
    printf("PMDA_PMID: 0,0 = %d\n", PMDA_PMID(0,0));
    printf("PMDA_PMID: 1,1 = %d\n", PMDA_PMID(1,1));
    printf("PMDA_PMID: 27,13 = %d\n", PMDA_PMID(27,13));
    printf("PMDA_PMID: %d,0 = %d\n", MAXINT, PMDA_PMID(MAXINT,0));
    printf("PMDA_PMID: 0,%d = %d\n", MAXINT, PMDA_PMID(0,MAXINT));
    printf("PMDA_PMID: %d,%d = %d\n", MAXINT,MAXINT, PMDA_PMID(MAXINT,MAXINT));
}
コード例 #3
0
ファイル: data.c プロジェクト: Aconex/pcp
};
int methodtab_sz = sizeof(methodtab) / sizeof(methodtab[0]);

#define CPU_OFF(field) ((int)&((perfstat_cpu_t *)0)->field)
#define CPU_TOTAL_OFF(field) ((int)&((perfstat_cpu_total_t *)0)->field)
#define DISK_OFF(field) ((int)&((perfstat_disk_t *)0)->field)
#define DISK_TOTAL_OFF(field) ((int)&((perfstat_disk_total_t *)0)->field)
#define NETIF_OFF(field) ((int)&((perfstat_netinterface_t *)0)->field)

/*
 * all metrics supported in this PMDA - one table entry for each metric
 */
metricdesc_t metricdesc[] = {

/* kernel.all.cpu.idle */
    { { PMDA_PMID(0,0), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
	PMDA_PMUNITS(0, 1, 0, 0, PM_TIME_MSEC, 0)
      }, M_CPU_TOTAL, CPU_TOTAL_OFF(idle) },

/* kernel.all.cpu.user */
    { { PMDA_PMID(0,1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
	PMDA_PMUNITS(0, 1, 0, 0, PM_TIME_MSEC, 0)
      }, M_CPU_TOTAL, CPU_TOTAL_OFF(user) },

/* kernel.all.cpu.sys */
    { { PMDA_PMID(0,2), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
	PMDA_PMUNITS(0, 1, 0, 0, PM_TIME_MSEC, 0)
      }, M_CPU_TOTAL, CPU_TOTAL_OFF(sys) },

/* kernel.all.cpu.wait.total */
    { { PMDA_PMID(0,3), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
コード例 #4
0
ファイル: logger.c プロジェクト: Aconex/pcp
void 
logger_init(pmdaInterface *dp, const char *configfile)
{
    size_t size;
    int	i, j, sts, item, numloggers;
    int numstatics = sizeof(static_metrictab)/sizeof(static_metrictab[0]);
    int numdynamics = sizeof(dynamic_metrictab)/sizeof(dynamic_metrictab[0]);
    pmdaMetric *pmetric;
    char name[MAXPATHLEN * 2];
    dynamic_metric_info_t *pinfo;

    __pmSetProcessIdentity(username);

    /* Read and parse config file. */
    if ((numloggers = event_config(configfile)) < 0)
	return;

    /* Create the dynamic metric info table based on the logfile table */
    size = sizeof(struct dynamic_metric_info) * numdynamics * numloggers;
    if ((dynamic_metric_infotab = malloc(size)) == NULL) {
	__pmNoMem("logger_init(dynamic)", size, PM_FATAL_ERR);
	return;
    }
    pinfo = dynamic_metric_infotab;
    for (i = 0; i < numloggers; i++) {
	for (j = 0; j < numdynamics; j++) {
	    pinfo->handle = i;
	    pinfo->pmid_index = j;
	    pinfo->help_text = dynamic_helptab[j];
	    pinfo++;
	}
    }

    /* Create the metric table based on the static and dynamic metric tables */
    nummetrics = numstatics + (numloggers * numdynamics);
    size = sizeof(pmdaMetric) * nummetrics;
    if ((metrictab = malloc(size)) == NULL) {
	free(dynamic_metric_infotab);
	__pmNoMem("logger_init(static)", size, PM_FATAL_ERR);
	return;
    }
    memcpy(metrictab, static_metrictab, sizeof(static_metrictab));
    pmetric = &metrictab[numstatics];
    pinfo = dynamic_metric_infotab;
    item = numstatics;
    for (i = 0; i < numloggers; i++) {
	memcpy(pmetric, dynamic_metrictab, sizeof(dynamic_metrictab));
	for (j = 0; j < numdynamics; j++) {
	    pmetric[j].m_desc.pmid = PMDA_PMID(0, item++);
	    pmetric[j].m_user = pinfo++;
	}
	pmetric += numdynamics;
    }

    if (dp->status != 0)
	return;

    dp->version.four.fetch = logger_fetch;
    dp->version.four.store = logger_store;
    dp->version.four.profile = logger_profile;
    dp->version.four.pmid = logger_pmid;
    dp->version.four.name = logger_name;
    dp->version.four.children = logger_children;
    dp->version.four.text = logger_text;

    pmdaSetFetchCallBack(dp, logger_fetchCallBack);
    pmdaSetEndContextCallBack(dp, logger_end_contextCallBack);

    pmdaInit(dp, NULL, 0, metrictab, nummetrics);

    /* Create the dynamic PMNS tree and populate it. */
    if ((sts = __pmNewPMNS(&pmns)) < 0) {
	__pmNotifyErr(LOG_ERR, "%s: failed to create new pmns: %s\n",
			pmProgname, pmErrStr(sts));
	pmns = NULL;
	return;
    }
    pmetric = &metrictab[numstatics];
    for (i = 0; i < numloggers; i++) {
	const char *id = event_pmnsname(i);
	for (j = 0; j < numdynamics; j++) {
	    snprintf(name, sizeof(name),
			"logger.perfile.%s.%s", id, dynamic_nametab[j]);
	    __pmAddPMNSNode(pmns, pmetric[j].m_desc.pmid, name);
	}
	pmetric += numdynamics;
    }
    /* for reverse (pmid->name) lookups */
    pmdaTreeRebuildHash(pmns, (numloggers * numdynamics));

    /* initialise the event and client tracking code */
    event_init(metrictab[2].m_desc.pmid);
}
コード例 #5
0
ファイル: logger.c プロジェクト: Aconex/pcp
/* perfile.{LOGFILE}.size */
    "The current size of this logfile.",
/* perfile.{LOGFILE}.path */
    "The path for this logfile.",
/* perfile.{LOGFILE}.numclients */
    "The number of attached clients for this logfile.",
/* perfile.{LOGFILE}.records */
    "Event records for this logfile.",
/* perfile.{LOGFILE}.queuemem */
    "Amount of memory used for event data.",
};

static pmdaMetric static_metrictab[] = {
/* numclients */
    { NULL, 
      { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT, 
    	PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
/* numlogfiles */
    { NULL,
      { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_DISCRETE, 
    	PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
/* param_string */
    { NULL,
      { PMDA_PMID(0,2), PM_TYPE_STRING, PM_INDOM_NULL, PM_SEM_INSTANT,
	PMDA_PMUNITS(0,0,0,0,0,0) }, },
/* perfile.maxmem */
    { NULL, 				/* m_user gets filled in later */
      { PMDA_PMID(0,3), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_DISCRETE,
	PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
};
コード例 #6
0
ファイル: pmda.c プロジェクト: Aconex/pcp
    CLUSTER_HINV,		/*  4 = hardware inventory */
    CLUSTER_FILESYS,		/*  5 = mounted filesystems */
    CLUSTER_CPULOAD,		/*  6 = number of ticks in state */
    CLUSTER_DISK,		/*  7 = disk device statistics */
    CLUSTER_CPU,		/*  8 = per-cpu statistics */
    CLUSTER_UPTIME,		/*  9 = system uptime in seconds */
    CLUSTER_NETWORK,		/* 10 = networking statistics */
    CLUSTER_NFS,		/* 11 = nfs filesystem statistics */
    NUM_CLUSTERS		/* total number of clusters */
};

static pmdaMetric metrictab[] = {

/* hinv.pagesize */
  { &mach_page_size, 
    { PMDA_PMID(CLUSTER_INIT,0), PM_TYPE_U64, PM_INDOM_NULL,
      PM_SEM_DISCRETE, PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
/* kernel.all.hz */
  { &mach_hertz,
    { PMDA_PMID(CLUSTER_INIT,1), PM_TYPE_U32, PM_INDOM_NULL,
      PM_SEM_DISCRETE, PMDA_PMUNITS(0,-1,1,0,PM_TIME_SEC,PM_COUNT_ONE) }, },

/* hinv.physmem */
  { NULL, 
    { PMDA_PMID(CLUSTER_VMSTAT,2), PM_TYPE_U32, PM_INDOM_NULL,
      PM_SEM_DISCRETE, PMDA_PMUNITS(1,0,0,PM_SPACE_MBYTE,0,0) }, },
/* mem.physmem */
  { NULL,
    { PMDA_PMID(CLUSTER_VMSTAT,3), PM_TYPE_U64, PM_INDOM_NULL,
      PM_SEM_DISCRETE, PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, },
/* mem.freemem */
コード例 #7
0
ファイル: pmda.c プロジェクト: Aconex/pcp
    { CLUSTER_KERNEL_FORWARD_WMI, 0,
	EVENT_TRACE_FLAG_FORWARD_WMI, "kernel.forward_wmi" },
    { CLUSTER_KERNEL_ENABLE_RESERVE, 0,
	EVENT_TRACE_FLAG_ENABLE_RESERVE, "kernel.enable_reserve" },

    { CLUSTER_SQLSERVER_RPC_STARTING, 0, 0, "sqlserver.rpc.starting" },
    { CLUSTER_SQLSERVER_BATCH_STARTING, 0, 0, "sqlserver.sql.batch_starting" },
};
static int numqueues = sizeof(etwevents)/sizeof(etw_event_t);
#endif


static pmdaMetric metrictab[] = {
/* etw.kernel.process.start.count */
    { &eventtab[EVENT_PROCESS_START],
      { PMDA_PMID(CLUSTER_KERNEL_PROCESS,0), PM_TYPE_U32, PM_INDOM_NULL,
	PM_SEM_COUNTER, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
/* etw.kernel.process.start.records */
    { &eventtab[EVENT_PROCESS_START],
      { PMDA_PMID(CLUSTER_KERNEL_PROCESS,1), PM_TYPE_EVENT, PM_INDOM_NULL,
	PM_SEM_INSTANT, PMDA_PMUNITS(0,0,0,0,0,0) }, },
/* etw.kernel.process.start.numclients */
    { &eventtab[EVENT_PROCESS_START],
      { PMDA_PMID(CLUSTER_KERNEL_PROCESS,2), PM_TYPE_U32, PM_INDOM_NULL,
	PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
/* etw.kernel.process.start.queuemem */
    { &eventtab[EVENT_PROCESS_START],
      { PMDA_PMID(CLUSTER_KERNEL_PROCESS,3), PM_TYPE_U64, PM_INDOM_NULL,
	PM_SEM_INSTANT, PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
/* etw.kernel.process.start.params.activityid */
    { &eventtab[EVENT_PROCESS_START],
コード例 #8
0
ファイル: generic.c プロジェクト: codewise/flamegraph-pmda
 * and could be extended to implement a much more complex PMDA.
 *
 * Metrics
 *	generic.systack	- Trigger to collect kernel/app stacks using perf and display via flamegraph.
 *	generic.jstack	- Trigger to process java stacks using jstack and display via flamegraph.
 *	generic.heatmap	- Trigger to collect block layer latency using perf and display via heatmap.
 */

/*
 * all metrics supported in this PMDA - one table entry for each
 */

static pmdaMetric metrictab[] = {
/* systack */
    { NULL, 
      { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER, 
        PMDA_PMUNITS(0, 1, 0, 0, PM_TIME_SEC, 0) } },
/* jstack */
    { NULL, 
      { PMDA_PMID(0,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER, 
        PMDA_PMUNITS(0, 1, 0, 0, PM_TIME_SEC, 0) } },
/* heatmap */
    { NULL, 
      { PMDA_PMID(0,3), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER, 
        PMDA_PMUNITS(0, 1, 0, 0, PM_TIME_SEC, 0) } },
};

//static char	*username = "******";
static char	*username;
static char	mypath[MAXPATHLEN];
static int	isDSO = 1;		/* ==0 if I am a daemon */
コード例 #9
0
ファイル: proc_partitions.c プロジェクト: aeppert/pcp
    }

    /*
     * success
     */
    if (fp)
	fclose(fp);
    return 0;
}

/*
 * This table must always match the definitions in root_linux
 * and metrictab[] in pmda.c
 */
static pmID disk_metric_table[] = {
    /* disk.dev.read */		     PMDA_PMID(CLUSTER_STAT,4),
    /* disk.dev.write */	     PMDA_PMID(CLUSTER_STAT,5),
    /* disk.dev.total */	     PMDA_PMID(CLUSTER_STAT,28),
    /* disk.dev.blkread */	     PMDA_PMID(CLUSTER_STAT,6),
    /* disk.dev.blkwrite */	     PMDA_PMID(CLUSTER_STAT,7),
    /* disk.dev.blktotal */	     PMDA_PMID(CLUSTER_STAT,36),
    /* disk.dev.read_bytes */	     PMDA_PMID(CLUSTER_STAT,38),
    /* disk.dev.write_bytes */	     PMDA_PMID(CLUSTER_STAT,39),
    /* disk.dev.total_bytes */	     PMDA_PMID(CLUSTER_STAT,40),
    /* disk.dev.read_merge */	     PMDA_PMID(CLUSTER_STAT,49),
    /* disk.dev.write_merge */	     PMDA_PMID(CLUSTER_STAT,50),
    /* disk.dev.avactive */	     PMDA_PMID(CLUSTER_STAT,46),
    /* disk.dev.aveq */		     PMDA_PMID(CLUSTER_STAT,47),
    /* disk.dev.scheduler */	     PMDA_PMID(CLUSTER_STAT,59),
    /* disk.dev.read_rawactive */    PMDA_PMID(CLUSTER_STAT,72),
    /* disk.dev.write_rawactive	*/   PMDA_PMID(CLUSTER_STAT,73),
コード例 #10
0
ファイル: broken_pmda.c プロジェクト: Aconex/pcp
#define INDOM_2		8
    { INDOM_2, 0, (pmdaInstid *)0 }
};



#ifndef BUG_3

/*
 * all metrics supported in this PMDA - one table entry for each
 */

static pmdaMetric metrictab[] = {
/* valid.one */
    { (void *)0, 
      { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT, 
        { 0, 1, 0, 0, PM_TIME_SEC, 0 } }, },
/* valid.two */
    { (void *)0, 
      { PMDA_PMID(0,1), PM_TYPE_U32, INDOM_0, PM_SEM_INSTANT, 
        { 0, 1, 0, 0, PM_TIME_SEC, 0 } }, },
/* bad.type */
    { (void *)0,
      { PMDA_PMID(0,5), PM_TYPE_NOSUPPORT, PM_INDOM_NULL, PM_SEM_COUNTER,
	{ 0, 0, 0, 0, 0, 0 } }, },
/* valid.three */
    { (void *)0, 
      { PMDA_PMID(0,7), PM_TYPE_U32, INDOM_1, PM_SEM_INSTANT, 
        { 0, 1, 0, 0, PM_TIME_SEC, 0 } }, },
/* no.fetch */
    { (void *)0, 
コード例 #11
0
ファイル: systemd.c プロジェクト: Aconex/pcp
/* Track per-context PCP_ATTR_USERID | _GROUPID, so we
   can filter event records for that context. */
static int uid_gid_filter_p = 1;
struct uid_gid_tuple {
    char wildcard_p; /* do not filter for this context. */
    char uid_p; char gid_p; /* uid/gid received flags. */
    int uid; int gid; }; /* uid/gid received from PCP_ATTR_* */
static struct uid_gid_tuple *ctxtab = NULL;
int ctxtab_size = 0;


static pmdaMetric metrictab[] = {
/* numclients */
#define METRICTAB_NUMCLIENTS_PMID metrictab[0].m_desc.pmid
    { NULL,
      { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
        PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
/* maxmem */
#define METRICTAB_MAXMEM_PMID metrictab[1].m_desc.pmid
    { NULL,
      { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
        PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
/* journal.field.cursor */
#define METRICTAB_JOURNAL_CURSOR_PMID metrictab[2].m_desc.pmid
    { NULL,
      { PMDA_PMID(1,0), PM_TYPE_STRING, PM_INDOM_NULL, PM_SEM_INSTANT,
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
/* journal.field.string */
#define METRICTAB_JOURNAL_STRING_PMID metrictab[3].m_desc.pmid
    { NULL,
      { PMDA_PMID(1,1), PM_TYPE_STRING, PM_INDOM_NULL, PM_SEM_INSTANT,
コード例 #12
0
ファイル: openbsd.c プロジェクト: ColeJackes/pcp
 *
 * cluster map
 * CL_SYSCTL	simple sysctl() metrics, either one metric per mib, or
 *		one struct per mib
 * CL_SPECIAL	trickier sysctl() metrics involving synthesis or arithmetic
 *		or other methods
 * CL_DISK	disk metrics
 * CL_CPUTIME	percpu cpu time metrics
 * CL_NETIF	network interface metrics
 * CL_FILESYS	filesys metrics
 * CL_VM_UVMEXP	vm stats
 */

static pmdaMetric metrictab[] = {
    { (void *)"hinv.ncpu",
      { PMDA_PMID(CL_SYSCTL,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_DISCRETE,
	PMDA_PMUNITS(0,0,0,0,0,0) } },
    { (void *)"hinv.physmem",
      { PMDA_PMID(CL_SYSCTL,1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_DISCRETE,
	PMDA_PMUNITS(1,0,0,PM_SPACE_MBYTE,0,0) } },
    { NULL,	/* kernel.all.load */
      { PMDA_PMID(CL_SPECIAL,2), PM_TYPE_FLOAT, LOADAV_INDOM, PM_SEM_INSTANT,
	PMDA_PMUNITS(0,0,0,0,0,0) } },
    { (void *)"kernel.all.cpu.user",
      { PMDA_PMID(CL_SYSCTL,3), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER, 
	PMDA_PMUNITS(0,1,0,0,PM_TIME_MSEC,0) } },
    { (void *)"kernel.all.cpu.nice",
      { PMDA_PMID(CL_SYSCTL,4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER, 
	PMDA_PMUNITS(0,1,0,0,PM_TIME_MSEC,0) } },
    { (void *)"kernel.all.cpu.sys",
      { PMDA_PMID(CL_SYSCTL,5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER, 
コード例 #13
0
ファイル: freebsd.c プロジェクト: Aconex/pcp
 * a pointer to the corresponding entry in mib[] (based on matching,
 * or prefix matching (see matchname()) the PCP name here with
 * m_pcpname[] in the mib[] entries.
 *
 * cluster map
 * CL_SYSCTL	simple sysctl() metrics, either one metric per mib, or
 *		one struct per mib
 * CL_SPECIAL	trickier sysctl() metrics involving synthesis or arithmetic
 *		or other methods
 * CL_DISK	disk metrics
 * CL_NETIF	network interface metrics
 */

static pmdaMetric metrictab[] = {
    { (void *)"hinv.ncpu",
      { PMDA_PMID(CL_SYSCTL,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_DISCRETE,
	PMDA_PMUNITS(0,0,0,0,0,0) } },
    { (void *)"hinv.physmem",
      { PMDA_PMID(CL_SYSCTL,1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_DISCRETE,
	PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) } },
    { (void *)"kernel.all.load",
      { PMDA_PMID(CL_SYSCTL,2), PM_TYPE_FLOAT, LOADAV_INDOM, PM_SEM_INSTANT,
	PMDA_PMUNITS(0,0,0,0,0,0) } },
    { (void *)"kernel.all.cpu.user",
      { PMDA_PMID(CL_SYSCTL,3), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER, 
	PMDA_PMUNITS(0,1,0,0,PM_TIME_MSEC,0) } },
    { (void *)"kernel.all.cpu.nice",
      { PMDA_PMID(CL_SYSCTL,4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER, 
	PMDA_PMUNITS(0,1,0,0,PM_TIME_MSEC,0) } },
    { (void *)"kernel.all.cpu.sys",
      { PMDA_PMID(CL_SYSCTL,5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER, 
コード例 #14
0
ファイル: mounts.c プロジェクト: Aconex/pcp
#define MOUNT_FILE "/etc/vfstab"
#else
#define MOUNT_FILE "/proc/mounts"
#endif

static pmdaInstid *mounts;

static pmdaIndom indomtab[] = {
#define MOUNTS_INDOM    0
  { MOUNTS_INDOM, 0, NULL }
};

static pmdaMetric metrictab[] = {
/* mounts.device */
    { NULL,
      { PMDA_PMID(0,0), PM_TYPE_STRING, MOUNTS_INDOM, PM_SEM_INSTANT,
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
/* mounts.type */
    { NULL,
      { PMDA_PMID(0,1), PM_TYPE_STRING, MOUNTS_INDOM, PM_SEM_INSTANT,
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
/* mounts.options */
    { NULL,
      { PMDA_PMID(0,2), PM_TYPE_STRING, MOUNTS_INDOM, PM_SEM_INSTANT,
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
/* mounts.up */
    { NULL,
      { PMDA_PMID(0,3), PM_TYPE_DOUBLE, MOUNTS_INDOM, PM_SEM_INSTANT,
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
};
コード例 #15
0
ファイル: mounts.c プロジェクト: felipebetancur/pcp
    MOUNTS_FLAG_STAT	= 0x4,
};

static pmdaInstid *mounts;

static pmdaIndom indomtab[] = {
    { MOUNTS_INDOM, 0, NULL }
};


/*
 * all metrics supported in this PMDA - one table entry for each
 */
static pmdaMetric metrictab[] = {
    {   NULL,	/* mounts.device */
        {   PMDA_PMID(MOUNTS_CLUSTER, MOUNTS_DEVICE),
            PM_TYPE_STRING, MOUNTS_INDOM, PM_SEM_DISCRETE,
            PMDA_PMUNITS(0,0,0,0,0,0)
        },
    },
    {   NULL,	/* mounts.type */
        {   PMDA_PMID(MOUNTS_CLUSTER, MOUNTS_TYPE),
            PM_TYPE_STRING, MOUNTS_INDOM, PM_SEM_DISCRETE,
            PMDA_PMUNITS(0,0,0,0,0,0)
        },
    },
    {   NULL,	/* mounts.options */
        {   PMDA_PMID(MOUNTS_CLUSTER, MOUNTS_OPTIONS),
            PM_TYPE_STRING, MOUNTS_INDOM, PM_SEM_INSTANT,
            PMDA_PMUNITS(0,0,0,0,0,0)
        },
コード例 #16
0
ファイル: pmda_ctdb.c プロジェクト: DanilKorotenko/samba
 * statistics for export via PCP. The ctdbd Unix domain socket path can be
 * specified with the CTDB_SOCKET environment variable, otherwise the default
 * path is used.
 */

/*
 * All metrics supported in this PMDA - one table entry for each.
 * The 4th field specifies the serial number of the instance domain
 * for the metric, and must be either PM_INDOM_NULL (denoting a
 * metric that only ever has a single value), or the serial number
 * of one of the instance domains declared in the instance domain table
 * (i.e. in indomtab, above).
 */
static pmdaMetric metrictab[] = {
	/* num_clients */
	{ NULL, { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
		PMDA_PMUNITS(0,0,0,0,0,0) }, },
	/* frozen */
	{ NULL, { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
		PMDA_PMUNITS(0,0,0,0,0,0) }, },
	/* recovering */
	{ NULL, { PMDA_PMID(0,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
		PMDA_PMUNITS(0,0,0,0,0,0) }, },
	/* client_packets_sent */
	{ NULL, { PMDA_PMID(0,3), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
		PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
	/* client_packets_recv */
	{ NULL, { PMDA_PMID(0,4), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
		PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
	/* node_packets_sent */
	{ NULL, { PMDA_PMID(0,5), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
コード例 #17
0
ファイル: events.c プロジェクト: Aconex/pcp
#include <pcp/impl.h>
#include <pcp/pmda.h>
#include "events.h"

static int		nfetch;
static int		xnfetch;
static int		myarray[2];

static int		nhrfetch;
static int		xnhrfetch;
static int		hrarray[2];

/* event parameters */
static pmValueBlock	*aggr;
static char		aggrval[] = { '\01', '\03', '\07', '\017', '\037', '\077', '\177', '\377' };
static pmID		pmid_type = PMDA_PMID(0,127);	/* event.type */
static pmID		pmid_32 = PMDA_PMID(0,128);	/* event.param_32 */
static pmID		pmid_u32 = PMDA_PMID(0,129);	/* event.param_u32 */
static pmID		pmid_64 = PMDA_PMID(0,130);	/* event.param_64 */
static pmID		pmid_u64 = PMDA_PMID(0,131);	/* event.param_u64 */
static pmID		pmid_float = PMDA_PMID(0,132);	/* event.param_float */
static pmID		pmid_double = PMDA_PMID(0,133);	/* event.param_double */
static pmID		pmid_string = PMDA_PMID(0,134);	/* event.param_string */
static pmID		pmid_aggregate = PMDA_PMID(0,135);	/* event.param_aggregate */

void
init_events(int domain)
{
    int	i, sts;

    /*
コード例 #18
0
ファイル: events.c プロジェクト: Aconex/pcp
int
sample_fetch_events(pmValueBlock **vbpp, int inst)
{
    int			c;
    int			sts;
    int			flags;
    struct timeval	stamp;
    pmAtomValue		atom;

    if (nfetch >= 0)
	c = nfetch % 4;
    else /* one of the error injection cases */
	c = nfetch;

    if (inst == PM_IN_NULL || inst > 1 || inst < 0)
	inst = 1;

    pmdaEventResetArray(myarray[inst]);
    gettimeofday(&stamp, NULL);

    if (inst == 0) {
	/* original instance ... */
	/* rebase event records 10 secs in past, add 1 sec for each new record */
	stamp.tv_sec -= 10;

	switch (c) {
	    case 0:
		/*
		 * 1st fetch
		 * No events
		 */
		 break;
	    case 1:
		/*
		 * 2nd fetch
		 * 1 event with NO parameters
		 */
		flags = PM_EVENT_FLAG_POINT;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		break;
	    case 2:
		/*
		 * 3rd fetch
		 * 1 event with one U32 parameter
		 * 1 event with 2 parameters(U32 and 64 types)
		 */
		flags = PM_EVENT_FLAG_POINT;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = 1;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = 2;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		atom.ll = -3;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_64, PM_TYPE_64, &atom)) < 0)
		    return sts;
		break;
	    case 3:
		/*
		 * 4th fetch
		 * 1 event start with 3 parameters (U32, U64 and STRING types)
		 * 1 event with 3 parameters (U32 and 2 DOUBLE types)
		 * 1 event end with 6 (U32, U64, STRING, STRING, 32 and U32 types)
		 * 7 "missed" events
		 * 1 event with 3 parameters (U32, FLOAT and AGGREGATE types)
		 */
		flags = PM_EVENT_FLAG_START|PM_EVENT_FLAG_ID|PM_EVENT_FLAG_PARENT;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = 4;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		atom.ull = 5;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_u64, PM_TYPE_U64, &atom)) < 0)
		    return sts;
		atom.cp = "6";
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_string, PM_TYPE_STRING, &atom)) < 0)
		    return sts;
		flags = PM_EVENT_FLAG_POINT;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = 7;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		atom.d = 8;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_double, PM_TYPE_DOUBLE, &atom)) < 0)
		    return sts;
		atom.d = -9;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_double, PM_TYPE_DOUBLE, &atom)) < 0)
		    return sts;
		flags = PM_EVENT_FLAG_END;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = 10;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		atom.ull = 11;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_u64, PM_TYPE_U64, &atom)) < 0)
		    return sts;
		atom.cp = "twelve";
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_string, PM_TYPE_STRING, &atom)) < 0)
		    return sts;
		atom.cp = "thirteen";
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_string, PM_TYPE_STRING, &atom)) < 0)
		    return sts;
		atom.l = -14;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_32, PM_TYPE_32, &atom)) < 0)
		    return sts;
		atom.ul = 15;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_u32, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		/* "missed" 7 records */
		if ((sts = pmdaEventAddMissedRecord(myarray[inst], &stamp, 7)) < 0)
		    return sts;
		stamp.tv_sec++;
		flags = PM_EVENT_FLAG_POINT;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = 16;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		atom.f = -17;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_float, PM_TYPE_FLOAT, &atom)) < 0)
		    return sts;
		atom.vbp = aggr;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_aggregate, PM_TYPE_AGGREGATE, &atom)) < 0)
		    return sts;
		break;
	    case -1:
		/* error injection */
		flags = PM_EVENT_FLAG_POINT;
		if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		    return sts;
		stamp.tv_sec++;
		atom.ul = c;
		if ((sts = pmdaEventAddParam(myarray[inst], pmid_type, PM_TYPE_U32, &atom)) < 0)
		    return sts;
		/* pmid that is not in PMNS and not known to the PMDA */
		if ((sts = pmdaEventAddParam(myarray[inst], PMDA_PMID(100,200), PM_TYPE_U32, &atom)) < 0)
		    return sts;
		break;
	}
	nfetch++;
    }
    else {
	/*
	 * new, boring instance ..., either instance ["bogus"] for
	 * sample.events.rrecord or singular instance for
	 * sample.events.no_indom_records
	 */
	static char hrecord1[20];
	static char hrecord2[] = "bingo!";

	flags = PM_EVENT_FLAG_POINT;
	if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
	    return sts;
	snprintf(hrecord1, sizeof(hrecord1), "fetch #%d", xnfetch);
	atom.cp = hrecord1;
	if ((sts = pmdaEventAddParam(myarray[inst], pmid_string, PM_TYPE_STRING, &atom)) < 0)
	    return sts;
	if ((xnfetch % 3) == 0) {
	    if ((sts = pmdaEventAddRecord(myarray[inst], &stamp, flags)) < 0)
		return sts;
	    atom.cp = hrecord2;
	    if ((sts = pmdaEventAddParam(myarray[inst], pmid_string, PM_TYPE_STRING, &atom)) < 0)
		return sts;
	}
	xnfetch++;
    }

    *vbpp = (pmValueBlock *)pmdaEventGetAddr(myarray[inst]);

    return 0;
}
コード例 #19
0
ファイル: mailq.c プロジェクト: Aconex/pcp
/*
 * list of instance domains
 */
static pmdaIndom indomtab[] = {
#define DELAY_INDOM	0
    { DELAY_INDOM, 0, NULL },
};

/*
 * all metrics supported in this PMDA - one table entry for each
 */
static pmdaMetric metrictab[] = {
/* length */
    { NULL, 
      { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT, 
        PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
/* deferred */
    { NULL, 
      { PMDA_PMID(0,1), PM_TYPE_U32, DELAY_INDOM, PM_SEM_INSTANT, 
        PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
};

static int
mailq_histogram(char *option)
{
    struct timeval	tv;
    char		*errmsg;
    char		*q;
    int			sts;