fi
fi
-# --with-libpthread {{{
-AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
-[ if test "x$withval" != "xno" \
- && test "x$withval" != "xyes"
- then
- LDFLAGS="$LDFLAGS -L$withval/lib"
- CPPFLAGS="$CPPFLAGS -I$withval/include"
- with_libpthread="yes"
- else
- if test "x$withval" = "xno"
- then
- with_libpthread="no (disabled)"
- fi
- fi
-], [with_libpthread="yes"])
+SAVE_LIBS="$LIBS"
+AC_CHECK_LIB([pthread],
+ [pthread_create],
+ [],
+ [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread"])],
+ []
+)
+PTHREAD_LIBS="$LIBS"
+LIBS="$SAVE_LIBS"
+AC_CHECK_HEADERS([pthread.h],
+ [],
+ [AC_MSG_ERROR([pthread.h not found])]
+)
AC_SUBST([PTHREAD_LIBS])
-if test "x$with_libpthread" = "xyes"
-then
- SAVE_LIBS="$LIBS"
- AC_CHECK_LIB(pthread, pthread_create, [], [with_libpthread="no (Symbol 'pthread_create' not found)"], [])
- PTHREAD_LIBS="$LIBS"
- LIBS="$SAVE_LIBS"
-fi
-
-if test "x$with_libpthread" = "xyes"
-then
- AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
-fi
-if test "x$with_libpthread" = "xyes"
-then
- collect_pthread=1
-else
- collect_pthread=0
-fi
-AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
- [Wether or not to use pthread (POSIX threads) library])
-AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
-# }}}
m4_divert_once([HELP_WITH], [
collectd additional packages:])
AC_DEFINE(HAVE_CURLOPT_TIMEOUT_MS, 1, [Define if libcurl supports CURLOPT_TIMEOUT_MS option.])
fi
fi
-AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
# }}}
# --with-libdbi {{{
fi
if test "x$with_oracle" = "xyes"
then
- BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
+ BUILD_WITH_ORACLE_CPPFLAGS="$with_oracle_cppflags"
BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
- AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
+ AC_SUBST(BUILD_WITH_ORACLE_CPPFLAGS)
AC_SUBST(BUILD_WITH_ORACLE_LIBS)
fi
# }}}
CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
+ LIBXENCTL_CPPFLAGS="$with_libxenctl_cppflags"
+ LIBXENCTL_LDFLAGS="$with_libxenctl_ldflags"
+ AC_SUBST(LIBXENCTL_CPPFLAGS)
+ AC_SUBST(LIBXENCTL_LDFLAGS)
fi
# --with-libxmms {{{
AC_PLUGIN([bind], [$plugin_bind], [ISC Bind nameserver statistics])
AC_PLUGIN([ceph], [$plugin_ceph], [Ceph daemon statistics])
AC_PLUGIN([cgroups], [$plugin_cgroups], [CGroups CPU usage accounting])
+AC_PLUGIN([chrony], [yes], [Chrony statistics])
AC_PLUGIN([conntrack], [$plugin_conntrack], [nf_conntrack statistics])
AC_PLUGIN([contextswitch], [$plugin_contextswitch], [context switch statistics])
AC_PLUGIN([cpu], [$plugin_cpu], [CPU usage statistics])
libperfstat . . . . . $with_perfstat
libperl . . . . . . . $with_libperl
libpq . . . . . . . . $with_libpq
- libpthread . . . . . $with_libpthread
librabbitmq . . . . . $with_librabbitmq
libriemann-client . . $with_libriemann_client
librdkafka . . . . . $with_librdkafka
bind . . . . . . . . $enable_bind
ceph . . . . . . . . $enable_ceph
cgroups . . . . . . . $enable_cgroups
+ chrony. . . . . . . . $enable_chrony
conntrack . . . . . . $enable_conntrack
contextswitch . . . . $enable_contextswitch
cpu . . . . . . . . . $enable_cpu
%global _hardened_build 1
%{?perl_default_filter}
-# plugins only buildable on RHEL6
-# (NB: %{elN} macro is not available on RHEL < 6)
-%{?el6:%global _has_libyajl 1}
-%{?el6:%global _has_recent_libpcap 1}
-%{?el6:%global _has_recent_sockios_h 1}
-%{?el6:%global _has_recent_libganglia 1}
-%{?el6:%global _has_working_libiptc 1}
-%{?el6:%global _has_ip_vs_h 1}
-%{?el6:%global _has_lvm2app_h 1}
-%{?el6:%global _has_libmodbus 1}
-%{?el6:%global _has_libudev 1}
-%{?el6:%global _has_iproute 1}
-%{?el6:%global _has_atasmart 1}
-%{?el6:%global _has_hiredis 1}
-%{?el6:%global _has_asm_msr_index 1}
-
-%{?el7:%global _has_libyajl 1}
-%{?el7:%global _has_recent_libpcap 1}
-%{?el7:%global _has_recent_sockios_h 1}
-%{?el7:%global _has_working_libiptc 1}
-%{?el7:%global _has_ip_vs_h 1}
-%{?el7:%global _has_lvm2app_h 1}
-%{?el7:%global _has_libudev 1}
-%{?el7:%global _has_recent_librrd 1}
-%{?el7:%global _has_iproute 1}
-%{?el7:%global _has_atasmart 1}
-%{?el7:%global _has_hiredis 1}
-%{?el7:%global _has_asm_msr_index 1}
-%{?el7:%global _has_libmosquitto 1}
-%{?el7:%global _has_libmodbus 1}
-%{?el7:%global _has_xmms 1}
-
# plugins enabled by default
%define with_aggregation 0%{!?_without_aggregation:1}
%define with_amqp 0%{!?_without_amqp:1}
%define with_ascent 0%{!?_without_ascent:1}
%define with_battery 0%{!?_without_battery:1}
%define with_bind 0%{!?_without_bind:1}
-%define with_ceph 0%{!?_without_ceph:0%{?_has_libyajl}}
+%define with_ceph 0%{!?_without_ceph:1}
%define with_cgroups 0%{!?_without_cgroups:1}
+%define with_chrony 0%{!?_without_chrony:1}
%define with_conntrack 0%{!?_without_conntrack:1}
%define with_contextswitch 0%{!?_without_contextswitch:1}
%define with_cpu 0%{!?_without_cpu:1}
%define with_cpufreq 0%{!?_without_cpufreq:1}
%define with_csv 0%{!?_without_csv:1}
%define with_curl 0%{!?_without_curl:1}
-%define with_curl_json 0%{!?_without_curl_json:0%{?_has_libyajl}}
+%define with_curl_json 0%{!?_without_curl_json:1}
%define with_curl_xml 0%{!?_without_curl_xml:1}
%define with_dbi 0%{!?_without_dbi:1}
%define with_df 0%{!?_without_df:1}
%define with_disk 0%{!?_without_disk:1}
-%define with_dns 0%{!?_without_dns:0%{?_has_recent_libpcap}}
+%define with_dns 0%{!?_without_dns:1}
%define with_drbd 0%{!?_without_drbd:1}
%define with_email 0%{!?_without_email:1}
%define with_entropy 0%{!?_without_entropy:1}
-%define with_ethstat 0%{!?_without_ethstat:0%{?_has_recent_sockios_h}}
+%define with_ethstat 0%{!?_without_ethstat:1}
%define with_exec 0%{!?_without_exec:1}
%define with_fhcount 0%{!?_without_fhcount:1}
%define with_filecount 0%{!?_without_filecount:1}
%define with_fscache 0%{!?_without_fscache:1}
-%define with_gmond 0%{!?_without_gmond:0%{?_has_recent_libganglia}}
+%define with_gmond 0%{!?_without_gmond:1}
%define with_hddtemp 0%{!?_without_hddtemp:1}
%define with_interface 0%{!?_without_interface:1}
%define with_ipc 0%{!?_without_ipc:1}
%define with_ipmi 0%{!?_without_ipmi:1}
-%define with_iptables 0%{!?_without_iptables:0%{?_has_working_libiptc}}
-%define with_ipvs 0%{!?_without_ipvs:0%{?_has_ip_vs_h}}
+%define with_iptables 0%{!?_without_iptables:1}
+%define with_ipvs 0%{!?_without_ipvs:1}
%define with_irq 0%{!?_without_irq:1}
%define with_java 0%{!?_without_java:1}
-%define with_virt 0%{!?_without_virt:1}
%define with_load 0%{!?_without_load:1}
+%define with_log_logstash 0%{!?_without_log_logstash:1}
%define with_logfile 0%{!?_without_logfile:1}
-%define with_log_logstash 0%{!?_without_log_logstash:0%{?_has_libyajl}}
-%define with_lvm 0%{!?_without_lvm:0%{?_has_lvm2app_h}}
+%define with_lvm 0%{!?_without_lvm:1}
%define with_madwifi 0%{!?_without_madwifi:1}
%define with_mbmon 0%{!?_without_mbmon:1}
%define with_md 0%{!?_without_md:1}
%define with_memcachec 0%{!?_without_memcachec:1}
%define with_memcached 0%{!?_without_memcached:1}
%define with_memory 0%{!?_without_memory:1}
+%define with_modbus 0%{!?_without_modbus:1}
+%define with_mqtt 0%{!?_without_mqtt:1}
%define with_multimeter 0%{!?_without_multimeter:1}
-%define with_modbus 0%{!?_without_modbus:0%{?_has_libmodbus}}
-%define with_mqtt 0%{!?_without_mqtt:0%{?_has_libmosquitto}}
%define with_mysql 0%{!?_without_mysql:1}
-%define with_netlink 0%{!?_without_netlink:0%{?_has_iproute}}
+%define with_netlink 0%{!?_without_netlink:1}
%define with_network 0%{!?_without_network:1}
%define with_nfs 0%{!?_without_nfs:1}
%define with_nginx 0%{!?_without_nginx:1}
%define with_processes 0%{!?_without_processes:1}
%define with_protocols 0%{!?_without_protocols:1}
%define with_python 0%{!?_without_python:1}
-%define with_redis 0%{!?_without_redis:0%{?_has_hiredis}}
-%define with_rrdcached 0%{!?_without_rrdcached:0%{?_has_recent_librrd}}
+%define with_redis 0%{!?_without_redis:1}
+%define with_rrdcached 0%{!?_without_rrdcached:1}
%define with_rrdtool 0%{!?_without_rrdtool:1}
%define with_sensors 0%{!?_without_sensors:1}
%define with_serial 0%{!?_without_serial:1}
-%define with_smart 0%{!?_without_smart:0%{?_has_atasmart}}
+%define with_smart 0%{!?_without_smart:1}
%define with_snmp 0%{!?_without_snmp:1}
%define with_statsd 0%{!?_without_statsd:1}
%define with_swap 0%{!?_without_swap:1}
%define with_ted 0%{!?_without_ted:1}
%define with_thermal 0%{!?_without_thermal:1}
%define with_threshold 0%{!?_without_threshold:1}
-%define with_turbostat 0%{!?_without_turbostat:0%{?_has_asm_msr_index}}
+%define with_turbostat 0%{!?_without_turbostat:1}
%define with_unixsock 0%{!?_without_unixsock:1}
%define with_uptime 0%{!?_without_uptime:1}
%define with_users 0%{!?_without_users:1}
%define with_uuid 0%{!?_without_uuid:1}
%define with_varnish 0%{!?_without_varnish:1}
+%define with_virt 0%{!?_without_virt:1}
%define with_vmem 0%{!?_without_vmem:1}
%define with_vserver 0%{!?_without_vserver:1}
%define with_wireless 0%{!?_without_wireless:1}
%define with_write_graphite 0%{!?_without_write_graphite:1}
%define with_write_http 0%{!?_without_write_http:1}
%define with_write_log 0%{!?_without_write_log:1}
-%define with_write_redis 0%{!?_without_write_redis:0%{?_has_hiredis}}
-%define with_write_riemann 0%{!?_without_write_riemann:0%{?_has_recent_riemann_c_client}}
+%define with_write_redis 0%{!?_without_write_redis:1}
%define with_write_sensu 0%{!?_without_write_sensu:1}
%define with_write_tsdb 0%{!?_without_write_tsdb:1}
%define with_xmms 0%{!?_without_xmms:0%{?_has_xmms}}
%define with_write_kafka 0%{!?_without_write_kafka:0}
# plugin write_mongodb disabled, requires libmongoc
%define with_write_mongodb 0%{!?_without_write_mongodb:0}
+# plugin write_riemann disabled, requires a new enough riemann_c_client
+%define with_write_riemann 0%{!?_without_write_riemann:0}
# plugin xencpu disabled, requires xen-devel from non-default repo
%define with_xencpu 0%{!?_without_xencpu:0}
# plugin zone disabled, requires Solaris
%define with_zone 0%{!?_without_zone:0}
-Summary: statistics collection and monitoring daemon
+# Plugins not buildable on RHEL < 6
+%if 0%{?rhel} && 0%{?rhel} < 6
+%define with_ceph 0
+%define with_curl_json 0
+%define with_log_logstash 0
+%define with_dns 0
+%define with_ethstat 0
+%define with_gmond 0
+%define with_iptables 0
+%define with_ipvs 0
+%define with_lvm 0
+%define with_modbus 0
+%define with_netlink 0
+%define with_redis 0
+%define with_smart 0
+%define with_turbostat 0
+%define with_write_redis 0
+%endif
+
+# Plugins not buildable on RHEL < 7
+%if 0%{?rhel} && 0%{?rhel} < 7
+%define with_mqtt 0
+%define with_rrdcached 0
+%define with_xmms 0
+%endif
+
+Summary: Statistics collection and monitoring daemon
Name: collectd
Version: 5.5.1
Release: 1%{?dist}
BuildRequires: libgcrypt-devel, kernel-headers, libtool-ltdl-devel, libcap-devel
Vendor: collectd development team <collectd@verplant.org>
-%if 0%{?el7:1}
-Requires(pre): initscripts
-Requires(post): systemd
-Requires(preun): systemd
-Requires(postun): systemd
+%if 0%{?fedora} || 0%{?rhel} >= 7
+%{?systemd_requires}
+BuildRequires: systemd
%else
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Ceph plugin for collectd
%endif
+%if %{with_chrony}
+%package chrony
+Summary: Chrony plugin for collectd
+Group: System Environment/Daemons
+Requires: %{name}%{?_isa} = %{version}-%{release}
+%description chrony
+Chrony plugin for collectd
+%endif
+
%if %{with_curl}
%package curl
Summary: Curl plugin for collectd
Group: System Environment/Daemons
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
- %if 0%{?rhel} >= 6
-BuildRequires: perl-ExtUtils-Embed
- %else
+ %if 0%{?rhel} && 0%{?rhel} < 6
BuildRequires: perl
+ %else
+BuildRequires: perl-ExtUtils-Embed
%endif
%description perl
The Perl plugin embeds a Perl interpreter into collectd and exposes the
Summary: Python plugin for collectd
Group: System Environment/Daemons
Requires: %{name}%{?_isa} = %{version}-%{release}
- %if 0%{?rhel} >= 6
-BuildRequires: python-devel
- %else
+ %if 0%{?rhel} && 0%{?rhel} < 6
BuildRequires: python26-devel
+ %else
+BuildRequires: python-devel
%endif
%description python
The Python plugin embeds a Python interpreter into collectd and exposes the
%define _with_cgroups --disable-cgroups
%endif
+%if %{with_chrony}
+%define _with_chrony --enable-chrony
+%else
+%define _with_chrony --disable-chrony
+%endif
+
%if %{with_conntrack}
%define _with_conntrack --enable-conntrack
%else
%endif
%if %{with_python}
- %if 0%{?rhel} >= 6
-%define _with_python --enable-python
- %else
+ %if 0%{?rhel} && 0%{?rhel} < 6
%define _with_python --enable-python --with-python=%{_bindir}/python2.6
+ %else
+%define _with_python --enable-python
%endif
%else
%define _with_python --disable-python
%{?_with_bind} \
%{?_with_ceph} \
%{?_with_cgroups} \
+ %{?_with_chrony} \
%{?_with_conntrack} \
%{?_with_contextswitch} \
- %{?_with_cpu} \
%{?_with_cpufreq} \
+ %{?_with_cpu} \
%{?_with_csv} \
- %{?_with_curl} \
%{?_with_curl_json} \
%{?_with_curl_xml} \
+ %{?_with_curl} \
%{?_with_dbi} \
%{?_with_df} \
%{?_with_disk} \
%{?_with_ipmi} \
%{?_with_iptables} \
%{?_with_ipvs} \
+ %{?_with_irq} \
%{?_with_java} \
- %{?_with_virt} \
+ %{?_with_load} \
%{?_with_log_logstash} \
+ %{?_with_logfile} \
%{?_with_lpar} \
%{?_with_lvm} \
+ %{?_with_madwifi} \
+ %{?_with_mbmon} \
+ %{?_with_md} \
%{?_with_memcachec} \
+ %{?_with_memcached} \
+ %{?_with_memory} \
%{?_with_mic} \
%{?_with_modbus} \
- %{?_with_multimeter} \
%{?_with_mqtt} \
+ %{?_with_multimeter} \
%{?_with_mysql} \
%{?_with_netapp} \
%{?_with_netlink} \
+ %{?_with_network} \
+ %{?_with_nfs} \
%{?_with_nginx} \
%{?_with_notify_desktop} \
%{?_with_notify_email} \
+ %{?_with_notify_nagios} \
+ %{?_with_ntpd} \
+ %{?_with_numa} \
%{?_with_nut} \
+ %{?_with_olsrd} \
%{?_with_onewire} \
%{?_with_openldap} \
+ %{?_with_openvpn} \
%{?_with_oracle} \
%{?_with_perl} \
%{?_with_pf} \
%{?_with_pinba} \
%{?_with_ping} \
%{?_with_postgresql} \
+ %{?_with_powerdns} \
+ %{?_with_processes} \
+ %{?_with_protocols} \
%{?_with_python} \
%{?_with_redis} \
%{?_with_routeros} \
%{?_with_rrdcached} \
%{?_with_rrdtool} \
%{?_with_sensors} \
+ %{?_with_serial} \
%{?_with_sigrok} \
%{?_with_smart} \
%{?_with_snmp} \
- %{?_with_tape} \
- %{?_with_tokyotyrant} \
- %{?_with_varnish} \
- %{?_with_write_http} \
- %{?_with_write_kafka} \
- %{?_with_write_mongodb} \
- %{?_with_write_redis} \
- %{?_with_xencpu} \
- %{?_with_xmms} \
- %{?_with_zfs_arc} \
- %{?_with_zone} \
- %{?_with_zookeeper} \
- %{?_with_irq} \
- %{?_with_load} \
- %{?_with_logfile} \
- %{?_with_madwifi} \
- %{?_with_mbmon} \
- %{?_with_md} \
- %{?_with_memcached} \
- %{?_with_memory} \
- %{?_with_network} \
- %{?_with_nfs} \
- %{?_with_notify_nagios} \
- %{?_with_ntpd} \
- %{?_with_numa} \
- %{?_with_olsrd} \
- %{?_with_openvpn} \
- %{?_with_powerdns} \
- %{?_with_processes} \
- %{?_with_protocols} \
- %{?_with_serial} \
%{?_with_statsd} \
%{?_with_swap} \
%{?_with_syslog} \
%{?_with_table} \
- %{?_with_tail} \
%{?_with_tail_csv} \
+ %{?_with_tail} \
+ %{?_with_tape} \
%{?_with_tcpconns} \
%{?_with_teamspeak2} \
%{?_with_ted} \
%{?_with_thermal} \
%{?_with_threshold} \
+ %{?_with_tokyotyrant} \
%{?_with_turbostat} \
%{?_with_unixsock} \
%{?_with_uptime} \
%{?_with_users} \
%{?_with_uuid} \
+ %{?_with_varnish} \
+ %{?_with_virt} \
%{?_with_vmem} \
%{?_with_vserver} \
%{?_with_wireless}\
%{?_with_write_graphite} \
%{?_with_write_http} \
+ %{?_with_write_http} \
+ %{?_with_write_kafka} \
%{?_with_write_log} \
+ %{?_with_write_mongodb} \
+ %{?_with_write_redis} \
%{?_with_write_riemann} \
%{?_with_write_sensu} \
- %{?_with_write_tsdb}
+ %{?_with_write_tsdb} \
+ %{?_with_xencpu} \
+ %{?_with_xmms} \
+ %{?_with_zfs_arc} \
+ %{?_with_zone} \
+ %{?_with_zookeeper}
%{__make} %{?_smp_mflags}
%install
rm -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot}
-%if 0%{?el7:1}
+%if 0%{?fedora} || 0%{?rhel} >= 7
%{__install} -Dp -m0644 contrib/systemd.collectd.service %{buildroot}%{_unitdir}/collectd.service
%else
%{__install} -Dp -m0755 contrib/redhat/init.d-collectd %{buildroot}%{_initrddir}/collectd
%clean
rm -rf %{buildroot}
-%pre
-%if 0%{?el7:1}
-# stop sysv-based instance before upgrading to systemd
-if [ $1 -eq 2 ] && [ -f /var/lock/subsys/collectd ]; then
- SYSTEMCTL_SKIP_REDIRECT=1 %{_initddir}/collectd stop >/dev/null 2>&1 || :
-fi
-%endif
-
%post
-%if 0%{?el7:1}
-if [ $1 -eq 2 ]; then
- /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-fi
+%if 0%{?fedora} || 0%{?rhel} >= 7
%systemd_post collectd.service
%else
/sbin/chkconfig --add collectd || :
%endif
%preun
-%if 0%{?el7:1}
+%if 0%{?fedora} || 0%{?rhel} >= 7
%systemd_preun collectd.service
%else
# stop collectd only when uninstalling
%endif
%postun
-%if 0%{?el7:1}
+%if 0%{?fedora} || 0%{?rhel} >= 7
%systemd_postun_with_restart collectd.service
%else
# restart collectd only when upgrading
%files
%doc AUTHORS COPYING ChangeLog README
%config(noreplace) %{_sysconfdir}/collectd.conf
-%if 0%{?el7:1}
+%if 0%{?fedora} || 0%{?rhel} >= 7
%{_unitdir}/collectd.service
%else
%{_initrddir}/collectd
%{_libdir}/%{name}/ceph.so
%endif
+%if %{with_chrony}
+%files chrony
+%{_libdir}/%{name}/chrony.so
+%endif
+
%if %{with_curl}
%files curl
%{_libdir}/%{name}/curl.so
%doc contrib/
%changelog
-#* TODO: next feature release changelog
-#- New upstream version
-#- New plugins enabled by default: mqtt, notify_nagios
-#- New plugins disabled by default: zone, xencpu
-#
+* Sat Jun 04 2016 Ruben Kerkhof <ruben@rubenkerkhof.com> 5.5.1-1
+- New upstream version
+- New plugins enabled by default: chrony, mqtt, notify_nagios
+- New plugins disabled by default: zone, xencpu
+
* Wed May 27 2015 Marc Fournier <marc.fournier@camptocamp.com> 5.5.0-1
- New upstream version
- New plugins enabled by default: ceph, drbd, log_logstash, write_tsdb, smart,
bin_PROGRAMS = collectd-nagios collectdctl collectd-tg
collectdmon_SOURCES = collectdmon.c
-collectdmon_CPPFLAGS = $(AM_CPPFLAGS)
collectd_nagios_SOURCES = collectd-nagios.c
-collectd_nagios_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src/libcollectdclient/collectd -I$(top_builddir)/src/libcollectdclient/collectd
-collectd_nagios_LDADD =
+collectd_nagios_CPPFLAGS = $(AM_CPPFLAGS) \
+ -I$(top_srcdir)/src/libcollectdclient/collectd \
+ -I$(top_builddir)/src/libcollectdclient/collectd
+collectd_nagios_LDADD = libcollectdclient/libcollectdclient.la
if BUILD_WITH_LIBSOCKET
collectd_nagios_LDADD += -lsocket
endif
collectd_nagios_LDADD += -lm
endif
-collectd_nagios_LDADD += libcollectdclient/libcollectdclient.la
-collectd_nagios_DEPENDENCIES = libcollectdclient/libcollectdclient.la
-
collectdctl_SOURCES = collectdctl.c
-collectdctl_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src/libcollectdclient/collectd -I$(top_builddir)/src/libcollectdclient/collectd
-collectdctl_LDADD =
+collectdctl_CPPFLAGS = $(AM_CPPFLAGS) \
+ -I$(top_srcdir)/src/libcollectdclient/collectd \
+ -I$(top_builddir)/src/libcollectdclient/collectd
+collectdctl_LDADD = libcollectdclient/libcollectdclient.la
if BUILD_WITH_LIBSOCKET
collectdctl_LDADD += -lsocket
endif
if BUILD_AIX
collectdctl_LDADD += -lm
endif
-collectdctl_LDADD += libcollectdclient/libcollectdclient.la
-collectdctl_DEPENDENCIES = libcollectdclient/libcollectdclient.la
+
collectd_tg_SOURCES = collectd-tg.c
collectd_tg_CPPFLAGS = $(AM_CPPFLAGS) \
- -I$(top_srcdir)/src/libcollectdclient/collectd -I$(top_builddir)/src/libcollectdclient/collectd
-collectd_tg_LDADD = daemon/libheap.la
+ -I$(top_srcdir)/src/libcollectdclient/collectd \
+ -I$(top_builddir)/src/libcollectdclient/collectd
+collectd_tg_LDADD = \
+ $(PTHREAD_LIBS) \
+ daemon/libheap.la \
+ libcollectdclient/libcollectdclient.la
if BUILD_WITH_LIBSOCKET
collectd_tg_LDADD += -lsocket
endif
if BUILD_AIX
collectd_tg_LDADD += -lm
endif
-if BUILD_WITH_LIBPTHREAD
-collectd_tg_LDADD += $(PTHREAD_LIBS)
-endif
-collectd_tg_LDADD += libcollectdclient/libcollectdclient.la
-collectd_tg_DEPENDENCIES = libcollectdclient/libcollectdclient.la
pkglib_LTLIBRARIES =
pkglib_LTLIBRARIES += apache.la
apache_la_SOURCES = apache.c
apache_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-apache_la_CFLAGS = $(AM_CFLAGS)
-apache_la_LIBADD =
-if BUILD_WITH_LIBCURL
-apache_la_CFLAGS += $(BUILD_WITH_LIBCURL_CFLAGS)
-apache_la_LIBADD += $(BUILD_WITH_LIBCURL_LIBS)
-endif
+apache_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+apache_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS)
endif
if BUILD_PLUGIN_APCUPS
if BUILD_PLUGIN_APPLE_SENSORS
pkglib_LTLIBRARIES += apple_sensors.la
apple_sensors_la_SOURCES = apple_sensors.c
-apple_sensors_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-apple_sensors_la_LDFLAGS += -framework IOKit
+apple_sensors_la_LDFLAGS = $(PLUGIN_LDFLAGS) -framework IOKit
endif
if BUILD_PLUGIN_AQUAERO
pkglib_LTLIBRARIES += aquaero.la
aquaero_la_SOURCES = aquaero.c
-aquaero_la_LDFLAGS = $(PLUGIN_LDFLAGS)
aquaero_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBAQUAERO5_CFLAGS)
-aquaero_la_LIBADD = $(BUILD_WITH_LIBAQUAERO5_LDFLAGS) -laquaero5
+aquaero_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
+aquaero_la_LIBADD = -laquaero5
endif
if BUILD_PLUGIN_ASCENT
pkglib_LTLIBRARIES += battery.la
battery_la_SOURCES = battery.c
battery_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-battery_la_LIBADD =
if BUILD_WITH_LIBIOKIT
battery_la_LDFLAGS += -framework IOKit
endif
cgroups_la_LIBADD = libmount.la
endif
+if BUILD_PLUGIN_CHRONY
+pkglib_LTLIBRARIES += chrony.la
+chrony_la_SOURCES = chrony.c
+chrony_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
if BUILD_PLUGIN_CONNTRACK
pkglib_LTLIBRARIES += conntrack.la
conntrack_la_SOURCES = conntrack.c
pkglib_LTLIBRARIES += curl.la
curl_la_SOURCES = curl.c
curl_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-curl_la_CFLAGS = $(AM_CFLAGS)
-curl_la_LIBADD =
-if BUILD_WITH_LIBCURL
-curl_la_CFLAGS += $(BUILD_WITH_LIBCURL_CFLAGS)
-curl_la_LIBADD += $(BUILD_WITH_LIBCURL_LIBS)
-endif
+curl_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+curl_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS)
endif
if BUILD_PLUGIN_CURL_JSON
pkglib_LTLIBRARIES += curl_json.la
curl_json_la_SOURCES = curl_json.c
-curl_json_la_CFLAGS = $(AM_CFLAGS)
-curl_json_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+curl_json_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
curl_json_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
-curl_json_la_LIBADD = $(BUILD_WITH_LIBYAJL_LIBS)
-if BUILD_WITH_LIBCURL
-curl_json_la_CFLAGS += $(BUILD_WITH_LIBCURL_CFLAGS)
-curl_json_la_LIBADD += $(BUILD_WITH_LIBCURL_LIBS)
-endif
+curl_json_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+curl_json_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBYAJL_LIBS)
endif
if BUILD_PLUGIN_CURL_XML
pkglib_LTLIBRARIES += dns.la
dns_la_SOURCES = dns.c utils_dns.c utils_dns.h
dns_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-dns_la_LIBADD = $(PTHREAD_LIBS) -lpcap
+dns_la_LIBADD = -lpcap
endif
if BUILD_PLUGIN_DRBD
pkglib_LTLIBRARIES += email.la
email_la_SOURCES = email.c
email_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-email_la_LIBADD = $(PTHREAD_LIBS)
endif
if BUILD_PLUGIN_ENTROPY
utils_cmd_putval.c utils_cmd_putval.h \
utils_parse_option.h utils_parse_option.c
exec_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-exec_la_LIBADD = $(PTHREAD_LIBS)
endif
if BUILD_PLUGIN_ETHSTAT
if BUILD_PLUGIN_IPC
pkglib_LTLIBRARIES += ipc.la
ipc_la_SOURCES = ipc.c
-ipc_la_CFLAGS = $(AM_CFLAGS)
ipc_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
if BUILD_PLUGIN_IPVS
pkglib_LTLIBRARIES += ipvs.la
ipvs_la_SOURCES = ipvs.c
-if IP_VS_H_NEEDS_KERNEL_CFLAGS
-ipvs_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS)
-else
ipvs_la_CFLAGS = $(AM_CFLAGS)
+if IP_VS_H_NEEDS_KERNEL_CFLAGS
+ipvs_la_CFLAGS += $(KERNEL_CFLAGS)
endif
ipvs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
java_la_CPPFLAGS = $(AM_CPPFLAGS) $(JAVA_CPPFLAGS)
java_la_CFLAGS = $(AM_CFLAGS) $(JAVA_CFLAGS)
java_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(JAVA_LDFLAGS)
-java_la_LIBADD = $(PTHREAD_LIBS) $(JAVA_LIBS)
+java_la_LIBADD = $(JAVA_LIBS)
endif
if BUILD_PLUGIN_LOAD
if BUILD_PLUGIN_LOG_LOGSTASH
pkglib_LTLIBRARIES += log_logstash.la
log_logstash_la_SOURCES = log_logstash.c
-log_logstash_la_CFLAGS = $(AM_CFLAGS)
log_logstash_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
log_logstash_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
log_logstash_la_LIBADD = $(BUILD_WITH_LIBYAJL_LIBS)
if BUILD_PLUGIN_LVM
pkglib_LTLIBRARIES += lvm.la
lvm_la_SOURCES = lvm.c
-lvm_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+lvm_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
+lvm_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBLVM2APP_LDFLAGS)
lvm_la_LIBADD = $(BUILD_WITH_LIBLVM2APP_LIBS)
endif
if BUILD_PLUGIN_MYSQL
pkglib_LTLIBRARIES += mysql.la
mysql_la_SOURCES = mysql.c
+mysql_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMYSQL_CFLAGS)
mysql_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-mysql_la_CFLAGS = $(AM_CFLAGS)
-mysql_la_LIBADD =
-if BUILD_WITH_LIBMYSQL
-mysql_la_CFLAGS += $(BUILD_WITH_LIBMYSQL_CFLAGS)
-mysql_la_LIBADD += $(BUILD_WITH_LIBMYSQL_LIBS)
-endif
+mysql_la_LIBADD = $(BUILD_WITH_LIBMYSQL_LIBS)
endif
if BUILD_PLUGIN_NETAPP
utils_fbhash.c utils_fbhash.h
network_la_CPPFLAGS = $(AM_CPPFLAGS)
network_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-network_la_LIBADD = $(PTHREAD_LIBS)
+network_la_LIBADD =
if BUILD_WITH_LIBSOCKET
network_la_LIBADD += -lsocket
endif
if BUILD_PLUGIN_NGINX
pkglib_LTLIBRARIES += nginx.la
nginx_la_SOURCES = nginx.c
-nginx_la_CFLAGS = $(AM_CFLAGS)
-nginx_la_LIBADD =
+nginx_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
nginx_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-if BUILD_WITH_LIBCURL
-nginx_la_CFLAGS += $(BUILD_WITH_LIBCURL_CFLAGS)
-nginx_la_LIBADD += $(BUILD_WITH_LIBCURL_LIBS)
-endif
+nginx_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS)
endif
if BUILD_PLUGIN_NOTIFY_DESKTOP
pkglib_LTLIBRARIES += notify_email.la
notify_email_la_SOURCES = notify_email.c
notify_email_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-notify_email_la_LIBADD = $(PTHREAD_LIBS) -lesmtp -lssl -lcrypto
+notify_email_la_LIBADD = -lesmtp -lssl -lcrypto
endif
if BUILD_PLUGIN_NOTIFY_NAGIOS
nut_la_SOURCES = nut.c
nut_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
nut_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-nut_la_LIBADD = $(PTHREAD_LIBS) $(BUILD_WITH_LIBUPSCLIENT_LIBS)
+nut_la_LIBADD = $(BUILD_WITH_LIBUPSCLIENT_LIBS)
endif
if BUILD_PLUGIN_OLSRD
if BUILD_PLUGIN_ONEWIRE
pkglib_LTLIBRARIES += onewire.la
onewire_la_SOURCES = onewire.c
-onewire_la_CFLAGS = $(AM_CFLAGS)
onewire_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
onewire_la_LIBADD = $(BUILD_WITH_LIBOWCAPI_LIBS)
onewire_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBOWCAPI_LDFLAGS)
if BUILD_PLUGIN_OPENLDAP
pkglib_LTLIBRARIES += openldap.la
openldap_la_SOURCES = openldap.c
-openldap_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBLDAP_LDFLAGS)
-openldap_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBLDAP_CPPFLAGS)
+openldap_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBLDAP_CPPFLAGS)
+openldap_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBLDAP_LDFLAGS)
openldap_la_LIBADD = -lldap
endif
if BUILD_PLUGIN_OPENVPN
pkglib_LTLIBRARIES += openvpn.la
openvpn_la_SOURCES = openvpn.c
-openvpn_la_CFLAGS = $(AM_CFLAGS)
openvpn_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
pkglib_LTLIBRARIES += oracle.la
oracle_la_SOURCES = oracle.c \
utils_db_query.c utils_db_query.h
-oracle_la_CFLAGS = $(AM_CFLAGS)
-oracle_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_ORACLE_CFLAGS)
+oracle_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_ORACLE_CPPFLAGS)
oracle_la_LIBADD = $(BUILD_WITH_ORACLE_LIBS)
oracle_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
snmp_la_CFLAGS += $(BUILD_WITH_LIBSNMP_CFLAGS)
snmp_la_LIBADD += $(BUILD_WITH_LIBSNMP_LIBS)
endif
-if BUILD_WITH_LIBPTHREAD
-snmp_la_LIBADD += $(PTHREAD_LIBS)
-endif
endif
if BUILD_PLUGIN_STATSD
pkglib_LTLIBRARIES += statsd.la
statsd_la_SOURCES = statsd.c
statsd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-statsd_la_LIBADD = $(PTHREAD_LIBS) liblatency.la -lm
+statsd_la_LIBADD = liblatency.la -lm
endif
if BUILD_PLUGIN_SWAP
utils_cmd_putnotif.h utils_cmd_putnotif.c \
utils_parse_option.h utils_parse_option.c
unixsock_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-unixsock_la_LIBADD = $(PTHREAD_LIBS)
endif
if BUILD_PLUGIN_UPTIME
pkglib_LTLIBRARIES += write_http.la
write_http_la_SOURCES = write_http.c \
utils_format_json.c utils_format_json.h
+write_http_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
write_http_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-write_http_la_CFLAGS = $(AM_CFLAGS)
-write_http_la_LIBADD =
-if BUILD_WITH_LIBCURL
-write_http_la_CFLAGS += $(BUILD_WITH_LIBCURL_CFLAGS)
-write_http_la_LIBADD += $(BUILD_WITH_LIBCURL_LIBS)
-endif
+write_http_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS)
endif
if BUILD_PLUGIN_WRITE_KAFKA
pkglib_LTLIBRARIES += write_redis.la
write_redis_la_SOURCES = write_redis.c
write_redis_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBHIREDIS_LDFLAGS)
-write_redis_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
+write_redis_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
write_redis_la_LIBADD = -lhiredis
endif
if BUILD_PLUGIN_XENCPU
pkglib_LTLIBRARIES += xencpu.la
xencpu_la_SOURCES = xencpu.c
-xencpu_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+xencpu_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXENCTL_CPPFLAGS)
+xencpu_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBXENCTL_LDFLAGS)
xencpu_la_LIBADD = -lxenctrl
endif
if BUILD_PLUGIN_ZFS_ARC
pkglib_LTLIBRARIES += zfs_arc.la
zfs_arc_la_SOURCES = zfs_arc.c
-zfs_arc_la_CFLAGS = $(AM_CFLAGS)
zfs_arc_la_LDFLAGS = $(PLUGIN_LDFLAGS)
if BUILD_FREEBSD
zfs_arc_la_LIBADD = -lm
-else
-if BUILD_LINUX
-# zfs_arc requires no library on linux
-else
-# solaris
-zfs_arc_la_LIBADD = -lkstat
endif
+if BUILD_SOLARIS
+zfs_arc_la_LIBADD = -lkstat
endif
endif
if BUILD_PLUGIN_ZONE
pkglib_LTLIBRARIES += zone.la
zone_la_SOURCES = zone.c
-zone_la_CFLAGS = $(AM_CFLAGS)
zone_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
collectd-unixsock.5 \
types.db.5
-#collectd_1_SOURCES = collectd.pod
-
-EXTRA_DIST = types.db
-
-EXTRA_DIST += collectd.conf.pod \
+EXTRA_DIST = collectd.conf.pod \
collectd-email.pod \
collectd-exec.pod \
collectdctl.pod \
collectd-threshold.pod \
collectd-unixsock.pod \
postgresql_default.conf \
+ types.db \
types.db.pod
.pod.1:
#include "collectd.h"
-#include <pthread.h>
-
#include "plugin.h"
#include "common.h"
#include "configfile.h"
#include "utils_format_json.h"
#include "utils_format_graphite.h"
-#include <pthread.h>
-
#include <amqp.h>
#include <amqp_framing.h>
--- /dev/null
+/* chrony plugin for collectd (monitoring of chrony time server daemon)
+ **********************************************************************
+ * Copyright (C) Claudius M Zingerli, ZSeng, 2015-2016
+ *
+ * Internals roughly based on the ntpd plugin
+ * Some functions copied from chronyd/web (as marked)
+ *
+ * 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 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * TODO:
+ * - More robust udp parsing (using offsets instead of structs?)
+ * -> Currently chrony parses its data the same way as we do (using structs)
+ * - Plausibility checks on values received
+ * -> Done at higher levels
+ */
+
+#include "collectd.h"
+#include "common.h" /* auxiliary functions */
+#include "plugin.h" /* plugin_register_*, plugin_dispatch_values */
+
+#if HAVE_NETDB_H
+# include <netdb.h> /* struct addrinfo */
+#endif
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h> /* ntohs/ntohl */
+#endif
+
+
+#define CONFIG_KEY_HOST "Host"
+#define CONFIG_KEY_PORT "Port"
+#define CONFIG_KEY_TIMEOUT "Timeout"
+
+#define URAND_DEVICE_PATH "/dev/urandom" /* Used to initialize seq nr generator */
+#define RAND_DEVICE_PATH "/dev/random" /* Used to initialize seq nr generator (fall back) */
+
+static const char *g_config_keys[] = {
+ CONFIG_KEY_HOST,
+ CONFIG_KEY_PORT,
+ CONFIG_KEY_TIMEOUT
+};
+
+static int g_config_keys_num = STATIC_ARRAY_SIZE(g_config_keys);
+static int g_chrony_is_connected;
+static int g_chrony_socket = -1;
+static time_t g_chrony_timeout = -1;
+static char *g_chrony_plugin_instance;
+static char *g_chrony_host;
+static char *g_chrony_port;
+static uint32_t g_chrony_rand = 1;
+static uint32_t g_chrony_seq_is_initialized;
+
+#define PLUGIN_NAME_SHORT "chrony"
+#define PLUGIN_NAME PLUGIN_NAME_SHORT " plugin"
+#define DAEMON_NAME PLUGIN_NAME_SHORT
+#define CHRONY_DEFAULT_HOST "localhost"
+#define CHRONY_DEFAULT_PORT "323"
+#define CHRONY_DEFAULT_TIMEOUT 2
+
+/* Return codes (collectd expects non-zero on errors) */
+#define CHRONY_RC_OK 0
+#define CHRONY_RC_FAIL 1
+
+/* Chronyd command packet variables adapted from chrony/candm.h (GPL2) */
+#define PROTO_VERSION_NUMBER 6
+#define IPADDR_UNSPEC 0
+#define IPADDR_INET4 1
+#define IPADDR_INET6 2
+#define IPV6_STR_MAX_SIZE (8*4+7+1)
+
+typedef enum
+{
+ PKT_TYPE_CMD_REQUEST = 1,
+ PKT_TYPE_CMD_REPLY = 2
+} ePacketType;
+
+typedef enum
+{
+ REQ_N_SOURCES = 14,
+ REQ_SOURCE_DATA = 15,
+ REQ_TRACKING = 33,
+ REQ_SOURCE_STATS = 34
+} eDaemonRequests;
+
+
+typedef enum
+{
+ RPY_NULL = 1,
+ RPY_N_SOURCES = 2,
+ RPY_SOURCE_DATA = 3,
+ RPY_MANUAL_TIMESTAMP = 4,
+ RPY_TRACKING = 5,
+ RPY_SOURCE_STATS = 6,
+ RPY_RTC = 7
+} eDaemonReplies;
+
+
+#if defined(__GNUC__)
+# /* GNU gcc extension to enforce struct packing. */
+# define ATTRIB_PACKED __attribute__((packed))
+#else
+# error Not defining packed attribute (unknown compiler)
+# define ATTRIB_PACKED
+#endif
+
+typedef struct ATTRIB_PACKED
+{
+ int32_t value;
+} tFloat;
+
+typedef struct ATTRIB_PACKED
+{
+ uint32_t tv_sec_high;
+ uint32_t tv_sec_low;
+ uint32_t tv_nsec;
+} tTimeval;
+
+typedef enum
+{
+ STT_SUCCESS = 0,
+ STT_FAILED = 1,
+ STT_UNAUTH = 2,
+ STT_INVALID = 3,
+ STT_NOSUCHSOURCE = 4,
+ STT_INVALIDTS = 5,
+ STT_NOTENABLED = 6,
+ STT_BADSUBNET = 7,
+ STT_ACCESSALLOWED = 8,
+ STT_ACCESSDENIED = 9,
+ STT_NOHOSTACCESS = 10,
+ STT_SOURCEALREADYKNOWN = 11,
+ STT_TOOMANYSOURCES = 12,
+ STT_NORTC = 13,
+ STT_BADRTCFILE = 14,
+ STT_INACTIVE = 15,
+ STT_BADSAMPLE = 16,
+ STT_INVALIDAF = 17,
+ STT_BADPKTVERSION = 18,
+ STT_BADPKTLENGTH = 19
+} eChrony_Status;
+
+/* Chrony client request packets */
+typedef struct ATTRIB_PACKED
+{
+ uint8_t f_dummy0[80]; /* Chrony expects 80bytes dummy data (Avoiding UDP Amplification) */
+} tChrony_Req_Tracking;
+
+typedef struct ATTRIB_PACKED
+{
+ uint32_t f_n_sources;
+} tChrony_Req_N_Sources;
+
+typedef struct ATTRIB_PACKED
+{
+ int32_t f_index;
+ uint8_t f_dummy0[44];
+} tChrony_Req_Source_data;
+
+typedef struct ATTRIB_PACKED
+{
+ int32_t f_index;
+ uint8_t f_dummy0[56];
+} tChrony_Req_Source_stats;
+
+typedef struct ATTRIB_PACKED
+{
+ struct
+ {
+ uint8_t f_version;
+ uint8_t f_type;
+ uint8_t f_dummy0;
+ uint8_t f_dummy1;
+ uint16_t f_cmd;
+ uint16_t f_cmd_try;
+ uint32_t f_seq;
+
+ uint32_t f_dummy2;
+ uint32_t f_dummy3;
+ } header; /* Packed: 20Bytes */
+ union
+ {
+ tChrony_Req_N_Sources n_sources;
+ tChrony_Req_Source_data source_data;
+ tChrony_Req_Source_stats source_stats;
+ tChrony_Req_Tracking tracking;
+ } body;
+ uint8_t padding[4 + 16]; /* Padding to match minimal response size */
+} tChrony_Request;
+
+/* Chrony daemon response packets */
+typedef struct ATTRIB_PACKED
+{
+ uint32_t f_n_sources;
+} tChrony_Resp_N_Sources;
+
+typedef struct ATTRIB_PACKED
+{
+ union
+ {
+ uint32_t ip4;
+ uint8_t ip6[16];
+ } addr;
+ uint16_t f_family;
+} tChrony_IPAddr;
+
+typedef struct ATTRIB_PACKED
+{
+ tChrony_IPAddr addr;
+ uint16_t dummy; /* FIXME: Strange dummy space. Needed on gcc 4.8.3/clang 3.4.1 on x86_64 */
+ int16_t f_poll; /* 2^f_poll = Time between polls (s) */
+ uint16_t f_stratum; /* Remote clock stratum */
+ uint16_t f_state; /* 0 = RPY_SD_ST_SYNC, 1 = RPY_SD_ST_UNREACH, 2 = RPY_SD_ST_FALSETICKER */
+ /* 3 = RPY_SD_ST_JITTERY, 4 = RPY_SD_ST_CANDIDATE, 5 = RPY_SD_ST_OUTLIER */
+ uint16_t f_mode; /* 0 = RPY_SD_MD_CLIENT, 1 = RPY_SD_MD_PEER, 2 = RPY_SD_MD_REF */
+ uint16_t f_flags; /* unused */
+ uint16_t f_reachability; /* Bit mask of successfull tries to reach the source */
+
+ uint32_t f_since_sample; /* Time since last sample (s) */
+ tFloat f_origin_latest_meas; /* */
+ tFloat f_latest_meas; /* */
+ tFloat f_latest_meas_err; /* */
+} tChrony_Resp_Source_data;
+
+typedef struct ATTRIB_PACKED
+{
+ uint32_t f_ref_id;
+ tChrony_IPAddr addr;
+ uint16_t dummy; /* FIXME: Strange dummy space. Needed on gcc 4.8.3/clang 3.4.1 on x86_64 */
+ uint32_t f_n_samples; /* Number of measurements done */
+ uint32_t f_n_runs; /* How many measurements to come */
+ uint32_t f_span_seconds; /* For how long we're measuring */
+ tFloat f_rtc_seconds_fast; /* ??? */
+ tFloat f_rtc_gain_rate_ppm; /* Estimated relative frequency error */
+ tFloat f_skew_ppm; /* Clock skew (ppm) (worst case freq est error (skew: peak2peak)) */
+ tFloat f_est_offset; /* Estimated offset of source */
+ tFloat f_est_offset_err; /* Error of estimation */
+} tChrony_Resp_Source_stats;
+
+typedef struct ATTRIB_PACKED
+{
+ uint32_t f_ref_id;
+ tChrony_IPAddr addr;
+ uint16_t dummy; /* FIXME: Strange dummy space. Needed on gcc 4.8.3/clang 3.4.1 on x86_64 */
+ uint16_t f_stratum;
+ uint16_t f_leap_status;
+ tTimeval f_ref_time;
+ tFloat f_current_correction;
+ tFloat f_last_offset;
+ tFloat f_rms_offset;
+ tFloat f_freq_ppm;
+ tFloat f_resid_freq_ppm;
+ tFloat f_skew_ppm;
+ tFloat f_root_delay;
+ tFloat f_root_dispersion;
+ tFloat f_last_update_interval;
+} tChrony_Resp_Tracking;
+
+typedef struct ATTRIB_PACKED
+{
+ struct
+ {
+ uint8_t f_version;
+ uint8_t f_type;
+ uint8_t f_dummy0;
+ uint8_t f_dummy1;
+ uint16_t f_cmd;
+ uint16_t f_reply;
+ uint16_t f_status;
+ uint16_t f_dummy2;
+ uint16_t f_dummy3;
+ uint16_t f_dummy4;
+ uint32_t f_seq;
+ uint32_t f_dummy5;
+ uint32_t f_dummy6;
+ } header; /* Packed: 28 Bytes */
+
+ union
+ {
+ tChrony_Resp_N_Sources n_sources;
+ tChrony_Resp_Source_data source_data;
+ tChrony_Resp_Source_stats source_stats;
+ tChrony_Resp_Tracking tracking;
+ } body;
+
+ uint8_t padding[1024];
+} tChrony_Response;
+
+
+/*****************************************************************************/
+/* Internal functions */
+/*****************************************************************************/
+
+/* connect_client code adapted from: http://long.ccaba.upc.edu/long/045Guidelines/eva/ipv6.html#daytimeClient6 */
+/* License granted by Eva M Castro via e-mail on 2016-02-18 under the terms of GPLv3 */
+static int
+connect_client(const char *p_hostname,
+ const char *p_service, int p_family, int p_socktype)
+{
+ struct addrinfo hints, *res = NULL, *ressave = NULL;
+ int n, sockfd;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+
+ hints.ai_family = p_family;
+ hints.ai_socktype = p_socktype;
+
+ n = getaddrinfo(p_hostname, p_service, &hints, &res);
+
+ if (n < 0)
+ {
+ ERROR(PLUGIN_NAME ": getaddrinfo error:: [%s]", gai_strerror(n));
+ return -1;
+ }
+
+ ressave = res;
+
+ sockfd = -1;
+ while (res)
+ {
+ sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+
+ if (!(sockfd < 0))
+ {
+ if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0)
+ {
+ /* Success */
+ break;
+ }
+
+ close(sockfd);
+ sockfd = -1;
+ }
+ res = res->ai_next;
+ }
+
+ freeaddrinfo(ressave);
+ return sockfd;
+}
+
+
+/* niptoha code originally from: git://git.tuxfamily.org/gitroot/chrony/chrony.git:util.c */
+/* Original code licensed as GPLv2, by Richard P. Purnow, Miroslav Lichvar */
+/* Original name: char * UTI_IPToString(IPAddr *addr)*/
+static char *
+niptoha(const tChrony_IPAddr * addr, char *p_buf, size_t p_buf_size)
+{
+ int rc = 1;
+ unsigned long a, b, c, d, ip;
+
+ switch (ntohs(addr->f_family))
+ {
+ case IPADDR_UNSPEC:
+ rc = snprintf(p_buf, p_buf_size, "[UNSPEC]");
+ break;
+ case IPADDR_INET4:
+ ip = ntohl(addr->addr.ip4);
+ a = (ip >> 24) & 0xff;
+ b = (ip >> 16) & 0xff;
+ c = (ip >> 8) & 0xff;
+ d = (ip >> 0) & 0xff;
+ rc = snprintf(p_buf, p_buf_size, "%ld.%ld.%ld.%ld", a, b, c, d);
+ break;
+ case IPADDR_INET6:
+ {
+ const char *rp = inet_ntop(AF_INET6, addr->addr.ip6, p_buf, p_buf_size);
+ if (rp == NULL)
+ {
+ ERROR(PLUGIN_NAME ": Error converting ipv6 address to string. Errno = %d", errno);
+ rc = snprintf(p_buf, p_buf_size, "[UNKNOWN]");
+ }
+ break;
+ }
+ default:
+ rc = snprintf(p_buf, p_buf_size, "[UNKNOWN]");
+ }
+ assert(rc > 0);
+ return p_buf;
+}
+
+
+static int
+chrony_set_timeout()
+{
+ /* Set the socket's timeout to g_chrony_timeout; a value of 0 signals infinite timeout */
+ /* Returns 0 on success, !0 on error (check errno) */
+
+ struct timeval tv;
+ tv.tv_sec = g_chrony_timeout;
+ tv.tv_usec = 0;
+
+ assert(g_chrony_socket >= 0);
+ if (setsockopt(g_chrony_socket, SOL_SOCKET,
+ SO_RCVTIMEO, (char *) &tv, sizeof(struct timeval)) < 0)
+ {
+ return CHRONY_RC_FAIL;
+ }
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_connect()
+{
+ /* Connects to the chrony daemon */
+ /* Returns 0 on success, !0 on error (check errno) */
+ int socket;
+
+ if (g_chrony_host == NULL)
+ {
+ g_chrony_host = strdup(CHRONY_DEFAULT_HOST);
+ if (g_chrony_host == NULL)
+ {
+ ERROR(PLUGIN_NAME ": Error duplicating chrony host name");
+ return CHRONY_RC_FAIL;
+ }
+ }
+ if (g_chrony_port == NULL)
+ {
+ g_chrony_port = strdup(CHRONY_DEFAULT_PORT);
+ if (g_chrony_port == NULL)
+ {
+ ERROR(PLUGIN_NAME ": Error duplicating chrony port string");
+ return CHRONY_RC_FAIL;
+ }
+ }
+ if (g_chrony_timeout < 0)
+ {
+ g_chrony_timeout = CHRONY_DEFAULT_TIMEOUT;
+ assert(g_chrony_timeout >= 0);
+ }
+
+ DEBUG(PLUGIN_NAME ": Connecting to %s:%s", g_chrony_host, g_chrony_port);
+ socket = connect_client(g_chrony_host, g_chrony_port, AF_UNSPEC, SOCK_DGRAM);
+ if (socket < 0)
+ {
+ ERROR(PLUGIN_NAME ": Error connecting to daemon. Errno = %d", errno);
+ return CHRONY_RC_FAIL;
+ }
+ DEBUG(PLUGIN_NAME ": Connected");
+ g_chrony_socket = socket;
+
+ if (chrony_set_timeout())
+ {
+ ERROR(PLUGIN_NAME ": Error setting timeout to %lds. Errno = %d",
+ g_chrony_timeout, errno);
+ return CHRONY_RC_FAIL;
+ }
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_send_request(const tChrony_Request * p_req, size_t p_req_size)
+{
+ if (send(g_chrony_socket, p_req, p_req_size, 0) < 0)
+ {
+ ERROR(PLUGIN_NAME ": Error sending packet. Errno = %d", errno);
+ return CHRONY_RC_FAIL;
+ }
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_recv_response(tChrony_Response * p_resp, size_t p_resp_max_size,
+ size_t * p_resp_size)
+{
+ ssize_t rc = recv(g_chrony_socket, p_resp, p_resp_max_size, 0);
+ if (rc <= 0)
+ {
+ ERROR(PLUGIN_NAME ": Error receiving packet: %s (%d)", strerror(errno),
+ errno);
+ return CHRONY_RC_FAIL;
+ }
+ else
+ {
+ *p_resp_size = rc;
+ return CHRONY_RC_OK;
+ }
+}
+
+
+static int
+chrony_query(const int p_command, tChrony_Request * p_req,
+ tChrony_Response * p_resp, size_t * p_resp_size)
+{
+ /* Check connection. We simply perform one try as collectd already handles retries */
+ assert(p_req);
+ assert(p_resp);
+ assert(p_resp_size);
+
+ if (g_chrony_is_connected == 0)
+ {
+ if (chrony_connect() == CHRONY_RC_OK)
+ {
+ g_chrony_is_connected = 1;
+ }
+ else
+ {
+ ERROR(PLUGIN_NAME ": Unable to connect. Errno = %d", errno);
+ return CHRONY_RC_FAIL;
+ }
+ }
+
+ do
+ {
+ int valid_command = 0;
+ size_t req_size = sizeof(p_req->header) + sizeof(p_req->padding);
+ size_t resp_size = sizeof(p_resp->header);
+ uint16_t resp_code = RPY_NULL;
+ switch (p_command)
+ {
+ case REQ_TRACKING:
+ req_size += sizeof(p_req->body.tracking);
+ resp_size += sizeof(p_resp->body.tracking);
+ resp_code = RPY_TRACKING;
+ valid_command = 1;
+ break;
+ case REQ_N_SOURCES:
+ req_size += sizeof(p_req->body.n_sources);
+ resp_size += sizeof(p_resp->body.n_sources);
+ resp_code = RPY_N_SOURCES;
+ valid_command = 1;
+ break;
+ case REQ_SOURCE_DATA:
+ req_size += sizeof(p_req->body.source_data);
+ resp_size += sizeof(p_resp->body.source_data);
+ resp_code = RPY_SOURCE_DATA;
+ valid_command = 1;
+ break;
+ case REQ_SOURCE_STATS:
+ req_size += sizeof(p_req->body.source_stats);
+ resp_size += sizeof(p_resp->body.source_stats);
+ resp_code = RPY_SOURCE_STATS;
+ valid_command = 1;
+ break;
+ default:
+ ERROR(PLUGIN_NAME ": Unknown request command (Was: %d)", p_command);
+ break;
+ }
+
+ if (valid_command == 0)
+ break;
+
+ uint32_t seq_nr = rand_r(&g_chrony_rand);
+ p_req->header.f_cmd = htons(p_command);
+ p_req->header.f_cmd_try = 0;
+ p_req->header.f_seq = seq_nr;
+
+ DEBUG(PLUGIN_NAME ": Sending request (.cmd = %d, .seq = %d)", p_command,
+ seq_nr);
+ if (chrony_send_request(p_req, req_size) != 0)
+ break;
+
+ DEBUG(PLUGIN_NAME ": Waiting for response");
+ if (chrony_recv_response(p_resp, resp_size, p_resp_size) != 0)
+ break;
+
+ DEBUG(PLUGIN_NAME
+ ": Received response: .version = %u, .type = %u, .cmd = %u, .reply = %u, .status = %u, .seq = %u",
+ p_resp->header.f_version, p_resp->header.f_type,
+ ntohs(p_resp->header.f_cmd), ntohs(p_resp->header.f_reply),
+ ntohs(p_resp->header.f_status), p_resp->header.f_seq);
+
+ if (p_resp->header.f_version != p_req->header.f_version)
+ {
+ ERROR(PLUGIN_NAME ": Wrong protocol version (Was: %d, expected: %d)",
+ p_resp->header.f_version, p_req->header.f_version);
+ return CHRONY_RC_FAIL;
+ }
+ if (p_resp->header.f_type != PKT_TYPE_CMD_REPLY)
+ {
+ ERROR(PLUGIN_NAME ": Wrong packet type (Was: %d, expected: %d)",
+ p_resp->header.f_type, PKT_TYPE_CMD_REPLY);
+ return CHRONY_RC_FAIL;
+ }
+ if (p_resp->header.f_seq != seq_nr)
+ {
+ /* FIXME: Implement sequence number handling */
+ ERROR(PLUGIN_NAME
+ ": Unexpected sequence number (Was: %d, expected: %d)",
+ p_resp->header.f_seq, p_req->header.f_seq);
+ return CHRONY_RC_FAIL;
+ }
+ if (p_resp->header.f_cmd != p_req->header.f_cmd)
+ {
+ ERROR(PLUGIN_NAME ": Wrong reply command (Was: %d, expected: %d)",
+ p_resp->header.f_cmd, p_req->header.f_cmd);
+ return CHRONY_RC_FAIL;
+ }
+
+ if (ntohs(p_resp->header.f_reply) != resp_code)
+ {
+ ERROR(PLUGIN_NAME ": Wrong reply code (Was: %d, expected: %d)",
+ ntohs(p_resp->header.f_reply), resp_code);
+ return CHRONY_RC_FAIL;
+ }
+
+ switch (p_resp->header.f_status)
+ {
+ case STT_SUCCESS:
+ DEBUG(PLUGIN_NAME ": Reply packet status STT_SUCCESS");
+ break;
+ default:
+ ERROR(PLUGIN_NAME
+ ": Reply packet contains error status: %d (expected: %d)",
+ p_resp->header.f_status, STT_SUCCESS);
+ return CHRONY_RC_FAIL;
+ }
+
+ /* Good result */
+ return CHRONY_RC_OK;
+ }
+ while (0);
+
+ /* Some error occured */
+ return CHRONY_RC_FAIL;
+}
+
+
+static void
+chrony_init_req(tChrony_Request * p_req)
+{
+ memset(p_req, 0, sizeof(*p_req));
+ p_req->header.f_version = PROTO_VERSION_NUMBER;
+ p_req->header.f_type = PKT_TYPE_CMD_REQUEST;
+ p_req->header.f_dummy0 = 0;
+ p_req->header.f_dummy1 = 0;
+ p_req->header.f_dummy2 = 0;
+ p_req->header.f_dummy3 = 0;
+}
+
+
+/* ntohf code originally from: git://git.tuxfamily.org/gitroot/chrony/chrony.git:util.c */
+/* Original code licensed as GPLv2, by Richard P. Purnow, Miroslav Lichvar */
+/* Original name: double UTI_tFloatNetworkToHost(tFloat f) */
+static double
+ntohf(tFloat p_float)
+{
+ /* Convert tFloat in Network-bit-order to double in host-bit-order */
+
+#define FLOAT_EXP_BITS 7
+#define FLOAT_EXP_MIN (-(1 << (FLOAT_EXP_BITS - 1)))
+#define FLOAT_EXP_MAX (-FLOAT_EXP_MIN - 1)
+#define FLOAT_COEF_BITS ((int)sizeof (int32_t) * 8 - FLOAT_EXP_BITS)
+#define FLOAT_COEF_MIN (-(1 << (FLOAT_COEF_BITS - 1)))
+#define FLOAT_COEF_MAX (-FLOAT_COEF_MIN - 1)
+
+ int32_t exp, coef;
+ uint32_t uval;
+
+ uval = ntohl(p_float.value);
+ exp = (uval >> FLOAT_COEF_BITS) - FLOAT_COEF_BITS;
+ if (exp >= 1 << (FLOAT_EXP_BITS - 1))
+ exp -= 1 << FLOAT_EXP_BITS;
+
+ /* coef = (x << FLOAT_EXP_BITS) >> FLOAT_EXP_BITS; */
+ coef = uval % (1U << FLOAT_COEF_BITS);
+ if (coef >= 1 << (FLOAT_COEF_BITS - 1))
+ coef -= 1 << FLOAT_COEF_BITS;
+
+ return coef * pow(2.0, exp);
+}
+
+
+static void
+chrony_push_data(char *p_type, char *p_type_inst, double p_value)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].gauge = p_value; /* TODO: Check type??? (counter, gauge, derive, absolute) */
+
+ vl.values = values;
+ vl.values_len = 1;
+
+ /* XXX: Shall g_chrony_host/g_chrony_port be reflected in the plugin's output? */
+ /* hostname_g is set in daemon/collectd.c (from config, via gethostname or by resolving localhost) */
+ /* defined as: char hostname_g[DATA_MAX_NAME_LEN]; (never NULL) */
+ sstrncpy(vl.host, hostname_g, sizeof(vl.host));
+ sstrncpy(vl.plugin, PLUGIN_NAME_SHORT, sizeof(vl.plugin));
+ if (g_chrony_plugin_instance != NULL)
+ {
+ sstrncpy(vl.plugin_instance, g_chrony_plugin_instance,
+ sizeof(vl.plugin_instance));
+ }
+ if (p_type != NULL)
+ sstrncpy(vl.type, p_type, sizeof(vl.type));
+
+ if (p_type_inst != NULL)
+ sstrncpy(vl.type_instance, p_type_inst, sizeof(vl.type_instance));
+
+ plugin_dispatch_values(&vl);
+}
+
+
+static void
+chrony_push_data_valid(char *p_type, char *p_type_inst, const int p_is_valid,
+ double p_value)
+{
+ /* Push real value if p_is_valid is true, push NAN if p_is_valid is not true (idea from ntp plugin) */
+ if (p_is_valid == 0)
+ p_value = NAN;
+
+ chrony_push_data(p_type, p_type_inst, p_value);
+}
+
+
+static int
+chrony_init_seq()
+{
+ /* Initialize the sequence number generator from /dev/urandom */
+ /* Fallbacks: /dev/random and time(NULL) */
+
+ /* Try urandom */
+ int fh = open(URAND_DEVICE_PATH, O_RDONLY);
+ if (fh >= 0)
+ {
+ ssize_t rc = read(fh, &g_chrony_rand, sizeof(g_chrony_rand));
+ if (rc != sizeof(g_chrony_rand))
+ {
+ ERROR(PLUGIN_NAME ": Reading from random source \'%s\'failed: %s (%d)",
+ URAND_DEVICE_PATH, strerror(errno), errno);
+ close(fh);
+ return CHRONY_RC_FAIL;
+ }
+ close(fh);
+ DEBUG(PLUGIN_NAME ": Seeding RNG from " URAND_DEVICE_PATH);
+ }
+ else
+ {
+ if (errno == ENOENT)
+ {
+ /* URAND_DEVICE_PATH device not found. Try RAND_DEVICE_PATH as fall-back */
+ int fh = open(RAND_DEVICE_PATH, O_RDONLY);
+ if (fh >= 0)
+ {
+ ssize_t rc = read(fh, &g_chrony_rand, sizeof(g_chrony_rand));
+ if (rc != sizeof(g_chrony_rand))
+ {
+ ERROR(PLUGIN_NAME
+ ": Reading from random source \'%s\'failed: %s (%d)",
+ RAND_DEVICE_PATH, strerror(errno), errno);
+ close(fh);
+ return CHRONY_RC_FAIL;
+ }
+ close(fh);
+ DEBUG(PLUGIN_NAME ": Seeding RNG from " RAND_DEVICE_PATH);
+ }
+ else
+ {
+ /* Error opening RAND_DEVICE_PATH. Try time(NULL) as fall-back */
+ DEBUG(PLUGIN_NAME ": Seeding RNG from time(NULL)");
+ g_chrony_rand = time(NULL) ^ getpid();
+ }
+ }
+ else
+ {
+ ERROR(PLUGIN_NAME ": Opening random source \'%s\' failed: %s (%d)",
+ URAND_DEVICE_PATH, strerror(errno), errno);
+ return CHRONY_RC_FAIL;
+ }
+ }
+
+ return CHRONY_RC_OK;
+}
+
+
+/*****************************************************************************/
+/* Exported functions */
+/*****************************************************************************/
+static int
+chrony_config(const char *p_key, const char *p_value)
+{
+ assert(p_key);
+ assert(p_value);
+
+ /* Parse config variables */
+ if (strcasecmp(p_key, CONFIG_KEY_HOST) == 0)
+ {
+ if (g_chrony_host != NULL)
+ free(g_chrony_host);
+
+ if ((g_chrony_host = strdup(p_value)) == NULL)
+ {
+ ERROR(PLUGIN_NAME ": Error duplicating host name");
+ return CHRONY_RC_FAIL;
+ }
+ }
+ else
+ {
+ if (strcasecmp(p_key, CONFIG_KEY_PORT) == 0)
+ {
+ if (g_chrony_port != NULL)
+ free(g_chrony_port);
+
+ if ((g_chrony_port = strdup(p_value)) == NULL)
+ {
+ ERROR(PLUGIN_NAME ": Error duplicating port name");
+ return CHRONY_RC_FAIL;
+ }
+ }
+ else
+ {
+ if (strcasecmp(p_key, CONFIG_KEY_TIMEOUT) == 0)
+ {
+ time_t tosec = strtol(p_value, NULL, 0);
+ g_chrony_timeout = tosec;
+ }
+ else
+ {
+ WARNING(PLUGIN_NAME ": Unknown configuration variable: %s %s", p_key, p_value);
+ return CHRONY_RC_FAIL;
+ }
+ }
+ }
+ /* XXX: We could set g_chrony_plugin_instance here to "g_chrony_host-g_chrony_port", but as multiple instances aren't yet supported, we skip this for now */
+
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_request_daemon_stats()
+{
+ /* Perform Tracking request */
+ int rc;
+ size_t chrony_resp_size;
+ tChrony_Request chrony_req;
+ tChrony_Response chrony_resp;
+
+ chrony_init_req(&chrony_req);
+ rc =
+ chrony_query(REQ_TRACKING, &chrony_req, &chrony_resp, &chrony_resp_size);
+ if (rc != 0)
+ {
+ ERROR(PLUGIN_NAME ": chrony_query (REQ_TRACKING) failed with status %i",
+ rc);
+ return rc;
+ }
+#if COLLECT_DEBUG
+ {
+ char src_addr[IPV6_STR_MAX_SIZE];
+ memset(src_addr, 0, sizeof(src_addr));
+ niptoha(&chrony_resp.body.tracking.addr, src_addr, sizeof(src_addr));
+ DEBUG(PLUGIN_NAME ": Daemon stat: .addr = %s, .ref_id= %u, .stratum = %u, .leap_status = %u, .ref_time = %u:%u:%u, .current_correction = %f, .last_offset = %f, .rms_offset = %f, .freq_ppm = %f, .skew_ppm = %f, .root_delay = %f, .root_dispersion = %f, .last_update_interval = %f", src_addr, ntohs(chrony_resp.body.tracking.f_ref_id),
+ ntohs(chrony_resp.body.tracking.f_stratum),
+ ntohs(chrony_resp.body.tracking.f_leap_status),
+ ntohl(chrony_resp.body.tracking.f_ref_time.tv_sec_high),
+ ntohl(chrony_resp.body.tracking.f_ref_time.tv_sec_low),
+ ntohl(chrony_resp.body.tracking.f_ref_time.tv_nsec),
+ ntohf(chrony_resp.body.tracking.f_current_correction),
+ ntohf(chrony_resp.body.tracking.f_last_offset),
+ ntohf(chrony_resp.body.tracking.f_rms_offset),
+ ntohf(chrony_resp.body.tracking.f_freq_ppm),
+ ntohf(chrony_resp.body.tracking.f_skew_ppm),
+ ntohf(chrony_resp.body.tracking.f_root_delay),
+ ntohf(chrony_resp.body.tracking.f_root_dispersion),
+ ntohf(chrony_resp.body.tracking.f_last_update_interval));
+ }
+#endif
+
+ double time_ref = ntohl(chrony_resp.body.tracking.f_ref_time.tv_nsec);
+ time_ref /= 1000000000.0;
+ time_ref += ntohl(chrony_resp.body.tracking.f_ref_time.tv_sec_low);
+ if (chrony_resp.body.tracking.f_ref_time.tv_sec_high)
+ {
+ double secs_high =
+ ntohl(chrony_resp.body.tracking.f_ref_time.tv_sec_high);
+ secs_high *= 4294967296.0;
+ time_ref += secs_high;
+ }
+
+ /* Forward results to collectd-daemon */
+ /* Type_instance is always 'chrony' to tag daemon-wide data */
+ /* Type Type_instan Value */
+ chrony_push_data("clock_stratum", DAEMON_NAME, ntohs(chrony_resp.body.tracking.f_stratum));
+ chrony_push_data("time_ref", DAEMON_NAME, time_ref); /* unit: s */
+ chrony_push_data("time_offset_ntp", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_current_correction)); /* Offset between system time and NTP, unit: s */
+ chrony_push_data("time_offset", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_last_offset)); /* Estimated Offset of the NTP time, unit: s */
+ chrony_push_data("time_offset_rms", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_rms_offset)); /* averaged value of the above, unit: s */
+ chrony_push_data("frequency_error", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_freq_ppm)); /* Frequency error of the local osc, unit: ppm */
+ chrony_push_data("clock_skew_ppm", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_skew_ppm));
+ chrony_push_data("root_delay", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_root_delay)); /* Network latency between local daemon and the current source */
+ chrony_push_data("root_dispersion", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_root_dispersion));
+ chrony_push_data("clock_last_update", DAEMON_NAME, ntohf(chrony_resp.body.tracking.f_last_update_interval));
+
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_request_sources_count(unsigned int *p_count)
+{
+ /* Requests the number of time sources from the chrony daemon */
+ int rc;
+ size_t chrony_resp_size;
+ tChrony_Request chrony_req;
+ tChrony_Response chrony_resp;
+
+ DEBUG(PLUGIN_NAME ": Requesting data");
+ chrony_init_req(&chrony_req);
+ rc =
+ chrony_query(REQ_N_SOURCES, &chrony_req, &chrony_resp, &chrony_resp_size);
+ if (rc != 0)
+ {
+ ERROR(PLUGIN_NAME ": chrony_query (REQ_N_SOURCES) failed with status %i",
+ rc);
+ return rc;
+ }
+
+ *p_count = ntohl(chrony_resp.body.n_sources.f_n_sources);
+ DEBUG(PLUGIN_NAME ": Getting data of %d clock sources", *p_count);
+
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_request_source_data(int p_src_idx, int *p_is_reachable)
+{
+ /* Perform Source data request for source #p_src_idx */
+ int rc;
+ size_t chrony_resp_size;
+ tChrony_Request chrony_req;
+ tChrony_Response chrony_resp;
+
+ char src_addr[IPV6_STR_MAX_SIZE];
+ memset(src_addr, 0, sizeof(src_addr));
+
+ chrony_init_req(&chrony_req);
+ chrony_req.body.source_data.f_index = htonl(p_src_idx);
+ rc =
+ chrony_query(REQ_SOURCE_DATA, &chrony_req, &chrony_resp,
+ &chrony_resp_size);
+ if (rc != 0)
+ {
+ ERROR(PLUGIN_NAME
+ ": chrony_query (REQ_SOURCE_DATA) failed with status %i", rc);
+ return rc;
+ }
+
+ niptoha(&chrony_resp.body.source_data.addr, src_addr, sizeof(src_addr));
+ DEBUG(PLUGIN_NAME
+ ": Source[%d] data: .addr = %s, .poll = %u, .stratum = %u, .state = %u, .mode = %u, .flags = %u, .reach = %u, .latest_meas_ago = %u, .orig_latest_meas = %f, .latest_meas = %f, .latest_meas_err = %f",
+ p_src_idx, src_addr, ntohs(chrony_resp.body.source_data.f_poll),
+ ntohs(chrony_resp.body.source_data.f_stratum),
+ ntohs(chrony_resp.body.source_data.f_state),
+ ntohs(chrony_resp.body.source_data.f_mode),
+ ntohs(chrony_resp.body.source_data.f_flags),
+ ntohs(chrony_resp.body.source_data.f_reachability),
+ ntohl(chrony_resp.body.source_data.f_since_sample),
+ ntohf(chrony_resp.body.source_data.f_origin_latest_meas),
+ ntohf(chrony_resp.body.source_data.f_latest_meas),
+ ntohf(chrony_resp.body.source_data.f_latest_meas_err));
+
+ /* Push NaN if source is currently not reachable */
+ int is_reachable =
+ ntohs(chrony_resp.body.source_data.f_reachability) & 0x01;
+ *p_is_reachable = is_reachable;
+
+ /* Forward results to collectd-daemon */
+ chrony_push_data_valid("clock_stratum", src_addr, is_reachable,
+ ntohs(chrony_resp.body.source_data.f_stratum));
+ chrony_push_data_valid("clock_state", src_addr, is_reachable,
+ ntohs(chrony_resp.body.source_data.f_state));
+ chrony_push_data_valid("clock_mode", src_addr, is_reachable,
+ ntohs(chrony_resp.body.source_data.f_mode));
+ chrony_push_data_valid("clock_reachability", src_addr, is_reachable,
+ ntohs(chrony_resp.body.source_data.f_reachability));
+ chrony_push_data_valid("clock_last_meas", src_addr, is_reachable,
+ ntohs(chrony_resp.body.source_data.f_since_sample));
+
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_request_source_stats(int p_src_idx, const int *p_is_reachable)
+{
+ /* Perform Source stats request for source #p_src_idx */
+ int rc;
+ size_t chrony_resp_size;
+ tChrony_Request chrony_req;
+ tChrony_Response chrony_resp;
+ double skew_ppm, frequency_error, time_offset;
+
+ char src_addr[IPV6_STR_MAX_SIZE];
+ memset(src_addr, 0, sizeof(src_addr));
+
+ if (*p_is_reachable == 0)
+ {
+ skew_ppm = 0;
+ frequency_error = 0;
+ time_offset = 0;
+ }
+ else
+ {
+ chrony_init_req(&chrony_req);
+ chrony_req.body.source_stats.f_index = htonl(p_src_idx);
+ rc =
+ chrony_query(REQ_SOURCE_STATS, &chrony_req, &chrony_resp,
+ &chrony_resp_size);
+ if (rc != 0)
+ {
+ ERROR(PLUGIN_NAME
+ ": chrony_query (REQ_SOURCE_STATS) failed with status %i", rc);
+ return rc;
+ }
+
+ skew_ppm = ntohf(chrony_resp.body.source_stats.f_skew_ppm);
+ frequency_error =
+ ntohf(chrony_resp.body.source_stats.f_rtc_gain_rate_ppm);
+ time_offset = ntohf(chrony_resp.body.source_stats.f_est_offset);
+
+ niptoha(&chrony_resp.body.source_stats.addr, src_addr, sizeof(src_addr));
+ DEBUG(PLUGIN_NAME
+ ": Source[%d] stat: .addr = %s, .ref_id= %u, .n_samples = %u, "
+ ".n_runs = %u, .span_seconds = %u, .rtc_seconds_fast = %f, "
+ ".rtc_gain_rate_ppm = %f, .skew_ppm= %f, .est_offset = %f, .est_offset_err = %f",
+ p_src_idx, src_addr,
+ ntohl(chrony_resp.body.source_stats.f_ref_id),
+ ntohl(chrony_resp.body.source_stats.f_n_samples),
+ ntohl(chrony_resp.body.source_stats.f_n_runs),
+ ntohl(chrony_resp.body.source_stats.f_span_seconds),
+ ntohf(chrony_resp.body.source_stats.f_rtc_seconds_fast),
+ frequency_error, skew_ppm, time_offset,
+ ntohf(chrony_resp.body.source_stats.f_est_offset_err));
+
+ } /* if (*is_reachable) */
+
+ /* Forward results to collectd-daemon */
+ chrony_push_data_valid("clock_skew_ppm", src_addr, *p_is_reachable, skew_ppm);
+ chrony_push_data_valid("frequency_error", src_addr, *p_is_reachable, frequency_error); /* unit: ppm */
+ chrony_push_data_valid("time_offset", src_addr, *p_is_reachable, time_offset); /* unit: s */
+
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_read()
+{
+ /* collectd read callback: Perform data acquisition */
+ int rc;
+ unsigned int now_src, n_sources;
+
+ if (g_chrony_seq_is_initialized == 0)
+ {
+ /* Seed RNG for sequence number generation */
+ rc = chrony_init_seq();
+ if (rc != CHRONY_RC_OK)
+ return rc;
+
+ g_chrony_seq_is_initialized = 1;
+ }
+
+ /* Get daemon stats */
+ rc = chrony_request_daemon_stats();
+ if (rc != CHRONY_RC_OK)
+ return rc;
+
+ /* Get number of time sources, then check every source for status */
+ rc = chrony_request_sources_count(&n_sources);
+ if (rc != CHRONY_RC_OK)
+ return rc;
+
+ for (now_src = 0; now_src < n_sources; ++now_src)
+ {
+ int is_reachable;
+ rc = chrony_request_source_data(now_src, &is_reachable);
+ if (rc != CHRONY_RC_OK)
+ return rc;
+
+ rc = chrony_request_source_stats(now_src, &is_reachable);
+ if (rc != CHRONY_RC_OK)
+ return rc;
+
+ }
+ return CHRONY_RC_OK;
+}
+
+
+static int
+chrony_shutdown()
+{
+ /* Collectd shutdown callback: Free mem */
+ if (g_chrony_is_connected != 0)
+ {
+ close(g_chrony_socket);
+ g_chrony_is_connected = 0;
+ }
+ if (g_chrony_host != NULL)
+ sfree(g_chrony_host);
+
+ if (g_chrony_port != NULL)
+ sfree(g_chrony_port);
+
+ if (g_chrony_plugin_instance != NULL)
+ sfree(g_chrony_plugin_instance);
+
+ return CHRONY_RC_OK;
+}
+
+
+void
+module_register(void)
+{
+ plugin_register_config(PLUGIN_NAME_SHORT, chrony_config, g_config_keys,
+ g_config_keys_num);
+ plugin_register_read(PLUGIN_NAME_SHORT, chrony_read);
+ plugin_register_shutdown(PLUGIN_NAME_SHORT, chrony_shutdown);
+}
#@BUILD_PLUGIN_BIND_TRUE@LoadPlugin bind
#@BUILD_PLUGIN_CEPH_TRUE@LoadPlugin ceph
#@BUILD_PLUGIN_CGROUPS_TRUE@LoadPlugin cgroups
+#@BUILD_PLUGIN_CHRONY_TRUE@LoadPlugin chrony
#@BUILD_PLUGIN_CONNTRACK_TRUE@LoadPlugin conntrack
#@BUILD_PLUGIN_CONTEXTSWITCH_TRUE@LoadPlugin contextswitch
@BUILD_PLUGIN_CPU_TRUE@@BUILD_PLUGIN_CPU_TRUE@LoadPlugin cpu
# </Daemon>
#</Plugin>
+#<Plugin chrony>
+# Host "localhost"
+# Port "323"
+#</Plugin>
+
#<Plugin cgroups>
# CGroup "libvirt"
# IgnoreSelected false
AM_CPPFLAGS += -DPKGDATADIR='"${pkgdatadir}"'
# Link to these libraries..
-COMMON_LIBS =
+COMMON_LIBS = $(PTHREAD_LIBS)
if BUILD_WITH_LIBRT
COMMON_LIBS += -lrt
endif
if BUILD_WITH_LIBRESOLV
COMMON_LIBS += -lresolv
endif
-if BUILD_WITH_LIBPTHREAD
-COMMON_LIBS += -lpthread
-endif
if BUILD_WITH_LIBKSTAT
COMMON_LIBS += -lkstat
endif
#include "plugin.h"
#include "utils_cache.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
+#include <pthread.h>
#ifdef HAVE_MATH_H
# include <math.h>
#include "meta_data.h"
#include "utils_time.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
+#include <pthread.h>
#define PLUGIN_FLAGS_GLOBAL 0x0001
#include "configfile.h"
#include "utils_dns.h"
-#include <pthread.h>
#include <poll.h>
#include <pcap.h>
#include <stddef.h>
-#if HAVE_LIBPTHREAD
-# include <pthread.h>
-#endif
-
#include <sys/un.h>
#include <sys/select.h>
#include <grp.h>
#include <signal.h>
-#include <pthread.h>
-
#define PL_NORMAL 0x01
#define PL_NOTIF_ACTION 0x02
#include "configfile.h"
#include "utils_avltree.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
#if HAVE_NETDB_H
# include <netdb.h>
#endif
#include "plugin.h"
#include "utils_ignorelist.h"
-#include <pthread.h>
-
#include <OpenIPMI/ipmiif.h>
#include <OpenIPMI/ipmi_err.h>
#include <OpenIPMI/ipmi_posix.h>
#include "common.h"
#include "filter_chain.h"
-#include <pthread.h>
#include <jni.h>
#if !defined(JNI_VERSION_1_2)
#include "plugin.h"
#include <sys/types.h>
-#include <pthread.h>
#include <yajl/yajl_common.h>
#include <yajl/yajl_gen.h>
#if HAVE_YAJL_YAJL_VERSION_H
#include "common.h"
#include "plugin.h"
-#include <pthread.h>
-
#define DEFAULT_LOGFILE LOCALSTATEDIR"/log/collectd.log"
#if COLLECT_DEBUG
#include "utils_cache.h"
#include "utils_complain.h"
-#include <pthread.h>
-
#include <mosquitto.h>
#define MQTT_MAX_TOPIC_SIZE 1024
#include "network.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
#if HAVE_NETDB_H
# include <netdb.h>
#endif
#endif
#if HAVE_LIBGCRYPT
-# include <pthread.h>
# if defined __APPLE__
/* default xcode compiler throws warnings even when deprecated functionality
* is not used. -Werror breaks the build because of erroneous warnings.
#include <auth-client.h>
#include <libesmtp.h>
-#include <pthread.h>
#define MAXSTRING 256
#include "common.h"
#include "plugin.h"
-#include <pthread.h>
#include <upsclient.h>
#if HAVE_UPSCONN_T
* interface for collectd plugins written in perl.
*/
-/* do not automatically get the thread specific perl interpreter */
+/* do not automatically get the thread specific Perl interpreter */
#define PERL_NO_GET_CONTEXT
#define DONT_POISON_SPRINTF_YET 1
#include "filter_chain.h"
-#include <pthread.h>
-
#if !defined(USE_ITHREADS)
# error "Perl does not support ithreads!"
#endif /* !defined(USE_ITHREADS) */
typedef struct c_ithread_s {
/* the thread's Perl interpreter */
PerlInterpreter *interp;
- _Bool running; /* thread is inside pi */
+ _Bool running; /* thread is inside Perl interpreter */
_Bool shutdown;
pthread_t pthread;
} /* static int pplugin_call_all (int, ...) */
/*
- * collectd's perl interpreter based thread implementation.
+ * collectd's Perl interpreter based thread implementation.
*
* This has been inspired by Perl's ithreads introduced in version 5.6.0.
*/
thr->shutdown = 1;
if (thr->running) {
- /* Give some time to thread to exit from pi */
- WARNING ("perl shutdown: thread is running inside perl. Waiting.");
+ /* Give some time to thread to exit from Perl interpreter */
+ WARNING ("perl shutdown: Thread is running inside Perl. Waiting.");
ts_wait.tv_sec = 0;
ts_wait.tv_nsec = 500000;
nanosleep (&ts_wait, NULL);
}
if (thr->running) {
- ERROR ("perl shutdown: thread hangs inside perl. Thread killed.");
pthread_kill (thr->pthread, SIGTERM);
+ ERROR ("perl shutdown: Thread hangs inside Perl. Thread killed.");
}
c_ithread_destroy (thr);
}
aTHX = perl_threads->head->interp;
- log_debug ("perl_config: loading perl plugin \"%s\"", value);
+ log_debug ("perl_config: Loading Perl plugin \"%s\"", value);
load_module (PERL_LOADMOD_NOIMPORT,
newSVpv (module_name, strlen (module_name)), Nullsv);
return 0;
#include "plugin.h"
#include "configfile.h"
-#include <pthread.h>
#include <netdb.h>
#include <poll.h>
#include "configfile.h"
#include "utils_complain.h"
-#include <pthread.h>
#include <netinet/in.h>
#if HAVE_NETDB_H
# include <netdb.h> /* NI_MAXHOST */
#include "utils_db_query.h"
#include "utils_complain.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
-
#include <pg_config_manual.h>
#include <libpq-fe.h>
#include <structmember.h>
#include <signal.h>
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
#include "collectd.h"
#include "common.h"
#include "plugin.h"
#include "configfile.h"
-#include <pthread.h>
#include <sys/time.h>
#include <hiredis/hiredis.h>
#include <rrd.h>
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
-
/*
* Private types
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <pthread.h>
#include <glib.h>
#include <libsigrok/libsigrok.h>
#include "plugin.h"
#include "utils_complain.h"
-#include <pthread.h>
-
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include "utils_complain.h"
#include "utils_latency.h"
-#include <pthread.h>
-
#include <sys/types.h>
#include <netdb.h>
#include <poll.h>
#include "utils_threshold.h"
#include <assert.h>
-#include <pthread.h>
/*
* Threshold management
ceph_rate value:DERIVE:0:U
changes_since_last_save value:GAUGE:0:U
charge value:GAUGE:0:U
+clock_last_meas value:GAUGE:0:U
+clock_last_update value:GAUGE:U:U
+clock_mode value:GAUGE:0:U
+clock_reachability value:GAUGE:0:U
+clock_skew_ppm value:GAUGE:-2:2
+clock_state value:GAUGE:0:U
+clock_stratum value:GAUGE:0:U
compression uncompressed:DERIVE:0:U, compressed:DERIVE:0:U
compression_ratio value:GAUGE:0:2
connections value:DERIVE:0:U
flow value:GAUGE:0:U
fork_rate value:DERIVE:0:U
frequency value:GAUGE:0:U
+frequency_error value:GAUGE:-2:2
frequency_offset value:GAUGE:-1000000:1000000
fscache_stat value:DERIVE:0:U
gauge value:GAUGE:U:U
requests value:GAUGE:0:U
response_code value:GAUGE:0:U
response_time value:GAUGE:0:U
+root_delay value:GAUGE:U:U
+root_dispersion value:GAUGE:U:U
route_etx value:GAUGE:0:U
route_metric value:GAUGE:0:U
routes value:GAUGE:0:U
threads value:GAUGE:0:U
time_dispersion value:GAUGE:-1000000:1000000
time_offset value:GAUGE:-1000000:1000000
+time_offset_ntp value:GAUGE:-1000000:1000000
+time_offset_rms value:GAUGE:-1000000:1000000
+time_ref value:GAUGE:0:U
timeleft value:GAUGE:0:U
total_bytes value:DERIVE:0:U
total_connections value:DERIVE:0:U
#include "utils_cmd_putval.h"
#include "utils_cmd_putnotif.h"
-/* Folks without pthread will need to disable this plugin. */
-#include <pthread.h>
-
#include <sys/stat.h>
#include <sys/un.h>
#include "utils_complain.h"
#include "utils_format_graphite.h"
-/* Folks without pthread will need to disable this plugin. */
-#include <pthread.h>
-
#include <netdb.h>
#define WG_DEFAULT_NODE "localhost"
#include "utils_cache.h"
#include "utils_format_json.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
-
#include <curl/curl.h>
#ifndef WRITE_HTTP_DEFAULT_BUFFER_SIZE
#include <stdint.h>
#include <librdkafka/rdkafka.h>
-#include <pthread.h>
#include <zlib.h>
#include <errno.h>
#include "utils_format_graphite.h"
-/* Folks without pthread will need to disable this plugin. */
-#include <pthread.h>
-
#include <netdb.h>
#define WL_BUF_SIZE 8192
#include "configfile.h"
#include "utils_cache.h"
-#include <pthread.h>
-
#if HAVE_STDINT_H
# define MONGO_HAVE_STDINT 1
#else
#include "common.h"
#include "configfile.h"
-#include <pthread.h>
#include <sys/time.h>
#include <hiredis/hiredis.h>
#include <riemann/riemann-client.h>
#include <errno.h>
-#include <pthread.h>
#include "collectd.h"
#include "plugin.h"
#include <errno.h>
#include <netdb.h>
#include <inttypes.h>
-#include <pthread.h>
#include <stddef.h>
#include <stdlib.h>
#include "utils_cache.h"
-#include <pthread.h>
#include <netdb.h>
#ifndef WT_DEFAULT_NODE