-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# agent-local | ||
|
||
This repository contains a set of Unix agent scripts designed for monitoring Linux Debian servers with Observium. | ||
The typical location for these scripts on the server to be monitored is `/usr/lib/observium_agent/local`. | ||
Please note that installing the scripts alone isn't sufficient. Refer to [Observium's documentation](https://docs.observium.org/unix_agent/) for | ||
guidance on how to use them. | ||
|
||
## Script installation | ||
|
||
Use the provided `install.sh` to directly install from this repository without cloning it. | ||
|
||
## dpgk | ||
|
||
This local agent script supplies package information to Observium. This information is cached for up to 30 minutes | ||
to enhance the efficiency of the poller. No alterations have been applied. | ||
|
||
## ioping | ||
|
||
The local agent implementation of Observium's `ioping` local agent script was no longer functional as of Debian Bookworm. | ||
This revised implementation addresses the issue and introduces the capability to `ioping` multiple drives simultaneously. | ||
However, it's important to note that ioping remains relatively slow even when executed in parallel. | ||
Customize the `ioping.conf` file based on your requirements. | ||
|
||
## smarttemp | ||
|
||
This local agent script serves as a replacement for `hddtemp` since it has been abandoned and is no longer available as of Debian Bookworm. | ||
It utilizes a combination of smartmontools' `smartctl` and `jq` to determine the temperature of all hard drives and | ||
mimicks the output of the `hddtemp` local agent script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
# Cache the file for 30 minutes | ||
# If you want to override this, put the command in cron. | ||
# We cache because it is a 1sec delay, which is painful for the poller | ||
|
||
dpkg=`which dpkg-query` | ||
|
||
if [ $? -eq 0 ]; then | ||
DATE=$(date +%s) | ||
FILE=/tmp/observium-agent-dpkg | ||
|
||
if [ ! -e $FILE ]; then | ||
$dpkg -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE | ||
fi | ||
FILEMTIME=$(stat -c %Y $FILE) | ||
FILEAGE=$(($DATE-$FILEMTIME)) | ||
if [ $FILEAGE -gt 1800 ]; then | ||
$dpkg -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE | ||
fi | ||
echo "<<<dpkg>>>" | ||
cat $FILE | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
destination_dir=/usr/lib/observium_agent/local | ||
|
||
copy_and_set_permissions() { | ||
local script_name=$1 | ||
read -p "Install ${script_name} script? (y/n): " copy_script | ||
if [[ $copy_script =~ ^[Yy]$ ]]; then | ||
cp ./${script_name}* "${destination_dir}" && chmod +x "${destination_dir}/${script_name}" | ||
echo "${script_name} script copied and permissions set." | ||
fi | ||
} | ||
|
||
if [ -w "${destination_dir}" ]; then | ||
copy_and_set_permissions "dpkg" | ||
copy_and_set_permissions "ioping" | ||
copy_and_set_permissions "smarttemp" | ||
|
||
echo "Installation complete." | ||
if [ -f "${destination_dir}/ioping.conf" ]; then | ||
echo "Don't forget to edit ${destination_dir}/ioping.conf" | ||
fi | ||
else | ||
echo "Error: local agent scripts directory does not exist at ${destination_dir} or is not writeable" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
if ! command -v ioping &> /dev/null; then | ||
echo "Error: ioping is not installed. Please install it before running this script." | ||
exit 1 | ||
fi | ||
|
||
parallel=0 | ||
if [ -r "${0}.conf" ]; then | ||
first_line=$(head -n 1 "${0}.conf") | ||
if [ "${first_line}" = "parallel=yes" ]; then | ||
parallel=1 | ||
elif [ "${first_line}" != "parallel=no" ]; then | ||
echo "Error: first line in ${0}.conf should be 'parallel=no' or 'parallel=yes'" | ||
exit 1 | ||
fi | ||
else | ||
echo "Configuration file ${0}.conf not found or not readable" | ||
exit 1 | ||
fi | ||
|
||
echo '<<<app-ioping>>>' | ||
|
||
while IFS= read -r dev; do | ||
if [ "$parallel" -eq 0 ]; then | ||
echo "$dev $(ioping -q -s 16k -D -c 4 -P 3 $dev)" | ||
else | ||
echo "$dev $(ioping -q -s 16k -D -c 4 -P 3 $dev)" & | ||
fi | ||
done < <(tail -n +2 "${0}.conf") | ||
|
||
if [ "$parallel" -eq 1 ]; then | ||
wait | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
parallel=yes | ||
/dev/sda | ||
/dev/sdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
if ! command -v smartctl &> /dev/null || ! command -v jq &> /dev/null; then | ||
echo "Error: smartctl or jq is not installed. Please install them before running this script." | ||
exit 1 | ||
fi | ||
|
||
drives=() | ||
|
||
for drive in /dev/sd[a-z]; do | ||
drives+=("$drive") | ||
done | ||
|
||
echo '<<<hddtemp>>>' | ||
|
||
for drive in "${drives[@]}"; do | ||
smartctl_output=$(smartctl -a "${drive}" -j) | ||
|
||
model_name=$(echo "$smartctl_output" | jq -r '.model_name') | ||
temperature=$(echo "$smartctl_output" | jq -r '.temperature.current') | ||
|
||
if [ "$temperature" != "null" ]; then | ||
echo -n "|${drive}" | ||
echo -n "|$model_name" | ||
echo -n "|$temperature" | ||
echo -n "|C|" | ||
fi | ||
done | ||
|
||
echo |