Finalise initial collectd implementation
Some checks are pending
continuous-integration/laminar-eldarion Build failed with exit code 123 after 4 seconds

...it's still all untested.
This commit is contained in:
Starbeamrainbowlabs 2021-12-26 15:33:35 +00:00
parent 5f412703e5
commit 741d6c2c03
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 11 additions and 86 deletions

View file

@ -1,59 +0,0 @@
Interval 300
LoadPlugin load
LoadPlugin thermal
LoadPlugin memory
LoadPlugin disk
LoadPlugin swap
LoadPlugin uptime
#LoadPlugin smart
LoadPlugin df
LoadPlugin irq
LoadPlugin contextswitch
LoadPlugin interface
LoadPlugin ping
#LoadPlugin nginx
#LoadPlugin ntpd
LoadPlugin exec
LoadPlugin processes
LoadPlugin network
<Plugin df>
MountPoint "/"
MountPoint "/boot"
</Plugin>
<Plugin interface>
Interface "eth0"
IgnoreSelected false
</Plugin>
<Plugin ping>
Host "elessar.mooncarrot.space"
Host "wopplefox.mooncarrot.space"
Host "ubuntu.mirrors.ovh.net"
#Host "s3-eu-west-1.amazonaws.com"
#Host "github.com"
#Host "api.backblazeb2.com"
</Plugin>
#<Plugin ntpd>
# Host "localhost"
# Port "123"
#</Plugin>
<Plugin processes>
CollectMemoryMaps false
</Plugin>
<Plugin "network">
<Server "5.198.44.45">
SecurityLevel "Encrypt"
Username "cluster"
Password "{{{PASSWORD}}}"
</Server>
</Plugin>

View file

@ -1,25 +0,0 @@
#!/usr/bin/env bash
if [[ -z "${COLLECTD_PW}" ]]; then
echo "Error: COLLECTD_PW environment variable is not set";
exit 1;
fi
RUN "sudo apt-get install -y collectd liboping0";
tmpfile_collectd="$(mktemp --tmpdir "collectd-XXXXXXX")";
chmod 0600 "${tmpfile_collectd}";
sed -e "s/{{{PASSWORD}}}/${COLLECTD_PW}/g" <"${JOBFILE_DIR}/collectd.conf" >"${tmpfile_collectd}";
unset COLLECTD_PW;
COPY "${tmpfile_collectd}" "/tmp/collectd.conf";
rm "${tmpfile_collectd}";
RUN "sudo chown root:root /tmp/collectd.conf";
RUN "sudo chmod 0600 /tmp/collectd.conf";
RUN "sudo mv /tmp/collectd.conf /etc/collectd/collectd.conf";
RUN "sudo systemctl restart collectd.service";
RUN "sudo systemctl enable collectd.service";

View file

@ -10,6 +10,7 @@ iotop
jpegoptim
jq
less
liboping0
lnav
lsof
netcat

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash
collectd_conf_target="/etc/collectd/collectd.conf";
task_begin "Configurating collectd";
subtask_begin "Stopping collectd";
@ -8,15 +10,21 @@ subtask_end "$?";
if [[ -r "/etc/collectd/collectd.conf" ]]; then
subtask_begin "Moving existing config file aside";
mv "/etc/collectd/collectd.conf" "/etc/collectd/collectd.conf.bak-$(date +%Y-%m-%d)";
mv "${collectd_conf_target}" "${collectd_conf_target}.bak-$(date +%Y-%m-%d)";
subtask_end "$?";
fi
subtask_begin "Installing configuration file";
touch "${collectd_conf_target}";
chmod 0600 "${collectd_conf_target}";
#shellcheck disable=SC2154
cat configs/collectd.conf | awk -v "user=${collectd_username}" -v "pass=${collectd_password}" '{ gsub("|||USERNAME|||", user); gsub("|||PASSWORD|||", pass); print }' >/etc/collectd/collectd.conf;
cat configs/collectd.conf | awk -v "user=${collectd_username}" -v "pass=${collectd_password}" '{ gsub("|||USERNAME|||", user); gsub("|||PASSWORD|||", pass); print }' >"${collectd_conf_target}";
subtask-end "$?";
subtask_begin "Starting collectd & enabling on boot";
systemctl enable --now collectd;
subtask_end "$?";
subtask_begin "Cleaning up";
unset collectd_username collectd_password;
subtask_end "$?";