diff --git a/configure.ac b/configure.ac index a7a12ea69..3ddde13c7 100644 --- a/configure.ac +++ b/configure.ac @@ -1051,6 +1051,9 @@ ldms/src/sampler/app_sampler/Makefile ldms/src/sampler/slingshot_metrics/Makefile ldms/src/sampler/slingshot_info/Makefile ldms/src/sampler/json/Makefile +ldms/src/sampler/hweventpapi/Makefile \ +ldms/src/sampler/rapl/Makefile \ +ldms/src/sampler/tsampler/Makefile \ ldms/src/contrib/sampler/Makefile ldms/src/contrib/sampler/daos/Makefile ldms/src/contrib/sampler/daos/test/Makefile diff --git a/ldms/man/Makefile.am b/ldms/man/Makefile.am index 2a76a6152..e945ae388 100644 --- a/ldms/man/Makefile.am +++ b/ldms/man/Makefile.am @@ -25,13 +25,9 @@ ldms_quickstart.man \ ldms_sampler_base.man \ ldmsd_failover.man \ ldmsd_setgroup.man \ -Plugin_cray_system_sampler_variants.man \ -Plugin_cray_dvs_sampler.man \ Plugin_jobid.man \ Plugin_store_csv.man \ Plugin_store_sos.man \ -Plugin_lustre2_client.man \ -Plugin_shm_sampler.man \ Plugin_store_papi.man \ Plugin_store_app.man \ ldmsd_decomposition.man \ diff --git a/ldms/src/sampler/Makefile.am b/ldms/src/sampler/Makefile.am index 03117be2e..0bb8005f6 100644 --- a/ldms/src/sampler/Makefile.am +++ b/ldms/src/sampler/Makefile.am @@ -66,29 +66,9 @@ pkglib_LTLIBRARIES += libjobid.la endif if ENABLE_TSAMPLER -libtsampler_la_SOURCES = tsampler.c tsampler.h -libtsampler_la_LIBADD = $(COMMON_LIBADD) \ - $(top_builddir)/lib/src/ovis_event/libovis_event.la -lpthread -pkglib_LTLIBRARIES += libtsampler.la - -libtimer_base_la_SOURCES = timer_base.c timer_base.h -libtimer_base_la_LIBADD = $(COMMON_LIBADD) libtsampler.la $(JOBID_LIBFLAGS) -pkglib_LTLIBRARIES += libtimer_base.la - -libhfclock_la_SOURCES = hfclock.c -libhfclock_la_LIBADD = $(COMMON_LIBADD) libtimer_base.la -pkglib_LTLIBRARIES += libhfclock.la - -if ENABLE_CRAY_POWER_SAMPLER -libcray_power_sampler_la_SOURCES = cray_power_sampler.c -libcray_power_sampler_la_CFLAGS = $(AM_CFLAGS) -libcray_power_sampler_la_LIBADD = $(COMMON_LIBADD) \ - libtimer_base.la -pkglib_LTLIBRARIES += libcray_power_sampler.la +SUBDIRS += tsampler endif -endif #ENABLE_TSAMPLER - if ENABLE_KGNILND SUBDIRS += kgnilnd endif @@ -203,21 +183,13 @@ endif if HAVE_LIBPAPI SUBDIRS += papi + if HAVE_LIBPFM SUBDIRS += syspapi - -libhweventpapi_la_SOURCES = hweventpapi.c -libhweventpapi_la_CFLAGS = $(AM_CFLAGS) -libhweventpapi_la_LDFLAGS = $(AM_LDFLAGS) -libhweventpapi_la_LIBADD = $(COMMON_LIBADD) $(JOBID_LIBFLAGS) $(LTLIBPAPI) $(LTLIBPFM) -lm -pkglib_LTLIBRARIES += libhweventpapi.la - -librapl_la_SOURCES = rapl.c -librapl_la_CFLAGS = $(AM_CFLAGS) -librapl_la_LDFLAGS = $(AM_LDFLAGS) $(PAPI_LDFLAGS) -librapl_la_LIBADD = $(COMMON_LIBADD) $(LTLIBPAPI) $(LTLIBPFM) -lm -pkglib_LTLIBRARIES += librapl.la +SUBDIRS += rapl +SUBDIRS += hweventpapi endif + endif if ENABLE_PROCDISKSTATS diff --git a/ldms/src/sampler/cray_system_sampler/Makefile.am b/ldms/src/sampler/cray_system_sampler/Makefile.am index d3a18f41a..3e3816cd0 100644 --- a/ldms/src/sampler/cray_system_sampler/Makefile.am +++ b/ldms/src/sampler/cray_system_sampler/Makefile.am @@ -1,5 +1,6 @@ lib_LTLIBRARIES = pkglib_LTLIBRARIES = +dist_man7_MANS= AM_CPPFLAGS = @OVIS_INCLUDE_ABS@ AM_LDFLAGS = @OVIS_LIB_ABS@ @@ -15,6 +16,7 @@ if ENABLE_CRAY_SYSTEM_SAMPLER libcray_dvs_sampler_la_SOURCES = dvs_sampler.c libcray_dvs_sampler_la_LIBADD = $(COMMON_LIBADD) pkglib_LTLIBRARIES += libcray_dvs_sampler.la +dist_man7_MANS += Plugin_cray_dvs_sampler.man # then build cray_system_sampler @@ -64,6 +66,7 @@ endif libcray_gemini_r_sampler_la_LIBADD = $(CRAY_LIBADD_) \ ./librtr_util.la pkglib_LTLIBRARIES += libcray_gemini_r_sampler.la +dist_man7_MANS += Plugin_cray_system_sampler_variants.man endif if ENABLE_ARIES_GPCDR @@ -83,6 +86,7 @@ libcray_aries_r_sampler_la_LDFLAGS = $(CRAY_LDFLAGS_) endif libcray_aries_r_sampler_la_LIBADD = $(CRAY_LIBADD_) pkglib_LTLIBRARIES += libcray_aries_r_sampler.la +dist_man7_MANS += Plugin_cray_system_sampler_variants.man endif endif diff --git a/ldms/man/Plugin_cray_dvs_sampler.man b/ldms/src/sampler/cray_system_sampler/Plugin_cray_dvs_sampler.man similarity index 100% rename from ldms/man/Plugin_cray_dvs_sampler.man rename to ldms/src/sampler/cray_system_sampler/Plugin_cray_dvs_sampler.man diff --git a/ldms/man/Plugin_cray_system_sampler_variants.man b/ldms/src/sampler/cray_system_sampler/Plugin_cray_system_sampler_variants.man similarity index 100% rename from ldms/man/Plugin_cray_system_sampler_variants.man rename to ldms/src/sampler/cray_system_sampler/Plugin_cray_system_sampler_variants.man diff --git a/ldms/src/sampler/hweventpapi/Makefile.am b/ldms/src/sampler/hweventpapi/Makefile.am new file mode 100644 index 000000000..b2143e445 --- /dev/null +++ b/ldms/src/sampler/hweventpapi/Makefile.am @@ -0,0 +1,22 @@ + +AM_CPPFLAGS = @OVIS_INCLUDE_ABS@ +AM_LDFLAGS = @OVIS_LIB_ABS@ +COMMON_LIBADD = $(top_builddir)/ldms/src/sampler/libsampler_base.la \ + $(top_builddir)/ldms/src/core/libldms.la \ + @LDFLAGS_GETTIME@ \ + $(top_builddir)/lib/src/ovis_util/libovis_util.la \ + $(top_builddir)/lib/src/coll/libcoll.la + +# $(top_builddir)/lib/src/ovis_json/libovis_json.la \ +# $(top_builddir)/lib/src/ovis_log/libovis_log.la \ +# -lm -lpthread + + + +libhweventpapi_la_SOURCES = hweventpapi.c +libhweventpapi_la_CFLAGS = $(AM_CFLAGS) +libhweventpapi_la_LDFLAGS = $(AM_LDFLAGS) +libhweventpapi_la_LIBADD = $(COMMON_LIBADD) $(JOBID_LIBFLAGS) $(LTLIBPAPI) $(LTLIBPFM) -lm +pkglib_LTLIBRARIES = libhweventpapi.la + +dist_man7_MANS = Plugin_hweventpapi.man diff --git a/ldms/src/sampler/hweventpapi/Plugin_hweventpapi.man b/ldms/src/sampler/hweventpapi/Plugin_hweventpapi.man new file mode 100644 index 000000000..448ca6662 --- /dev/null +++ b/ldms/src/sampler/hweventpapi/Plugin_hweventpapi.man @@ -0,0 +1,71 @@ +.\" Manpage for Plugin_hweventpapi +.\" Contact ovis-help@ca.sandia.gov to correct errors or typos. +.TH man 7 "18 Feb 2018" "v4" "LDMS Plugin hweventpapi man page" + +.SH NAME +Plugin_hweventpapi - man page for the LDMS hweventpapi plugin + +.SH SYNOPSIS +Within ldmsd_controller or a configuration file: +.br +config name=hweventpapi [ = ] + +.SH DESCRIPTION +With LDMS (Lightweight Distributed Metric Service), plugins for the ldmsd (ldms daemon) are configured via ldmsd_controller +or a configuration file. The hweventpapi plugin provides energy sampling using RAPL via the PAPI interface for sandybridge. + +WARNING: This sampler is unsupported. + +.SH CONFIGURATION ATTRIBUTE SYNTAX +The hweventpapi plugin uses the sampler_base base class. This man page covers only the configuration attributes, or those with default values, specific to the this plugin; see ldms_sampler_base.man for the attributes of the base class. + + +.TP +.BR config +name= [schema=] +.br +configuration line +.RS +.TP +name= +.br +This MUST be hweventpapi. +.TP +schema= +.br +Optional schema name. It is intended that the same sampler on different nodes with different metrics have a +different schema. If not specified, will default to `hweventpapi`. +.TP +metafile= +.br +The metafile defines what to collect with undocumented "attribute=value" syntax. +The metafile is watched for changes and automatically reloaded. +.RE + +.SH BUGS +This man page is incomplete. + +.SH NOTES +.PP +.IP \[bu] +This sampler is unsupported. + +.SH EXAMPLES +.PP +Within ldmsd_controller or a configuration file: +.nf +load name=jobinfo +config name=jobinfo producer=${HOSTNAME} instance=${HOSTNAME}/jobinfo component_id=${COMPONENT_ID} uid=0 gid=0 perm=0700 +load name=hweventpapi +config name=hweventpapi producer=${HOSTNAME} instance=${HOSTNAME}/hweventpapi job_set=${HOSTNAME}/jobinfo component_id=${COMPONENT_ID} metafile=/tmp/papi.conf uid=0 gid=0 perm=0700 +start name=hweventpapi interval=1000000 offset=0 +.fi + +.PP +Within the metafile configuration: +.nf +this needs to be filled in. +.fi + +.SH SEE ALSO +ldmsd(8), ldms_quickstart(7), ldmsd_controller(8), ldms_sampler_base(7) diff --git a/ldms/src/sampler/hweventpapi.c b/ldms/src/sampler/hweventpapi/hweventpapi.c similarity index 100% rename from ldms/src/sampler/hweventpapi.c rename to ldms/src/sampler/hweventpapi/hweventpapi.c diff --git a/ldms/src/sampler/lustre/Makefile.am b/ldms/src/sampler/lustre/Makefile.am index c30921cbf..967913027 100644 --- a/ldms/src/sampler/lustre/Makefile.am +++ b/ldms/src/sampler/lustre/Makefile.am @@ -1,4 +1,5 @@ pkglib_LTLIBRARIES = +dist_man7_MANS = AM_CPPFLAGS = @OVIS_INCLUDE_ABS@ AM_LDFLAGS = @OVIS_LIB_ABS@ @@ -34,3 +35,4 @@ pkglib_LTLIBRARIES += liblustre2_oss.la liblustre2_client_la_SOURCES = lustre2_client.c liblustre2_client_la_LIBADD = $(COMMON_LIBADD) pkglib_LTLIBRARIES += liblustre2_client.la +dist_man7_MANS += Plugin_lustre2_client.man diff --git a/ldms/man/Plugin_lustre2_client.man b/ldms/src/sampler/lustre/Plugin_lustre2_client.man similarity index 97% rename from ldms/man/Plugin_lustre2_client.man rename to ldms/src/sampler/lustre/Plugin_lustre2_client.man index a40f269b7..ac00b0d01 100644 --- a/ldms/man/Plugin_lustre2_client.man +++ b/ldms/src/sampler/lustre/Plugin_lustre2_client.man @@ -61,8 +61,8 @@ to include the uid part. For example, 'lustre-ffff8803245d4000' is the actual file in /proc/fs/lustre/llite/, but you can just say llites=lustre to include this component into the set. .PP -osc_path, mdc_path, llite_path are optional full path names of stats files -if not in default location. The default locations are: +osc_path, mdc_path, llite_path are optional full path names of stats files +if not in default location. The default locations are: /sys/kernel/debug/lustre/{osc, mdc, llite}, and /proc/fs/lustre/{osc, mdc, llite} depends on the Lustre version. Be aware that /sys/kernel/debug is only readable by privileged users. diff --git a/ldms/man/Plugin_papi.man b/ldms/src/sampler/papi/Plugin_papi.man similarity index 94% rename from ldms/man/Plugin_papi.man rename to ldms/src/sampler/papi/Plugin_papi.man index 02eddd77a..121f8c713 100644 --- a/ldms/man/Plugin_papi.man +++ b/ldms/src/sampler/papi/Plugin_papi.man @@ -9,7 +9,7 @@ Plugin_papi - man page for the LDMS papi sampler plugin. Within ldmsctl .br -ldmsctl> config name=spapi [ = ] +ldmsctl> config name=spapi [ = ] .SH DESCRIPTION With LDMS (Lightweight Distributed Metric Service), plugins for the ldmsd (ldms daemon) are configured via ldmsctl. The papi sampler plugin runs on the nodes and provides data about the the occurrence of micro-architectural events using papi library by accessing hardware performance counters. @@ -37,7 +37,7 @@ The producer string value. instance= .br The name of the metric set -.TP +.TP schema= .br Optional schema name. It is intended that the same sampler on different nodes with different metrics have a different schema. @@ -90,10 +90,10 @@ ldmsctl> load name=spapi .br ldmsctl> config name=spapi producer=$PRODUCER_NAME instance=$INSTANCE_NAME pid=$PID events=PAPI_TOT_INS,PAPI_TOT_CYC,PAPI_BR_INS,PAPI_BR_MSP .br -ldmsctl> start name=spapi interval=$INTERVAL_VALUE +ldmsctl> start name=spapi interval=$INTERVAL_VALUE .br -ldmsctl> quit - +ldmsctl> quit + diff --git a/ldms/src/sampler/rapl/Makefile.am b/ldms/src/sampler/rapl/Makefile.am new file mode 100644 index 000000000..5826bcf22 --- /dev/null +++ b/ldms/src/sampler/rapl/Makefile.am @@ -0,0 +1,20 @@ + +AM_CPPFLAGS = @OVIS_INCLUDE_ABS@ +AM_LDFLAGS = @OVIS_LIB_ABS@ +COMMON_LIBADD = $(top_builddir)/ldms/src/sampler/libsampler_base.la \ + $(top_builddir)/ldms/src/core/libldms.la \ + @LDFLAGS_GETTIME@ \ + $(top_builddir)/lib/src/ovis_util/libovis_util.la \ + $(top_builddir)/lib/src/coll/libcoll.la + +# $(top_builddir)/lib/src/ovis_json/libovis_json.la \ +# $(top_builddir)/lib/src/ovis_log/libovis_log.la \ +# -lm -lpthread + + +librapl_la_SOURCES = rapl.c +librapl_la_CFLAGS = $(AM_CFLAGS) +librapl_la_LDFLAGS = $(AM_LDFLAGS) $(PAPI_LDFLAGS) +librapl_la_LIBADD = $(COMMON_LIBADD) $(LTLIBPAPI) $(LTLIBPFM) -lm +pkglib_LTLIBRARIES = librapl.la +dist_man7_MANS = Plugin_rapl.man diff --git a/ldms/man/Plugin_rapl.man b/ldms/src/sampler/rapl/Plugin_rapl.man similarity index 100% rename from ldms/man/Plugin_rapl.man rename to ldms/src/sampler/rapl/Plugin_rapl.man diff --git a/ldms/src/sampler/rapl.c b/ldms/src/sampler/rapl/rapl.c similarity index 100% rename from ldms/src/sampler/rapl.c rename to ldms/src/sampler/rapl/rapl.c diff --git a/ldms/src/sampler/shm/Makefile.am b/ldms/src/sampler/shm/Makefile.am index 9072f242f..7631ca3d5 100644 --- a/ldms/src/sampler/shm/Makefile.am +++ b/ldms/src/sampler/shm/Makefile.am @@ -19,6 +19,7 @@ LIBADD = $(COMMON_LIBADD) libshm_sampler_la_SOURCES = shm_sampler.c libshm_sampler_la_LIBADD = $(LIBADD) $(JOBID_LIBFLAGS) shm_util/liblshm.la -lm -lrt -lpthread pkglib_LTLIBRARIES += libshm_sampler.la +dist_man7_MANS = Plugin_shm_sampler.man EXTRA_DIST = \ outline \ diff --git a/ldms/man/Plugin_shm_sampler.man b/ldms/src/sampler/shm/Plugin_shm_sampler.man similarity index 83% rename from ldms/man/Plugin_shm_sampler.man rename to ldms/src/sampler/shm/Plugin_shm_sampler.man index 458fdbef7..86ea2bf02 100644 --- a/ldms/man/Plugin_shm_sampler.man +++ b/ldms/src/sampler/shm/Plugin_shm_sampler.man @@ -6,10 +6,10 @@ .Sh Name \" Section Header - required - don't modify .Nm shm_sampler -.Nd -This is a sampler plug-in module within the the LDMS that can read from a dynamic number of shm files. +.Nd +This is a sampler plug-in module within the the LDMS that can read from a dynamic number of shm files. -.Sh SYNOPSIS +.Sh SYNOPSIS Within ldmsd_controller or a configuration file: .br load name=shm_sampler @@ -19,44 +19,44 @@ config name=shm_sampler [ = ] .Sh DESCRIPTION \" Section Header - required - don't modify .Nm -is a sampler plug-in module within the the LDMS. This sampler can read from a dynamic number of shm files. -These files are tracked by a central index file in shared memory. +is a sampler plug-in module within the the LDMS. This sampler can read from a dynamic number of shm files. +These files are tracked by a central index file in shared memory. The main usage of this sampler is to stream application performance data. .Pp \" Inserts a space Configuration options: .br -producer= instance= [shm_index=][shm_boxmax=][shm_array_max=][shm_metric_max=] -[shm_set_timeout=][component_id=] [schema=] [job_set= job_id= app_id= +producer= instance= [shm_index=][shm_boxmax=][shm_array_max=][shm_metric_max=] +[shm_set_timeout=][component_id=] [schema=] [job_set= job_id= app_id= job_start= job_end=] .Bl -tag -width -indent \" Begins a tagged list .It producer \" Each item preceded by .It macro A unique name for the host providing the data .It instance A unique name for the metric set -.It shm_index +.It shm_index A unique name for the shared memory index file -.It shm_boxmax +.It shm_boxmax Maximum number of entries in the shared memory index file -.It shm_array_max +.It shm_array_max Maximum number of elements in array metrics -.It shm_metric_max +.It shm_metric_max Maximum number of metrics -.It shm_set_timeout +.It shm_set_timeout No read/write timeout in seconds -.It component_id +.It component_id A unique number for the component being monitored, Defaults to zero. -.It schema +.It schema The name of the metric set schema, Defaults to the sampler name -.It job_set +.It job_set The instance name of the set containing the job data, default is 'job_info' -.It job_id +.It job_id The name of the metric containing the Job Id, default is 'job_id' -.It app_id +.It app_id The name of the metric containing the Application Id, default is 'app_id' -.It job_start +.It job_start The name of the metric containing the Job start time, default is 'job_start' -.It job_end +.It job_end The name of the metric containing the Job end time, default is 'job_end' .El \" Ends the list diff --git a/ldms/src/sampler/tsampler/Makefile.am b/ldms/src/sampler/tsampler/Makefile.am new file mode 100644 index 000000000..ec69b1407 --- /dev/null +++ b/ldms/src/sampler/tsampler/Makefile.am @@ -0,0 +1,31 @@ +pkglib_LTLIBRARIES = + +AM_CPPFLAGS = @OVIS_INCLUDE_ABS@ +AM_LDFLAGS = @OVIS_LIB_ABS@ +COMMON_LIBADD = $(top_builddir)/ldms/src/sampler/libsampler_base.la \ + $(top_builddir)/ldms/src/core/libldms.la \ + @LDFLAGS_GETTIME@ \ + $(top_builddir)/lib/src/ovis_util/libovis_util.la \ + $(top_builddir)/lib/src/coll/libcoll.la + + +libtsampler_la_SOURCES = tsampler.c tsampler.h +libtsampler_la_LIBADD = $(COMMON_LIBADD) \ + $(top_builddir)/lib/src/ovis_event/libovis_event.la -lpthread +pkglib_LTLIBRARIES += libtsampler.la + +libtimer_base_la_SOURCES = timer_base.c timer_base.h +libtimer_base_la_LIBADD = $(COMMON_LIBADD) libtsampler.la $(JOBID_LIBFLAGS) +pkglib_LTLIBRARIES += libtimer_base.la + +libhfclock_la_SOURCES = hfclock.c +libhfclock_la_LIBADD = $(COMMON_LIBADD) libtimer_base.la +pkglib_LTLIBRARIES += libhfclock.la + +if ENABLE_CRAY_POWER_SAMPLER +libcray_power_sampler_la_SOURCES = cray_power_sampler.c +libcray_power_sampler_la_CFLAGS = $(AM_CFLAGS) +libcray_power_sampler_la_LIBADD = $(COMMON_LIBADD) \ + libtimer_base.la +pkglib_LTLIBRARIES += libcray_power_sampler.la +endif diff --git a/ldms/src/sampler/tsampler/cray_power_sampler.c b/ldms/src/sampler/tsampler/cray_power_sampler.c new file mode 100644 index 000000000..873730293 --- /dev/null +++ b/ldms/src/sampler/tsampler/cray_power_sampler.c @@ -0,0 +1,269 @@ +/* -*- c-basic-offset: 8 -*- + * Copyright (c) 2016-2018 National Technology & Engineering Solutions + * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with + * NTESS, the U.S. Government retains certain rights in this software. + * Copyright (c) 2016-2018 Open Grid Computing, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the BSD-type + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of Sandia nor the names of any contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Neither the name of Open Grid Computing nor the names of any + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Modified source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * \file cray_power_sampler.c + */ +#include +#include +#include +#include +#include +#include + +#include "ldms.h" +#include "ldmsd.h" +#include "timer_base.h" +#include "sampler_base.h" + +static ovis_log_t mylog; + +typedef enum { + CPS_ENERGY, + /* CPS_FRESHNESS, */ + /* CPS_GENERATION, */ + CPS_POWER, + /* CPS_POWER_CAP, */ + /* CPS_STARTUP, */ + /* CPS_VERSION, */ + CPS_LAST, +} cps_metric_type; + +static const char *cps_names[] = { + [CPS_ENERGY] = "energy", + /* [CPS_FRESHNESS] = "freshness", */ + /* [CPS_GENERATION] = "generation", */ + [CPS_POWER] = "power", + /* [CPS_POWER_CAP] = "power_cap", */ + /* [CPS_STARTUP] = "startup", */ + /* [CPS_VERSION] = "version", */ +}; + +static const char *cps_files[] = { + [CPS_ENERGY] = "/sys/cray/pm_counters/energy", + /* [CPS_FRESHNESS] = "/sys/cray/pm_counters/freshness", */ + /* [CPS_GENERATION] = "/sys/cray/pm_counters/generation", */ + [CPS_POWER] = "/sys/cray/pm_counters/power", + /* [CPS_POWER_CAP] = "/sys/cray/pm_counters/power_cap", */ + /* [CPS_STARTUP] = "/sys/cray/pm_counters/startup", */ + /* [CPS_VERSION] = "/sys/cray/pm_counters/version", */ +}; + +struct cray_power_sampler { + struct timer_base base; + int fd[CPS_LAST]; + struct timeval hfinterval; + int hfcount; +}; + +static const char *cray_power_sampler_usage(struct ldmsd_plugin *self) +{ + return "config name=cray_power_sampler producer=" + " instance= [hfinterval=] " + " [hfcount=] [component_id=] [schema=] " + " [with_jobid=(0|1)]\n" + " The producer name.\n" + " The instance name.\n" + " (Optional) the high-frequency interval (micro second, default: 100000).\n" + " (Optional) the number of elements in the ring buffer (default: 600).\n" + " (Optional) unique number identifier. Defaults to zero.\n" + " (Optional) schema name. Defaults to 'sampler_timer'.\n" + " with_jobid (Optional) enable(1) or disable(0) job info lookup (default: 1).\n" + ; +} + +static +void cray_power_sampler_cleanup(struct cray_power_sampler *cps) +{ + int fd, i; + /* terminate timers */ + timer_base_cleanup(&cps->base); + for (i = 0; i < CPS_LAST; i++) { + fd = cps->fd[i]; + if (fd >= 0) { + close(fd); + } + } +} + +static +void cray_power_sampler_term(struct ldmsd_plugin *self) +{ + cray_power_sampler_cleanup((void*)self); + if (mylog) + ovis_log_destroy(mylog); +} + +static +void cray_power_sampler_timer_cb(tsampler_timer_t t) +{ + int rc; + int cps_idx; + off_t off; + struct cray_power_sampler *cps; + uint64_t v; + char buff[64]; + + /* t->sampler, t->set and t->mid (metric-id) are set when the time is + * setup in create_metric_set(). + * + * t->idx is the current index in the array provided by timer. This will + * keep modulo-increasing call-after-call (per timer). + * */ + + cps = (void*)t->sampler; + + cps_idx = (uint64_t)t->ctxt; /* abuse ctxt */ + + off = lseek(cps->fd[cps_idx], 0, SEEK_SET); + if (off < 0) { + /* error */ + ovis_log(mylog, OVIS_LDEBUG, "lseek() error, " + "errno: %d, cps_idx: %d\n.", errno, cps_idx); + return; + } + + rc = read(cps->fd[cps_idx], buff, sizeof(buff)); + if (rc < 0) { + /* error */ + ovis_log(mylog, OVIS_LDEBUG, "read() error, " + "errno: %d, cps_idx: %d\n.", errno, cps_idx); + return; + } + + v = strtoul(buff, NULL, 0); + ldms_metric_array_set_u64(t->set, t->mid, t->idx, v); +} +static +int cray_power_sampler_config(struct ldmsd_plugin *self, + struct attr_value_list *kwl, + struct attr_value_list *avl) +{ + char *v; + uint64_t x; + int rc; + struct cray_power_sampler *cps = (void*)self; + int i; + + rc = timer_base_config(self, kwl, avl, mylog); + if (rc) { + goto out; + } + + /* set default values */ + cps->hfinterval.tv_sec = 0; + cps->hfinterval.tv_usec = 100000; + cps->hfcount = 600; + + v = av_value(avl, "hfinterval"); + if (v) { + x = strtoull(v, NULL, 0); + if (!x) { + rc = EINVAL; + goto cleanup; + } + cps->hfinterval.tv_sec = x / 1000000; + cps->hfinterval.tv_usec = x % 1000000; + } + + v = av_value(avl, "hfcount"); + if (v) { + cps->hfcount = strtol(v, NULL, 0); + if (!cps->hfcount) { + rc = EINVAL; + goto cleanup; + } + } + + for (i = 0; i < CPS_LAST; i++) { + cps->fd[i] = open(cps_files[i], O_RDONLY); + if (cps->fd[i] < 0) + goto cleanup; + rc = timer_base_add_hfmetric(&cps->base, cps_names[i], + LDMS_V_U64_ARRAY, cps->hfcount, + &cps->hfinterval, cray_power_sampler_timer_cb, + (void*)(uint64_t)i); + if (rc) + goto cleanup; + } + + rc = timer_base_create_set(&cps->base); + if (rc) { + goto cleanup; + } + goto out; + +cleanup: + timer_base_cleanup(&cps->base); +out: + return rc; +} +struct ldmsd_plugin *get_plugin() +{ + int rc; + mylog = ovis_log_register("sampler.cray_power_sampler", "The log subsystem of the cray_power_sampler plugin"); + if (!mylog) { + rc = errno; + ovis_log(NULL, OVIS_LWARN, "Failed to create the subsystem " + "of 'cray_power_sampler' plugin. Error %d\n", rc); + } + struct cray_power_sampler *cps = calloc(1, sizeof(*cps)); + + if (!cps) + return NULL; + + timer_base_init(&cps->base); + /* override */ + cps->base.base.base.usage = cray_power_sampler_usage; + cps->base.base.base.term = cray_power_sampler_term; + cps->base.base.base.config = cray_power_sampler_config; + snprintf(cps->base.base.base.name, sizeof(cps->base.base.base.name), + "cray_power_sampler"); + + return (void*)cps; +} diff --git a/ldms/src/sampler/tsampler/hfclock.c b/ldms/src/sampler/tsampler/hfclock.c new file mode 100644 index 000000000..03ae4f34b --- /dev/null +++ b/ldms/src/sampler/tsampler/hfclock.c @@ -0,0 +1,191 @@ +/* -*- c-basic-offset: 8 -*- + * Copyright (c) 2016,2018 National Technology & Engineering Solutions + * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with + * NTESS, the U.S. Government retains certain rights in this software. + * Copyright (c) 2016,2018 Open Grid Computing, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the BSD-type + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of Sandia nor the names of any contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Neither the name of Open Grid Computing nor the names of any + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Modified source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * \file hfclock.c + */ +#include +#include +#include +#include +#include +#include + +#include "ldms.h" +#include "ldmsd.h" +#include "timer_base.h" + +static ovis_log_t mylog; + +struct hfclock { + struct timer_base base; + struct timeval hfinterval; + int hfcount; +}; + +static const char *hfclock_usage(struct ldmsd_plugin *self) +{ + return "config name=hfclock producer=" + " instance= [hfinterval=] " + " [hfcount=] [component_id=] [schema=] " + " [with_jobid=(0|1)]\n" + " The producer name.\n" + " The instance name.\n" + " (Optional) the high-frequency interval (micro second, default: 100000).\n" + " (Optional) the number of elements in the ring buffer (default: 600).\n" + " (Optional) unique number identifier. Defaults to zero.\n" + " (Optional) schema name. Defaults to 'sampler_timer'.\n" + " with_jobid (Optional) enable(1) or disable(0) job info lookup (default: 1).\n" + ; +} + +static +void hfclock_cleanup(struct hfclock *hf) +{ + timer_base_cleanup(&hf->base); +} + +static +void hfclock_term(struct ldmsd_plugin *self) +{ + hfclock_cleanup((void*)self); + if (mylog) + ovis_log_destroy(mylog); +} + +static +void hfclock_timer_cb(tsampler_timer_t t) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + ldms_metric_array_set_double(t->set, t->mid, t->idx, tv.tv_sec + tv.tv_usec/1e6); +} + +static +int hfclock_config(struct ldmsd_plugin *self, + struct attr_value_list *kwl, + struct attr_value_list *avl) +{ + int rc; + char *v; + uint64_t x; + struct hfclock *hf = (void*)self; + + rc = timer_base_config(self, kwl, avl, mylog); + if (rc) + goto out; + + /* set default values */ + hf->hfinterval.tv_sec = 0; + hf->hfinterval.tv_usec = 100000; + hf->hfcount = 600; + + v = av_value(avl, "hfinterval"); + if (v) { + x = strtoull(v, NULL, 0); + if (!x) { + rc = EINVAL; + goto cleanup; + } + hf->hfinterval.tv_sec = x / 1000000; + hf->hfinterval.tv_usec = x % 1000000; + } + + v = av_value(avl, "hfcount"); + if (v) { + hf->hfcount = strtol(v, NULL, 0); + if (!hf->hfcount) { + rc = EINVAL; + goto cleanup; + } + } + + rc = timer_base_add_hfmetric(&hf->base, "clock", + LDMS_V_D64_ARRAY, hf->hfcount, + &hf->hfinterval, hfclock_timer_cb, + NULL); + if (rc) + goto cleanup; + + rc = timer_base_create_set(&hf->base); + if (rc) + goto cleanup; + + goto out; + +cleanup: + hfclock_cleanup(hf); + +out: + return rc; +} + +struct ldmsd_plugin *get_plugin() +{ + int rc; + mylog = ovis_log_register("sampler.hfclock", "The log subsystem of the hfclock plugin"); + if (!mylog) { + rc = errno; + ovis_log(NULL, OVIS_LWARN, "Failed to create the subsystem " + "of 'hfclock' plugin. Error %d\n", rc); + } + struct hfclock *hf = calloc(1, sizeof(*hf)); + + if (!hf) + return NULL; + + timer_base_init(&hf->base); + /* override */ + hf->base.base.base.usage = hfclock_usage; + hf->base.base.base.term = hfclock_term; + hf->base.base.base.config = hfclock_config; + snprintf(hf->base.base.base.name, sizeof(hf->base.base.base.name), + "hfclock"); + + return (void*)hf; +} diff --git a/ldms/src/sampler/tsampler/timer_base.c b/ldms/src/sampler/tsampler/timer_base.c new file mode 100644 index 000000000..79d6ad99d --- /dev/null +++ b/ldms/src/sampler/tsampler/timer_base.c @@ -0,0 +1,351 @@ +/* -*- c-basic-offset: 8 -*- + * Copyright (c) 2016-2018 National Technology & Engineering Solutions + * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with + * NTESS, the U.S. Government retains certain rights in this software. + * Copyright (c) 2016-2018 Open Grid Computing, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the BSD-type + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of Sandia nor the names of any contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Neither the name of Open Grid Computing nor the names of any + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Modified source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * \file timer_base.c + * \brief a base class of ldmsd sampler with additional timer. + * + * This is a base class of ldmsd sampler that uses tsampler utility (see \ref + * tsampler.h and \ref tsampler.c) as additional timer to sample high-frequency + * data. + * + * This sampler plugin will create metric arrays of timestamps, each array + * associated with the 'interval' parameter supplied in the configuration (see + * usage() and config()). The arrays then populated with 64-bit timestamp values + * [(high_32_bit) sec | (low_32_bit) usec]. + * + * The extra-timer is setup in create_metric_set(), and are started in sample(). + */ + +#include +#include +#include +#include +#include +#include +#include +#include "ldms.h" +#include "ldmsd.h" +#include "tsampler.h" +#include "timer_base.h" +#include "ldms_jobid.h" + +/* state of the sampler */ +typedef enum { + TBS_INIT, + TBS_CONFIGURED, + TBS_RUNNING, +} timer_base_state_e; + +/* Convenient functions to convert timeval <--> u64 */ +static inline +struct timeval u64_to_tv(uint64_t x) +{ + struct timeval tv; + tv.tv_sec = x >> 32; + tv.tv_usec = x & 0xFFFFFFFF; + return tv; +} + +static inline +uint64_t tv_to_u64(struct timeval tv) +{ + uint64_t x; + x = (((uint64_t)tv.tv_sec) << 32) | (tv.tv_usec & 0xFFFFFFFF); + return x; +} + +ldms_set_t timer_base_get_set(struct ldmsd_sampler *self) +{ + struct timer_base *tb = (void*)self; + return tb->set; +} + +int timer_base_create_metric_set(struct timer_base *tb) +{ + int rc = 0; + pthread_mutex_lock(&tb->mutex); + tb->set = ldms_set_new(tb->iname, tb->schema); + if (!tb->set) { + rc = errno; + goto out; + } + ldms_metric_set_u64(tb->set, 0, tb->compid); + ldms_metric_set_u64(tb->set, 1, 0); /* default jobid */ + tb->state = TBS_CONFIGURED; +out: + pthread_mutex_unlock(&tb->mutex); + return rc; +} + +int timer_base_add_hfmetric(struct timer_base *tb, + const char *name, + enum ldms_value_type type, + int n, + const struct timeval *interval, + tsampler_sample_cb cb, + void *ctxt) +{ + int rc = 0; + struct tsampler_timer_entry *t = calloc(1, sizeof(*t)); + if (!t) { + rc = errno; + goto out; + } + if (type < LDMS_V_CHAR_ARRAY || LDMS_V_D64_ARRAY < type) { + rc = EINVAL; + goto out; + } + t->timer.n = n; + t->timer.mid = ldms_schema_metric_array_add(tb->schema, name, type, t->timer.n); + if (t->timer.mid < 0) { + rc = -t->timer.mid; + goto out; + } + snprintf(tb->buff, sizeof(tb->buff), "%s_timeval", name); + t->timer.tid = ldms_schema_metric_array_add(tb->schema, tb->buff, + LDMS_V_U64_ARRAY, t->timer.n*2); + if (t->timer.tid < 0) { + rc = -t->timer.tid; + goto out; + } + t->timer.sampler = &tb->base; + t->timer.cb = cb; + t->timer.ctxt = ctxt; + t->timer.interval = *interval; + TAILQ_INSERT_TAIL(&tb->timer_list, t, entry); + /* timer will be activated later in sample() function */ +out: + if (rc && t) { + free(t); + } + return rc; +} + +int timer_base_config(struct ldmsd_plugin *self, struct attr_value_list *kwl, + struct attr_value_list *avl, ovis_log_t mylog) +{ + struct timer_base *tb; + int rc = 0; + + tb = (void*)self; + + tb->mylog = mylog; + + pthread_mutex_lock(&tb->mutex); + switch (tb->state) { + case TBS_INIT: + /* OK */ + break; + case TBS_CONFIGURED: + case TBS_RUNNING: + rc = EEXIST; + goto out; + } + + if (tb->schema) { + ovis_log(tb->mylog, OVIS_LERROR, "%s: schema existed.\n", tb->base.base.name); + rc = EEXIST; + goto out; + } + + if (tb->set) { + ovis_log(tb->mylog, OVIS_LERROR, "%s: set existed.\n", tb->base.base.name); + rc = EEXIST; + goto out; + } + tb->cfg = base_config(avl, tb->base.base.name, tb->base.base.name, mylog); + if (!tb->cfg) { + rc = errno; + goto out; + } + + + snprintf(tb->pname, sizeof(tb->pname), "%s", tb->cfg->producer_name); + snprintf(tb->iname, sizeof(tb->iname), "%s", tb->cfg->instance_name); + tb->compid = tb->cfg->component_id; + tb->schema = base_schema_new(tb->cfg); + if (!tb->schema) { + rc = errno; + goto out; + } + + rc = 0; + tb->state = TBS_CONFIGURED; + +out: + pthread_mutex_unlock(&tb->mutex); + return rc; +} + +int timer_base_create_set(struct timer_base *tb) +{ + tb->set = base_set_new(tb->cfg); + if (!tb->set) { + ovis_log(tb->mylog, OVIS_LERROR, "%s: ldms_set_new() failed, errno: %d.\n", + tb->base.base.name, errno); + return errno; + } + return 0; +} + +void timer_base_cleanup(struct timer_base *tb); + +void timer_base_term(struct ldmsd_plugin *self) +{ + /* remove all timers when we terminate */ + timer_base_cleanup((void*)self); +} + +int timer_base_sample(struct ldmsd_sampler *self) +{ + struct timer_base *tb = (void*)self; + int rc = 0; + struct tsampler_timer_entry *ent; + + + pthread_mutex_lock(&tb->mutex); + base_sample_begin(tb->cfg); + switch (tb->state) { + case TBS_INIT: + assert(0); + break; + case TBS_CONFIGURED: + /* add timers if this is the first sample() */ + TAILQ_FOREACH(ent, &tb->timer_list, entry) { + ent->timer.set = tb->set; + rc = tsampler_timer_add(&ent->timer); + if (rc) + goto timer_cleanup; + } + tb->state = TBS_RUNNING; + break; + case TBS_RUNNING: + /* do nothing */ + break; + } + base_sample_end(tb->cfg); + pthread_mutex_unlock(&tb->mutex); + + goto out; + +timer_cleanup: + /* remove added timers at cleanup */ + while ((ent = TAILQ_FIRST(&tb->timer_list))) { + TAILQ_REMOVE(&tb->timer_list, ent, entry); + tsampler_timer_remove(&ent->timer); + } + pthread_mutex_unlock(&tb->mutex); + +out: + ldms_transaction_end(tb->set); + return rc; +} + +const char *timer_base_usage(struct ldmsd_plugin *self) +{ + return "timer_base is a base-class sampler that cannot be used by itself."; +} + +void timer_base_remove_timers(struct timer_base *tb) +{ + struct tsampler_timer_entry *ent; + while ((ent = TAILQ_FIRST(&tb->timer_list))) { + TAILQ_REMOVE(&tb->timer_list, ent, entry); + tsampler_timer_remove(&ent->timer); + free(ent); + } +} + +void timer_base_cleanup(struct timer_base *tb) +{ + timer_base_remove_timers(tb); + if (tb->set) { + ldms_set_delete(tb->set); + tb->set = NULL; + } + if (tb->cfg) { + base_del(tb->cfg); + tb->cfg = NULL; + } + tb->schema = NULL; + tb->state = TBS_INIT; +} + +static +int __config(struct ldmsd_plugin *self, struct attr_value_list *kwl, +struct attr_value_list *avl) +{ + assert(0 == "ERROR timer_base.config() not overridden."); + return ENOSYS; +} + +void timer_base_init(struct timer_base *tb) +{ + /* sub-class can override these values after calling this function */ + snprintf(tb->base.base.name, sizeof(tb->base.base.name), "timer_base"); + tb->base.base.type = LDMSD_PLUGIN_SAMPLER; + tb->base.base.term = timer_base_term; + tb->base.base.config = __config; + tb->base.base.usage = timer_base_usage; + tb->base.get_set = timer_base_get_set; + tb->base.sample = timer_base_sample; + tb->state = TBS_INIT; + TAILQ_INIT(&tb->timer_list); + pthread_mutex_init(&tb->mutex, NULL); +} + +struct ldmsd_plugin *get_plugin() +{ + struct timer_base *tb = calloc(1, sizeof(*tb)); + if (!tb) + return NULL; + timer_base_init(tb); + return (void*)tb; +} diff --git a/ldms/src/sampler/tsampler/timer_base.h b/ldms/src/sampler/tsampler/timer_base.h new file mode 100644 index 000000000..8239f28c8 --- /dev/null +++ b/ldms/src/sampler/tsampler/timer_base.h @@ -0,0 +1,105 @@ +/* -*- c-basic-offset: 8 -*- + * Copyright (c) 2016-2018 National Technology & Engineering Solutions + * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with + * NTESS, the U.S. Government retains certain rights in this software. + * Copyright (c) 2016-2018 Open Grid Computing, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the BSD-type + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of Sandia nor the names of any contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * Neither the name of Open Grid Computing nor the names of any + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Modified source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __TIMER_BASE_H +#define __TIMER_BASE_H + +#include "ldms.h" +#include "ldmsd.h" +#include "tsampler.h" +#include +#include +#include "sampler_base.h" + +struct tsampler_timer_entry { + struct tsampler_timer timer; + TAILQ_ENTRY(tsampler_timer_entry) entry; +}; + +struct timer_base { + struct ldmsd_sampler base; + enum { + ST_INIT, + ST_CONFIGURED, + ST_RUNNING, + } state; + base_data_t cfg; /* sampler base class data */ + ldms_set_t set; + ldms_schema_t schema; + uint64_t compid; + pthread_mutex_t mutex; + ovis_log_t mylog; + TAILQ_HEAD(, tsampler_timer_entry) timer_list; + char buff[1024]; /* string buffer for internal timer_base use */ + char iname[1024]; /* iname for internal use */ + char pname[1024]; /* producer name for internal use */ +}; + +void timer_base_init(struct timer_base *tb); + +int timer_base_config(struct ldmsd_plugin *self, struct attr_value_list *kwl, + struct attr_value_list *avl, ovis_log_t mylog); + +int timer_base_create_set(struct timer_base *tb); + +ldms_set_t timer_base_get_set(struct ldmsd_sampler *self); + +void timer_base_term(struct ldmsd_plugin *self); + +int timer_base_sample(struct ldmsd_sampler *self); + +void timer_base_cleanup(struct timer_base *tb); + +int timer_base_add_hfmetric(struct timer_base *tb, + const char *name, + enum ldms_value_type type, + int n, + const struct timeval *interval, + tsampler_sample_cb cb, + void *ctxt); +#endif diff --git a/ldms/src/sampler/tsampler.c b/ldms/src/sampler/tsampler/tsampler.c similarity index 100% rename from ldms/src/sampler/tsampler.c rename to ldms/src/sampler/tsampler/tsampler.c diff --git a/ldms/src/sampler/tsampler.h b/ldms/src/sampler/tsampler/tsampler.h similarity index 100% rename from ldms/src/sampler/tsampler.h rename to ldms/src/sampler/tsampler/tsampler.h