Skip to content

Commit

Permalink
plugin: smart
Browse files Browse the repository at this point in the history
add note main.yml to promote the plugins
  • Loading branch information
crpb committed Nov 18, 2024
1 parent 7bcb232 commit 9e60a1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ opn_check_mk_patches:
# the old list syntax opn_check_mk_local_checks: [] is still supported
opn_check_mk_local_checks:
all:
- gateways_status.py
- check_powerunit.sh
- crash_status.py
- firmware_status.py
- gateways_status.py
- pfctl_status.sh
- pkg_audit.py
- pkg_check.sh
- pfctl_status.sh
- check_powerunit.sh

# dict of lists of mrpe checks to run
# example:
Expand All @@ -65,6 +65,11 @@ opn_check_mk_additional_files: {}
# add here some plugin files (and add them to files/ too!
# for example:
# https://raw.githubusercontent.com/zerwes/check_mk_extensions/wireguard-fix-plugin-interpreter/wireguard/agents/plugins/wireguard
#
# plugins shipped within this repository and ready to be deployed:
# opn_check_mk_plugins:
# - wireguard
# - smart
opn_check_mk_plugins: []

# set this to "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}"
Expand Down
16 changes: 16 additions & 0 deletions files/smart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
#shellcheck disable=SC2086
echo '<<<smart>>>'
for disk in $(sysctl -n kern.disks)
do
data=$(smartctl -a "/dev/${disk}")
model=$(awk '/^(Device Model|Product).*/ {print $NF}' <<< "$data")
serial=$(awk '/^Serial( |Number).*/ {print $NF}' <<< "$data")
name=$(tr ' ' '_' <<< "$model $serial")
fname="$name $model"
stats=$(grep -E '^[ 12][ 0-9][0-9]' <<< "$data")
while IFS= read -r line
do
echo "$line"
done < <(printf '%s %s\n' $fname "$stats")
done

0 comments on commit 9e60a1d

Please sign in to comment.