From d11506c302f03f36a9d68f88b70926917164937e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 26 Dec 2021 14:48:57 +0000 Subject: [PATCH] Add collectd --- src/apt-packages.txt | 33 ++++++++-------- src/configs/collectd.conf | 59 ++++++++++++++++++++++++++++ src/run.sh | 27 ++++++++++++- src/steps-postinstall/20-collectd.sh | 22 +++++++++++ 4 files changed, 123 insertions(+), 18 deletions(-) create mode 100644 src/configs/collectd.conf create mode 100755 src/steps-postinstall/20-collectd.sh diff --git a/src/apt-packages.txt b/src/apt-packages.txt index 42fa86a..5d291e4 100644 --- a/src/apt-packages.txt +++ b/src/apt-packages.txt @@ -1,22 +1,23 @@ -git -net-tools +collectd +curl +ddrescue dnsutils -uptimed -software-properties-common +f3 +ffmpeg +git iftop iotop +jpegoptim +jq +less +lnav +lsof +netcat +net-tools +openssh-client +optipng pv screen -netcat -f3 -less -optipng -jpegoptim -lsof +software-properties-common strace -ddrescue -ffmpeg -lnav -jq -openssh-client -curl +uptimed diff --git a/src/configs/collectd.conf b/src/configs/collectd.conf new file mode 100644 index 0000000..4c6f4bc --- /dev/null +++ b/src/configs/collectd.conf @@ -0,0 +1,59 @@ +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 + + + MountPoint "/" + MountPoint "/boot" + + + + Interface "eth0" + IgnoreSelected false + + + + 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" + + +# +# Host "localhost" +# Port "123" +# + + + CollectMemoryMaps false + + + + + SecurityLevel "Encrypt" + Username "|||USERNAME|||" + Password "|||PASSWORD|||" + + diff --git a/src/run.sh b/src/run.sh index 47715e4..634c033 100755 --- a/src/run.sh +++ b/src/run.sh @@ -32,6 +32,10 @@ source "/etc/os-release"; ############################################################################### +rainbow="cat"; +if command_exists lolcat; then + rainbow="lolcat"; +fi ############################################################################### @@ -42,6 +46,21 @@ ask_yesno() { return "$?"; # Not actually needed, but best to be explicit } +ask_text() { + local title="$1"; + local question="$2"; + local default_text="$3"; + whiptail --title "${title}" --inputbox "${question}" 10 40 "${default_text}" 3>&1 1>&2 2>&3; + return "$?"; # Not actually needed, but best to be explicit +} +ask_password() { + local title="$1"; + local question="$2"; + local default_text="$3"; + whiptail --title "${title}" --passwordbox "${question}" 10 40 "${default_text}" 3>&1 1>&2 2>&3; + return "$?"; # Not actually needed, but best to be explicit +} + queue_postinstall_step() { local stepname="$1"; @@ -124,6 +143,10 @@ if ask_yesno "Add Laminar CI SSH public key to root authorized_keys?"; then source ./steps-config/80-laminar-ssh.sh; fi +#shellcheck disable=2034 +collectd_username="$(ask_text "collectd", "Enter collectd username")"; +#shellcheck disable=2034 +collectd_password="$(ask_password "collectd" "Enter collectd password")"; ### # Autonomous config tasks @@ -193,5 +216,5 @@ echo " ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ███████ ███████ ██ ███████ ██ -$(cat /etc/hostname) is now ready for use (you might want to reboot it though) -"; +$(cat /etc/hostname) is now ready for use! Please reboot me to ensure everything is working as intended. +" | "${rainbow}"; diff --git a/src/steps-postinstall/20-collectd.sh b/src/steps-postinstall/20-collectd.sh new file mode 100755 index 0000000..9999336 --- /dev/null +++ b/src/steps-postinstall/20-collectd.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +task_begin "Configurating collectd"; + +subtask_begin "Stopping collectd"; +systemctl stop collectd; +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)"; + subtask_end "$?"; +fi + +subtask_begin "Installing configuration file"; +#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; +subtask-end "$?"; + +subtask_begin "Starting collectd & enabling on boot"; +systemctl enable --now collectd; +subtask_end "$?";