├── .cirrus.yml ├── .clang-format ├── .github ├── issue_template.md └── workflows │ ├── build.yml │ ├── distcheck.yml │ └── release.yml ├── .gitignore ├── .gitmodules ├── .mailmap ├── AUTHORS ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── COPYING ├── ChangeLog ├── Makefile.am ├── README.md ├── bindings ├── java │ └── org │ │ └── collectd │ │ ├── api │ │ ├── Collectd.java │ │ ├── CollectdConfigInterface.java │ │ ├── CollectdFlushInterface.java │ │ ├── CollectdInitInterface.java │ │ ├── CollectdLogInterface.java │ │ ├── CollectdMatchFactoryInterface.java │ │ ├── CollectdMatchInterface.java │ │ ├── CollectdNotificationInterface.java │ │ ├── CollectdReadInterface.java │ │ ├── CollectdShutdownInterface.java │ │ ├── CollectdTargetFactoryInterface.java │ │ ├── CollectdTargetInterface.java │ │ ├── CollectdWriteInterface.java │ │ ├── DataSet.java │ │ ├── DataSource.java │ │ ├── Notification.java │ │ ├── OConfigItem.java │ │ ├── OConfigValue.java │ │ ├── PluginData.java │ │ └── ValueList.java │ │ └── java │ │ ├── GenericJMX.java │ │ ├── GenericJMXConfConnection.java │ │ ├── GenericJMXConfMBean.java │ │ ├── GenericJMXConfValue.java │ │ └── JMXMemory.java └── perl │ ├── Makefile.PL │ ├── lib │ ├── Collectd.pm │ └── Collectd │ │ ├── MockDaemon.pm │ │ ├── Plugins │ │ ├── Monitorus.pm │ │ └── OpenVZ.pm │ │ └── Unixsock.pm │ ├── t │ ├── 00_load.t │ └── 01_methods.t │ └── uninstall_mod.pl ├── build.sh ├── clean.sh ├── configure.ac ├── contrib ├── 99-storage-collectd.rules ├── GenericJMX.conf ├── README ├── SpamAssassin │ ├── Collectd.pm │ └── example.cf ├── add_rra.sh ├── aix │ ├── collectd.spec │ └── init.d-collectd ├── collectd2html.pl ├── collectd_network.py ├── collectd_unix_sock.rb ├── collectd_unixsock.py ├── collection.cgi ├── collection.conf ├── collection3 │ ├── README │ ├── bin │ │ ├── .htaccess │ │ ├── graph.cgi │ │ ├── index.cgi │ │ └── json.cgi │ ├── etc │ │ ├── .htaccess │ │ └── collection.conf │ ├── lib │ │ ├── .htaccess │ │ └── Collectd │ │ │ ├── Config.pm │ │ │ └── Graph │ │ │ ├── Common.pm │ │ │ ├── Config.pm │ │ │ ├── Type.pm │ │ │ ├── Type │ │ │ ├── ArcCounts.pm │ │ │ ├── Df.pm │ │ │ ├── GenericIO.pm │ │ │ ├── GenericStacked.pm │ │ │ ├── JavaMemory.pm │ │ │ ├── Load.pm │ │ │ ├── PsCputime.pm │ │ │ ├── TableSize.pm │ │ │ └── Wirkleistung.pm │ │ │ └── TypeLoader.pm │ └── share │ │ ├── .htaccess │ │ ├── navigate.js │ │ ├── shortcut-icon.png │ │ └── style.css ├── curl_jolokia │ ├── curl_jolokia.conf │ └── jolokia_2_collectdcfg.py ├── curl_json │ └── php-fpm.conf ├── cussh.pl ├── docker │ ├── 50docker-apt-conf │ ├── Dockerfile │ ├── collectd.conf │ ├── collectd.conf.d │ │ └── sample.conf │ └── rootfs_prefix │ │ ├── .gitignore │ │ ├── Makefile │ │ └── rootfs_prefix.c ├── examples │ ├── MyPlugin.pm │ └── myplugin.c ├── exec-borg ├── exec-ksm.sh ├── exec-munin.conf ├── exec-munin.px ├── exec-nagios.conf ├── exec-nagios.px ├── exec-smartctl ├── format.sh ├── iptables │ └── accounting.sh ├── migrate-3-4.px ├── migrate-4-5.px ├── network-proxy.py ├── oracle │ ├── create_schema.ddl │ └── db_systat.sql ├── php-collection │ ├── browser.js │ ├── config.php │ ├── definitions.local.php │ ├── definitions.php │ ├── functions.php │ ├── graph.php │ └── index.php ├── postgresql │ ├── README.md │ ├── collectd_insert.sql │ └── collectd_insert2.sql ├── python │ └── getsigchld.py ├── redhat │ ├── collectd.spec │ ├── collection3.conf │ ├── init.d-collectd │ └── php-collection.conf ├── rrd_filter.px ├── sles10.1 │ ├── collectd.spec │ └── init.d-collectd ├── snmp-data.conf ├── snmp-probe-host.px ├── solaris-smf │ ├── README │ ├── collectd │ └── collectd.xml ├── systemd.collectd.service ├── upstart.collectd.conf └── wiki2changelog.pl ├── docs ├── BUILD.dpdkstat.md ├── BUILD.java.md ├── CONTRIBUTING.md ├── README.virt.md ├── coding_style.md ├── maintainer_guide.md ├── review_comments.md └── review_comments_example.png ├── m4 ├── .gitignore ├── ax_compare_version.m4 └── ax_compiler_vendor.m4 ├── proto ├── collectd.proto ├── prometheus.proto └── types.proto ├── src ├── aggregation.c ├── amqp.c ├── amqp1.c ├── apache.c ├── apcups.c ├── apple_sensors.c ├── aquaero.c ├── ascent.c ├── barometer.c ├── battery.c ├── battery_statefs.c ├── bind.c ├── buddyinfo.c ├── capabilities.c ├── capabilities_test.c ├── ceph.c ├── ceph_test.c ├── cgroups.c ├── check_uptime.c ├── chrony.c ├── collectd-email.pod ├── collectd-exec.pod ├── collectd-java.pod ├── collectd-lua.pod ├── collectd-nagios.c ├── collectd-nagios.pod ├── collectd-perl.pod ├── collectd-python.pod ├── collectd-snmp.pod ├── collectd-tg.c ├── collectd-tg.pod ├── collectd-threshold.pod ├── collectd-unixsock.pod ├── collectd.conf.in ├── collectd.conf.pod ├── collectd.pod ├── collectdctl.c ├── collectdctl.pod ├── collectdmon.c ├── collectdmon.pod ├── connectivity.c ├── conntrack.c ├── contextswitch.c ├── cpu.c ├── cpufreq.c ├── cpusleep.c ├── cpython.h ├── csv.c ├── curl.c ├── curl_jolokia.c ├── curl_json.c ├── curl_json_test.c ├── curl_xml.c ├── daemon │ ├── cmd.c │ ├── cmd.h │ ├── cmd_windows.c │ ├── collectd.c │ ├── collectd.h │ ├── configfile.c │ ├── configfile.h │ ├── filter_chain.c │ ├── filter_chain.h │ ├── globals.c │ ├── globals.h │ ├── plugin.c │ ├── plugin.h │ ├── plugin_mock.c │ ├── types_list.c │ ├── types_list.h │ ├── utils_cache.c │ ├── utils_cache.h │ ├── utils_cache_mock.c │ ├── utils_complain.c │ ├── utils_complain.h │ ├── utils_llist.c │ ├── utils_llist.h │ ├── utils_random.c │ ├── utils_random.h │ ├── utils_subst.c │ ├── utils_subst.h │ ├── utils_subst_test.c │ ├── utils_threshold.c │ ├── utils_threshold.h │ ├── utils_time.c │ ├── utils_time.h │ └── utils_time_test.c ├── dbi.c ├── dcpmm.c ├── df.c ├── disk.c ├── dns.c ├── dpdk_telemetry.c ├── dpdkevents.c ├── dpdkstat.c ├── drbd.c ├── email.c ├── entropy.c ├── epics.c ├── ethstat.c ├── exec.c ├── fhcount.c ├── filecount.c ├── fscache.c ├── gmond.c ├── gps.c ├── gpu_nvidia.c ├── grpc.cc ├── hddtemp.c ├── hugepages.c ├── infiniband.c ├── intel-nvme.h ├── intel_pmu.c ├── intel_pmu_test.c ├── intel_rdt.c ├── intel_rdt_test.c ├── interface.c ├── ipc.c ├── ipmi.c ├── ipstats.c ├── iptables.c ├── ipvs.c ├── irq.c ├── java.c ├── libcollectdclient │ ├── client.c │ ├── collectd │ │ ├── client.h │ │ ├── lcc_features.h.in │ │ ├── network.h │ │ ├── network_buffer.h │ │ ├── network_parse.h │ │ ├── server.h │ │ ├── stdendian.h │ │ └── types.h │ ├── libcollectdclient.pc.in │ ├── network.c │ ├── network_buffer.c │ ├── network_parse.c │ ├── network_parse_test.c │ └── server.c ├── liboconfig │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── aux_types.h │ ├── oconfig.c │ ├── oconfig.h │ ├── parser.y │ └── scanner.l ├── load.c ├── log_logstash.c ├── logfile.c ├── logparser.c ├── logparser_test.c ├── lpar.c ├── lua.c ├── madwifi.c ├── madwifi.h ├── match_empty_counter.c ├── match_hashed.c ├── match_regex.c ├── match_timediff.c ├── match_value.c ├── mbmon.c ├── mcelog.c ├── md.c ├── mdevents.c ├── mdevents_test.c ├── memcachec.c ├── memcached.c ├── memory.c ├── mic.c ├── mmc.c ├── modbus.c ├── mqtt.c ├── msr-index.h ├── multimeter.c ├── mysql.c ├── netapp.c ├── netlink.c ├── netlink_test.c ├── netstat_udp.c ├── network.c ├── network.h ├── network_test.c ├── nfs.c ├── nginx.c ├── notify_desktop.c ├── notify_email.c ├── notify_nagios.c ├── ntpd.c ├── numa.c ├── nut.c ├── nvme.h ├── olsrd.c ├── onewire.c ├── openldap.c ├── openvpn.c ├── oracle.c ├── ovs_events.c ├── ovs_stats.c ├── pcie_errors.c ├── pcie_errors_test.c ├── perl.c ├── pf.c ├── pinba.c ├── pinba.proto ├── ping.c ├── postgresql.c ├── postgresql_default.conf ├── powerdns.c ├── processes.c ├── procevent.c ├── protocols.c ├── pyconfig.c ├── python.c ├── pyvalues.c ├── ras.c ├── ras_test.c ├── redfish.c ├── redfish_test.c ├── redis.c ├── routeros.c ├── rrdcached.c ├── rrdtool.c ├── sensors.c ├── serial.c ├── sigrok.c ├── slurm.c ├── smart.c ├── smart_test.c ├── snmp.c ├── snmp_agent.c ├── snmp_agent_test.c ├── statsd.c ├── swap.c ├── synproxy.c ├── sysevent.c ├── syslog.c ├── table.c ├── tail.c ├── tail_csv.c ├── tape.c ├── target_notification.c ├── target_replace.c ├── target_scale.c ├── target_set.c ├── target_v5upgrade.c ├── tcpconns.c ├── teamspeak2.c ├── ted.c ├── testing.h ├── thermal.c ├── threshold.c ├── tokyotyrant.c ├── turbostat.c ├── types.db ├── types.db.pod ├── ubi.c ├── unixsock.c ├── uptime.c ├── users.c ├── utils │ ├── avltree │ │ ├── avltree.c │ │ ├── avltree.h │ │ └── avltree_test.c │ ├── cmds │ │ ├── cmds.c │ │ ├── cmds.h │ │ ├── cmds_test.c │ │ ├── flush.c │ │ ├── flush.h │ │ ├── getthreshold.c │ │ ├── getthreshold.h │ │ ├── getval.c │ │ ├── getval.h │ │ ├── listval.c │ │ ├── listval.h │ │ ├── parse_option.c │ │ ├── parse_option.h │ │ ├── putnotif.c │ │ ├── putnotif.h │ │ ├── putval.c │ │ ├── putval.h │ │ └── putval_test.c │ ├── common │ │ ├── common.c │ │ ├── common.h │ │ └── common_test.c │ ├── config_cores │ │ ├── config_cores.c │ │ ├── config_cores.h │ │ └── config_cores_test.c │ ├── crc32 │ │ ├── crc32.c │ │ └── crc32.h │ ├── curl_stats │ │ ├── curl_stats.c │ │ └── curl_stats.h │ ├── db_query │ │ ├── db_query.c │ │ └── db_query.h │ ├── deq │ │ └── deq.h │ ├── dmi │ │ ├── dmi.c │ │ └── dmi.h │ ├── dns │ │ ├── dns.c │ │ └── dns.h │ ├── dpdk │ │ ├── dpdk.c │ │ └── dpdk.h │ ├── format_graphite │ │ ├── format_graphite.c │ │ ├── format_graphite.h │ │ └── format_graphite_test.c │ ├── format_influxdb │ │ ├── format_influxdb.c │ │ └── format_influxdb.h │ ├── format_json │ │ ├── format_json.c │ │ ├── format_json.h │ │ └── format_json_test.c │ ├── format_kairosdb │ │ ├── format_kairosdb.c │ │ └── format_kairosdb.h │ ├── format_stackdriver │ │ ├── format_stackdriver.c │ │ ├── format_stackdriver.h │ │ └── format_stackdriver_test.c │ ├── gce │ │ ├── gce.c │ │ └── gce.h │ ├── heap │ │ ├── heap.c │ │ ├── heap.h │ │ └── heap_test.c │ ├── ignorelist │ │ ├── ignorelist.c │ │ └── ignorelist.h │ ├── latency │ │ ├── latency.c │ │ ├── latency.h │ │ ├── latency_config.c │ │ ├── latency_config.h │ │ └── latency_test.c │ ├── lookup │ │ ├── vl_lookup.c │ │ ├── vl_lookup.h │ │ └── vl_lookup_test.c │ ├── match │ │ ├── match.c │ │ └── match.h │ ├── message_parser │ │ ├── message_parser.c │ │ ├── message_parser.h │ │ └── message_parser_test.c │ ├── metadata │ │ ├── meta_data.c │ │ ├── meta_data.h │ │ └── meta_data_test.c │ ├── mount │ │ ├── mount.c │ │ ├── mount.h │ │ └── mount_test.c │ ├── oauth │ │ ├── oauth.c │ │ ├── oauth.h │ │ └── oauth_test.c │ ├── ovs │ │ ├── ovs.c │ │ └── ovs.h │ ├── proc_pids │ │ ├── proc_pids.c │ │ ├── proc_pids.h │ │ └── proc_pids_test.c │ ├── rrdcreate │ │ ├── rrdcreate.c │ │ └── rrdcreate.h │ ├── tail │ │ ├── tail.c │ │ └── tail.h │ └── taskstats │ │ ├── taskstats.c │ │ └── taskstats.h ├── utils_fbhash.c ├── utils_fbhash.h ├── utils_lua.c ├── utils_lua.h ├── utils_tail_match.c ├── utils_tail_match.h ├── uuid.c ├── valgrind.FreeBSD.suppress ├── valgrind.suppress ├── varnish.c ├── virt.c ├── virt_test.c ├── vmem.c ├── vserver.c ├── wireless.c ├── write_graphite.c ├── write_http.c ├── write_influxdb_udp.c ├── write_kafka.c ├── write_log.c ├── write_mongodb.c ├── write_prometheus.c ├── write_redis.c ├── write_riemann.c ├── write_riemann_threshold.c ├── write_riemann_threshold.h ├── write_sensu.c ├── write_stackdriver.c ├── write_syslog.c ├── write_tsdb.c ├── xencpu.c ├── xmms.c ├── zfs_arc.c ├── zone.c └── zookeeper.c ├── testwrapper.sh └── version-gen.sh /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | IncludeCategories: 4 | - Regex: '"collectd.h"' 5 | - Priority: -1 6 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | * Version of collectd: 2 | * Operating system / distribution: 3 | * Kernel version (if applicable): 4 | 5 | ## Expected behavior 6 | 7 | (Description of the behavior / output that you expected) 8 | 9 | ## Actual behavior 10 | 11 | (Description of the behavior / output that you observed) 12 | 13 | ## Steps to reproduce 14 | 15 | * step 1 16 | * step 2 17 | * step 3 18 | -------------------------------------------------------------------------------- /.github/workflows/distcheck.yml: -------------------------------------------------------------------------------- 1 | name: Check the Distribution 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | defaults: 13 | run: 14 | shell: bash 15 | 16 | jobs: 17 | make_distcheck: 18 | runs-on: ubuntu-latest 19 | container: collectd/ci:debian12 20 | env: 21 | # this env var picked up by valgrind during make check phase 22 | VALGRIND_OPTS: "--errors-for-leak-kinds=definite" 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Install bzip2 26 | run: apt install -y bzip2 27 | - name: Print available packages 28 | run: pkg-config --list-all | sort 29 | - name: Generate configure script 30 | run: ./build.sh 31 | - name: Run configure script 32 | run: ./configure 33 | - name: Run make distcheck 34 | run: make $MAKEFLAG distcheck 35 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | release: 5 | types: [released, prereleased] 6 | 7 | permissions: 8 | contents: write 9 | 10 | defaults: 11 | run: 12 | shell: bash 13 | 14 | jobs: 15 | asset: 16 | runs-on: ubuntu-latest 17 | container: collectd/ci:debian12 18 | steps: 19 | - uses: actions/checkout@v4 20 | - run: | 21 | git config --global --add safe.directory "$(pwd)" 22 | git submodule init -- opentelemetry-proto 23 | git submodule update -- opentelemetry-proto 24 | - name: Generate configure script 25 | run: ./build.sh 26 | - name: Run configure script 27 | run: ./configure 28 | - name: Run make distcheck 29 | run: make -j $(nproc) distcheck 30 | - name: Upload distribution package 31 | run: | 32 | echo "GITHUB_REF_NAME=\"${GITHUB_REF_NAME}\"" 33 | [[ -e "${GITHUB_REF_NAME:?}.tar.bz2" ]] && gh release upload "${GITHUB_REF_NAME:?}" "${GITHUB_REF_NAME:?}.tar.bz2" 34 | env: 35 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build.sh stuff: 2 | Makefile.in 3 | /INSTALL 4 | /aclocal.m4 5 | /autom4te.cache 6 | /autom4te.cache 7 | /build-aux/ 8 | /compile 9 | /config.guess 10 | /config.sub 11 | /configure 12 | /depcomp 13 | /install-sh 14 | /libltdl/ 15 | /ltmain.sh 16 | /m4/libtool.m4 17 | /m4/ltargz.m4 18 | /m4/ltdl.m4 19 | /m4/lt~obsolete.m4 20 | /m4/ltoptions.m4 21 | /m4/ltsugar.m4 22 | /m4/ltversion.m4 23 | /missing 24 | /src/config.h.in 25 | 26 | # configure stuff: 27 | Makefile 28 | config.log 29 | config.status 30 | libtool 31 | src/collectd.conf 32 | src/config.h 33 | src/libcollectdclient/libcollectdclient.pc 34 | src/stamp-h1 35 | 36 | # make stuff: 37 | *.la 38 | *.lo 39 | *.o 40 | .dirstamp 41 | .libs/ 42 | .deps/ 43 | /collectd-nagios 44 | /collectd-tg 45 | /collectdctl 46 | /collectdmon 47 | src/*.1 48 | src/*.5 49 | src/.pod2man.tmp.* 50 | src/libcollectdclient/collectd/lcc_features.h 51 | 52 | # patch stuff 53 | *.rej 54 | *.orig 55 | 56 | # lex / yacc stuff: 57 | ylwrap 58 | src/liboconfig/parser.c 59 | src/liboconfig/parser.h 60 | src/liboconfig/scanner.c 61 | 62 | # protobuf stuff: 63 | *.pb-c.[ch] 64 | *.grpc.pb.cc 65 | *.pb.cc 66 | *.pb.h 67 | 68 | # make dist stuff: 69 | /collectd-*.tar.gz 70 | /collectd-*.tar.bz2 71 | 72 | # perl stuff: 73 | /.perl-directory-stamp 74 | bindings/perl/Collectd/pm_to_blib 75 | bindings/perl/blib/ 76 | bindings/perl/pm_to_blib 77 | /buildperl 78 | 79 | # java stuff 80 | *.jar 81 | /org/collectd/api/*.class 82 | /org/collectd/java/*.class 83 | /bindings/java/java-build-stamp 84 | /classnoinst.stamp 85 | 86 | # python stuff 87 | *.pyc 88 | 89 | # backup stuff 90 | *~ 91 | 92 | # lint stuff 93 | *.ln 94 | 95 | #ide stuff 96 | .vscode 97 | 98 | # cscope stuff 99 | cscope.* 100 | 101 | # Unit tests 102 | test-suite.log 103 | src/tests/ 104 | test_* 105 | 106 | # src/daemon/... 107 | /collectd 108 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gnulib"] 2 | path = gnulib 3 | url = git://git.savannah.gnu.org/gnulib.git 4 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Anthony 2 | Florian Forster 3 | Florian Forster 4 | Luboš Staněk 5 | Luboš Staněk 6 | Niki W. Waibel 7 | Sebastian Harl 8 | Rodolphe Quiedeville 9 | 10 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code ownership information. 2 | # See 3 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 4 | # for details. 5 | 6 | # Order is important; the *last* matching pattern takes precedence. 7 | 8 | # Default 9 | # 10 | # These owners will be the default owners for everything in the repo. Unless a 11 | # later match takes precedence, @collectd/trusted-contributors will be 12 | # requested for review when someone opens a pull request. 13 | * @collectd/trusted-contributors 14 | 15 | # Per-plugin owners 16 | # 17 | # These plugins are owned by subject matter experts and require their review. 18 | /src/intel_pmu.c @collectd/intel 19 | /src/intel_rdt.c @collectd/intel 20 | /src/ipmi.c @collectd/intel 21 | /src/mcelog.c @collectd/intel 22 | /src/virt.c @collectd/intel 23 | # TODO(#2926): Add the following owners: 24 | #/src/redfish.c @collectd/intel 25 | 26 | # Core 27 | # 28 | # The daemon and some plugins with a huge "blast radius" are considered "core" 29 | # to the collectd project and require review form a "core owner". 30 | /CODEOWNERS @collectd/core-maintainers 31 | /src/daemon/ @collectd/core-maintainers 32 | /src/liboconfig/ @collectd/core-maintainers 33 | /src/cpu.c @collectd/core-maintainers 34 | /src/df.c @collectd/core-maintainers 35 | /src/disk.c @collectd/core-maintainers 36 | /src/exec.c @collectd/core-maintainers 37 | /src/interface.c @collectd/core-maintainers 38 | /src/memory.c @collectd/core-maintainers 39 | /src/network.* @collectd/core-maintainers 40 | /src/utils/avltree/ @collectd/core-maintainers 41 | /src/utils/common/ @collectd/core-maintainers 42 | /src/utils_fbhash.* @collectd/core-maintainers 43 | /src/utils/heap/ @collectd/core-maintainers 44 | /src/utils/ignorelist/ @collectd/core-maintainers 45 | /src/utils/metadata/ @collectd/core-maintainers 46 | /src/utils/mount/ @collectd/core-maintainers 47 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdConfigInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdConfigInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a config method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerConfig(String, CollectdConfigInterface) 34 | */ 35 | public interface CollectdConfigInterface 36 | { 37 | public int config (OConfigItem ci); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdFlushInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdFlushInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a flush method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerFlush 34 | */ 35 | public interface CollectdFlushInterface 36 | { 37 | public int flush (Number timeout, String identifier); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdInitInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdInitInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing an init method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerInit 34 | */ 35 | public interface CollectdInitInterface 36 | { 37 | public int init (); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdLogInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdLogInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a log method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerLog 34 | */ 35 | public interface CollectdLogInterface 36 | { 37 | public void log (int severity, String message); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdMatchFactoryInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdMatchFactoryInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a "match factory". 31 | * 32 | * Objects implementing this interface are used to create objects implementing 33 | * the CollectdMatchInterface interface. 34 | * 35 | * @author Florian Forster <octo at collectd.org> 36 | * @see CollectdMatchInterface 37 | * @see Collectd#registerMatch 38 | */ 39 | public interface CollectdMatchFactoryInterface 40 | { 41 | /** 42 | * Create a new "match" object. 43 | * 44 | * This method uses the configuration provided as argument to create a 45 | * new object which must implement the {@link CollectdMatchInterface} 46 | * interface. 47 | * 48 | * This function corresponds to the create member of the 49 | * src/filter_chain.h:match_proc_t struct. 50 | * 51 | * @return New {@link CollectdMatchInterface} object. 52 | */ 53 | public CollectdMatchInterface createMatch (OConfigItem ci); 54 | } 55 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdMatchInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdMatchInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a match method. 31 | * 32 | * These objects are instantiated using objects which implement the 33 | * CollectdMatchFactoryInterface interface. They are not instantiated by the 34 | * daemon directly! 35 | * 36 | * @author Florian Forster <octo at collectd.org> 37 | * @see CollectdMatchFactoryInterface 38 | * @see Collectd#registerMatch 39 | */ 40 | public interface CollectdMatchInterface 41 | { 42 | /** 43 | * Callback method for matches. 44 | * 45 | * This method is called to decide whether or not a given ValueList 46 | * matches or not. How this is determined is the is the main part of 47 | * this function. 48 | * 49 | * @return One of {@link Collectd#FC_MATCH_NO_MATCH} and {@link Collectd#FC_MATCH_MATCHES}. 50 | * @see CollectdMatchFactoryInterface 51 | */ 52 | public int match (DataSet ds, ValueList vl); 53 | } /* public interface CollectdMatchInterface */ 54 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdNotificationInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdNotificationInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a notification method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerNotification 34 | */ 35 | public interface CollectdNotificationInterface 36 | { 37 | public int notification (Notification n); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdReadInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdReadInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a read method. 31 | * 32 | * Objects implementing this interface can be registered with the daemon. Their 33 | * read method is then called periodically to acquire and submit values. 34 | * 35 | * @author Florian Forster <octo at collectd.org> 36 | * @see Collectd#registerRead 37 | */ 38 | public interface CollectdReadInterface 39 | { 40 | /** 41 | * Callback method for read plugins. 42 | * 43 | * This method is called once every few seconds (depends on the 44 | * configuration of the daemon). It is supposed to gather values in 45 | * some way and submit them to the daemon using 46 | * {@link Collectd#dispatchValues}. 47 | * 48 | * @return zero when successful, non-zero when an error occurred. 49 | * @see Collectd#dispatchValues 50 | */ 51 | public int read (); 52 | } 53 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdShutdownInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdShutdownInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a shutdown method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerShutdown 34 | */ 35 | public interface CollectdShutdownInterface 36 | { 37 | public int shutdown (); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdTargetFactoryInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdTargetFactoryInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a "target factory". 31 | * 32 | * Objects implementing this interface are used to create objects implementing 33 | * the CollectdTargetInterface interface. 34 | * 35 | * @author Florian Forster <octo at collectd.org> 36 | * @see CollectdTargetInterface 37 | * @see Collectd#registerTarget 38 | */ 39 | public interface CollectdTargetFactoryInterface 40 | { 41 | /** 42 | * Create a new "target" object. 43 | * 44 | * This method uses the configuration provided as argument to create a 45 | * new object which must implement the {@link CollectdTargetInterface} 46 | * interface. 47 | * 48 | * This function corresponds to the {@code create} member of the 49 | * {@code src/filter_chain.h:target_proc_t} struct. 50 | * 51 | * @return New {@link CollectdTargetInterface} object. 52 | */ 53 | public CollectdTargetInterface createTarget (OConfigItem ci); 54 | } 55 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdTargetInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdTargetInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a target method. 31 | * 32 | * These objects are instantiated using objects which implement the 33 | * CollectdTargetFactoryInterface interface. They are not instantiated by the 34 | * daemon directly! 35 | * 36 | * @author Florian Forster <octo at collectd.org> 37 | * @see CollectdTargetFactoryInterface 38 | * @see Collectd#registerTarget 39 | */ 40 | public interface CollectdTargetInterface 41 | { 42 | /** 43 | * Callback method for targets. 44 | * 45 | * This method is called to perform some action on the given ValueList. 46 | * What precisely is done depends entirely on the implementing class. 47 | * 48 | * @return One of: {@link Collectd#FC_TARGET_CONTINUE}, 49 | * {@link Collectd#FC_TARGET_STOP}, {@link Collectd#FC_TARGET_RETURN} 50 | * @see CollectdTargetFactoryInterface 51 | */ 52 | public int invoke (DataSet ds, ValueList vl); 53 | } /* public interface CollectdTargetInterface */ 54 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/CollectdWriteInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - bindings/java/org/collectd/api/CollectdWriteInterface.java 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | package org.collectd.api; 28 | 29 | /** 30 | * Interface for objects implementing a write method. 31 | * 32 | * @author Florian Forster <octo at collectd.org> 33 | * @see Collectd#registerWrite 34 | */ 35 | public interface CollectdWriteInterface 36 | { 37 | public int write (ValueList vl); 38 | } 39 | -------------------------------------------------------------------------------- /bindings/java/org/collectd/api/Notification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * jcollectd 3 | * Copyright (C) 2009 Hyperic, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; only version 2 of the License is applicable. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | package org.collectd.api; 20 | 21 | /** 22 | * Java representation of collectd/src/plugin.h:notfication_t structure. 23 | */ 24 | public class Notification extends PluginData { 25 | public static final int FAILURE = 1; 26 | public static final int WARNING = 2; 27 | public static final int OKAY = 4; 28 | 29 | public static String[] SEVERITY = { 30 | "FAILURE", 31 | "WARNING", 32 | "OKAY", 33 | "UNKNOWN" 34 | }; 35 | 36 | private int _severity; 37 | private String _message; 38 | 39 | public Notification () { 40 | _severity = 0; 41 | _message = "Initial notification message"; 42 | } 43 | 44 | public Notification (PluginData pd) { 45 | super (pd); 46 | _severity = 0; 47 | _message = "Initial notification message"; 48 | } 49 | 50 | public void setSeverity (int severity) { 51 | if ((severity == FAILURE) 52 | || (severity == WARNING) 53 | || (severity == OKAY)) 54 | this._severity = severity; 55 | } 56 | 57 | public int getSeverity() { 58 | return _severity; 59 | } 60 | 61 | public String getSeverityString() { 62 | switch (_severity) { 63 | case FAILURE: 64 | return SEVERITY[0]; 65 | case WARNING: 66 | return SEVERITY[1]; 67 | case OKAY: 68 | return SEVERITY[2]; 69 | default: 70 | return SEVERITY[3]; 71 | } 72 | } 73 | 74 | public void setMessage (String message) { 75 | this._message = message; 76 | } 77 | 78 | public String getMessage() { 79 | return _message; 80 | } 81 | 82 | public String toString() { 83 | StringBuffer sb = new StringBuffer(super.toString()); 84 | sb.append(" [").append(getSeverityString()).append("] "); 85 | sb.append(_message); 86 | return sb.toString(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /bindings/perl/Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | 3 | WriteMakefile( 4 | NAME => 'Collectd', 5 | AUTHOR => 'Sebastian Harl ', 6 | TEST_REQUIRES => { 'YAML::Any' => 0 }, 7 | ); 8 | 9 | # vim: set sw=4 ts=4 tw=78 noexpandtab : 10 | -------------------------------------------------------------------------------- /bindings/perl/t/00_load.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More tests => 1; 6 | use_ok 'Collectd::Unixsock'; 7 | -------------------------------------------------------------------------------- /bindings/perl/t/01_methods.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More tests => 14; 6 | use Collectd::Unixsock; 7 | use Collectd::MockDaemon; 8 | 9 | my $path = mockd_start(); 10 | END { mockd_stop(); } 11 | 12 | sub test_query { 13 | my ($s, $attr, $results) = @_; 14 | my ($nresults, $resultdata) = @$results; 15 | my $r = $s->getval(%{Collectd::Unixsock::_parse_identifier($attr)}); 16 | is(ref $r, 'HASH', "Got a result for $attr"); 17 | is(scalar keys %$r, $nresults, "$nresults result result for $attr"); 18 | is_deeply($r, $resultdata, "Data or $attr matches"); 19 | } 20 | 21 | my $s = Collectd::Unixsock->new($path); 22 | isnt($s, undef, "Collectd::Unixsock object created"); 23 | 24 | my %queries = ( 25 | 'w83df6600/vmem/vmpage_number-vmscan_write' => [ 1, { value => 0 } ], 26 | 'a1d8f6310/load/load' => [ 3, { longterm => '0.07', shortterm => 0, midterm => '0.06' } ], 27 | 'w83df6600/disk-sda/disk_octets' => [ 2, { read => 0, write => 0 } ], 28 | ); 29 | 30 | test_query($s, $_, $queries{$_}) for sort keys %queries; 31 | 32 | my @values = $s->listval; 33 | is(scalar @values, 4984, "Correct number of results from LISTVAL"); 34 | is_deeply($values[1234], { 35 | type_instance => 'nice', 36 | plugin_instance => 21, 37 | plugin => 'cpu', 38 | type => 'cpu', 39 | host => 'h2gdf6120', 40 | time => 1479835354.434, 41 | }, "Correct data returned for select element"); 42 | @values = (); 43 | 44 | is_deeply([ $s->listval_filter() ] , [ $s->listval ], "listval_filter() w/o filter equivalent to listval()"); 45 | is_deeply( 46 | [ $s->listval_filter(host => 'a1d8f6310', plugin => 'disk', plugin_instance => 'vda6') ], 47 | [ 48 | { 'plugin_instance' => 'vda6', 'type' => 'disk_merged', 'plugin' => 'disk', 'host' => 'a1d8f6310', time => 1479835354.434 }, 49 | { 'host' => 'a1d8f6310', 'plugin' => 'disk', 'plugin_instance' => 'vda6', 'type' => 'disk_octets', time => 1479835356 }, 50 | { 'type' => 'disk_ops', 'plugin_instance' => 'vda6', 'plugin' => 'disk', 'host' => 'a1d8f6310', time => 1479835354 }, 51 | { 'plugin' => 'disk', 'host' => 'a1d8f6310', 'type' => 'disk_time', 'plugin_instance' => 'vda6', time => 1479835354 } 52 | ], 53 | "Correct result from listval_filter on , and " 54 | ); 55 | 56 | # TODO more test for putval() and the like 57 | 58 | -------------------------------------------------------------------------------- /bindings/perl/uninstall_mod.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | use strict; 4 | use ExtUtils::Installed; 5 | 6 | my $mod = $ARGV[0] || die "Usage : $0 Module\n"; 7 | my $inst = ExtUtils::Installed->new(); 8 | unlink $inst->files($mod), $inst->packlist($mod)->packlist_file(); 9 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -x 4 | 5 | true \ 6 | && rm -f aclocal.m4 \ 7 | && rm -f -r autom4te.cache \ 8 | && rm -f collectd-*.tar.bz2 \ 9 | && rm -f collectd-*.tar.gz \ 10 | && rm -f compile \ 11 | && rm -f config.guess \ 12 | && rm -f config.log \ 13 | && rm -f config.status \ 14 | && rm -f config.sub \ 15 | && rm -f configure \ 16 | && rm -f depcomp \ 17 | && rm -f install-sh \ 18 | && rm -f libtool \ 19 | && rm -f ltmain.sh \ 20 | && rm -f Makefile \ 21 | && rm -f Makefile.in \ 22 | && rm -f missing \ 23 | && rm -f INSTALL \ 24 | && rm -f -r src/.deps \ 25 | && rm -f -r src/.libs \ 26 | && rm -f src/*.o \ 27 | && rm -f src/*.la \ 28 | && rm -f src/*.lo \ 29 | && rm -f src/collectd.1 \ 30 | && rm -f src/collectd.conf \ 31 | && rm -f src/collectdctl \ 32 | && rm -f src/collectd-tg \ 33 | && rm -f src/collectd-nagios \ 34 | && rm -f src/collectdmon \ 35 | && rm -f src/config.h \ 36 | && rm -f src/config.h.in \ 37 | && rm -f src/config.h.in~ \ 38 | && rm -f src/Makefile \ 39 | && rm -f src/Makefile.in \ 40 | && rm -f src/stamp-h1 \ 41 | && rm -f src/stamp-h1.in \ 42 | && rm -f src/*.pb-c.c \ 43 | && rm -f src/*.pb-c.h \ 44 | && rm -f src/Makefile.in \ 45 | && rm -f src/test-suite.log \ 46 | && rm -f src/test_common* \ 47 | && rm -f src/test_utils* \ 48 | && rm -f -r src/tests/.deps \ 49 | && rm -f -r src/tests/mock/.deps \ 50 | && rm -f src/tests/*.o \ 51 | && rm -f src/tests/mock/*.o \ 52 | && rm -f -r src/daemon/.deps \ 53 | && rm -f -r src/daemon/.libs \ 54 | && rm -f src/daemon/*.o \ 55 | && rm -f src/daemon/*.la \ 56 | && rm -f src/daemon/*.lo \ 57 | && rm -f src/daemon/collectd \ 58 | && rm -f src/daemon/Makefile.in \ 59 | && rm -f src/daemon/Makefile \ 60 | && rm -f src/liboconfig/*.o \ 61 | && rm -f src/liboconfig/*.la \ 62 | && rm -f src/liboconfig/*.lo \ 63 | && rm -f -r src/liboconfig/.libs \ 64 | && rm -f -r src/liboconfig/Makefile \ 65 | && rm -f -r src/liboconfig/Makefile.in \ 66 | && rm -f -r src/liboconfig/parser.c \ 67 | && rm -f -r src/liboconfig/parser.h \ 68 | && rm -f -r src/liboconfig/scanner.c \ 69 | && rm -f -r src/libping/.libs \ 70 | && rm -f src/libping/*.o \ 71 | && rm -f src/libping/*.la \ 72 | && rm -f src/libping/*.lo \ 73 | && rm -f src/libping/config.h \ 74 | && rm -f src/libping/config.h.in \ 75 | && rm -f src/libping/Makefile \ 76 | && rm -f src/libping/Makefile.in \ 77 | && rm -f src/libping/stamp-h2 \ 78 | && rm -f -r src/libcollectdclient/.libs \ 79 | && rm -f src/libcollectdclient/*.o \ 80 | && rm -f src/libcollectdclient/*.la \ 81 | && rm -f src/libcollectdclient/*.lo \ 82 | && rm -f src/libcollectdclient/Makefile \ 83 | && rm -f src/libcollectdclient/Makefile.in \ 84 | && rm -f src/libcollectdclient/collectd/lcc_features.h \ 85 | && rm -f src/libcollectdclient/libcollectdclient.pc \ 86 | && rm -f bindings/Makefile \ 87 | && rm -f bindings/Makefile.in \ 88 | && rm -f -r bindings/java/.libs \ 89 | && rm -f bindings/java/Makefile \ 90 | && rm -f bindings/java/Makefile.in \ 91 | && rm -f bindings/java/java-build-stamp \ 92 | && rm -f bindings/java/org/collectd/api/*.class \ 93 | && rm -f bindings/java/org/collectd/java/*.class \ 94 | && rm -f bindings/.perl-directory-stamp \ 95 | && rm -f -r bindings/buildperl 96 | -------------------------------------------------------------------------------- /contrib/99-storage-collectd.rules: -------------------------------------------------------------------------------- 1 | # Using ID_SERIAL attribute for naming disks in collectd results in 2 | # data about the whole disk and each partition being mixed together 3 | # incorrectly, see: https://github.com/collectd/collectd/issues/823 4 | # 5 | # The rules below provide a ID_COLLECTD attribute instead, which 6 | # differentiates between the whole disk and its particular partitions. 7 | 8 | ACTION=="remove", GOTO="collectd_end" 9 | 10 | SUBSYSTEM!="block", GOTO="collectd_end" 11 | 12 | ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", ENV{ID_COLLECTD}="$env{ID_SERIAL}-disk" 13 | ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", ENV{PARTN}=="?*", ENV{ID_COLLECTD}="$env{ID_SERIAL}-part$env{PARTN}" 14 | 15 | LABEL="collectd_end" 16 | -------------------------------------------------------------------------------- /contrib/SpamAssassin/example.cf: -------------------------------------------------------------------------------- 1 | collectd_buffersize 256 2 | collectd_socket /var/run/collectd-email 3 | collectd_timeout 2 4 | collectd_retries 3 5 | 6 | -------------------------------------------------------------------------------- /contrib/add_rra.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INPUT=$1 4 | OUTPUT=$2 5 | 6 | if [ -z "$INPUT" -o -z "$OUTPUT" ] 7 | then 8 | cat < 10 | USAGE 11 | exit 1 12 | fi 13 | 14 | if [ ! -e "$INPUT" ] 15 | then 16 | echo "No such file: $INPUT" 17 | exit 1 18 | fi 19 | 20 | if [ -e "$OUTPUT" ] 21 | then 22 | echo "File exists: $OUTPUT" 23 | exit 1 24 | fi 25 | 26 | NUM_DS=0 27 | rrdtool dump "$INPUT" | while read LINE 28 | do 29 | echo "$LINE" 30 | 31 | if [ "$LINE" = "" ] 32 | then 33 | NUM_DS=$(($NUM_DS + 1)) 34 | fi 35 | 36 | if [ "$LINE" = "" ] 37 | then 38 | for CF in MIN MAX AVERAGE 39 | do 40 | cat < 42 | $CF 43 | 1 44 | 0.0000000000e+00 45 | 46 | 47 | RRA 48 | for ((i=0; i < $NUM_DS; i++)) 49 | do 50 | echo " NaN 1 " 51 | done 52 | echo " " 53 | echo " " 54 | 55 | DS_VALUES=`for ((i=0; i < $NUM_DS; i++)); do echo -n " NaN "; done` 56 | for ((i=0; i < 2200; i++)) 57 | do 58 | echo " $DS_VALUES" 59 | done 60 | echo " " 61 | echo " " 62 | done 63 | fi 64 | done >"$OUTPUT.xml" 65 | 66 | rrdtool restore "$OUTPUT.xml" "$OUTPUT" -r >/dev/null 67 | rm -f "$OUTPUT.xml" 68 | -------------------------------------------------------------------------------- /contrib/aix/collectd.spec: -------------------------------------------------------------------------------- 1 | 2 | %define name collectd 3 | %define version 4.10.1 4 | %define release 1 5 | 6 | Name: %{name} 7 | Summary: Statistics collection daemon for filling RRD files. 8 | Version: %{version} 9 | Release: %{release} 10 | #Source: http://collectd.org/files/%{name}-%{version}.tar.gz 11 | Source0: %{name}-%{version}.tar.gz 12 | Group: System Environment/Daemons 13 | BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot 14 | License: GPL 15 | BuildPrereq: rrdtool-devel,net-snmp-devel 16 | Requires: rrdtool,net-snmp 17 | Packager: Aurelien Reynaud 18 | Vendor: collectd development team 19 | 20 | %description 21 | collectd is a small daemon which collects system information periodically and 22 | provides mechanisms to monitor and store the values in a variety of ways. It 23 | is written in C for performance. Since the daemon doesn't need to startup 24 | every time it wants to update the values it's very fast and easy on the 25 | system. Also, the statistics are very fine grained since the files are updated 26 | every 10 seconds. 27 | 28 | %prep 29 | %setup 30 | 31 | %build 32 | # The RM variable in the RPM environment conflicts with that of the build environment, 33 | # at least when building on AIX 6.1. This is definitely a bug in one of the tools but 34 | # for now we work around it by unsetting the variable below. 35 | [ -n "$RM" ] && unset RM 36 | ./configure LDFLAGS="-Wl,-brtl" --prefix=/opt/freeware --mandir=/opt/freeware/man --disable-dns --with-libnetsnmp=/opt/freeware/bin/net-snmp-config 37 | make 38 | 39 | %install 40 | make install DESTDIR=$RPM_BUILD_ROOT 41 | mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/%{name} 42 | mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/run 43 | mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d 44 | cp contrib/aix/init.d-collectd $RPM_BUILD_ROOT/etc/rc.d/init.d/collectd 45 | 46 | %clean 47 | [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT" 48 | 49 | %files 50 | %defattr(-,root,system) 51 | %doc AUTHORS COPYING ChangeLog INSTALL NEWS README 52 | %config(noreplace) %attr(0644,root,system) %{_sysconfdir}/collectd.conf 53 | %attr(0755,root,system) /etc/rc.d/init.d/collectd 54 | %attr(0755,root,system) %{_sbindir}/collectd 55 | %attr(0755,root,system) %{_bindir}/collectd-nagios 56 | %attr(0755,root,system) %{_sbindir}/collectdmon 57 | %attr(0644,root,system) %{_mandir}/man1/* 58 | %attr(0644,root,system) %{_mandir}/man5/* 59 | 60 | # client 61 | %attr(0644,root,system) %{_includedir}/%{name}/client.h 62 | %attr(0644,root,system) %{_includedir}/%{name}/lcc_features.h 63 | 64 | %attr(0644,root,system) %{_libdir}/libcollectdclient.* 65 | %attr(0644,root,system) %{_libdir}/pkgconfig/libcollectdclient.pc 66 | 67 | %attr(0444,root,system) %{_libdir}/%{name}/*.so 68 | %attr(0444,root,system) %{_libdir}/%{name}/*.a 69 | %attr(0444,root,system) %{_libdir}/%{name}/*.la 70 | 71 | %attr(0644,root,system) %{_datadir}/%{name}/types.db 72 | 73 | %dir %{_localstatedir}/lib/%{name} 74 | %dir %{_localstatedir}/run 75 | 76 | -------------------------------------------------------------------------------- /contrib/aix/init.d-collectd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # description: collectd startup script 4 | # 5 | # March 2010, Aurelien Reynaud 6 | # 7 | 8 | # Some plugins need libs in non-standard paths 9 | case `uname` in 10 | SunOS) 11 | LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/ssl/lib" 12 | export LD_LIBRARY_PATH 13 | ;; 14 | *) 15 | ;; 16 | esac 17 | 18 | # Set umask 19 | umask 022 20 | 21 | COLLECTD_BIN=/opt/freeware/sbin/collectd 22 | PIDFILE=/opt/freeware/var/run/collectd.pid 23 | 24 | # Check for missing binaries (stale symlinks should not happen) 25 | if [ ! -x $COLLECTD_BIN ]; then 26 | echo "$COLLECTD_BIN not installed" 27 | [ "$1" = "stop" ] && exit 0 28 | exit 5 29 | fi 30 | 31 | # Check for existence of needed config file and read it 32 | COLLECTD_CONFIG=/opt/freeware/etc/collectd.conf 33 | if [ ! -r $COLLECTD_CONFIG ]; then 34 | echo "$COLLECTD_CONFIG not existing" 35 | [ "$1" = "stop" ] && exit 0 36 | exit 6 37 | fi 38 | 39 | case "$1" in 40 | start) 41 | if [ -r $PIDFILE ]; then 42 | echo "collectd daemon is already running with PID `cat $PIDFILE`." 43 | exit 1 44 | fi 45 | echo "Starting collectd..." 46 | 47 | ## Start daemon 48 | $COLLECTD_BIN 49 | ;; 50 | stop) 51 | echo "Shutting down collectd daemon... " 52 | ## Stop daemon. 53 | if [ -r $PIDFILE ]; then 54 | pid=`cat $PIDFILE` 55 | kill -15 $pid 56 | while ps -p $pid >/dev/null; do 57 | sleep 1 58 | done 59 | rm -f $PIDFILE 60 | fi 61 | ;; 62 | status) 63 | if [ -r $PIDFILE ]; then 64 | echo "collectd daemon is running with PID `cat $PIDFILE`." 65 | else 66 | echo "collectd daemon is not running." 67 | fi 68 | ;; 69 | restart) 70 | ## Stop the service and regardless of whether it was 71 | ## running or not, start it again. 72 | $0 stop 73 | $0 start 74 | ;; 75 | *) 76 | echo "Usage: $0 {start|stop|status|restart}" 77 | exit 1 78 | ;; 79 | esac 80 | -------------------------------------------------------------------------------- /contrib/collectd2html.pl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octo/collectd/3a3ef49092b924afe9a3351c73206cad96e625d3/contrib/collectd2html.pl -------------------------------------------------------------------------------- /contrib/collection.conf: -------------------------------------------------------------------------------- 1 | datadir: "/opt/collectd/var/lib/collectd/rrd/" 2 | libdir: "/opt/collectd/lib/collectd/" 3 | 4 | -------------------------------------------------------------------------------- /contrib/collection3/README: -------------------------------------------------------------------------------- 1 | collection3 - Web frontend for collectd 2 | ========================================= 3 | http://collectd.org/ 4 | 5 | About 6 | ----- 7 | 8 | collection3 is a graphing front-end for the RRD files created by and filled 9 | with collectd. It is written in Perl and should be run as an CGI-script. 10 | Graphs are generated on-the-fly, so no cron job or similar is necessary. 11 | 12 | Layout 13 | ------ 14 | 15 | The files used by collection3 are organized in a typical UNIX fashion: The 16 | configuration resides in etc/, executable scripts are in bin/, supplementary 17 | Perl modules are in lib/ and static data for displaying the web page are in 18 | share/. 19 | 20 | All files in all subdirectories except bin/ should NOT be executable. 21 | Ideally, the webserver should not serve them either. Consider using 22 | `.htaccess' files or other means to configure the web server to deny access 23 | to these directories. 24 | 25 | Dependencies 26 | ------------ 27 | 28 | collection3 depends on the following Perl modules not included in the Perl 29 | distribution itself: 30 | 31 | * Config::General 32 | * Regexp::Common 33 | * HTML::Entities 34 | * RRDs 35 | 36 | Copyright and License 37 | --------------------- 38 | 39 | Copyright (C) 2008 Florian octo Forster 40 | 41 | collection3 is provided under the terms of the GNU General Public License, 42 | version 2 (GPLv2). 43 | 44 | -------------------------------------------------------------------------------- /contrib/collection3/bin/.htaccess: -------------------------------------------------------------------------------- 1 | Options +ExecCGI 2 | AddHandler cgi-script .cgi 3 | -------------------------------------------------------------------------------- /contrib/collection3/etc/.htaccess: -------------------------------------------------------------------------------- 1 | Deny from all 2 | -------------------------------------------------------------------------------- /contrib/collection3/lib/.htaccess: -------------------------------------------------------------------------------- 1 | Deny from all 2 | -------------------------------------------------------------------------------- /contrib/collection3/lib/Collectd/Graph/Type/Df.pm: -------------------------------------------------------------------------------- 1 | package Collectd::Graph::Type::Df; 2 | 3 | # Copyright (C) 2008,2009 Florian octo Forster 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation; only version 2 of the License is applicable. 8 | # 9 | # This program is distributed in the hope that it will be useful, but WITHOUT 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 12 | # details. 13 | # 14 | # You should have received a copy of the GNU General Public License along with 15 | # this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | use strict; 19 | use warnings; 20 | use base ('Collectd::Graph::Type'); 21 | 22 | use Collectd::Graph::Common (qw(ident_to_filename get_faded_color)); 23 | 24 | return (1); 25 | 26 | sub getDataSources 27 | { 28 | return ([qw(free used)]); 29 | } # getDataSources 30 | 31 | sub new 32 | { 33 | my $pkg = shift; 34 | my $obj = Collectd::Graph::Type->new (@_); 35 | $obj->{'data_sources'} = [qw(free used)]; 36 | $obj->{'rrd_opts'} = ['-v', 'Bytes']; 37 | $obj->{'rrd_title'} = 'Disk space ({instance})'; 38 | $obj->{'rrd_format'} = '%5.1lf%sB'; 39 | $obj->{'colors'} = [qw(00b000 ff0000)]; 40 | 41 | return (bless ($obj, $pkg)); 42 | } # new 43 | 44 | sub getRRDArgs 45 | { 46 | my $obj = shift; 47 | my $index = shift; 48 | 49 | my $ident = $obj->{'files'}[$index]; 50 | if (!$ident) 51 | { 52 | cluck ("Invalid index: $index"); 53 | return; 54 | } 55 | my $filename = ident_to_filename ($ident); 56 | $filename =~ s#:#\\:#g; 57 | 58 | my $faded_green = get_faded_color ('00ff00'); 59 | my $faded_red = get_faded_color ('ff0000'); 60 | 61 | return (['-t', $obj->getTitle ($ident), '-v', 'Bytes', '-l', '0', 62 | "DEF:free_min=${filename}:free:MIN", 63 | "DEF:free_avg=${filename}:free:AVERAGE", 64 | "DEF:free_max=${filename}:free:MAX", 65 | "DEF:used_min=${filename}:used:MIN", 66 | "DEF:used_avg=${filename}:used:AVERAGE", 67 | "DEF:used_max=${filename}:used:MAX", 68 | "CDEF:both_avg=free_avg,used_avg,+", 69 | "AREA:both_avg#${faded_green}", 70 | "AREA:used_avg#${faded_red}", 71 | 'LINE1:both_avg#00ff00:Free', 72 | 'GPRINT:free_min:MIN:%5.1lf%sB Min,', 73 | 'GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,', 74 | 'GPRINT:free_max:MAX:%5.1lf%sB Max,', 75 | 'GPRINT:free_avg:LAST:%5.1lf%sB Last\l', 76 | 'LINE1:used_avg#ff0000:Used', 77 | 'GPRINT:used_min:MIN:%5.1lf%sB Min,', 78 | 'GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,', 79 | 'GPRINT:used_max:MAX:%5.1lf%sB Max,', 80 | 'GPRINT:used_avg:LAST:%5.1lf%sB Last\l']); 81 | } # getRRDArgs 82 | 83 | # vim: set shiftwidth=2 softtabstop=2 tabstop=8 : 84 | -------------------------------------------------------------------------------- /contrib/collection3/lib/Collectd/Graph/Type/Load.pm: -------------------------------------------------------------------------------- 1 | package Collectd::Graph::Type::Load; 2 | 3 | use strict; 4 | use warnings; 5 | use base ('Collectd::Graph::Type'); 6 | 7 | use Collectd::Graph::Common (qw($ColorCanvas ident_to_filename get_faded_color)); 8 | 9 | return (1); 10 | 11 | sub new 12 | { 13 | my $pkg = shift; 14 | my $obj = Collectd::Graph::Type->new (@_); 15 | $obj->{'data_sources'} = [qw(shortterm midterm longterm)]; 16 | $obj->{'rrd_opts'} = ['-v', 'System load']; 17 | $obj->{'rrd_title'} = 'System load'; 18 | $obj->{'rrd_format'} = '%.2lf'; 19 | $obj->{'colors'} = [qw(00ff00 0000ff ff0000)]; 20 | 21 | return (bless ($obj, $pkg)); 22 | } # new 23 | 24 | sub getRRDArgs 25 | { 26 | my $obj = shift; 27 | my $index = shift; 28 | 29 | my $ident = $obj->{'files'}[$index]; 30 | if (!$ident) 31 | { 32 | cluck ("Invalid index: $index"); 33 | return; 34 | } 35 | my $filename = ident_to_filename ($ident); 36 | $filename =~ s#:#\\:#g; 37 | 38 | my $faded_green = get_faded_color ('00ff00'); 39 | 40 | return (['-t', 'System load', '-v', 'System load', 41 | "DEF:s_min=${filename}:shortterm:MIN", 42 | "DEF:s_avg=${filename}:shortterm:AVERAGE", 43 | "DEF:s_max=${filename}:shortterm:MAX", 44 | "DEF:m_min=${filename}:midterm:MIN", 45 | "DEF:m_avg=${filename}:midterm:AVERAGE", 46 | "DEF:m_max=${filename}:midterm:MAX", 47 | "DEF:l_min=${filename}:longterm:MIN", 48 | "DEF:l_avg=${filename}:longterm:AVERAGE", 49 | "DEF:l_max=${filename}:longterm:MAX", 50 | "AREA:s_max#${faded_green}", 51 | "AREA:s_min#${ColorCanvas}", 52 | "LINE1:s_avg#00ff00: 1 min", 53 | "GPRINT:s_min:MIN:%.2lf Min,", 54 | "GPRINT:s_avg:AVERAGE:%.2lf Avg,", 55 | "GPRINT:s_max:MAX:%.2lf Max,", 56 | "GPRINT:s_avg:LAST:%.2lf Last\\l", 57 | "LINE1:m_avg#0000ff: 5 min", 58 | "GPRINT:m_min:MIN:%.2lf Min,", 59 | "GPRINT:m_avg:AVERAGE:%.2lf Avg,", 60 | "GPRINT:m_max:MAX:%.2lf Max,", 61 | "GPRINT:m_avg:LAST:%.2lf Last\\l", 62 | "LINE1:l_avg#ff0000:15 min", 63 | "GPRINT:l_min:MIN:%.2lf Min,", 64 | "GPRINT:l_avg:AVERAGE:%.2lf Avg,", 65 | "GPRINT:l_max:MAX:%.2lf Max,", 66 | "GPRINT:l_avg:LAST:%.2lf Last\\l"]); 67 | } # sub getRRDArgs 68 | 69 | # vim: set shiftwidth=2 softtabstop=2 tabstop=8 : 70 | -------------------------------------------------------------------------------- /contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm: -------------------------------------------------------------------------------- 1 | package Collectd::Graph::Type::Wirkleistung; 2 | 3 | # Copyright (C) 2009 Stefan Pfab 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation; only version 2 of the License is applicable. 8 | # 9 | # This program is distributed in the hope that it will be useful, but WITHOUT 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 12 | # details. 13 | # 14 | # You should have received a copy of the GNU General Public License along with 15 | # this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | use strict; 19 | use warnings; 20 | use base ('Collectd::Graph::Type'); 21 | 22 | use Collectd::Graph::Common (qw(ident_to_filename get_faded_color)); 23 | 24 | return (1); 25 | 26 | sub getDataSources 27 | { 28 | return ([qw(wirkleistung)]); 29 | } # getDataSources 30 | 31 | sub new 32 | { 33 | my $pkg = shift; 34 | my $obj = Collectd::Graph::Type->new (@_); 35 | $obj->{'data_sources'} = [qw(wirkleistung)]; 36 | $obj->{'rrd_opts'} = ['-v', 'Watt']; 37 | $obj->{'rrd_title'} = 'Wirkleistung ({type_instance})'; 38 | $obj->{'rrd_format'} = '%5.1lf%s W'; 39 | $obj->{'colors'} = [qw(000000 f00000)]; 40 | 41 | return (bless ($obj, $pkg)); 42 | } # new 43 | 44 | sub getRRDArgs 45 | { 46 | my $obj = shift; 47 | my $index = shift; 48 | 49 | my $ident = $obj->{'files'}[$index]; 50 | if (!$ident) 51 | { 52 | cluck ("Invalid index: $index"); 53 | return; 54 | } 55 | my $filename = ident_to_filename ($ident); 56 | $filename =~ s#:#\\:#g; 57 | 58 | my $faded_green = get_faded_color ('00ff00'); 59 | my $faded_red = get_faded_color ('ff0000'); 60 | 61 | return (['-t', 'Wirkleistung (' . $ident->{'type_instance'} . ')', '-v', 'Watt', '-l', '0', 62 | "DEF:min0=${filename}:kWh:MIN", 63 | "DEF:avg0=${filename}:kWh:AVERAGE", 64 | "DEF:max0=${filename}:kWh:MAX", 65 | 'AREA:max0#bfbfbf', 66 | 'AREA:min0#FFFFFF', 67 | 'CDEF:watt_avg0=avg0,36000,*,', 68 | 'CDEF:watt_min0=min0,36000,*,', 69 | 'CDEF:watt_max0=max0,36000,*,', 70 | 'CDEF:watt_total=avg0,10,*,', 71 | 'VDEF:total=watt_total,TOTAL', 72 | 'VDEF:first=watt_total,FIRST', 73 | 'VDEF:last=watt_total,LAST', 74 | #'CDEF:first_value=first,POP', 75 | #'CDEF:first_time=first,POP', 76 | 'LINE1:watt_avg0#000000:W', 77 | 'HRULE:190#ff0000', 78 | 'GPRINT:watt_min0:MIN:%4.1lfW Min,', 79 | 'GPRINT:watt_avg0:AVERAGE:%4.1lfW Avg,', 80 | 'GPRINT:watt_max0:MAX:%4.1lfW Max,', 81 | 'GPRINT:watt_avg0:LAST:%4.1lfW Last\l', 82 | 'GPRINT:total:%4.1lf%sWh Gesamtverbrauch im angezeigten Zeitraum\l', 83 | 'GPRINT:first:erster Wert %c:strftime', 84 | 'GPRINT:last:letzter Wert %c:strftime']); 85 | 86 | # HRULE:190\ ff0000 87 | 88 | } # getRRDArgs 89 | 90 | # vim: set shiftwidth=2 softtabstop=2 tabstop=8 : 91 | -------------------------------------------------------------------------------- /contrib/collection3/share/.htaccess: -------------------------------------------------------------------------------- 1 | Options -ExecCGI 2 | SetHandler none 3 | -------------------------------------------------------------------------------- /contrib/collection3/share/shortcut-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octo/collectd/3a3ef49092b924afe9a3351c73206cad96e625d3/contrib/collection3/share/shortcut-icon.png -------------------------------------------------------------------------------- /contrib/collection3/share/style.css: -------------------------------------------------------------------------------- 1 | form { 2 | display: flex; 3 | margin-bottom: 10px; 4 | } 5 | 6 | fieldset { 7 | margin-left: 0; 8 | } 9 | 10 | div.graph 11 | { 12 | } 13 | 14 | div.graph_canvas div.graph_float 15 | { 16 | float: left; 17 | position: relative; 18 | } 19 | 20 | div.graph_float div.controls 21 | { 22 | display: none; 23 | position: absolute; 24 | } 25 | 26 | div.graph_float:hover div.controls 27 | { 28 | display: block; 29 | } 30 | 31 | div.graph_float div.controls.zoom 32 | { 33 | right: 5px; 34 | bottom: 10px; 35 | } 36 | 37 | div.graph_float div.controls.preset 38 | { 39 | right: 5px; 40 | top: 5px; 41 | } 42 | 43 | div.graph_float div.controls div 44 | { 45 | display: block; 46 | 47 | color: gray; 48 | background: white; 49 | 50 | text-decoration: none; 51 | text-align: center; 52 | font-size: small; 53 | 54 | cursor: pointer; 55 | 56 | border: 1px solid gray; 57 | width: 1em; 58 | height: 1em; 59 | padding: 1px; 60 | margin: 0px; 61 | } 62 | 63 | div.graph_float div.controls div:hover 64 | { 65 | color: black; 66 | border-color: black; 67 | } 68 | 69 | div.graph_float div.controls.preset div 70 | { 71 | margin: 1px 0px 1px 0px; 72 | } 73 | 74 | div.graph_float div.controls.zoom div 75 | { 76 | float: left; 77 | margin: 0px 1px 0px 1px; 78 | } 79 | 80 | table 81 | { 82 | border-collapse: collapse; 83 | } 84 | td, th 85 | { 86 | border: 1px solid gray; 87 | } 88 | /* vim: set sw=2 sts=2 et : */ 89 | -------------------------------------------------------------------------------- /contrib/curl_json/php-fpm.conf: -------------------------------------------------------------------------------- 1 | # Example configuration for PHP-FPM 2 | 3 | 4 | Plugin "phpfpm" 5 | Instance "main" 6 | 7 | Type "total_requests" 8 | Instance "accepted" 9 | 10 | 11 | Type "total_requests" 12 | Instance "slow" 13 | 14 | 15 | Type "queue_length" 16 | Instance "listen" 17 | 18 | 19 | Type "vs_processes" 20 | Instance "active" 21 | 22 | 23 | Type "vs_processes" 24 | Instance "total" 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /contrib/docker/50docker-apt-conf: -------------------------------------------------------------------------------- 1 | APT::Install-Recommends "1"; 2 | APT::Install-Suggests "1"; 3 | APT::Get::Assume-Yes "1"; 4 | APT::Get::AutomaticRemove "1"; 5 | -------------------------------------------------------------------------------- /contrib/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | ENV DEBIAN_FRONTEND noninteractive 4 | COPY 50docker-apt-conf /etc/apt/apt.conf.d/ 5 | 6 | COPY rootfs_prefix/ /usr/src/rootfs_prefix/ 7 | 8 | RUN apt-get update \ 9 | && apt-get upgrade \ 10 | && apt-get install \ 11 | collectd-core \ 12 | collectd-utils \ 13 | build-essential \ 14 | && make -C /usr/src/rootfs_prefix/ \ 15 | && apt-get --purge remove build-essential \ 16 | && apt-get clean \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | COPY collectd.conf /etc/collectd/collectd.conf 20 | COPY collectd.conf.d /etc/collectd/collectd.conf.d 21 | 22 | ENV LD_PRELOAD /usr/src/rootfs_prefix/rootfs_prefix.so 23 | 24 | ENTRYPOINT ["/usr/sbin/collectd"] 25 | CMD ["-f"] 26 | -------------------------------------------------------------------------------- /contrib/docker/collectd.conf: -------------------------------------------------------------------------------- 1 | LoadPlugin logfile 2 | 3 | LogLevel "info" 4 | File STDOUT 5 | Timestamp true 6 | PrintSeverity true 7 | 8 | 9 | LoadPlugin unixsock 10 | 11 | SocketGroup "nogroup" 12 | 13 | 14 | 15 | Filter "*.conf" 16 | 17 | -------------------------------------------------------------------------------- /contrib/docker/collectd.conf.d/sample.conf: -------------------------------------------------------------------------------- 1 | LoadPlugin cpu 2 | LoadPlugin memory 3 | LoadPlugin disk 4 | LoadPlugin df 5 | -------------------------------------------------------------------------------- /contrib/docker/rootfs_prefix/.gitignore: -------------------------------------------------------------------------------- 1 | rootprefix.so 2 | -------------------------------------------------------------------------------- /contrib/docker/rootfs_prefix/Makefile: -------------------------------------------------------------------------------- 1 | rootfs_prefix.so: rootfs_prefix.c 2 | $(CC) -Wall -Werror -fPIC -shared -o rootfs_prefix.so rootfs_prefix.c -ldl 3 | -------------------------------------------------------------------------------- /contrib/exec-ksm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # collectd - contrib/exec-ksm.sh 4 | # Copyright (C) 2011 Florian Forster 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a 7 | # copy of this software and associated documentation files (the "Software"), 8 | # to deal in the Software without restriction, including without limitation 9 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | # and/or sell copies of the Software, and to permit persons to whom the 11 | # Software is furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | # DEALINGS IN THE SOFTWARE. 23 | # 24 | # Authors: 25 | # Florian Forster 26 | 27 | HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}" 28 | INTERVAL="${COLLECTD_INTERVAL:-60}" 29 | 30 | function read_file() { 31 | local type="$1" 32 | local type_instance="$2" 33 | local file_name="/sys/kernel/mm/ksm/$3" 34 | local ident="$HOSTNAME/exec-ksm/vmpage_number-${type_instance}" 35 | 36 | echo "PUTVAL \"$ident\" interval=$INTERVAL N:$(< $file_name)" 37 | } 38 | 39 | if [[ 0 -eq $(< /sys/kernel/mm/ksm/run) ]]; then 40 | echo "$0: KSM not active." >&2 41 | exit 1 42 | fi 43 | 44 | while sleep "$INTERVAL" 45 | do 46 | read_file vmpage_number shared pages_shared 47 | read_file vmpage_number saved pages_sharing 48 | read_file vmpage_number unshared pages_unshared 49 | read_file vmpage_number volatile pages_volatile 50 | read_file total_operations scan full_scans 51 | done 52 | 53 | exit 0 54 | -------------------------------------------------------------------------------- /contrib/exec-munin.conf: -------------------------------------------------------------------------------- 1 | AddType temperature temperature 2 | 3 | Interval 300 4 | 5 | Script /tmp/ipmisens2 6 | Script /tmp/munin-sensors.pl 7 | -------------------------------------------------------------------------------- /contrib/exec-nagios.conf: -------------------------------------------------------------------------------- 1 | # Run `perldoc exec-nagios.px' for details on this config file. 2 | 3 | NRPEConfig /etc/nrpe.cfg 4 | 5 | Interval 300 6 | 7 | 11 | 12 | 16 | -------------------------------------------------------------------------------- /contrib/exec-smartctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sample script for the exec plugin (collectd-exec(5)) 4 | # 5 | # This script uses smartctl(8) to read HDD temperatures. The drives are 6 | # attached to a 3ware RAID controller which hddtempd can't handle. 7 | # Unfortunately the smartmontools don't have a library so we can't write a 8 | # C-plugin, at least not easily. 9 | # Please note that only root can read the SMART attributes from harddrives, 10 | # because special ``capabilities'' are necessary. However, the exec plugin will 11 | # refuse to run scripts as root, which is why `sudo' is used here for 12 | # fine-grained root privileges for the user `smart'. This isn't as straigt 13 | # forward as one might hope, but we think that the gained security is worth it. 14 | 15 | # The sudo configuration looks something like this: 16 | # -- 8< -- 17 | # Cmnd_Alias SMARTCTL = /usr/sbin/smartctl -d 3ware\,0 -A /dev/twe0, /usr/sbin/smartctl -d 3ware\,1 -A /dev/twe0, /usr/sbin/smartctl -d ata -A /dev/sda 18 | # smart ALL = (root) NOPASSWD: SMARTCTL 19 | # -- >8 -- 20 | 21 | HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}" 22 | INTERVAL="${COLLECTD_INTERVAL:-60}" 23 | 24 | while sleep "$INTERVAL" 25 | do 26 | TEMP=$((sudo smartctl -d 3ware,0 -A /dev/twe0 | grep Temperature_Celsius | awk '{ print $10; }') 2>/dev/null); 27 | if [ $? -ne 0 ] 28 | then 29 | TEMP="U" 30 | fi 31 | echo "PUTVAL $HOSTNAME/exec-smart/temperature-3ware_0 interval=$INTERVAL N:$TEMP" 32 | 33 | TEMP=$((sudo smartctl -d 3ware,1 -A /dev/twe0 | grep Temperature_Celsius | awk '{ print $10; }') 2>/dev/null); 34 | if [ $? -ne 0 ] 35 | then 36 | TEMP="U" 37 | fi 38 | echo "PUTVAL $HOSTNAME/exec-smart/temperature-3ware_1 interval=$INTERVAL N:$TEMP" 39 | 40 | TEMP=$((sudo smartctl -d ata -A /dev/sda | grep Temperature_Celsius | awk '{ print $10; }') 2>/dev/null); 41 | if [ $? -ne 0 ] 42 | then 43 | TEMP="U" 44 | fi 45 | echo "PUTVAL $HOSTNAME/exec-smart/temperature-sata_0 interval=$INTERVAL N:$TEMP" 46 | done 47 | -------------------------------------------------------------------------------- /contrib/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script sends files to a web service using POST requests and reads back 4 | # the correctly formatted source files. This allows to apply clang-format 5 | # without having to install the tool locally. 6 | 7 | if test $# -lt 1; then 8 | echo "Usage $0 [ ...]" 9 | exit 1 10 | fi 11 | 12 | for i in "$@"; do 13 | d="`dirname "${i}"`" 14 | o="`TMPDIR="${d}" mktemp format.XXXXXX`" 15 | 16 | curl --silent --data-binary "@-" https://format.collectd.org/ <"${i}" >"${o}" 17 | if test $? -eq 0; then 18 | cat "${o}" >"${i}" 19 | fi 20 | rm -f "${o}" 21 | done 22 | -------------------------------------------------------------------------------- /contrib/iptables/accounting.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Simple script that sets up some chains in mangle table to do global logging of all 3 | #traffic going in and out of an interface 4 | #Could also use the regular input/output tree but this also catches the forwarded nat traffic 5 | 6 | IT="iptables -t mangle" 7 | 8 | #First clear the old stuff 9 | $IT -F incoming 10 | $IT -F outgoing 11 | $IT -N incoming 12 | $IT -N outgoing 13 | 14 | $IT -D PREROUTING -i eth0 -j incoming 15 | $IT -D POSTROUTING -o eth0 -j outgoing 16 | 17 | #should add some arg == stop exit here... 18 | 19 | $IT -A PREROUTING -i eth0 -j incoming 20 | $IT -A POSTROUTING -o eth0 -j outgoing 21 | 22 | $IT -A incoming -p tcp -m comment --comment "tcp" 23 | $IT -A incoming -p udp -m comment --comment "udp" 24 | $IT -A incoming -p icmp -m comment --comment "icmp" 25 | 26 | $IT -A outgoing -p tcp -m comment --comment "tcp" 27 | $IT -A outgoing -p udp -m comment --comment "udp" 28 | $IT -A outgoing -p icmp -m comment --comment "icmp" 29 | 30 | -------------------------------------------------------------------------------- /contrib/network-proxy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # vim: sts=4 sw=4 et 3 | 4 | # Simple unicast proxy to send collectd traffic to another host/port. 5 | # Copyright (C) 2007 Pavel Shramov 6 | # 7 | # This program is free software; you can redistribute it and/or modify it 8 | # under the terms of the GNU General Public License as published by the Free 9 | # Software Foundation; only version 2 of the License is applicable. 10 | # 11 | # This program is distributed in the hope that it will be useful, but WITHOUT 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | # more details. 15 | # 16 | # You should have received a copy of the GNU General Public License along with 17 | # this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | # Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | """ 21 | Simple unicast proxy for collectd (>= 4.0). 22 | Binds to 'local' address and forwards all traffic to 'remote'. 23 | """ 24 | 25 | import socket 26 | import struct 27 | 28 | """ Local multicast group/port""" 29 | local = ("239.192.74.66", 25826) 30 | """ Address to send packets """ 31 | remote = ("grid.pp.ru", 35826) 32 | 33 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) 34 | mreq = struct.pack("4sl", socket.inet_aton(local[0]), socket.INADDR_ANY) 35 | 36 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 37 | sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 1) 38 | sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) 39 | sock.bind(local) 40 | 41 | out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) 42 | 43 | if __name__ == "__main__": 44 | while True: 45 | (buf, addr) = sock.recvfrom(2048) 46 | sock.sendto(buf, remote) 47 | -------------------------------------------------------------------------------- /contrib/oracle/db_systat.sql: -------------------------------------------------------------------------------- 1 | -- Table sizes 2 | SELECT owner, 3 | TABLE_NAME, 4 | bytes 5 | FROM collectdu.c_tbl_size; 6 | 7 | -- Tablespace sizes 8 | SELECT tablespace_name, 9 | bytes_free, 10 | bytes_used 11 | FROM collectdu.c_tbs_usage; 12 | 13 | -- IO per Tablespace 14 | SELECT SUM(vf.phyblkrd) *8192 AS 15 | phy_blk_r, 16 | SUM(vf.phyblkwrt) *8192 AS 17 | phy_blk_w, 18 | 'tablespace' AS 19 | i_prefix, 20 | dt.tablespace_name 21 | FROM((dba_data_files dd JOIN v$filestat vf ON dd.file_id = vf.file#) JOIN dba_tablespaces dt ON dd.tablespace_name = dt.tablespace_name) 22 | GROUP BY dt.tablespace_name; 23 | 24 | -- Buffer Pool Hit Ratio: 25 | SELECT DISTINCT 100 *ROUND(1 -((MAX(decode(name, 'physical reads cache', VALUE))) /(MAX(decode(name, 'db block gets from cache', VALUE)) + MAX(decode(name, 'consistent gets from cache', VALUE)))), 4) AS 26 | VALUE, 27 | 'BUFFER_CACHE_HIT_RATIO' AS 28 | buffer_cache_hit_ratio 29 | FROM v$sysstat; 30 | 31 | -- Shared Pool Hit Ratio: 32 | SELECT 33 | 100.0 * sum(PINHITS) / sum(pins) as VALUE, 34 | 'SHAREDPOOL_HIT_RATIO' AS SHAREDPOOL_HIT_RATIO 35 | FROM V$LIBRARYCACHE; 36 | 37 | -- PGA Hit Ratio: 38 | SELECT VALUE, 39 | 'PGA_HIT_RATIO' AS 40 | pga_hit_ratio 41 | FROM v$pgastat 42 | WHERE name = 'cache hit percentage'; 43 | 44 | -- DB Efficiency 45 | SELECT ROUND(SUM(decode(metric_name, 'Database Wait Time Ratio', VALUE)), 2) AS 46 | database_wait_time_ratio, 47 | ROUND(SUM(decode(metric_name, 'Database CPU Time Ratio', VALUE)), 2) AS 48 | database_cpu_time_ratio, 49 | 'DB_EFFICIENCY' AS 50 | db_efficiency 51 | FROM sys.v_$sysmetric 52 | WHERE metric_name IN('Database CPU Time Ratio', 'Database Wait Time Ratio') 53 | AND intsize_csec = 54 | (SELECT MAX(intsize_csec) 55 | FROM sys.v_$sysmetric); 56 | -------------------------------------------------------------------------------- /contrib/php-collection/config.php: -------------------------------------------------------------------------------- 1 | 'hour', 'label'=>'past hour', 'seconds'=>3600), 15 | array('name'=>'day', 'label'=>'past day', 'seconds'=>86400), 16 | array('name'=>'week', 'label'=>'past week', 'seconds'=>604800), 17 | array('name'=>'month', 'label'=>'past month', 'seconds'=>2678400), 18 | array('name'=>'year', 'label'=>'past year', 'seconds'=>31622400)); 19 | // Interval at which values are collectd (currently ignored) 20 | $config['rrd_interval'] = 10; 21 | // Average rows/rra (currently ignored) 22 | $config['rrd_rows'] = 2400; 23 | // Additional options to pass to rrdgraph 24 | $config['rrd_opts'] = array(); 25 | // Predefined set of colors for use by collectd_draw_rrd() 26 | $config['rrd_colors'] = array( 27 | 'h_1'=>'F7B7B7', 'f_1'=>'FF0000', // Red 28 | 'h_2'=>'B7EFB7', 'f_2'=>'00E000', // Green 29 | 'h_3'=>'B7B7F7', 'f_3'=>'0000FF', // Blue 30 | 'h_4'=>'F3DFB7', 'f_4'=>'F0A000', // Yellow 31 | 'h_5'=>'B7DFF7', 'f_5'=>'00A0FF', // Cyan 32 | 'h_6'=>'DFB7F7', 'f_6'=>'A000FF', // Magenta 33 | 'h_7'=>'FFC782', 'f_7'=>'FF8C00', // Orange 34 | 'h_8'=>'DCFF96', 'f_8'=>'AAFF00', // Lime 35 | 'h_9'=>'83FFCD', 'f_9'=>'00FF99', 36 | 'h_10'=>'81D9FF', 'f_10'=>'00B2FF', 37 | 'h_11'=>'FF89F5', 'f_11'=>'FF00EA', 38 | 'h_12'=>'FF89AE', 'f_12'=>'FF0051', 39 | 'h_13'=>'BBBBBB', 'f_13'=>'555555', 40 | ); 41 | /* 42 | * URL to collectd's unix socket (unixsock plugin) 43 | * enabled: 'unix:///var/run/collectd/collectd-unixsock' 44 | * disabled: null 45 | */ 46 | $config['collectd_sock'] = null; 47 | /* 48 | * Path to TTF font file to use in error images 49 | * (fallback when file does not exist is GD fixed font) 50 | */ 51 | $config['error_font'] = '/usr/share/fonts/corefonts/arial.ttf'; 52 | 53 | /* 54 | * Constant defining full path to rrdtool 55 | */ 56 | define('RRDTOOL', '/usr/bin/rrdtool'); 57 | 58 | ?> 59 | -------------------------------------------------------------------------------- /contrib/php-collection/definitions.local.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License as published by the Free Software 7 | * Foundation; only version 2 of the License is applicable. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU General Public License along with 15 | * this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | function load_graph_definitions_local($logarithmic = false, $tinylegend = false) { 20 | global $GraphDefs, $MetaGraphDefs; 21 | 22 | // Define 1-rrd Graph definitions here 23 | $GraphDefs['local_type'] = array( 24 | '-v', 'Commits', 25 | 'DEF:avg={file}:value:AVERAGE', 26 | 'DEF:min={file}:value:MIN', 27 | 'DEF:max={file}:value:MAX', 28 | "AREA:max#B7B7F7", 29 | "AREA:min#FFFFFF", 30 | "LINE1:avg#0000FF:Commits", 31 | 'GPRINT:min:MIN:%6.1lf Min,', 32 | 'GPRINT:avg:AVERAGE:%6.1lf Avg,', 33 | 'GPRINT:max:MAX:%6.1lf Max,', 34 | 'GPRINT:avg:LAST:%6.1lf Last\l'); 35 | 36 | // Define MetaGraph definition type -> function mappings here 37 | $MetaGraphDefs['local_meta'] = 'meta_graph_local'; 38 | } 39 | 40 | function meta_graph_local($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array()) { 41 | global $config; 42 | $sources = array(); 43 | 44 | $title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type"; 45 | if (!isset($opts['title'])) 46 | $opts['title'] = $title; 47 | $opts['rrd_opts'] = array('-v', 'Events'); 48 | 49 | $files = array(); 50 | /* $opts['colors'] = array( 51 | 'ham' => '00e000', 52 | 'spam' => '0000ff', 53 | 'malware' => '990000', 54 | 55 | 'sent' => '00e000', 56 | 'deferred' => 'a0e000', 57 | 'reject' => 'ff0000', 58 | 'bounced' => 'a00050' 59 | ); 60 | 61 | $type_instances = array('ham', 'spam', 'malware', 'sent', 'deferred', 'reject', 'bounced'); */ 62 | foreach ($type_instances as $inst) { 63 | $file = ''; 64 | foreach ($config['datadirs'] as $datadir) 65 | if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) { 66 | $file = $datadir.'/'.$title.'-'.$inst.'.rrd'; 67 | break; 68 | } 69 | if ($file == '') 70 | continue; 71 | 72 | $sources[] = array('name'=>$inst, 'file'=>$file); 73 | } 74 | 75 | // return collectd_draw_meta_stack($opts, $sources); 76 | return collectd_draw_meta_line($opts, $sources); 77 | } 78 | 79 | ?> 80 | -------------------------------------------------------------------------------- /contrib/python/getsigchld.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | ############################################################################### 4 | # WARNING! Importing this script will break the exec plugin! # 5 | ############################################################################### 6 | # Use this if you want to create new processes from your python scripts. # 7 | # Normally you will get a OSError exception when the new process terminates # 8 | # because collectd will ignore the SIGCHLD python is waiting for. # 9 | # This script will restore the default SIGCHLD behavior so python scripts can # 10 | # create new processes without errors. # 11 | ############################################################################### 12 | # WARNING! Importing this script will break the exec plugin! # 13 | ############################################################################### 14 | 15 | import signal 16 | import collectd 17 | 18 | def init(): 19 | signal.signal(signal.SIGCHLD, signal.SIG_DFL) 20 | 21 | collectd.register_init(init) 22 | -------------------------------------------------------------------------------- /contrib/redhat/collection3.conf: -------------------------------------------------------------------------------- 1 | Alias /collection3/ /var/www/collection3/ 2 | 3 | Options +Indexes 4 | AllowOverride all 5 | 6 | -------------------------------------------------------------------------------- /contrib/redhat/init.d-collectd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # collectd Startup script for the Collectd statistics gathering daemon 4 | # chkconfig: - 99 01 5 | # description: Collectd is a statistics gathering daemon used to collect \ 6 | # system information ie. cpu, memory, disk, network 7 | # processname: collectd 8 | # config: /etc/collectd.conf 9 | # config: /etc/sysconfig/collectd 10 | # pidfile: /var/run/collectd.pid 11 | 12 | # Source function library. 13 | . /etc/init.d/functions 14 | 15 | RETVAL=0 16 | ARGS="" 17 | prog="collectdmon" 18 | service="collectd" 19 | CONFIG=/etc/collectd.conf 20 | COLLECTD=/usr/sbin/collectd 21 | COLLECTDMONPIDDIR="/var/run" 22 | COLLECTDMONPID="$COLLECTDMONPIDDIR/collectdmon.pid" 23 | 24 | MAXWAIT=30 25 | 26 | if [ -r /etc/sysconfig/$service ]; then 27 | . /etc/sysconfig/$service 28 | fi 29 | 30 | if [[ ! -d $COLLECTDMONPIDDIR ]]; then 31 | mkdir -p $COLLECTDMONPIDDIR 32 | [ -n "${RUNAS}" ] && chown "${RUNAS}:" "$COLLECTDMONPIDDIR" 33 | fi 34 | 35 | check_config() { 36 | if test ! -r "$CONFIG"; then 37 | return 2 38 | fi 39 | if ! $COLLECTD -t -C "$CONFIG"; then 40 | return 1 41 | fi 42 | return 0 43 | } 44 | 45 | start () { 46 | echo -n $"Starting collectd: " 47 | check_config 48 | rc="$?" 49 | if test "$rc" -ne 0; then 50 | RETVAL=6 51 | echo $"not starting due to configuration error" 52 | failure $"not starting $service due to configuration error" 53 | else 54 | daemon --user "${RUNAS:-root}" $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG" $ARGS 55 | RETVAL=$? 56 | echo 57 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$service 58 | fi 59 | } 60 | 61 | stop () { 62 | echo -n $"Stopping collectd: " 63 | killproc -p $COLLECTDMONPID -d $MAXWAIT $prog 64 | RETVAL=$? 65 | echo 66 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$service 67 | } 68 | 69 | restart () { 70 | check_config 71 | rc="$?" 72 | if test "$rc" -ne 0; then 73 | RETVAL=6 74 | echo $"not restarting due to configuration error" 75 | failure $"not restarting $service due to configuration error" 76 | else 77 | stop 78 | start 79 | fi 80 | } 81 | 82 | # See how we were called. 83 | case "$1" in 84 | start) 85 | start 86 | ;; 87 | stop) 88 | stop 89 | ;; 90 | status) 91 | status -p $COLLECTDMONPID $prog 92 | ;; 93 | restart|reload) 94 | restart 95 | ;; 96 | condrestart) 97 | [ -f /var/lock/subsys/$service ] && restart || : 98 | ;; 99 | *) 100 | echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" 101 | exit 1 102 | esac 103 | 104 | exit $? 105 | 106 | # vim:syntax=sh 107 | -------------------------------------------------------------------------------- /contrib/redhat/php-collection.conf: -------------------------------------------------------------------------------- 1 | Alias /php-collection/ /var/www/php-collection/ 2 | 3 | DirectoryIndex index.php 4 | Options -Indexes 5 | AddType application/x-httpd-php .php 6 | 7 | -------------------------------------------------------------------------------- /contrib/sles10.1/init.d-collectd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: collectd 5 | # Required-Start: $local_fs $remote_fs $network 6 | # X-UnitedLinux-Should-Start: $named $time apache mysql 7 | # Required-Stop: $local_fs $remote_fs $network 8 | # X-UnitedLinux-Should-Stop: 9 | # Default-Start: 3 5 10 | # Default-Stop: 0 1 2 6 11 | # Short-Description: Statistics daemon collectd 12 | # Description: Start the statistics daemon collectd 13 | ### END INIT INFO 14 | 15 | 16 | # 17 | # load the configuration 18 | # 19 | test -s /etc/rc.status && . /etc/rc.status && rc_reset 20 | 21 | RETVAL=0 22 | ARGS="" 23 | prog="collectd" 24 | CONFIG=/etc/collectd.conf 25 | 26 | if [ -r /etc/default/$prog ]; then 27 | . /etc/default/$prog 28 | fi 29 | 30 | start () { 31 | echo -n $"Starting $prog: " 32 | RETVAL=1 33 | if [ -r "$CONFIG" ] 34 | then 35 | eval startproc /usr/sbin/collectd -C "$CONFIG" 36 | RETVAL=$? 37 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog 38 | fi 39 | rc_failed $RETVAL 40 | rc_status -v 41 | } 42 | stop () { 43 | echo -n $"Stopping $prog: " 44 | killproc $prog 45 | RETVAL=$? 46 | rc_failed $RETVAL 47 | rc_status -v 48 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog 49 | } 50 | # See how we were called. 51 | case "$1" in 52 | start) 53 | start 54 | ;; 55 | stop) 56 | stop 57 | ;; 58 | status) 59 | status $prog 60 | ;; 61 | restart|reload) 62 | stop 63 | sleep 1 64 | start 65 | ;; 66 | condrestart) 67 | [ -f /var/lock/subsys/$prog ] && restart || : 68 | ;; 69 | *) 70 | echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" 71 | exit 1 72 | esac 73 | 74 | rc_exit 75 | # vim:syntax=sh 76 | -------------------------------------------------------------------------------- /contrib/solaris-smf/collectd: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | PIDFILE=/opt/collectd/var/run/collectd.pid 4 | DAEMON=/opt/collectd/sbin/collectd 5 | 6 | . /lib/svc/share/smf_include.sh 7 | 8 | case "$1" in 9 | start) 10 | if [ -f $PIDFILE ] ; then 11 | echo "Already running. Stale PID file?" 12 | PID=`cat $PIDFILE` 13 | echo "$PIDFILE contains $PID" 14 | ps -p $PID 15 | exit $SMF_EXIT_ERR_FATAL 16 | fi 17 | $DAEMON 18 | if [ $? -ne 0 ] ; then 19 | echo $DAEMON faild to start 20 | exit $SMF_EXIT_ERR_FATAL 21 | fi 22 | ;; 23 | stop) 24 | PID=`cat $PIDFILE 2>/dev/null` 25 | kill -15 $PID 2>/dev/null 26 | pwait $PID 1> /dev/null 2>/dev/null 27 | ;; 28 | restart) 29 | $0 stop 30 | $0 start 31 | ;; 32 | status) 33 | ps -ef | grep collectd | grep -v status | grep -v grep 34 | ;; 35 | *) 36 | echo "Usage: $0 [ start | stop | restart | status ]" 37 | exit 1 38 | ;; 39 | esac 40 | 41 | 42 | exit $SMF_EXIT_OK 43 | -------------------------------------------------------------------------------- /contrib/solaris-smf/collectd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | 27 | 28 | 29 | 30 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /contrib/systemd.collectd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Collectd statistics daemon 3 | Documentation=man:collectd(1) man:collectd.conf(5) 4 | After=local-fs.target network-online.target 5 | Requires=local-fs.target network-online.target 6 | 7 | [Service] 8 | ExecStart=/usr/sbin/collectd 9 | EnvironmentFile=-/etc/sysconfig/collectd 10 | EnvironmentFile=-/etc/default/collectd 11 | 12 | # A few plugins won't work without some privileges, which you'll have to 13 | # specify using the CapabilityBoundingSet directive below. 14 | # 15 | # Here's a (incomplete) list of the plugins known capability requirements: 16 | # ceph CAP_DAC_OVERRIDE 17 | # dns CAP_NET_RAW 18 | # exec CAP_SETUID CAP_SETGID 19 | # intel_rdt CAP_SYS_RAWIO 20 | # intel_pmu CAP_SYS_ADMIN 21 | # iptables CAP_NET_ADMIN 22 | # ping CAP_NET_RAW 23 | # processes CAP_NET_ADMIN (CollectDelayAccounting only) 24 | # smart CAP_SYS_RAWIO 25 | # turbostat CAP_SYS_RAWIO 26 | # 27 | # Example, if you use the iptables plugin alongside the dns or ping plugin: 28 | #CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN 29 | # 30 | # By default, drop all capabilities: 31 | CapabilityBoundingSet= 32 | 33 | # Tell systemd it will receive a notification from collectd over its control 34 | # socket once the daemon is ready. See systemd.service(5) for more details. 35 | Type=notify 36 | 37 | # Restart the collectd daemon when it fails. 38 | Restart=on-failure 39 | 40 | [Install] 41 | WantedBy=multi-user.target 42 | -------------------------------------------------------------------------------- /contrib/upstart.collectd.conf: -------------------------------------------------------------------------------- 1 | description "start/stop/control collectd" 2 | # http://collectd.org/ 3 | # Upstart is the replacement init system used in Debian, Ubuntu, 4 | # and in Fedora. Refer to http://upstart.ubuntu.com/cookbook/ 5 | # 6 | # Normally this file will live as `/etc/init/collectd.conf` 7 | 8 | usage "initctl collectd" 9 | author "Dave Cottlehuber " 10 | version "1.1" 11 | 12 | # There are a number of alternative start sequences however 13 | # most of those do not work on all Ubuntu flavours and releases. 14 | start on started networking and filesystem 15 | stop on runlevel [!2345] 16 | 17 | # collectd itself will run with reduced privileges, but not 18 | # all plugins will. Test and edit as required. 19 | # An alternative configuration is as a user script in ~/.init/ however 20 | # these cannot be started at boot time by the system without 21 | # arcane trickery. Also a root user will not see these tasks/jobs 22 | # by default. set*id is a reasonable and secure compromise. 23 | # These options are not supported on early upstart versions. 24 | #setuid nobody 25 | #setgid nobody 26 | 27 | # Other parameters such as the path to the configuration file 28 | # will have been compiled into the binary. These are trivially 29 | # added as environment variables below, and then into both 30 | # `pre-start` command check before collectd runs, and subsequent 31 | # `exec` command parameters below. Remember that upstart runs all 32 | # shell commands via `sh -e`. 33 | env DAEMON=/usr/sbin/collectd 34 | 35 | # Tell upstart to wait for collectd to SIGSTOP itself, signaling it is ready 36 | # to run. Warning: this only works with collectd 5.5 and newer. You'll have to 37 | # use "expect fork" instead, if using collectd 5.4 and older. 38 | expect stop 39 | 40 | # prevent thrashing - 10 restarts in 5 seconds 41 | respawn 42 | respawn limit 10 5 43 | 44 | # Uncomment to make a log available in /var/log/upstart/collectd.log 45 | # (not supported on early upstart versions). 46 | #console log 47 | 48 | # The daemon will not start if the configuration is invalid. 49 | pre-start exec $DAEMON -t 50 | # Let's start! 51 | exec $DAEMON 52 | -------------------------------------------------------------------------------- /contrib/wiki2changelog.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | =head1 NAME 7 | 8 | wiki2changelog.pl 9 | 10 | =head1 DESCRIPTION 11 | 12 | This script takes the change log from one of the "Version x.y" pages in 13 | collectd's wiki and converts it to the format used by the "ChangeLog" file. 14 | This is usually done as part of the release process. 15 | 16 | =cut 17 | 18 | our $TextWidth = 80; 19 | 20 | sub format_entry 21 | { 22 | my $in = shift; 23 | my $out = ''; 24 | 25 | my $line = "\t*"; 26 | my $line_len = 9; 27 | 28 | for (split (' ', $in)) { 29 | my $word = $_; 30 | my $word_len = 1 + length $word; 31 | 32 | if (($line_len + $word_len) > $TextWidth) { 33 | $out .= "$line\n"; 34 | $line = "\t "; 35 | $line_len = 9; 36 | } 37 | 38 | $line .= " $word"; 39 | $line_len += $word_len; 40 | } 41 | 42 | if ($line_len != 9) { 43 | $out .= "$line\n"; 44 | } 45 | 46 | return $out; 47 | } 48 | 49 | while (<>) 50 | { 51 | chomp; 52 | my $line = $_; 53 | 54 | if ($line =~ m#^\* (.*)#) { 55 | $line = $1; 56 | } else { 57 | next; 58 | } 59 | 60 | $line =~ s#<#<#g; 61 | $line =~ s#>#>#g; 62 | $line =~ s# # #g; 63 | $line =~ s#"#"#g; 64 | 65 | $line =~ s#\{\{Plugin\|([^}]+)\}\}#$1 plugin#g; 66 | $line =~ s@\{\{Issue\|([^}]+)\}\}@#$1@g; 67 | $line =~ s#\[\[[^|\]]+\|([^\]]+)\]\]#$1#g; 68 | $line =~ s#\[\[([^|\]]+)\]\]#$1#g; 69 | 70 | $line =~ s#'''(.*?)'''#*$1*#g; 71 | $line =~ s#''(.*?)''#$1#g; 72 | $line =~ s#(.*?)#"$1"#gi; 73 | 74 | print format_entry($line); 75 | } 76 | -------------------------------------------------------------------------------- /docs/BUILD.java.md: -------------------------------------------------------------------------------- 1 | # Building with Java 2 | 3 | This file gives some background and hints how the *java plugin* needs to be 4 | configured. 5 | 6 | ## Dependencies 7 | 8 | The *java plugin* requires a version of Java with *Java Native Interface* (JNI) 9 | **1.2** or later. 10 | 11 | ## Configure and flags 12 | 13 | To determine the location of the required files of a Java installation is not an 14 | easy task, because the locations vary with your kernel (Linux, SunOS, …) and 15 | with your architecture (x86, SPARC, …) and there is no `java-config` script we 16 | could use. Configuration of the JVM library is therefore a bit tricky. 17 | 18 | The easiest way to use the `--with-java="${JAVA_HOME}"` option, where 19 | `JAVA_HOME` is usually something like: 20 | 21 | /usr/lib/jvm/java-1.5.0-sun-1.5.0.14 22 | 23 | The configure script will then use *find(1)* to look for the following files: 24 | 25 | * `jni.h` 26 | * `jni_md.h` 27 | * `libjvm.so` 28 | 29 | If found, appropriate CPP-flags and LD-flags are set and the following library 30 | checks succeed. 31 | 32 | If this doesn't work for you, you have the possibility to specify CPP-flags, 33 | C-flags, LD-flags and LIBS for the *java plugin* by hand, using the following 34 | environment variables: 35 | 36 | * `JAVA_CPPFLAGS` 37 | * `JAVA_CFLAGS` 38 | * `JAVA_LDFLAGS` 39 | * `JAVA_LIBS` 40 | 41 | For example (shortened for demonstration purposes): 42 | 43 | ./configure JAVA_CPPFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux" 44 | 45 | Adding `-ljvm` to JAVA_LIBS is done automatically, you don't have to do that. 46 | 47 | ## License 48 | 49 | The *java plugin* is licensed under the *GNU General Public License, version 2*. 50 | Full licensing terms can be found in the file `COPYING`. 51 | -------------------------------------------------------------------------------- /docs/maintainer_guide.md: -------------------------------------------------------------------------------- 1 | ## Maintainer Guide 2 | 3 | This document documents best practises and guidelines for *collectd* 4 | maintainers. 5 | 6 | ### Ideology 7 | 8 | As maintainer of an open-source project, you are one of the most knowledgable 9 | people of the project's structure, best practices, goals, etc. You are most 10 | helping the project by *facilitating change*, in other words "help contributors 11 | make changes to the codebase." 12 | 13 | The most common form of helping users is doing *code reviews* and (eventually) 14 | using your commit rights to merge the pull request. 15 | 16 | ### Code reviews 17 | 18 | * Be friendly, especially with new contributors. Write "Hi" and thank them for their contribution before diving into review comments. 19 | * Criticize code, not people. Ideally, tell the contributor a better way to do what they need. 20 | * Clearly mark optional suggestions as such. Best practise, start your comment with *At your option: …* 21 | * Wait for a successful run of our [continuous integration system](https://ci.collectd.org/) before merging. 22 | 23 | ### Repository access 24 | 25 | You have write access to the *collectd/collectd* repository. Please use it 26 | responsibly. 27 | -------------------------------------------------------------------------------- /docs/review_comments_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octo/collectd/3a3ef49092b924afe9a3351c73206cad96e625d3/docs/review_comments_example.png -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | -------------------------------------------------------------------------------- /proto/collectd.proto: -------------------------------------------------------------------------------- 1 | // collectd - proto/collectd.proto 2 | // Copyright (C) 2015-2016 Sebastian Harl 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | // 22 | // Authors: 23 | // Sebastian Harl 24 | 25 | syntax = "proto3"; 26 | 27 | package collectd; 28 | option go_package = "collectd.org/rpc/proto"; 29 | 30 | import "types.proto"; 31 | 32 | service Collectd { 33 | // PutValues reads the value lists from the PutValuesRequest stream. 34 | // The gRPC server embedded into collectd will inject them into the system 35 | // just like the network plugin. 36 | rpc PutValues(stream PutValuesRequest) returns(PutValuesResponse); 37 | 38 | // QueryValues returns a stream of matching value lists from collectd's 39 | // internal cache. 40 | rpc QueryValues(QueryValuesRequest) returns(stream QueryValuesResponse); 41 | } 42 | 43 | // The arguments to PutValues. 44 | message PutValuesRequest { 45 | // value_list is the metric to be sent to the server. 46 | collectd.types.ValueList value_list = 1; 47 | } 48 | 49 | // The response from PutValues. 50 | message PutValuesResponse {} 51 | 52 | // The arguments to QueryValues. 53 | message QueryValuesRequest { 54 | // Query by the fields of the identifier. Only return values matching the 55 | // specified shell wildcard patterns (see fnmatch(3)). Use '*' to match 56 | // any value. 57 | collectd.types.Identifier identifier = 1; 58 | } 59 | 60 | // The response from QueryValues. 61 | message QueryValuesResponse { collectd.types.ValueList value_list = 1; } 62 | -------------------------------------------------------------------------------- /proto/prometheus.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Prometheus Team 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | syntax = "proto2"; 15 | 16 | package io.prometheus.client; 17 | option java_package = "io.prometheus.client"; 18 | 19 | message LabelPair { 20 | optional string name = 1; 21 | optional string value = 2; 22 | } 23 | 24 | enum MetricType { 25 | COUNTER = 0; GAUGE = 1; SUMMARY = 2; UNTYPED = 3; HISTOGRAM = 4; 26 | } 27 | 28 | message Gauge { optional double value = 1; } 29 | 30 | message Counter { optional double value = 1; } 31 | 32 | message Quantile { 33 | optional double quantile = 1; 34 | optional double value = 2; 35 | } 36 | 37 | message Summary { 38 | optional uint64 sample_count = 1; 39 | optional double sample_sum = 2; 40 | repeated Quantile quantile = 3; 41 | } 42 | 43 | message Untyped { optional double value = 1; } 44 | 45 | message Histogram { 46 | optional uint64 sample_count = 1; 47 | optional double sample_sum = 2; 48 | repeated Bucket bucket = 49 | 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional. 50 | } 51 | 52 | message Bucket { 53 | optional uint64 cumulative_count = 1; // Cumulative in increasing order. 54 | optional double upper_bound = 2; // Inclusive. 55 | } 56 | 57 | message Metric { 58 | repeated LabelPair label = 1; 59 | optional Gauge gauge = 2; 60 | optional Counter counter = 3; 61 | optional Summary summary = 4; 62 | optional Untyped untyped = 5; 63 | optional Histogram histogram = 7; 64 | optional int64 timestamp_ms = 6; 65 | } 66 | 67 | message MetricFamily { 68 | optional string name = 1; 69 | optional string help = 2; 70 | optional MetricType type = 3; 71 | repeated Metric metric = 4; 72 | } 73 | -------------------------------------------------------------------------------- /proto/types.proto: -------------------------------------------------------------------------------- 1 | // collectd - proto/types.proto 2 | // Copyright (C) 2015-2016 Sebastian Harl 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a 5 | // copy of this software and associated documentation files (the "Software"), 6 | // to deal in the Software without restriction, including without limitation 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | // and/or sell copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | // 22 | // Authors: 23 | // Sebastian Harl 24 | 25 | syntax = "proto3"; 26 | 27 | package collectd.types; 28 | option go_package = "collectd.org/rpc/proto/types"; 29 | 30 | import "google/protobuf/duration.proto"; 31 | import "google/protobuf/timestamp.proto"; 32 | 33 | message Identifier { 34 | string host = 1; 35 | string plugin = 2; 36 | string plugin_instance = 3; 37 | string type = 4; 38 | string type_instance = 5; 39 | } 40 | 41 | message MetadataValue { 42 | oneof value { 43 | string string_value = 1; 44 | int64 int64_value = 2; 45 | uint64 uint64_value = 3; 46 | double double_value = 4; 47 | bool bool_value = 5; 48 | }; 49 | } 50 | 51 | message Value { 52 | oneof value { 53 | uint64 counter = 1; 54 | double gauge = 2; 55 | int64 derive = 3; 56 | uint64 absolute = 4; 57 | }; 58 | } 59 | 60 | message ValueList { 61 | repeated Value values = 1; 62 | 63 | google.protobuf.Timestamp time = 2; 64 | google.protobuf.Duration interval = 3; 65 | 66 | Identifier identifier = 4; 67 | 68 | repeated string ds_names = 5; 69 | map meta_data = 6; 70 | } -------------------------------------------------------------------------------- /src/collectd-email.pod: -------------------------------------------------------------------------------- 1 | =encoding UTF-8 2 | 3 | =head1 NAME 4 | 5 | collectd-email - Documentation of collectd's C 6 | 7 | =head1 SYNOPSIS 8 | 9 | # See collectd.conf(5) 10 | LoadPlugin email 11 | # ... 12 | 13 | SocketGroup "collectd" 14 | SocketPerms "0770" 15 | MaxConns 5 16 | 17 | 18 | =head1 DESCRIPTION 19 | 20 | The C opens an UNIX-socket over which one can submit email 21 | statistics, such as the number of "ham", "spam", "virus", etc. mails 22 | received/handled, spam scores and matched spam checks. 23 | 24 | This plugin is intended to be used with the 25 | L SpamAssassin-plugin which is included 26 | in F, but is of course not limited to that use. 27 | 28 | =head1 OPERATION 29 | 30 | This plugin collects data indirectly by providing a UNIX-socket that external 31 | programs can connect to. A simple line based protocol is used to communicate 32 | with the plugin: 33 | 34 | =over 4 35 | 36 | =item * 37 | 38 | E-Mail type (e.g. "ham", "spam", "virus", ...) and size (bytes): 39 | 40 | e:: 41 | 42 | If C is less than or equal to zero, C is ignored. 43 | 44 | =item * 45 | 46 | Spam score: 47 | 48 | s: 49 | 50 | =item * 51 | 52 | Successful spam checks (e.g. "BAYES_99", "SUBJECT_DRUG_GAP_C", ...): 53 | 54 | c:[,,...] 55 | 56 | Each line is limited to 256 characters (including the newline character). 57 | Longer lines will be ignored. 58 | 59 | =back 60 | 61 | =head1 SEE ALSO 62 | 63 | L, 64 | L 65 | 66 | =head1 AUTHOR 67 | 68 | The C has been written by Sebastian Harl EshEatEtokkee.orgE. 69 | 70 | The SpamAssassin-plugin has been written by Alexander Wirt EformorerEatEformorer.deE. 71 | 72 | This manpage has been written by Florian Forster EoctoEatEcollectd.orgE. 73 | 74 | =cut 75 | -------------------------------------------------------------------------------- /src/collectd-tg.pod: -------------------------------------------------------------------------------- 1 | =encoding UTF-8 2 | 3 | =head1 NAME 4 | 5 | collectd-tg - Traffic generator for collectd. 6 | 7 | =head1 SYNOPSIS 8 | 9 | collectd-tg B<-n> I B<-H> I B<-p> I B<-i> I B<-d> I B<-D> I 10 | 11 | =head1 DESCRIPTION 12 | 13 | B generates bogus I network traffic. While host, plugin 14 | and values are generated randomly, the generated traffic tries to mimic "real" 15 | traffic as closely as possible. 16 | 17 | =head1 ARGUMENTS AND OPTIONS 18 | 19 | The following options are understood by I. The order of the 20 | arguments generally doesn't matter, as long as no argument is passed more than 21 | once. 22 | 23 | =over 4 24 | 25 | =item B<-n> I 26 | 27 | Sets the number of unique I (VL) to generate. Defaults to 10000. 28 | 29 | =item B<-H> I 30 | 31 | Sets the number of unique hosts to simulate. Defaults to 1000. 32 | 33 | =item B<-p> I 34 | 35 | Sets the number of unique plugins to simulate. Defaults to 20. 36 | 37 | =item B<-i> I 38 | 39 | Sets the interval in which each I is dispatched. Defaults to 10.0 40 | seconds. 41 | 42 | =item B<-d> I 43 | 44 | Sets the destination to which to send the generated network traffic. Defaults 45 | to the IPv6 multicast address, C. 46 | 47 | =item B<-D> I 48 | 49 | Sets the destination port or service to which to send the generated network 50 | traffic. Defaults to I default port, C<25826>. 51 | 52 | =item B<-h> 53 | 54 | Print usage summary. 55 | 56 | =back 57 | 58 | =head1 SEE ALSO 59 | 60 | L, 61 | L 62 | 63 | =head1 AUTHOR 64 | 65 | Florian Forster EoctoEatEcollectd.orgE 66 | 67 | =cut 68 | -------------------------------------------------------------------------------- /src/collectdctl.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octo/collectd/3a3ef49092b924afe9a3351c73206cad96e625d3/src/collectdctl.c -------------------------------------------------------------------------------- /src/collectdmon.pod: -------------------------------------------------------------------------------- 1 | =encoding UTF-8 2 | 3 | =head1 NAME 4 | 5 | collectdmon - Monitoring daemon for collectd 6 | 7 | =head1 SYNOPSIS 8 | 9 | collectdmon I<[options]> [-- I] 10 | 11 | =head1 DESCRIPTION 12 | 13 | collectdmon is a small "wrapper" daemon which starts and monitors the collectd 14 | daemon. If collectd terminates it will automatically be restarted, unless 15 | collectdmon was told to shut it down. 16 | 17 | =head1 OPTIONS 18 | 19 | collectdmon supports the following options: 20 | 21 | =over 4 22 | 23 | =item B<-c> IpathE> 24 | 25 | Specify the pathname of the collectd binary. You may either specify an 26 | absolute path or simply the name of the binary in which case the B 27 | variable will be searched for it. The default is "B". 28 | 29 | =item B<-P> Ipid-fileE> 30 | 31 | Specify the pid file. The default is "I". 32 | 33 | =item B<-h> 34 | 35 | Output usage information and exit. 36 | 37 | =item I 38 | 39 | Specify options that are passed on to collectd. If it is not already included, 40 | B<-f> will be added to these options. See L. 41 | 42 | =back 43 | 44 | =head1 SIGNALS 45 | 46 | B accepts the following signals: 47 | 48 | =over 4 49 | 50 | =item B, B 51 | 52 | These signals cause B to terminate B, wait for its 53 | termination and then shut down. 54 | 55 | =item B 56 | 57 | This signal causes B to terminate B, wait for its 58 | termination and then restart it. 59 | 60 | =back 61 | 62 | =head1 SEE ALSO 63 | 64 | L, 65 | L, 66 | L 67 | 68 | =head1 AUTHOR 69 | 70 | collectd has been written by Florian Forster Eocto at collectd.orgE 71 | and many contributors (see `AUTHORS'). 72 | 73 | collectdmon has been written by Sebastian Harl Esh@tokkee.orgE. 74 | 75 | =cut 76 | -------------------------------------------------------------------------------- /src/cpusleep.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/cpusleep.c 3 | * Copyright (C) 2016 rinigus 4 | * 5 | * The MIT License (MIT) 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Authors: 26 | * rinigus 27 | * 28 | * CPU sleep is reported in milliseconds of sleep per second of wall 29 | * time. For that, the time difference between BOOT and MONOTONIC clocks 30 | * is reported using derive type. 31 | **/ 32 | 33 | #include "collectd.h" 34 | 35 | #include "plugin.h" 36 | #include "utils/common/common.h" 37 | #include 38 | 39 | static void cpusleep_submit(derive_t cpu_sleep) { 40 | value_list_t vl = VALUE_LIST_INIT; 41 | 42 | vl.values = &(value_t){.derive = cpu_sleep}; 43 | vl.values_len = 1; 44 | sstrncpy(vl.plugin, "cpusleep", sizeof(vl.plugin)); 45 | sstrncpy(vl.type, "total_time_in_ms", sizeof(vl.type)); 46 | 47 | plugin_dispatch_values(&vl); 48 | } 49 | 50 | static int cpusleep_read(void) { 51 | struct timespec b, m; 52 | if (clock_gettime(CLOCK_BOOTTIME, &b) < 0) { 53 | ERROR("cpusleep plugin: clock_boottime failed"); 54 | return -1; 55 | } 56 | 57 | if (clock_gettime(CLOCK_MONOTONIC, &m) < 0) { 58 | ERROR("cpusleep plugin: clock_monotonic failed"); 59 | return -1; 60 | } 61 | 62 | // to avoid false positives in counter overflow due to reboot, 63 | // derive is used. Sleep is calculated in milliseconds 64 | derive_t diffsec = b.tv_sec - m.tv_sec; 65 | derive_t diffnsec = b.tv_nsec - m.tv_nsec; 66 | derive_t sleep = diffsec * 1000 + diffnsec / 1000000; 67 | 68 | cpusleep_submit(sleep); 69 | 70 | return 0; 71 | } 72 | 73 | void module_register(void) { 74 | plugin_register_read("cpusleep", cpusleep_read); 75 | } /* void module_register */ 76 | -------------------------------------------------------------------------------- /src/daemon/cmd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/daemon/cmd.h 3 | * Copyright (C) 2018 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | **/ 23 | 24 | #ifndef CMD_H 25 | #define CMD_H 26 | 27 | #include 28 | 29 | struct cmdline_config { 30 | bool test_config; 31 | bool test_readall; 32 | bool create_basedir; 33 | const char *configfile; 34 | bool daemonize; 35 | }; 36 | 37 | void stop_collectd(void); 38 | struct cmdline_config init_config(int argc, char **argv); 39 | int run_loop(bool test_readall, void (*notify_func)(void)); 40 | 41 | #endif /* CMD_H */ 42 | -------------------------------------------------------------------------------- /src/daemon/cmd_windows.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/collectd_windows.c 3 | * Copyright (C) 2017 Google LLC 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | **/ 23 | 24 | #include "cmd.h" 25 | #include "plugin.h" 26 | #include 27 | #include 28 | 29 | int main(int argc, char **argv) { 30 | WSADATA wsaData; 31 | WORD wVersionRequested = MAKEWORD(2, 2); 32 | int err = WSAStartup(wVersionRequested, &wsaData); 33 | if (err != 0) { 34 | ERROR("WSAStartup failed with error: %d\n", err); 35 | return 1; 36 | } 37 | 38 | struct cmdline_config config = init_config(argc, argv); 39 | return run_loop(config.test_readall); 40 | } 41 | -------------------------------------------------------------------------------- /src/daemon/globals.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/globals.c 3 | * Copyright (C) 2017 Google LLC 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | **/ 23 | 24 | // clang-format off 25 | /* 26 | * Explicit order is required or _FILE_OFFSET_BITS will have definition mismatches on Solaris 27 | * See Github Issue #3193 for details 28 | */ 29 | #include "utils/common/common.h" 30 | #include "globals.h" 31 | // clang-format on 32 | 33 | #if HAVE_KSTAT_H 34 | #include 35 | #endif 36 | 37 | /* 38 | * Global variables 39 | */ 40 | char *hostname_g; 41 | cdtime_t interval_g; 42 | int timeout_g; 43 | #if HAVE_KSTAT_H 44 | kstat_ctl_t *kc; 45 | #endif 46 | 47 | void hostname_set(char const *hostname) { 48 | char *h = strdup(hostname); 49 | if (h == NULL) 50 | return; 51 | 52 | sfree(hostname_g); 53 | hostname_g = h; 54 | } 55 | -------------------------------------------------------------------------------- /src/daemon/globals.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/globals.h 3 | * Copyright (C) 2017 Google LLC 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | **/ 23 | 24 | #ifndef GLOBALS_H 25 | #define GLOBALS_H 26 | 27 | #include 28 | 29 | #ifndef DATA_MAX_NAME_LEN 30 | #define DATA_MAX_NAME_LEN 128 31 | #endif 32 | 33 | #ifndef PRIsz 34 | #ifdef WIN32 35 | #define PRIsz "Iu" 36 | #else 37 | #define PRIsz "zu" 38 | #endif /* WIN32 */ 39 | #endif /* !PRIsz */ 40 | 41 | /* Type for time as used by "utils_time.h" */ 42 | typedef uint64_t cdtime_t; 43 | 44 | /* hostname_set updates hostname_g */ 45 | void hostname_set(char const *hostname); 46 | 47 | extern char *hostname_g; 48 | extern cdtime_t interval_g; 49 | extern int pidfile_from_cli; 50 | extern int timeout_g; 51 | #endif /* GLOBALS_H */ 52 | -------------------------------------------------------------------------------- /src/daemon/types_list.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/types_list.h 3 | * Copyright (C) 2007 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef TYPES_LIST_H 28 | #define TYPES_LIST_H 1 29 | 30 | int read_types_list(const char *file); 31 | 32 | #endif /* TYPES_LIST_H */ 33 | -------------------------------------------------------------------------------- /src/daemon/utils_cache_mock.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/tests/mock/utils_cache.c 3 | * Copyright (C) 2013 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | #include "utils_cache.h" 28 | #include 29 | 30 | #include 31 | 32 | gauge_t *uc_get_rate(__attribute__((unused)) data_set_t const *ds, 33 | __attribute__((unused)) value_list_t const *vl) { 34 | errno = ENOTSUP; 35 | return NULL; 36 | } 37 | 38 | int uc_get_rate_by_name(const char *name, gauge_t **ret_values, 39 | size_t *ret_values_num) { 40 | return ENOTSUP; 41 | } 42 | 43 | int uc_get_names(char ***ret_names, cdtime_t **ret_times, size_t *ret_number) { 44 | return ENOTSUP; 45 | } 46 | 47 | int uc_get_value_by_name(const char *name, value_t **ret_values, 48 | size_t *ret_values_num) { 49 | return ENOTSUP; 50 | } 51 | 52 | int uc_meta_data_get_signed_int(const value_list_t *vl, const char *key, 53 | int64_t *value) { 54 | return -ENOENT; 55 | } 56 | 57 | int uc_meta_data_get_unsigned_int(const value_list_t *vl, const char *key, 58 | uint64_t *value) { 59 | return -ENOENT; 60 | } 61 | 62 | int uc_meta_data_add_signed_int(const value_list_t *vl, const char *key, 63 | int64_t value) { 64 | return 0; 65 | } 66 | 67 | int uc_meta_data_add_unsigned_int(const value_list_t *vl, const char *key, 68 | uint64_t value) { 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /src/daemon/utils_llist.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_llist.h 3 | * Copyright (C) 2006 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian Forster 25 | */ 26 | 27 | #ifndef UTILS_LLIST_H 28 | #define UTILS_LLIST_H 1 29 | 30 | /* 31 | * Data types 32 | */ 33 | struct llentry_s { 34 | char *key; 35 | void *value; 36 | struct llentry_s *next; 37 | }; 38 | typedef struct llentry_s llentry_t; 39 | 40 | struct llist_s; 41 | typedef struct llist_s llist_t; 42 | 43 | /* 44 | * Functions 45 | */ 46 | llist_t *llist_create(void); 47 | void llist_destroy(llist_t *l); 48 | 49 | llentry_t *llentry_create(char *key, void *value); 50 | void llentry_destroy(llentry_t *e); 51 | 52 | void llist_append(llist_t *l, llentry_t *e); 53 | void llist_prepend(llist_t *l, llentry_t *e); 54 | void llist_remove(llist_t *l, llentry_t *e); 55 | 56 | int llist_size(llist_t *l); 57 | 58 | llentry_t *llist_search(llist_t *l, const char *key); 59 | llentry_t *llist_search_custom(llist_t *l, int (*compare)(llentry_t *, void *), 60 | void *user_data); 61 | 62 | llentry_t *llist_head(llist_t *l); 63 | llentry_t *llist_tail(llist_t *l); 64 | 65 | #endif /* UTILS_LLIST_H */ 66 | -------------------------------------------------------------------------------- /src/daemon/utils_random.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_random.c 3 | * Copyright (C) 2013 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian Forster 25 | **/ 26 | 27 | #include "collectd.h" 28 | 29 | #include "utils_random.h" 30 | #include "utils_time.h" 31 | 32 | #include 33 | 34 | #ifdef WIN32 35 | double erand48(unsigned short unused[3]) { 36 | return (double)rand() / (double)RAND_MAX; 37 | } 38 | 39 | long int jrand48(unsigned short unused[3]) { return rand(); } 40 | #endif 41 | 42 | static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; 43 | static bool have_seed; 44 | static unsigned short seed[3]; 45 | 46 | static void cdrand_seed(void) { 47 | cdtime_t t; 48 | 49 | if (have_seed) 50 | return; 51 | 52 | t = cdtime(); 53 | 54 | seed[0] = (unsigned short)t; 55 | seed[1] = (unsigned short)(t >> 16); 56 | seed[2] = (unsigned short)(t >> 32); 57 | 58 | #ifdef WIN32 59 | srand((unsigned)t); 60 | #endif 61 | 62 | have_seed = true; 63 | } 64 | 65 | double cdrand_d(void) { 66 | double r; 67 | 68 | pthread_mutex_lock(&lock); 69 | cdrand_seed(); 70 | r = erand48(seed); 71 | pthread_mutex_unlock(&lock); 72 | 73 | return r; 74 | } 75 | 76 | uint32_t cdrand_u(void) { 77 | long r; 78 | 79 | pthread_mutex_lock(&lock); 80 | cdrand_seed(); 81 | r = jrand48(seed); 82 | pthread_mutex_unlock(&lock); 83 | 84 | return (uint32_t)r; 85 | } 86 | 87 | long cdrand_range(long min, long max) { 88 | long range; 89 | long r; 90 | 91 | range = 1 + max - min; 92 | 93 | r = (long)(0.5 + (cdrand_d() * range)); 94 | r += min; 95 | 96 | return r; 97 | } 98 | -------------------------------------------------------------------------------- /src/daemon/utils_random.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_random.h 3 | * Copyright (C) 2013 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian Forster 25 | **/ 26 | 27 | #ifndef UTILS_RANDOM_H 28 | #define UTILS_RANDOM_H 1 29 | 30 | /** 31 | * Returns a random double value in the range [0..1), i.e. excluding 1. 32 | * 33 | * This function is thread- and reentrant-safe. 34 | */ 35 | double cdrand_d(void); 36 | 37 | /** 38 | * cdrand_u returns a random uint32_t value uniformly distributed in the range 39 | * [0-2^32). 40 | * 41 | * This function is thread- and reentrant-safe. 42 | */ 43 | uint32_t cdrand_u(void); 44 | 45 | /** 46 | * Returns a random long between min and max, inclusively. 47 | * 48 | * If min is larger than max, the result may be rounded incorrectly and may be 49 | * outside the intended range. This function is thread- and reentrant-safe. 50 | */ 51 | long cdrand_range(long min, long max); 52 | 53 | #endif /* !UTILS_RANDOM_H */ 54 | -------------------------------------------------------------------------------- /src/daemon/utils_threshold.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_threshold.h 3 | * Copyright (C) 2014 Pierre-Yves Ritschard 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Pierre-Yves Ritschard 25 | **/ 26 | 27 | #ifndef UTILS_THRESHOLD_H 28 | #define UTILS_THRESHOLD_H 1 29 | 30 | #define UT_FLAG_INVERT 0x01 31 | #define UT_FLAG_PERSIST 0x02 32 | #define UT_FLAG_PERCENTAGE 0x04 33 | #define UT_FLAG_INTERESTING 0x08 34 | #define UT_FLAG_PERSIST_OK 0x10 35 | typedef struct threshold_s { 36 | char host[DATA_MAX_NAME_LEN]; 37 | char plugin[DATA_MAX_NAME_LEN]; 38 | char plugin_instance[DATA_MAX_NAME_LEN]; 39 | char type[DATA_MAX_NAME_LEN]; 40 | char type_instance[DATA_MAX_NAME_LEN]; 41 | char data_source[DATA_MAX_NAME_LEN]; 42 | gauge_t warning_min; 43 | gauge_t warning_max; 44 | gauge_t failure_min; 45 | gauge_t failure_max; 46 | gauge_t hysteresis; 47 | unsigned int flags; 48 | int hits; 49 | struct threshold_s *next; 50 | } threshold_t; 51 | 52 | extern c_avl_tree_t *threshold_tree; 53 | extern pthread_mutex_t threshold_lock; 54 | 55 | threshold_t *threshold_get(const char *hostname, const char *plugin, 56 | const char *plugin_instance, const char *type, 57 | const char *type_instance); 58 | 59 | threshold_t *threshold_search(const value_list_t *vl); 60 | 61 | int ut_search_threshold(const value_list_t *vl, threshold_t *ret_threshold); 62 | 63 | #endif /* UTILS_THRESHOLD_H */ 64 | -------------------------------------------------------------------------------- /src/hddtemp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octo/collectd/3a3ef49092b924afe9a3351c73206cad96e625d3/src/hddtemp.c -------------------------------------------------------------------------------- /src/intel-nvme.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/intel-nvme.h 3 | * MIT License 4 | * 5 | * Copyright (C) 2020 Intel Corporation. All rights reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | * 25 | * Authors: 26 | * Bartlomiej Kotlowski 27 | * **/ 28 | 29 | #include 30 | 31 | #ifdef __CHECKER__ 32 | #define __force __attribute__((force)) 33 | #else 34 | #define __force 35 | #endif 36 | 37 | #define NVME_SMART_INTEL_CDW10 0x008000ca 38 | #define INTEL_VENDOR_ID 0x8086 39 | 40 | struct __attribute__((packed)) nvme_additional_smart_log_item { 41 | __u8 key; 42 | __u8 _kp[2]; 43 | __u8 norm; 44 | __u8 _np; 45 | union __attribute__((packed)) { 46 | __u8 raw[6]; 47 | struct __attribute__((packed)) wear_level { 48 | __le16 min; 49 | __le16 max; 50 | __le16 avg; 51 | } wear_level; 52 | struct __attribute__((packed)) thermal_throttle { 53 | __u8 pct; 54 | __u32 count; 55 | } thermal_throttle; 56 | }; 57 | __u8 _rp; 58 | }; 59 | 60 | struct nvme_additional_smart_log { 61 | struct nvme_additional_smart_log_item program_fail_cnt; 62 | struct nvme_additional_smart_log_item erase_fail_cnt; 63 | struct nvme_additional_smart_log_item wear_leveling_cnt; 64 | struct nvme_additional_smart_log_item e2e_err_cnt; 65 | struct nvme_additional_smart_log_item crc_err_cnt; 66 | struct nvme_additional_smart_log_item timed_workload_media_wear; 67 | struct nvme_additional_smart_log_item timed_workload_host_reads; 68 | struct nvme_additional_smart_log_item timed_workload_timer; 69 | struct nvme_additional_smart_log_item thermal_throttle_status; 70 | struct nvme_additional_smart_log_item retry_buffer_overflow_cnt; 71 | struct nvme_additional_smart_log_item pll_lock_loss_cnt; 72 | struct nvme_additional_smart_log_item nand_bytes_written; 73 | struct nvme_additional_smart_log_item host_bytes_written; 74 | }; 75 | -------------------------------------------------------------------------------- /src/libcollectdclient/collectd/lcc_features.h.in: -------------------------------------------------------------------------------- 1 | /** 2 | * libcollectdclient - src/libcollectdclient/lcc_features.h 3 | * Copyright (C) 2009 Sebastian Harl 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Sebastian tokkee Harl 25 | **/ 26 | 27 | #ifndef LIBCOLLECTD_LCC_FEATURES_H 28 | #define LIBCOLLECTD_LCC_FEATURES_H 1 29 | 30 | #ifdef __cplusplus 31 | # define LCC_BEGIN_DECLS extern "C" { 32 | # define LCC_END_DECLS } 33 | #else 34 | # define LCC_BEGIN_DECLS 35 | # define LCC_END_DECLS 36 | #endif 37 | 38 | #define LCC_API_VERSION 0 39 | 40 | #define LCC_VERSION_MAJOR @LCC_VERSION_MAJOR@ 41 | #define LCC_VERSION_MINOR @LCC_VERSION_MINOR@ 42 | #define LCC_VERSION_PATCH @LCC_VERSION_PATCH@ 43 | 44 | #define LCC_VERSION_EXTRA "@LCC_VERSION_EXTRA@" 45 | 46 | #define LCC_VERSION_STRING "@LCC_VERSION_STRING@" 47 | 48 | #define LCC_VERSION_ENCODE(major, minor, patch) \ 49 | ((major) * 10000 + (minor) * 100 + (patch)) 50 | 51 | #define LCC_VERSION \ 52 | LCC_VERSION_ENCODE(LCC_VERSION_MAJOR, LCC_VERSION_MINOR, LCC_VERSION_PATCH) 53 | 54 | LCC_BEGIN_DECLS 55 | 56 | unsigned int lcc_version (void); 57 | 58 | const char *lcc_version_string (void); 59 | 60 | const char *lcc_version_extra (void); 61 | 62 | LCC_END_DECLS 63 | 64 | #endif /* ! LIBCOLLECTD_LCC_FEATURES_H */ 65 | -------------------------------------------------------------------------------- /src/libcollectdclient/collectd/network.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/libcollectdclient/collectd/network.h 3 | * Copyright (C) 2005-2012 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef LIBCOLLECTDCLIENT_NETWORK_H 28 | #define LIBCOLLECTDCLIENT_NETWORK_H 1 29 | 30 | #include "collectd/client.h" 31 | 32 | #include 33 | #include 34 | 35 | #ifdef WIN32 36 | extern unsigned int if_nametoindex(const char *interface_name); 37 | #endif 38 | 39 | #define NET_DEFAULT_V4_ADDR "239.192.74.66" 40 | #define NET_DEFAULT_V6_ADDR "ff18::efc0:4a42" 41 | #define NET_DEFAULT_PORT "25826" 42 | 43 | struct lcc_network_s; 44 | typedef struct lcc_network_s lcc_network_t; 45 | 46 | struct lcc_server_s; 47 | typedef struct lcc_server_s lcc_server_t; 48 | 49 | enum lcc_security_level_e { NONE, SIGN, ENCRYPT }; 50 | typedef enum lcc_security_level_e lcc_security_level_t; 51 | 52 | /* 53 | * Create / destroy object 54 | */ 55 | lcc_network_t *lcc_network_create(void); 56 | void lcc_network_destroy(lcc_network_t *net); 57 | 58 | /* 59 | * Add servers 60 | */ 61 | lcc_server_t *lcc_server_create(lcc_network_t *net, const char *node, 62 | const char *service); 63 | int lcc_server_destroy(lcc_network_t *net, lcc_server_t *srv); 64 | 65 | /* Configure servers */ 66 | int lcc_server_set_ttl(lcc_server_t *srv, uint8_t ttl); 67 | int lcc_server_set_interface(lcc_server_t *srv, char const *iface); 68 | int lcc_server_set_security_level(lcc_server_t *srv, lcc_security_level_t level, 69 | const char *username, const char *password); 70 | 71 | /* 72 | * Send data 73 | */ 74 | int lcc_network_values_send(lcc_network_t *net, const lcc_value_list_t *vl); 75 | #if 0 76 | int lcc_network_notification_send (lcc_network_t *net, 77 | const lcc_notification_t *notif); 78 | #endif 79 | 80 | #endif /* LIBCOLLECTDCLIENT_NETWORK_H */ 81 | -------------------------------------------------------------------------------- /src/libcollectdclient/collectd/network_buffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/libcollectdclient/collectd/network_buffer.h 3 | * Copyright (C) 2010-2012 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef LIBCOLLECTDCLIENT_NETWORK_BUFFER_H 28 | #define LIBCOLLECTDCLIENT_NETWORK_BUFFER_H 1 29 | 30 | #include "config.h" 31 | 32 | #include "collectd/network.h" /* for lcc_security_level_t */ 33 | #include "collectd/types.h" 34 | 35 | /* Ethernet frame - (IPv6 header + UDP header) */ 36 | #define LCC_NETWORK_BUFFER_SIZE_DEFAULT 1452 37 | 38 | struct lcc_network_buffer_s; 39 | typedef struct lcc_network_buffer_s lcc_network_buffer_t; 40 | 41 | lcc_network_buffer_t *lcc_network_buffer_create(size_t size); 42 | void lcc_network_buffer_destroy(lcc_network_buffer_t *nb); 43 | 44 | int lcc_network_buffer_set_security_level(lcc_network_buffer_t *nb, 45 | lcc_security_level_t level, 46 | const char *user, 47 | const char *password); 48 | 49 | int lcc_network_buffer_initialize(lcc_network_buffer_t *nb); 50 | int lcc_network_buffer_finalize(lcc_network_buffer_t *nb); 51 | 52 | int lcc_network_buffer_add_value(lcc_network_buffer_t *nb, 53 | const lcc_value_list_t *vl); 54 | 55 | int lcc_network_buffer_get(lcc_network_buffer_t *nb, void *buffer, 56 | size_t *buffer_size); 57 | 58 | #endif /* LIBCOLLECTDCLIENT_NETWORK_BUFFER_H */ 59 | -------------------------------------------------------------------------------- /src/libcollectdclient/collectd/network_parse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Florian Forster 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | * 22 | * Authors: 23 | * Florian octo Forster 24 | **/ 25 | 26 | #ifndef LIBCOLLECTD_NETWORK_PARSE_H 27 | #define LIBCOLLECTD_NETWORK_PARSE_H 1 28 | 29 | #include "collectd/lcc_features.h" 30 | 31 | #include "collectd/network.h" /* for lcc_security_level_t */ 32 | #include "collectd/types.h" 33 | 34 | #include 35 | 36 | LCC_BEGIN_DECLS 37 | 38 | typedef struct { 39 | /* writer is the callback used to send incoming lcc_value_list_t to. */ 40 | lcc_value_list_writer_t writer; 41 | 42 | /* password_lookup is used to look up the password for a given username. */ 43 | lcc_password_lookup_t password_lookup; 44 | 45 | /* security_level is the minimal required security level. */ 46 | lcc_security_level_t security_level; 47 | } lcc_network_parse_options_t; 48 | 49 | /* lcc_network_parse parses data received from the network and calls "w" with 50 | * the parsed lcc_value_list_ts. */ 51 | int lcc_network_parse(void *buffer, size_t buffer_size, 52 | lcc_network_parse_options_t opts); 53 | 54 | LCC_END_DECLS 55 | 56 | #endif /* LIBCOLLECTD_NETWORK_PARSE_H */ 57 | -------------------------------------------------------------------------------- /src/libcollectdclient/libcollectdclient.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libcollectdclient 7 | Description: Client library for the unixsock plugin of collectd. 8 | Version: @LCC_VERSION_STRING@ 9 | URL: http://collectd.org/ 10 | Libs: -L${libdir} -lcollectdclient 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /src/liboconfig/AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octo/collectd/3a3ef49092b924afe9a3351c73206cad96e625d3/src/liboconfig/AUTHORS -------------------------------------------------------------------------------- /src/liboconfig/ChangeLog: -------------------------------------------------------------------------------- 1 | 2007-02-15, Version 0.1.1 2 | * src/parser.y: Fixes a memory leak. 3 | 4 | 2007-02-11, Version 0.1.0 5 | * Initial release. 6 | -------------------------------------------------------------------------------- /src/liboconfig/aux_types.h: -------------------------------------------------------------------------------- 1 | #ifndef AUX_TYPES_H 2 | #define AUX_TYPES_H 1 3 | 4 | struct statement_list_s { 5 | oconfig_item_t *statement; 6 | int statement_num; 7 | }; 8 | typedef struct statement_list_s statement_list_t; 9 | 10 | struct argument_list_s { 11 | oconfig_value_t *argument; 12 | int argument_num; 13 | }; 14 | typedef struct argument_list_s argument_list_t; 15 | 16 | #endif /* AUX_TYPES_H */ 17 | -------------------------------------------------------------------------------- /src/liboconfig/oconfig.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/liboconfig/oconfig.h 3 | * Copyright (C) 2006-2009 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian Forster 25 | */ 26 | 27 | #ifndef OCONFIG_H 28 | #define OCONFIG_H 1 29 | 30 | #include 31 | 32 | /* 33 | * Types 34 | */ 35 | #define OCONFIG_TYPE_STRING 0 36 | #define OCONFIG_TYPE_NUMBER 1 37 | #define OCONFIG_TYPE_BOOLEAN 2 38 | 39 | struct oconfig_value_s { 40 | union { 41 | char *string; 42 | double number; 43 | int boolean; 44 | } value; 45 | int type; 46 | }; 47 | typedef struct oconfig_value_s oconfig_value_t; 48 | 49 | struct oconfig_item_s; 50 | typedef struct oconfig_item_s oconfig_item_t; 51 | struct oconfig_item_s { 52 | char *key; 53 | oconfig_value_t *values; 54 | int values_num; 55 | 56 | oconfig_item_t *parent; 57 | oconfig_item_t *children; 58 | int children_num; 59 | }; 60 | 61 | /* 62 | * Functions 63 | */ 64 | oconfig_item_t *oconfig_parse_file(const char *file); 65 | 66 | oconfig_item_t *oconfig_clone(const oconfig_item_t *ci); 67 | 68 | void oconfig_free(oconfig_item_t *ci); 69 | 70 | #endif /* OCONFIG_H */ 71 | -------------------------------------------------------------------------------- /src/msr-index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Partial header file imported from the linux kernel 3 | * (arch/x86/include/asm/msr-index.h) 4 | * as it is not provided by the kernel sources anymore 5 | * 6 | * Only the minimal blocks of macro have been included 7 | * ---- 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms and conditions of the GNU General Public License, 10 | * version 2, as published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 | * more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along with 18 | * this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 20 | * ---- 21 | */ 22 | 23 | #ifndef _ASM_X86_MSR_INDEX_H 24 | #define _ASM_X86_MSR_INDEX_H 25 | 26 | /* 27 | * CPU model specific register (MSR) numbers. 28 | * 29 | * Do not add new entries to this file unless the definitions are shared 30 | * between multiple compilation units. 31 | */ 32 | 33 | /* Intel MSRs. Some also available on other CPUs */ 34 | 35 | /* C-state Residency Counters */ 36 | #define MSR_PKG_C3_RESIDENCY 0x000003f8 37 | #define MSR_PKG_C6_RESIDENCY 0x000003f9 38 | #define MSR_ATOM_PKG_C6_RESIDENCY 0x000003fa 39 | #define MSR_PKG_C7_RESIDENCY 0x000003fa 40 | #define MSR_CORE_C3_RESIDENCY 0x000003fc 41 | #define MSR_CORE_C6_RESIDENCY 0x000003fd 42 | #define MSR_CORE_C7_RESIDENCY 0x000003fe 43 | #define MSR_KNL_CORE_C6_RESIDENCY 0x000003ff 44 | #define MSR_PKG_C2_RESIDENCY 0x0000060d 45 | #define MSR_PKG_C8_RESIDENCY 0x00000630 46 | #define MSR_PKG_C9_RESIDENCY 0x00000631 47 | #define MSR_PKG_C10_RESIDENCY 0x00000632 48 | 49 | /* Run Time Average Power Limiting (RAPL) Interface */ 50 | 51 | #define MSR_RAPL_POWER_UNIT 0x00000606 52 | 53 | #define MSR_PKG_POWER_LIMIT 0x00000610 54 | #define MSR_PKG_ENERGY_STATUS 0x00000611 55 | #define MSR_PKG_PERF_STATUS 0x00000613 56 | #define MSR_PKG_POWER_INFO 0x00000614 57 | 58 | #define MSR_DRAM_POWER_LIMIT 0x00000618 59 | #define MSR_DRAM_ENERGY_STATUS 0x00000619 60 | #define MSR_UNCORE_FREQ_SCALING 0x00000621 61 | #define MSR_DRAM_PERF_STATUS 0x0000061b 62 | #define MSR_DRAM_POWER_INFO 0x0000061c 63 | 64 | #define MSR_PP0_POWER_LIMIT 0x00000638 65 | #define MSR_PP0_ENERGY_STATUS 0x00000639 66 | #define MSR_PP0_POLICY 0x0000063a 67 | #define MSR_PP0_PERF_STATUS 0x0000063b 68 | 69 | #define MSR_PP1_POWER_LIMIT 0x00000640 70 | #define MSR_PP1_ENERGY_STATUS 0x00000641 71 | #define MSR_PP1_POLICY 0x00000642 72 | 73 | /* Intel defined MSRs. */ 74 | #define MSR_IA32_TSC 0x00000010 75 | #define MSR_SMI_COUNT 0x00000034 76 | 77 | #define MSR_IA32_MPERF 0x000000e7 78 | #define MSR_IA32_APERF 0x000000e8 79 | 80 | #define MSR_IA32_THERM_STATUS 0x0000019c 81 | 82 | #define MSR_IA32_MISC_ENABLE 0x000001a0 83 | #define MSR_IA32_TEMPERATURE_TARGET 0x000001a2 84 | 85 | #define MSR_IA32_PACKAGE_THERM_STATUS 0x000001b1 86 | 87 | #endif /* _ASM_X86_MSR_INDEX_H */ 88 | -------------------------------------------------------------------------------- /src/network.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/network.h 3 | * Copyright (C) 2005-2008 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef NETWORK_H 28 | #define NETWORK_H 29 | 30 | /* 31 | * From RFC2365: Administratively Scoped IP Multicast 32 | * 33 | * The IPv4 Organization Local Scope -- 239.192.0.0/14 34 | * 35 | * 239.192.0.0/14 is defined to be the IPv4 Organization Local Scope, and is 36 | * the space from which an organization should allocate sub-ranges when 37 | * defining scopes for private use. 38 | * 39 | * Port 25826 is not assigned as of 2005-09-12 40 | */ 41 | 42 | /* 43 | * From RFC2373: IP Version 6 Addressing Architecture 44 | * 45 | * 2.7 Multicast Addresses 46 | * 47 | * | 8 | 4 | 4 | 80 bits | 32 bits | 48 | * +--------+----+----+---------------------------+-----------------+ 49 | * |11111111|flgs|scop| reserved must be zero | group ID | 50 | * +--------+----+----+---------------------------+-----------------+ 51 | * 52 | * flgs = 1 => non-permanently-assigned ("transient") multicast address. 53 | * scop = 8 => organization-local scope 54 | * 55 | * group = efc0:4a42 = 239.192.74.66 56 | */ 57 | 58 | #define NET_DEFAULT_V4_ADDR "239.192.74.66" 59 | #define NET_DEFAULT_V6_ADDR "ff18::efc0:4a42" 60 | #define NET_DEFAULT_PORT "25826" 61 | 62 | #define TYPE_HOST 0x0000 63 | #define TYPE_TIME 0x0001 64 | #define TYPE_TIME_HR 0x0008 65 | #define TYPE_PLUGIN 0x0002 66 | #define TYPE_PLUGIN_INSTANCE 0x0003 67 | #define TYPE_TYPE 0x0004 68 | #define TYPE_TYPE_INSTANCE 0x0005 69 | #define TYPE_VALUES 0x0006 70 | #define TYPE_INTERVAL 0x0007 71 | #define TYPE_INTERVAL_HR 0x0009 72 | 73 | /* Types to transmit notifications */ 74 | #define TYPE_MESSAGE 0x0100 75 | #define TYPE_SEVERITY 0x0101 76 | 77 | #define TYPE_SIGN_SHA256 0x0200 78 | #define TYPE_ENCR_AES256 0x0210 79 | 80 | #endif /* NETWORK_H */ 81 | -------------------------------------------------------------------------------- /src/nvme.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/nvme.h 3 | * MIT License 4 | * 5 | * Copyright (C) 2020 Intel Corporation. All rights reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | * 25 | * Authors: 26 | * Bartlomiej Kotlowski 27 | * **/ 28 | 29 | #include 30 | 31 | #define NVME_NSID_ALL 0xffffffff 32 | #define NVME_ADMIN_GET_LOG_PAGE 0x02 33 | #define NVME_ADMIN_IDENTIFY 0x06 34 | 35 | union nvme_smart_log { 36 | struct { 37 | __u8 critical_warning; 38 | __u8 temperature[2]; 39 | __u8 avail_spare; 40 | __u8 spare_thresh; 41 | __u8 percent_used; 42 | __u8 endu_grp_crit_warn_sumry; 43 | __u8 rsvd1[25]; 44 | __u8 data_units_read[16]; 45 | __u8 data_units_written[16]; 46 | __u8 host_commands_read[16]; 47 | __u8 host_commands_written[16]; 48 | __u8 ctrl_busy_time[16]; 49 | __u8 power_cycles[16]; 50 | __u8 power_on_hours[16]; 51 | __u8 unsafe_shutdowns[16]; 52 | __u8 media_errors[16]; 53 | __u8 num_err_log_entries[16]; 54 | __le32 warning_temp_time; 55 | __le32 critical_comp_time; 56 | __le16 temp_sensor[8]; 57 | __le32 thm_temp1_trans_count; 58 | __le32 thm_temp2_trans_count; 59 | __le32 thm_temp1_total_time; 60 | __le32 thm_temp2_total_time; 61 | __u8 rsvd2[280]; 62 | } data; 63 | __u8 raw[512]; 64 | }; 65 | -------------------------------------------------------------------------------- /src/pinba.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package Pinba; 4 | option optimize_for = SPEED; 5 | 6 | message Request { 7 | required string hostname = 1; 8 | required string server_name = 2; 9 | required string script_name = 3; 10 | required uint32 request_count = 4; 11 | required uint32 document_size = 5; 12 | required uint32 memory_peak = 6; 13 | required float request_time = 7; 14 | required float ru_utime = 8; 15 | required float ru_stime = 9; 16 | 17 | repeated uint32 timer_hit_count = 10; 18 | repeated float timer_value = 11; 19 | repeated uint32 timer_tag_count = 12; 20 | repeated uint32 timer_tag_name = 13; 21 | repeated uint32 timer_tag_value = 14; 22 | repeated string dictionary = 15; 23 | optional uint32 status = 16; 24 | } 25 | -------------------------------------------------------------------------------- /src/utils/cmds/flush.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_cmd_flush.h 3 | * Copyright (C) 2008, 2016 Sebastian Harl 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Sebastian "tokkee" Harl 25 | **/ 26 | 27 | #ifndef UTILS_CMD_FLUSH_H 28 | #define UTILS_CMD_FLUSH_H 1 29 | 30 | #include "utils/cmds/cmds.h" 31 | 32 | #include 33 | 34 | cmd_status_t cmd_parse_flush(size_t argc, char **argv, cmd_flush_t *ret_flush, 35 | const cmd_options_t *opts, 36 | cmd_error_handler_t *err); 37 | 38 | cmd_status_t cmd_handle_flush(FILE *fh, char *buffer); 39 | 40 | void cmd_destroy_flush(cmd_flush_t *flush); 41 | 42 | #endif /* UTILS_CMD_FLUSH_H */ 43 | -------------------------------------------------------------------------------- /src/utils/cmds/getthreshold.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_cmd_getthreshold.h 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_CMD_GETTHRESHOLD_H 28 | #define UTILS_CMD_GETTHRESHOLD_H 1 29 | 30 | #include 31 | 32 | int handle_getthreshold(FILE *fh, char *buffer); 33 | 34 | #endif /* UTILS_CMD_GETTHRESHOLD_H */ 35 | -------------------------------------------------------------------------------- /src/utils/cmds/getval.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_cmd_getval.h 3 | * Copyright (C) 2008 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_CMD_GETVAL_H 28 | #define UTILS_CMD_GETVAL_H 1 29 | 30 | #include 31 | 32 | #include "utils/cmds/cmds.h" 33 | 34 | cmd_status_t cmd_parse_getval(size_t argc, char **argv, 35 | cmd_getval_t *ret_getval, 36 | const cmd_options_t *opts, 37 | cmd_error_handler_t *err); 38 | 39 | cmd_status_t cmd_handle_getval(FILE *fh, char *buffer); 40 | 41 | void cmd_destroy_getval(cmd_getval_t *getval); 42 | 43 | #endif /* UTILS_CMD_GETVAL_H */ 44 | -------------------------------------------------------------------------------- /src/utils/cmds/listval.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_cmd_listval.h 3 | * Copyright (C) 2008 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_CMD_LISTVAL_H 28 | #define UTILS_CMD_LISTVAL_H 1 29 | 30 | #include 31 | 32 | #include "utils/cmds/cmds.h" 33 | 34 | cmd_status_t cmd_parse_listval(size_t argc, char **argv, 35 | const cmd_options_t *opts, 36 | cmd_error_handler_t *err); 37 | 38 | cmd_status_t cmd_handle_listval(FILE *fh, char *buffer); 39 | 40 | #endif /* UTILS_CMD_LISTVAL_H */ 41 | -------------------------------------------------------------------------------- /src/utils/cmds/parse_option.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_parse_option.h 3 | * Copyright (C) 2008 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_PARSE_OPTION 28 | #define UTILS_PARSE_OPTION 1 29 | 30 | int parse_string(char **ret_buffer, char **ret_string); 31 | int parse_option(char **ret_buffer, char **ret_key, char **ret_value); 32 | 33 | #endif /* UTILS_PARSE_OPTION */ 34 | -------------------------------------------------------------------------------- /src/utils/cmds/putnotif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_cmd_putnotif.h 3 | * Copyright (C) 2008 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_CMD_PUTNOTIF_H 28 | #define UTILS_CMD_PUTNOTIF_H 1 29 | 30 | #include 31 | 32 | int handle_putnotif(FILE *fh, char *buffer); 33 | 34 | #endif /* UTILS_CMD_PUTNOTIF_H */ 35 | -------------------------------------------------------------------------------- /src/utils/cmds/putval.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_cmd_putval.h 3 | * Copyright (C) 2007 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_CMD_PUTVAL_H 28 | #define UTILS_CMD_PUTVAL_H 1 29 | 30 | #include "plugin.h" 31 | #include "utils/cmds/cmds.h" 32 | 33 | #include 34 | 35 | cmd_status_t cmd_parse_putval(size_t argc, char **argv, 36 | cmd_putval_t *ret_putval, 37 | const cmd_options_t *opts, 38 | cmd_error_handler_t *err); 39 | 40 | cmd_status_t cmd_handle_putval(FILE *fh, char *buffer); 41 | 42 | void cmd_destroy_putval(cmd_putval_t *putval); 43 | 44 | int cmd_create_putval(char *ret, size_t ret_len, const data_set_t *ds, 45 | const value_list_t *vl); 46 | 47 | #endif /* UTILS_CMD_PUTVAL_H */ 48 | -------------------------------------------------------------------------------- /src/utils/crc32/crc32.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_crc32.h 3 | * Copyright (C) 2014 Pierre-Yves Ritschard 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Pierre-Yves Ritschard 25 | */ 26 | 27 | #ifndef UTILS_CRC32_H 28 | #define UTILS_CRC32_H 1 29 | 30 | uint32_t crc32_buffer(const unsigned char *, size_t); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/utils/curl_stats/curl_stats.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_curl_stats.h 3 | * Copyright (C) 2015 Sebastian 'tokkee' Harl 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Sebastian Harl 25 | **/ 26 | 27 | #ifndef UTILS_CURL_STATS_H 28 | #define UTILS_CURL_STATS_H 1 29 | 30 | #include "plugin.h" 31 | 32 | #include 33 | 34 | struct curl_stats_s; 35 | typedef struct curl_stats_s curl_stats_t; 36 | 37 | /* 38 | * curl_stats_from_config allocates and constructs a cURL statistics object 39 | * from the specified configuration which is expected to be a single block of 40 | * boolean options named after cURL information fields. The boolean value 41 | * indicates whether to collect the respective information. 42 | * 43 | * See http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html 44 | */ 45 | curl_stats_t *curl_stats_from_config(oconfig_item_t *ci); 46 | 47 | void curl_stats_destroy(curl_stats_t *s); 48 | 49 | /* 50 | * curl_stats_dispatch dispatches performance values from the the specified 51 | * cURL session to the daemon. 52 | */ 53 | int curl_stats_dispatch(curl_stats_t *s, CURL *curl, const char *hostname, 54 | const char *plugin, const char *plugin_instance); 55 | 56 | #endif /* UTILS_CURL_STATS_H */ 57 | -------------------------------------------------------------------------------- /src/utils/format_graphite/format_graphite.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_format_graphite.h 3 | * Copyright (C) 2012 Thomas Meson 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; only version 2 of the License is applicable. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | * Author: 19 | * Thomas Meson 20 | **/ 21 | 22 | #ifndef UTILS_FORMAT_GRAPHITE_H 23 | #define UTILS_FORMAT_GRAPHITE_H 1 24 | 25 | #include "collectd.h" 26 | 27 | #include "plugin.h" 28 | 29 | #define GRAPHITE_STORE_RATES 0x01 30 | #define GRAPHITE_SEPARATE_INSTANCES 0x02 31 | #define GRAPHITE_ALWAYS_APPEND_DS 0x04 32 | #define GRAPHITE_DROP_DUPE_FIELDS 0x08 33 | #define GRAPHITE_PRESERVE_SEPARATOR 0x10 34 | #define GRAPHITE_USE_TAGS 0x20 35 | #define GRAPHITE_REVERSE_HOST 0x40 36 | 37 | int format_graphite(char *buffer, size_t buffer_size, const data_set_t *ds, 38 | const value_list_t *vl, const char *prefix, 39 | const char *postfix, const char escape_char, 40 | unsigned int flags); 41 | 42 | #endif /* UTILS_FORMAT_GRAPHITE_H */ 43 | -------------------------------------------------------------------------------- /src/utils/format_influxdb/format_influxdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_format_influxdb.h 3 | * Copyright (C) 2007-2009 Florian octo Forster 4 | * Copyright (C) 2009 Aman Gupta 5 | * Copyright (C) 2019 Carlos Peon Costa 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; only version 2 of the License is applicable. 10 | * 11 | * This program is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | * Authors: 21 | * Florian octo Forster 22 | * Aman Gupta 23 | * Carlos Peon Costa 24 | * multiple Server directives by: 25 | * Paul (systemcrash) 26 | **/ 27 | 28 | #ifndef UTILS_FORMAT_INFLUXDB_H 29 | #define UTILS_FORMAT_INFLUXDB_H 1 30 | 31 | #include "collectd.h" 32 | 33 | #include "plugin.h" 34 | 35 | typedef enum { 36 | NS, 37 | US, 38 | MS, 39 | } format_influxdb_time_precision_t; 40 | 41 | int format_influxdb_value_list(char *buffer, int buffer_len, 42 | const data_set_t *ds, const value_list_t *vl, 43 | format_influxdb_time_precision_t time_precision, 44 | bool store_rates, bool write_meta); 45 | 46 | #endif /* UTILS_FORMAT_INFLUXDB_H */ 47 | -------------------------------------------------------------------------------- /src/utils/format_json/format_json.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_format_json.h 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_FORMAT_JSON_H 28 | #define UTILS_FORMAT_JSON_H 1 29 | 30 | #include "collectd.h" 31 | 32 | #include "plugin.h" 33 | 34 | #ifndef JSON_GAUGE_FORMAT 35 | #define JSON_GAUGE_FORMAT GAUGE_FORMAT 36 | #endif 37 | 38 | int format_json_initialize(char *buffer, size_t *ret_buffer_fill, 39 | size_t *ret_buffer_free); 40 | int format_json_value_list(char *buffer, size_t *ret_buffer_fill, 41 | size_t *ret_buffer_free, const data_set_t *ds, 42 | const value_list_t *vl, int store_rates); 43 | int format_json_finalize(char *buffer, size_t *ret_buffer_fill, 44 | size_t *ret_buffer_free); 45 | int format_json_notification(char *buffer, size_t buffer_size, 46 | notification_t const *n); 47 | 48 | #endif /* UTILS_FORMAT_JSON_H */ 49 | -------------------------------------------------------------------------------- /src/utils/format_kairosdb/format_kairosdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_format_kairosdb.h 3 | * Copyright (C) 2016 Aurelien Rougemont 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Aurelien beorn Rougemont 25 | **/ 26 | 27 | #ifndef UTILS_FORMAT_KAIROSDB_H 28 | #define UTILS_FORMAT_KAIROSDB_H 1 29 | 30 | #include "collectd.h" 31 | 32 | #include "plugin.h" 33 | 34 | #ifndef JSON_GAUGE_FORMAT 35 | #define JSON_GAUGE_FORMAT GAUGE_FORMAT 36 | #endif 37 | 38 | int format_kairosdb_initialize(char *buffer, size_t *ret_buffer_fill, 39 | size_t *ret_buffer_free); 40 | int format_kairosdb_value_list(char *buffer, size_t *ret_buffer_fill, 41 | size_t *ret_buffer_free, const data_set_t *ds, 42 | const value_list_t *vl, int store_rates, 43 | char const *const *http_attrs, 44 | size_t http_attrs_num, int data_ttl, 45 | char const *metrics_prefix); 46 | int format_kairosdb_finalize(char *buffer, size_t *ret_buffer_fill, 47 | size_t *ret_buffer_free); 48 | 49 | #endif /* UTILS_FORMAT_KAIROSDB_H */ 50 | -------------------------------------------------------------------------------- /src/utils/format_stackdriver/format_stackdriver_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_format_stackdriver_test.c 3 | * ISC license 4 | * 5 | * Copyright (C) 2017 Florian Forster 6 | * 7 | * Permission to use, copy, modify, and/or distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | * 19 | * Authors: 20 | * Florian Forster 21 | **/ 22 | 23 | #include "collectd.h" 24 | 25 | #include "testing.h" 26 | #include "utils/format_stackdriver/format_stackdriver.h" 27 | 28 | DEF_TEST(sd_format_metric_descriptor) { 29 | value_list_t vl = { 30 | .host = "example.com", 31 | .plugin = "unit-test", 32 | .type = "example", 33 | }; 34 | char got[1024]; 35 | 36 | data_set_t ds_single = { 37 | .type = "example", 38 | .ds_num = 1, 39 | .ds = 40 | &(data_source_t){ 41 | .name = "value", 42 | .type = DS_TYPE_GAUGE, 43 | .min = NAN, 44 | .max = NAN, 45 | }, 46 | }; 47 | EXPECT_EQ_INT( 48 | 0, sd_format_metric_descriptor(got, sizeof(got), &ds_single, &vl, 0)); 49 | char const *want_single = 50 | "{\"type\":\"custom.googleapis.com/collectd/unit_test/" 51 | "example\",\"metricKind\":\"GAUGE\",\"valueType\":\"DOUBLE\",\"labels\":[" 52 | "{\"key\":\"host\",\"valueType\":\"STRING\"},{\"key\":\"plugin_" 53 | "instance\",\"valueType\":\"STRING\"},{\"key\":\"type_instance\"," 54 | "\"valueType\":\"STRING\"}]}"; 55 | EXPECT_EQ_STR(want_single, got); 56 | 57 | data_set_t ds_double = { 58 | .type = "example", 59 | .ds_num = 2, 60 | .ds = 61 | (data_source_t[]){ 62 | {.name = "one", .type = DS_TYPE_DERIVE, .min = 0, .max = NAN}, 63 | {.name = "two", .type = DS_TYPE_DERIVE, .min = 0, .max = NAN}, 64 | }, 65 | }; 66 | EXPECT_EQ_INT( 67 | 0, sd_format_metric_descriptor(got, sizeof(got), &ds_double, &vl, 0)); 68 | char const *want_double = 69 | "{\"type\":\"custom.googleapis.com/collectd/unit_test/" 70 | "example_one\",\"metricKind\":\"CUMULATIVE\",\"valueType\":\"INT64\"," 71 | "\"labels\":[{\"key\":\"host\",\"valueType\":\"STRING\"},{\"key\":" 72 | "\"plugin_instance\",\"valueType\":\"STRING\"},{\"key\":\"type_" 73 | "instance\",\"valueType\":\"STRING\"}]}"; 74 | EXPECT_EQ_STR(want_double, got); 75 | return 0; 76 | } 77 | 78 | int main(int argc, char **argv) { 79 | RUN_TEST(sd_format_metric_descriptor); 80 | 81 | END_TEST; 82 | } 83 | -------------------------------------------------------------------------------- /src/utils/gce/gce.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_gce.h 3 | * ISC license 4 | * 5 | * Copyright (C) 2017 Florian Forster 6 | * 7 | * Permission to use, copy, modify, and/or distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | * 19 | * Authors: 20 | * Florian Forster 21 | **/ 22 | 23 | #ifndef UTILS_GCE_H 24 | #define UTILS_GCE_H 1 25 | 26 | /* gce_check returns 1 when running on Google Compute Engine (GCE) and 0 27 | * otherwise. */ 28 | _Bool gce_check(void); 29 | 30 | /* gce_project_id returns the project ID of the instance, as configured when 31 | * creating the project. 32 | * For example "example-project-a". */ 33 | char *gce_project_id(void); 34 | 35 | /* gce_instance_id returns the unique ID of the GCE instance. */ 36 | char *gce_instance_id(void); 37 | 38 | /* gce_zone returns the zone in which the GCE instance runs. */ 39 | char *gce_zone(void); 40 | 41 | /* gce_scope returns the list of scopes for the given service account (or the 42 | * default service account when NULL is passed). */ 43 | char *gce_scope(char const *email); 44 | 45 | /* gce_access_token acquires an OAuth access token for the given service account 46 | * (or 47 | * the default service account when NULL is passed) and stores it in buffer. 48 | * Access tokens are automatically cached and renewed when they expire. Returns 49 | * zero on success, non-zero otherwise. */ 50 | int gce_access_token(char const *email, char *buffer, size_t buffer_size); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/utils/heap/heap_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/tests/test_utils_heap.c 3 | * Copyright (C) 2013 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | */ 26 | 27 | #include "collectd.h" 28 | 29 | #include "testing.h" 30 | #include "utils/heap/heap.h" 31 | 32 | static int compare(void const *v0, void const *v1) { 33 | int const *i0 = v0; 34 | int const *i1 = v1; 35 | 36 | if ((*i0) < (*i1)) 37 | return -1; 38 | else if ((*i0) > (*i1)) 39 | return 1; 40 | else 41 | return 0; 42 | } 43 | 44 | DEF_TEST(simple) { 45 | int values[] = {9, 5, 6, 1, 3, 4, 0, 8, 2, 7}; 46 | c_heap_t *h; 47 | 48 | CHECK_NOT_NULL(h = c_heap_create(compare)); 49 | for (int i = 0; i < 10; i++) 50 | CHECK_ZERO(c_heap_insert(h, &values[i])); 51 | 52 | for (int i = 0; i < 5; i++) { 53 | int *ret = NULL; 54 | CHECK_NOT_NULL(ret = c_heap_get_root(h)); 55 | OK(*ret == i); 56 | } 57 | 58 | CHECK_ZERO(c_heap_insert(h, &values[6] /* = 0 */)); 59 | CHECK_ZERO(c_heap_insert(h, &values[3] /* = 1 */)); 60 | CHECK_ZERO(c_heap_insert(h, &values[8] /* = 2 */)); 61 | CHECK_ZERO(c_heap_insert(h, &values[4] /* = 3 */)); 62 | CHECK_ZERO(c_heap_insert(h, &values[5] /* = 4 */)); 63 | 64 | for (int i = 0; i < 10; i++) { 65 | int *ret = NULL; 66 | CHECK_NOT_NULL(ret = c_heap_get_root(h)); 67 | OK(*ret == i); 68 | } 69 | 70 | c_heap_destroy(h); 71 | return 0; 72 | } 73 | 74 | int main(void) { 75 | RUN_TEST(simple); 76 | 77 | END_TEST; 78 | } 79 | -------------------------------------------------------------------------------- /src/utils/ignorelist/ignorelist.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_ignorelist.h 3 | * Copyright (C) 2006 Lubos Stanek 4 | * 5 | * This program is free software; you can redistribute it and/ 6 | * or modify it under the terms of the GNU General Public Li- 7 | * cence as published by the Free Software Foundation; either 8 | * version 2 of the Licence, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be use- 11 | * ful, but WITHOUT ANY WARRANTY; without even the implied war- 12 | * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public Licence for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | * Authors: 20 | * Lubos Stanek 21 | **/ 22 | /** 23 | * ignorelist handles plugin's list of configured collectable 24 | * entries with global ignore action 25 | **/ 26 | 27 | #ifndef UTILS_IGNORELIST_H 28 | #define UTILS_IGNORELIST_H 1 29 | 30 | #include "collectd.h" 31 | 32 | #if HAVE_REGEX_H 33 | #include 34 | #endif 35 | 36 | /* public prototypes */ 37 | 38 | struct ignorelist_s; 39 | typedef struct ignorelist_s ignorelist_t; 40 | 41 | /* 42 | * create the ignorelist_t with known ignore state 43 | * return pointer to ignorelist_t 44 | */ 45 | ignorelist_t *ignorelist_create(int invert); 46 | 47 | /* 48 | * free memory used by ignorelist_t 49 | */ 50 | void ignorelist_free(ignorelist_t *il); 51 | 52 | /* 53 | * set ignore state of the ignorelist_t 54 | */ 55 | void ignorelist_set_invert(ignorelist_t *il, int invert); 56 | 57 | /* 58 | * append entry to ignorelist_t 59 | * returns zero on success, non-zero upon failure. 60 | */ 61 | int ignorelist_add(ignorelist_t *il, const char *entry); 62 | 63 | /* 64 | * remote entry from ignorelist_t 65 | * returns zero on success, non-zero upon failure. 66 | */ 67 | int ignorelist_remove(ignorelist_t *il, const char *entry); 68 | 69 | /* 70 | * check list for entry 71 | * return 1 for ignored entry 72 | */ 73 | int ignorelist_match(ignorelist_t *il, const char *entry); 74 | 75 | #endif /* UTILS_IGNORELIST_H */ 76 | -------------------------------------------------------------------------------- /src/utils/latency/latency.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_latency.h 3 | * Copyright (C) 2013 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian Forster 25 | **/ 26 | 27 | #ifndef UTILS_LATENCY_LATENCY_H 28 | #define UTILS_LATENCY_LATENCY_H 1 29 | 30 | #include "collectd.h" 31 | 32 | #include "utils_time.h" 33 | 34 | #ifndef HISTOGRAM_NUM_BINS 35 | #define HISTOGRAM_NUM_BINS 1000 36 | #endif 37 | 38 | struct latency_counter_s; 39 | typedef struct latency_counter_s latency_counter_t; 40 | 41 | latency_counter_t *latency_counter_create(void); 42 | void latency_counter_destroy(latency_counter_t *lc); 43 | 44 | void latency_counter_add(latency_counter_t *lc, cdtime_t latency); 45 | void latency_counter_reset(latency_counter_t *lc); 46 | 47 | cdtime_t latency_counter_get_min(latency_counter_t *lc); 48 | cdtime_t latency_counter_get_max(latency_counter_t *lc); 49 | cdtime_t latency_counter_get_sum(latency_counter_t *lc); 50 | size_t latency_counter_get_num(latency_counter_t *lc); 51 | cdtime_t latency_counter_get_average(latency_counter_t *lc); 52 | cdtime_t latency_counter_get_percentile(latency_counter_t *lc, double percent); 53 | 54 | /* 55 | * NAME 56 | * latency_counter_get_rate(counter,lower,upper,now) 57 | * 58 | * DESCRIPTION 59 | * Calculates rate of latency values fall within requested interval. 60 | * Interval specified as (lower,upper], i.e. the lower boundary is exclusive, 61 | * the upper boundary is inclusive. 62 | * When lower is zero, then the interval is (0, upper]. 63 | * When upper is zero, then the interval is (lower, infinity). 64 | */ 65 | double latency_counter_get_rate(const latency_counter_t *lc, cdtime_t lower, 66 | cdtime_t upper, const cdtime_t now); 67 | 68 | #endif /* UTILS_LATENCY_LATENCY_H */ 69 | -------------------------------------------------------------------------------- /src/utils/latency/latency_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_latency_config.c 3 | * Copyright (C) 2013-2016 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | * Pavel Rochnyack 26 | */ 27 | 28 | #ifndef UTILS_LATENCY_CONFIG_H 29 | #define UTILS_LATENCY_CONFIG_H 1 30 | 31 | #include "collectd.h" 32 | 33 | #include "liboconfig/oconfig.h" 34 | #include "utils_time.h" 35 | 36 | typedef struct { 37 | cdtime_t lower_bound; 38 | cdtime_t upper_bound; 39 | } latency_bucket_t; 40 | 41 | typedef struct { 42 | double *percentile; 43 | size_t percentile_num; 44 | 45 | latency_bucket_t *buckets; 46 | size_t buckets_num; 47 | char *bucket_type; 48 | 49 | /* 50 | bool lower; 51 | bool upper; 52 | bool avg; 53 | */ 54 | } latency_config_t; 55 | 56 | int latency_config(latency_config_t *conf, oconfig_item_t *ci); 57 | 58 | int latency_config_copy(latency_config_t *dst, const latency_config_t src); 59 | 60 | void latency_config_free(latency_config_t conf); 61 | 62 | #endif /* UTILS_LATENCY_CONFIG_H */ 63 | -------------------------------------------------------------------------------- /src/utils/oauth/oauth.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_oauth.h 3 | * ISC license 4 | * 5 | * Copyright (C) 2017 Florian Forster 6 | * 7 | * Permission to use, copy, modify, and/or distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | * 19 | * Authors: 20 | * Florian Forster 21 | **/ 22 | 23 | #ifndef UTILS_OAUTH_H 24 | #define UTILS_OAUTH_H 25 | 26 | #include "collectd.h" 27 | #include "utils_time.h" 28 | 29 | #ifndef GOOGLE_OAUTH_URL 30 | #define GOOGLE_OAUTH_URL "https://www.googleapis.com/oauth2/v3/token" 31 | #endif 32 | 33 | #ifndef GOOGLE_OAUTH_ACCESS_TOKEN_SIZE 34 | #define GOOGLE_OAUTH_ACCESS_TOKEN_SIZE 2048 35 | #endif 36 | 37 | struct oauth_s; 38 | typedef struct oauth_s oauth_t; 39 | 40 | int oauth_parse_json_token(char const *json, char *out_access_token, 41 | size_t access_token_size, cdtime_t *expires_in); 42 | 43 | typedef struct { 44 | char *project_id; 45 | oauth_t *oauth; 46 | } oauth_google_t; 47 | 48 | /* oauth_create_google_json creates an OAuth object from JSON encoded 49 | * credentials. */ 50 | oauth_google_t oauth_create_google_json(char const *json, char const *scope); 51 | 52 | /* oauth_create_google_file reads path, which contains JSON encoded service 53 | * account credentials, and returns an OAuth object. */ 54 | oauth_google_t oauth_create_google_file(char const *path, char const *scope); 55 | 56 | /* oauth_create_google_default looks for service account credentials in a couple 57 | * of well-known places and returns an OAuth object if found. The well known 58 | * locations are: 59 | * 60 | * - ${GOOGLE_APPLICATION_CREDENTIALS} 61 | * - ${HOME}/.config/gcloud/application_default_credentials.json 62 | */ 63 | oauth_google_t oauth_create_google_default(char const *scope); 64 | 65 | /* oauth_destroy frees all resources associated with an OAuth object. */ 66 | void oauth_destroy(oauth_t *auth); 67 | 68 | int oauth_access_token(oauth_t *auth, char *buffer, size_t buffer_size); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/utils/rrdcreate/rrdcreate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_rrdcreate.h 3 | * Copyright (C) 2008-2013 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_RRDCREATE_H 28 | #define UTILS_RRDCREATE_H 1 29 | 30 | #include "plugin.h" 31 | 32 | #include 33 | 34 | struct rrdcreate_config_s { 35 | unsigned long stepsize; 36 | int heartbeat; 37 | int rrarows; 38 | double xff; 39 | 40 | int *timespans; 41 | size_t timespans_num; 42 | 43 | char **consolidation_functions; 44 | size_t consolidation_functions_num; 45 | 46 | bool async; 47 | }; 48 | typedef struct rrdcreate_config_s rrdcreate_config_t; 49 | 50 | int cu_rrd_create_file(const char *filename, const data_set_t *ds, 51 | const value_list_t *vl, const rrdcreate_config_t *cfg); 52 | 53 | #endif /* UTILS_RRDCREATE_H */ 54 | -------------------------------------------------------------------------------- /src/utils/taskstats/taskstats.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_taskstats.h 3 | * Copyright (C) 2017 Florian octo Forster 4 | * 5 | * ISC License (ISC) 6 | * 7 | * Permission to use, copy, modify, and/or distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | * 19 | * Authors: 20 | * Florian octo Forster 21 | */ 22 | 23 | #ifndef UTILS_TASKSTATS_H 24 | #define UTILS_TASKSTATS_H 1 25 | 26 | #include "collectd.h" 27 | 28 | #include "utils_time.h" 29 | 30 | struct ts_s; 31 | typedef struct ts_s ts_t; 32 | 33 | typedef struct { 34 | uint64_t cpu_ns; 35 | uint64_t blkio_ns; 36 | uint64_t swapin_ns; 37 | uint64_t freepages_ns; 38 | } ts_delay_t; 39 | 40 | ts_t *ts_create(void); 41 | void ts_destroy(ts_t *); 42 | 43 | /* ts_delay_by_tgid returns Linux delay accounting information for the task 44 | * identified by tgid. Returns zero on success and an errno otherwise. */ 45 | int ts_delay_by_tgid(ts_t *ts, uint32_t tgid, ts_delay_t *out); 46 | 47 | #endif /* UTILS_TASKSTATS_H */ 48 | -------------------------------------------------------------------------------- /src/utils_fbhash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_fbhash.h 3 | * Copyright (C) 2009 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef UTILS_FBHASH_H 28 | #define UTILS_FBHASH_H 1 29 | 30 | /* 31 | * File-backed hash 32 | * 33 | * This module reads a file of the form 34 | * key: value 35 | * into a hash, which can then be queried. The file is given to `fbh_create', 36 | * the hash is queried using `fbh_get'. If the file is changed during runtime, 37 | * it will automatically be re-read. 38 | */ 39 | 40 | struct fbhash_s; 41 | typedef struct fbhash_s fbhash_t; 42 | 43 | fbhash_t *fbh_create(const char *file); 44 | void fbh_destroy(fbhash_t *h); 45 | 46 | /* Returns the value as a newly allocated `char *'. It's the caller's 47 | * responsibility to free this memory. */ 48 | char *fbh_get(fbhash_t *h, const char *key); 49 | 50 | #endif /* UTILS_FBHASH_H */ 51 | -------------------------------------------------------------------------------- /src/utils_lua.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/utils_lua.h 3 | * Copyright (C) 2010 Florian Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian Forster 25 | **/ 26 | 27 | #ifndef UTILS_LUA_H 28 | #define UTILS_LUA_H 1 29 | 30 | #include "collectd.h" 31 | #include "plugin.h" 32 | 33 | #include 34 | 35 | /* 36 | * access functions (stack -> C) 37 | */ 38 | cdtime_t luaC_tocdtime(lua_State *L, int idx); 39 | int luaC_tostringbuffer(lua_State *L, int idx, char *buffer, 40 | size_t buffer_size); 41 | value_t luaC_tovalue(lua_State *L, int idx, int ds_type); 42 | value_list_t *luaC_tovaluelist(lua_State *L, int idx); 43 | int luaC_pushoconfigitem(lua_State *L, const oconfig_item_t *ci); 44 | 45 | /* 46 | * push functions (C -> stack) 47 | */ 48 | int luaC_pushcdtime(lua_State *L, cdtime_t t); 49 | int luaC_pushvalue(lua_State *L, value_t v, int ds_type); 50 | int luaC_pushvaluelist(lua_State *L, const data_set_t *ds, 51 | const value_list_t *vl); 52 | int luaC_pushnotification(lua_State *L, const notification_t *notification); 53 | 54 | #endif /* UTILS_LUA_H */ 55 | -------------------------------------------------------------------------------- /src/valgrind.FreeBSD.suppress: -------------------------------------------------------------------------------- 1 | { 2 | strlen_bogus_invalid_read_after_strdup 3 | Memcheck:Addr4 4 | fun:parse_value 5 | ... 6 | fun:main 7 | } 8 | -------------------------------------------------------------------------------- /src/valgrind.suppress: -------------------------------------------------------------------------------- 1 | { 2 | libnl1_virt_initialization_unpreventable_leak 3 | Memcheck:Leak 4 | ... 5 | obj:*libnl.so.1.* 6 | ... 7 | } 8 | 9 | { 10 | libvirt memory allocated at init 11 | Memcheck:Leak 12 | fun:calloc 13 | fun:g_malloc0 14 | ... 15 | fun:virOnce 16 | } 17 | -------------------------------------------------------------------------------- /src/virt_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/virt_test.c 3 | * Copyright (C) 2016 Francesco Romani 4 | * Based on 5 | * collectd - src/ceph_test.c 6 | * Copyright (C) 2015 Florian octo Forster 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; only version 2 of the License is applicable. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * Florian octo Forster 23 | **/ 24 | 25 | #include "testing.h" 26 | #include "virt.c" /* sic */ 27 | 28 | static virDomainPtr *domains; 29 | static int nr_domains; 30 | 31 | static int setup(void) { 32 | if (virInitialize() != 0) { 33 | printf("ERROR: virInitialize() != 0\n"); 34 | return -1; 35 | } 36 | 37 | conn = virConnectOpen("test:///default"); 38 | if (conn == NULL) { 39 | printf("ERROR: virConnectOpen == NULL\n"); 40 | return -1; 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | static int teardown(void) { 47 | if (domains) { 48 | for (int i = 0; i < nr_domains; ++i) 49 | virDomainFree(domains[i]); 50 | sfree(domains); 51 | } 52 | nr_domains = 0; 53 | if (conn != NULL) 54 | virConnectClose(conn); 55 | 56 | return 0; 57 | } 58 | 59 | #ifdef HAVE_LIST_ALL_DOMAINS 60 | DEF_TEST(get_domain_state_notify) { 61 | if (setup() == 0) { 62 | nr_domains = virConnectListAllDomains(conn, &domains, 63 | VIR_CONNECT_LIST_DOMAINS_PERSISTENT); 64 | if (nr_domains <= 0) { 65 | printf("ERROR: virConnectListAllDomains: nr_domains <= 0\n"); 66 | return -1; 67 | } 68 | 69 | int ret = get_domain_state_notify(domains[0]); 70 | EXPECT_EQ_INT(0, ret); 71 | } 72 | teardown(); 73 | 74 | return 0; 75 | } 76 | #endif 77 | 78 | DEF_TEST(persistent_domains_state_notification) { 79 | if (setup() == 0) { 80 | int ret = persistent_domains_state_notification(); 81 | EXPECT_EQ_INT(0, ret); 82 | } 83 | teardown(); 84 | 85 | return 0; 86 | } 87 | 88 | int main(void) { 89 | #ifdef HAVE_LIST_ALL_DOMAINS 90 | RUN_TEST(get_domain_state_notify); 91 | #endif 92 | RUN_TEST(persistent_domains_state_notification); 93 | 94 | END_TEST; 95 | } 96 | -------------------------------------------------------------------------------- /src/write_riemann_threshold.h: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/write_riemann_threshold.h 3 | * Copyright (C) 2016 Ruben Kerkhof 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; only version 2 of the License is applicable. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | * Author: 19 | * Ruben Kerkhof 20 | **/ 21 | 22 | #ifndef WRITE_RIEMANN_THRESHOLD_H 23 | #define WRITE_RIEMANN_THRESHOLD_H 24 | 25 | #include "plugin.h" 26 | 27 | /* write_riemann_threshold_check tests all matching thresholds and returns the 28 | * worst result for each data source in "statuses". "statuses" must point to 29 | * ds->ds_num integers to which the result is written. 30 | * 31 | * Returns zero on success and if no threshold has been configured. Returns 32 | * less than zero on failure. */ 33 | int write_riemann_threshold_check(const data_set_t *ds, const value_list_t *vl, 34 | int *statuses); 35 | 36 | #endif /* WRITE_RIEMANN_THRESHOLD_H */ 37 | -------------------------------------------------------------------------------- /src/xmms.c: -------------------------------------------------------------------------------- 1 | /** 2 | * collectd - src/xmms.c 3 | * Copyright (C) 2007 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #include "collectd.h" 28 | 29 | #include "plugin.h" 30 | #include "utils/common/common.h" 31 | 32 | #include 33 | 34 | static gint xmms_session; 35 | 36 | static void cxmms_submit(const char *type, gauge_t value) { 37 | value_list_t vl = VALUE_LIST_INIT; 38 | 39 | vl.values = &(value_t){.gauge = value}; 40 | vl.values_len = 1; 41 | sstrncpy(vl.plugin, "xmms", sizeof(vl.plugin)); 42 | sstrncpy(vl.type, type, sizeof(vl.type)); 43 | 44 | plugin_dispatch_values(&vl); 45 | } /* void cxmms_submit */ 46 | 47 | static int cxmms_read(void) { 48 | gint rate; 49 | gint freq; 50 | gint nch; 51 | 52 | if (!xmms_remote_is_running(xmms_session)) 53 | return 0; 54 | 55 | xmms_remote_get_info(xmms_session, &rate, &freq, &nch); 56 | 57 | if ((freq == 0) || (nch == 0)) 58 | return -1; 59 | 60 | cxmms_submit("bitrate", rate); 61 | cxmms_submit("frequency", freq); 62 | 63 | return 0; 64 | } /* int read */ 65 | 66 | void module_register(void) { 67 | plugin_register_read("xmms", cxmms_read); 68 | } /* void module_register */ 69 | -------------------------------------------------------------------------------- /testwrapper.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # collectd -- testwrapper.sh 4 | # 5 | # A wrapper script for running tests. If valgrind is available, memory 6 | # checking will be enabled for all tests. 7 | 8 | set -e 9 | 10 | MEMCHECK="" 11 | 12 | if test -n "$VALGRIND"; then 13 | MEMCHECK="$VALGRIND --quiet --tool=memcheck --error-exitcode=1" 14 | MEMCHECK="$MEMCHECK --trace-children=yes" 15 | MEMCHECK="$MEMCHECK --leak-check=full" 16 | MEMCHECK="$MEMCHECK --gen-suppressions=all" 17 | 18 | for f in "valgrind.$( uname -s ).suppress" "valgrind.suppress"; do 19 | filename="$( dirname "$0" )/src/$f" 20 | if test -e "$filename"; then 21 | # Valgrind supports up to 100 suppression files. 22 | MEMCHECK="$MEMCHECK --suppressions=$filename" 23 | fi 24 | done 25 | fi 26 | 27 | exec $MEMCHECK "$@" 28 | 29 | # vim: set tw=78 sw=4 ts=4 noexpandtab : 30 | 31 | -------------------------------------------------------------------------------- /version-gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DEFAULT_VERSION="5.12.0.git" 4 | 5 | if [ -d .git ]; then 6 | VERSION="`git describe --tags --dirty=+ --abbrev=7 2> /dev/null | sed -e '/^collectd-/!d' -e 's///' -e 'y/-/./'`" 7 | fi 8 | 9 | if test -z "$VERSION"; then 10 | VERSION="$DEFAULT_VERSION" 11 | fi 12 | 13 | printf "%s" "$VERSION" 14 | --------------------------------------------------------------------------------