mirror of
https://github.com/collectd/collectd.git
synced 2026-02-09 04:09:15 +08:00
This adds a script that installs necessary build dependencies to the
system, builds and installs collectd into an 'install/' subdirectory,
installs a sample config and starts collectd in foreground mode
afterwards.
Note that this script is entirely optional but it may help you to get
started (some plugins don't compile, so this script is only building a
few). Once installed this way, another 'make install' will re-install
collectd into install/sbin/collectd and it can be started normally.
NOTE: collectd segfaults in src/daemon/metric.c:208 (called from
src/cpu.c:545) when build this way from the current branch HEAD. It
works on tree 630b948, so it's likely caused by your code and you
already got something to fix. :-)
ChangeLog: collectd: added bootstrap helper script
49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eux
|
|
|
|
readonly DO_CLEAN=true # Clean up previous build results (true/false)
|
|
|
|
readonly MYDIR="$(dirname "$(readlink -f "$0")")" # Directory this script is in
|
|
readonly PREFIX="$MYDIR/install" # Where to install collectd
|
|
|
|
# Install dependencies
|
|
sudo apt install liboping-dev libcurl4-openssl-dev libyajl-dev socat
|
|
|
|
# Go to collectd root
|
|
cd "$MYDIR"
|
|
|
|
# Clean up previous build results
|
|
if $DO_CLEAN; then
|
|
./clean.sh
|
|
rm -rf "$PREFIX"
|
|
fi
|
|
|
|
# Rebuild
|
|
./build.sh
|
|
./configure --prefix="$PREFIX" \
|
|
--disable-all-plugins \
|
|
--enable-cpu \
|
|
--enable-memory \
|
|
--enable-ping \
|
|
--enable-write-http \
|
|
--enable-write-log
|
|
make -j"$(grep -c '^processor' /proc/cpuinfo)"
|
|
|
|
# Install to collectd/install/*
|
|
make install
|
|
|
|
# Make the ping plugin work without being root
|
|
sudo setcap cap_net_raw+ep "$PREFIX"/sbin/collectd
|
|
|
|
# Copy configuration
|
|
readonly SRC_CONF="$MYDIR/collectd.conf" # source config to copy
|
|
readonly TGT_CONF="$PREFIX/etc/collectd.conf" # target where collectd expects it
|
|
if [ ! -e "$TGT_CONF".orig ]; then
|
|
# Make a backup for reference
|
|
cp -v "$TGT_CONF" "$TGT_CONF".orig || true
|
|
fi
|
|
cp -v "$SRC_CONF" "$TGT_CONF"
|
|
|
|
# Start collectd
|
|
"$PREFIX"/sbin/collectd -f
|