Skip to content

Commit

Permalink
Merge branch 'Rosa-Luxemburgstiftung-Berlin:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
crpb authored Sep 14, 2024
2 parents 462d5bf + 3adb7f5 commit 575b42c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,40 @@ Sample output:
0 PowerUnitGroup2 - OK - Power Unit Group: 2 Status: Present, OK
```

### check cputemp

Make sure you configure your OPNsense router as follows:

Modify the /boot/loader.conf file and add at least on of the following entries:

```
coretemp_load="YES"
amdtemp_load="YES"
```
It's also acceptable to have both entries in your configuration.

In some cases, if the script does not recognize the thermal sensor, you can manually switch it to either amdtemp or coretemp via the GUI.

To do this, navigate to: ```System > Settings > Miscellaneous > Thermal Sensors > Hardware```

Alternatively, you can set this configuration using the OPNsense role under general settings:
```
opn_general:
system/webgui/thermal_hardware: "amdtemp"
```

Troubleshoot the functionality of your thermal sensors by using this command on your opnsense:
```
sysctl -a | grep temperature
```

## Plugins
The role includes some (optional) plugins

## wireguard

a improved version of the checkkmk wireguard plugin (see [PR #32](https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-opnsense-checkmk/pull/32))

## Role Variables

[defaults/main.yml](defaults/main.yml)
Expand Down
41 changes: 41 additions & 0 deletions files/cputemp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/local/bin/bash

declare temp_warn=60
declare temp_crit=80

# Function to display temperatures for all found sensors of a specific type
display_temps() {
local sensor_pattern=$1

# Collect all relevant sensor readings
sysctl -a | grep -E "$sensor_pattern" | while read sensor_data; do
local sensor_id=$(echo $sensor_data | awk '{print $1}')
local temp=$(echo $sensor_data | awk '{print $2}' | sed 's/C//') # Removing 'C' from '44.0C'
local temp_int=$(echo "$temp" | awk '{printf "%.0f", $1}')
local ECODE=0
local TXT="CPU Temp normal"

# Determine status based on temperature thresholds
if (( $(echo "$temp >= $temp_crit" | bc -l) )); then
ECODE=2
TXT="CPU Temp critical"
elif (( $(echo "$temp >= $temp_warn" | bc -l) )); then
ECODE=1
TXT="CPU Temp warning"
fi
echo "$ECODE CPUTEMP-$sensor_id - temperature is $temp°C - $TXT"
done
}
# Main script execution to check different sensor types
# Check AMD temperature sensors
if sysctl -a | grep -q 'dev.amdtemp.0.core0.sensor0'; then
display_temps 'dev.amdtemp.[0-9]+.core[0-1].sensor[0-1]'
# Check Intel CPU temperature sensors
elif sysctl -a | grep -q 'dev.cpu.0.temperature'; then
display_temps 'dev.cpu.[0-9]+.temperature'
# Check PCH temperature sensors, if any
elif sysctl -a | grep -q 'dev.pchtherm.0.temperature'; then
display_temps 'dev.pchtherm.[0-9]+.temperature'
else
echo "3 CPUTEMP - UNKNOWN - No thermal sensors found or active"
fi
12 changes: 12 additions & 0 deletions files/wireguard
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

wg=$(which wg)

if ! [ "$(pluginctl -S wireguard)" = "[]" ]; then
echo '<<<wireguard:sep(9)>>>'
for iface in $($wg show interfaces); do
echo "[[$iface]]"
$wg show $iface dump | tail -n +2 | cut -f1,3- -d' '
done

fi

0 comments on commit 575b42c

Please sign in to comment.