From b82746cbd4869f423e8cdc8bf0fa496dd338a82b85fd70a8a1193b30b3cd689c Mon Sep 17 00:00:00 2001 From: Lars Vogdt Date: Sun, 29 Oct 2017 16:50:16 +0000 Subject: [PATCH] Accepting request 532580 from home:StefanBruens:branches:server:monitoring - Sort list of plugins bundled in main package, add line breaks - Add BuildRequires for libsigrok and create a sigrok plugin subpackage - Add 9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch Apply patch conditionally for libsigrok >= 0.4.0, the API is different from the libsigrok 0.3.0 API. OBS-URL: https://build.opensuse.org/request/show/532580 OBS-URL: https://build.opensuse.org/package/show/server:monitoring/collectd?expand=0&rev=146 --- ...grok_Update_to_support_libsigrok_0_4.patch | 175 ++++++++++++++++++ collectd.changes | 10 + collectd.spec | 37 +++- 3 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch diff --git a/9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch b/9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch new file mode 100644 index 0000000..4a189fc --- /dev/null +++ b/9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch @@ -0,0 +1,175 @@ +From 9e36cd85a2bbd6daa55f1f392f60f9c95573ae2c Mon Sep 17 00:00:00 2001 +From: Jonathan McDowell +Date: Wed, 30 Aug 2017 18:48:55 +0100 +Subject: [PATCH] sigrok: Update to support libsigrok 0.4 + +libsigrok 0.4 changes API in an incompatible manner to previous +versions. Fix up the plugin to work with this version. + +Note: Compile tested only; my sigrok device has no analog channels + +Closes: collectd/collectd#1574 +[sbruens: adapted to 5.7 branch (ssnprintf vs snprintf)] +--- + configure.ac | 2 +- + src/sigrok.c | 51 +++++++++++++++++++++++++++------------------------ + 2 files changed, 28 insertions(+), 25 deletions(-) + +diff --git a/configure.ac b/configure.ac +index f50df28a6d..6b7aad43ae 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5084,7 +5084,7 @@ AC_SUBST([BUILD_WITH_LIBSENSORS_LIBS]) + # libsigrok {{{ + AC_SUBST([LIBSIGROK_CFLAGS]) + AC_SUBST([LIBSIGROK_LIBS]) +-PKG_CHECK_MODULES([LIBSIGROK], [libsigrok < 0.4], ++PKG_CHECK_MODULES([LIBSIGROK], [libsigrok >= 0.4], + [with_libsigrok="yes"], + [with_libsigrok="no (pkg-config could not find libsigrok)"] + ) +diff --git a/src/sigrok.c b/src/sigrok.c +index 8a325fe9f0..a44c95e4b8 100644 +--- a/src/sigrok.c ++++ b/src/sigrok.c +@@ -127,22 +127,22 @@ static int sigrok_config(oconfig_item_t *ci) { + return 0; + } + +-static const char *sigrok_value_type(const struct sr_datafeed_analog *analog) { ++static const char *sigrok_value_type(const struct sr_analog_meaning *meaning) { + const char *s; + +- if (analog->mq == SR_MQ_VOLTAGE) ++ if (meaning->mq == SR_MQ_VOLTAGE) + s = "voltage"; +- else if (analog->mq == SR_MQ_CURRENT) ++ else if (meaning->mq == SR_MQ_CURRENT) + s = "current"; +- else if (analog->mq == SR_MQ_FREQUENCY) ++ else if (meaning->mq == SR_MQ_FREQUENCY) + s = "frequency"; +- else if (analog->mq == SR_MQ_POWER) ++ else if (meaning->mq == SR_MQ_POWER) + s = "power"; +- else if (analog->mq == SR_MQ_TEMPERATURE) ++ else if (meaning->mq == SR_MQ_TEMPERATURE) + s = "temperature"; +- else if (analog->mq == SR_MQ_RELATIVE_HUMIDITY) ++ else if (meaning->mq == SR_MQ_RELATIVE_HUMIDITY) + s = "humidity"; +- else if (analog->mq == SR_MQ_SOUND_PRESSURE_LEVEL) ++ else if (meaning->mq == SR_MQ_SOUND_PRESSURE_LEVEL) + s = "spl"; + else + s = "gauge"; +@@ -172,7 +172,7 @@ static void sigrok_feed_callback(const struct sr_dev_inst *sdi, + ERROR("sigrok plugin: Received data from driver \"%s\" but " + "can't find a configuration / device matching " + "it.", +- sdi->driver->name); ++ sr_dev_inst_driver_get(sdi)->name); + return; + } + +@@ -191,11 +191,11 @@ static void sigrok_feed_callback(const struct sr_dev_inst *sdi, + + /* Ignore all but the first sample on the first probe. */ + analog = packet->payload; +- vl.values = &(value_t){.gauge = analog->data[0]}; ++ vl.values = &(value_t){.gauge = ((float *) analog->data)[0]}; + vl.values_len = 1; + sstrncpy(vl.plugin, "sigrok", sizeof(vl.plugin)); + sstrncpy(vl.plugin_instance, cfdev->name, sizeof(vl.plugin_instance)); +- sstrncpy(vl.type, sigrok_value_type(analog), sizeof(vl.type)); ++ sstrncpy(vl.type, sigrok_value_type(&analog->meaning[0]), sizeof(vl.type)); + + plugin_dispatch_values(&vl); + cfdev->last_dispatch = cdtime(); +@@ -207,6 +207,7 @@ static void sigrok_free_drvopts(struct sr_config *src) { + } + + static int sigrok_init_driver(struct config_device *cfdev, ++ struct sr_session *session, + struct sr_dev_driver *drv) { + struct sr_config *src; + GSList *devlist, *drvopts; +@@ -248,21 +249,22 @@ static int sigrok_init_driver(struct config_device *cfdev, + cfdev->sdi = devlist->data; + g_slist_free(devlist); + ssnprintf(hwident, sizeof(hwident), "%s %s %s", +- cfdev->sdi->vendor ? cfdev->sdi->vendor : "", +- cfdev->sdi->model ? cfdev->sdi->model : "", +- cfdev->sdi->version ? cfdev->sdi->version : ""); ++ sr_dev_inst_vendor_get(cfdev->sdi), ++ sr_dev_inst_model_get(cfdev->sdi), ++ sr_dev_inst_version_get(cfdev->sdi)); + INFO("sigrok plugin: Device \"%s\" is a %s", cfdev->name, hwident); + + if (sr_dev_open(cfdev->sdi) != SR_OK) + return -1; + +- if (sr_session_dev_add(cfdev->sdi) != SR_OK) ++ if (sr_session_dev_add(session, cfdev->sdi) != SR_OK) + return -1; + + return 1; + } + + static void *sigrok_read_thread(void *arg __attribute__((unused))) { ++ struct sr_session *session; + struct sr_dev_driver *drv, **drvlist; + GSList *l; + struct config_device *cfdev; +@@ -277,11 +279,11 @@ static void *sigrok_read_thread(void *arg __attribute__((unused))) { + return NULL; + } + +- if (!sr_session_new()) ++ if (!sr_session_new(sr_ctx, &session)) + return NULL; + + num_devices = 0; +- drvlist = sr_driver_list(); ++ drvlist = sr_driver_list(sr_ctx); + for (l = config_devices; l; l = l->next) { + cfdev = l->data; + drv = NULL; +@@ -296,7 +298,7 @@ static void *sigrok_read_thread(void *arg __attribute__((unused))) { + return NULL; + } + +- if ((ret = sigrok_init_driver(cfdev, drv)) < 0) ++ if ((ret = sigrok_init_driver(cfdev, session, drv)) < 0) + /* Error was already logged. */ + return NULL; + +@@ -305,21 +307,22 @@ static void *sigrok_read_thread(void *arg __attribute__((unused))) { + + if (num_devices > 0) { + /* Do this only when we're sure there's hardware to talk to. */ +- if (sr_session_datafeed_callback_add(sigrok_feed_callback, NULL) != SR_OK) ++ if (sr_session_datafeed_callback_add(session, sigrok_feed_callback, ++ NULL) != SR_OK) + return NULL; + + /* Start acquisition on all devices. */ +- if (sr_session_start() != SR_OK) ++ if (sr_session_start(session) != SR_OK) + return NULL; + + /* Main loop, runs forever. */ +- sr_session_run(); ++ sr_session_run(session); + +- sr_session_stop(); +- sr_session_dev_remove_all(); ++ sr_session_stop(session); ++ sr_session_dev_remove_all(session); + } + +- sr_session_destroy(); ++ sr_session_destroy(session); + + sr_exit(sr_ctx); + diff --git a/collectd.changes b/collectd.changes index 89b6687..d655179 100644 --- a/collectd.changes +++ b/collectd.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Fri Sep 8 15:28:48 UTC 2017 - stefan.bruens@rwth-aachen.de + +- Sort list of plugins bundled in main package, add line breaks +- Add BuildRequires for libsigrok and create a sigrok plugin + subpackage +- Add 9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch + Apply patch conditionally for libsigrok >= 0.4.0, the API + is different from the libsigrok 0.3.0 API. + ------------------------------------------------------------------- Tue Jun 27 11:18:06 UTC 2017 - tchvatal@suse.com diff --git a/collectd.spec b/collectd.spec index a3ebc21..b1a35c4 100644 --- a/collectd.spec +++ b/collectd.spec @@ -17,7 +17,23 @@ # -%define plugins apache apcups battery bind cgroups chrony curl curl_json curl_xml conntrack contextswitch cpu cpufreq cpusleep csv df disk dns email entropy exec filecount fscache hddtemp hugepages interface ipvs irq load logfile match_empty_counter match_hashed match_regex match_timediff match_value mbmon memcached memory multimeter netlink network nfs nginx notify_nagios ntpd olsrd openvpn perl ping protocols powerdns processes rrdtool %{expand:%{sensors_plugin}} serial statsd swap syslog table tail target_notification target_replace target_scale target_set target_v5upgrade tcpconns teamspeak2 ted thermal threshold unixsock uptime users uuid vmem vserver wireless write_http ascent iptables madwifi rrdcached aggregation ethstat md numa tail_csv write_graphite ceph drbd fhcount ipc log_logstash write_log write_sensu write_tsdb write_prometheus zfs_arc zookeeper +%define plugins apache apcups aggregation ascent battery bind \\\ + ceph cgroups chrony curl curl_json curl_xml conntrack contextswitch cpu cpufreq cpusleep csv \\\ + df disk dns drbd \\\ + email entropy ethstat exec fhcount filecount fscache hddtemp hugepages \\\ + interface ipc iptables ipvs irq \\\ + load logfile log_logstash \\\ + madwifi match_empty_counter match_hashed match_regex match_timediff match_value \\\ + mbmon md memcached memory multimeter \\\ + netlink network nfs nginx notify_nagios ntpd numa olsrd openvpn \\\ + perl ping protocols powerdns processes \\\ + rrdcached rrdtool %{expand:%{sensors_plugin}} serial statsd swap syslog \\\ + table tail tail_csv target_notification target_replace target_scale target_set target_v5upgrade \\\ + tcpconns teamspeak2 ted thermal threshold \\\ + unixsock uptime users uuid vmem vserver \\\ + wireless write_graphite write_http write_log write_sensu write_tsdb write_prometheus \\\ + zfs_arc zookeeper + %ifnarch s390 s390x %define sensors 1 %define sensors_plugin sensors @@ -47,6 +63,7 @@ Patch19: collectd-fix_spamassassin_doc.patch Patch20: collectd-split_README.patch Patch21: collectd-fix_collectd_config_path_in_snmp_probe.patch Patch23: collectd-javac_target.patch +Patch24: 9e36cd85a2bb_sigrok_Update_to_support_libsigrok_0_4.patch # for /etc/apache2/... ownership (rpmlint): BuildRequires: apache2 BuildRequires: autoconf @@ -99,6 +116,7 @@ BuildRequires: pkgconfig(libmnl) BuildRequires: pkgconfig(libnotify) BuildRequires: pkgconfig(liboping) BuildRequires: pkgconfig(librrd) +BuildRequires: pkgconfig(libsigrok) BuildRequires: pkgconfig(libstatgrab) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(libupsclient) @@ -289,6 +307,15 @@ Requires: %{name} = %{version}-%{release} Optional %{name} plugin to receive and dispatch timing values from Pinba, a profiling extension for PHP. +%package plugin-sigrok +Summary: Sigrok Monitoring Plugin for %{name} +Group: System/Monitoring +Requires: %{name} = %{version}-%{release} + +%description plugin-sigrok +Optional %{name} plugin to collect measurements from +various devices supported by libsigrok. + %package plugin-smart Summary: SMART Monitoring Plugin for %{name} Group: System/Monitoring @@ -332,6 +359,7 @@ Requires: %{name}-plugin-openldap = %{version}-%{release} Requires: %{name}-plugin-pinba = %{version}-%{release} Requires: %{name}-plugin-postgresql = %{version}-%{release} Requires: %{name}-plugin-python3 = %{version}-%{release} +Requires: %{name}-plugin-sigrok = %{version}-%{release} Requires: %{name}-plugin-smart = %{version}-%{release} Requires: %{name}-plugin-snmp = %{version}-%{release} Requires: %{name}-plugin-virt = %{version}-%{release} @@ -386,6 +414,9 @@ to write %{name} unixsock clients. %patch20 %patch21 %patch23 -p1 +%if 0%{?suse_version} > 1320 +%patch24 -p1 +%endif sed -i 's|@@VERSION@@|%{version}|g' configure.ac @@ -643,6 +674,10 @@ ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name} %{_libdir}/collectd/memcachec.so %{_libdir}/collectd/memcachec.la +%files plugin-sigrok +%{_libdir}/collectd/sigrok.so +%{_libdir}/collectd/sigrok.la + %files plugin-smart %{_libdir}/collectd/smart.so %{_libdir}/collectd/smart.la