A straightforward script designed to alert you when your pfSense box surpasses a predefined temperature threshold.
-
Copy the script to the local pfsense router.
-
Login via ssh using root user and password.
-
Select shell command
8
. -
Change your directory to /usr/local/bin.
cd /usr/local/bin
- Download the script file.
curl -LJO https://raw.githubusercontent.com/dmytrokoren/PfSense-CPU-Temp-Alert/main/PfCPU_temp_alert_hc.sh
- Install nano file editor
pkg update pkg install nano
- Change 'hcUUID', 'alert', 'iterations' and 'timeInSeconds' using nano
Note: Need to sign up for healthchecks.io and copy UUID
nano PfCPU_temp_alert_hc.sh
-
(OPTONAL) Change the script to customize your experience.
- Change 'alert', 'iterations' and 'timeInSeconds'.
- Uncomment the print lines. if you want to see feedback on the console. But by-default it is off.
-
After Pasting the Script. Press
ESC
then:x
to exit from the vi editor.
-
-
To test the script on your local pfsense box.
- Install bash, if not installed already.
pkg install bash
- Change permisson to executable.
chmod +x PfCPU_temp_alert_hc.sh
- Run it as "bash PfCPU_temp_alert_hc.sh".
bash PfCPU_temp_alert_hc.sh
-
To run the the script on your local pfsence box on schedule.
- Install cron, if not installed already.
System > Package Manager > Available Packages > Search "cron" > install.
- Configure the cron service.
Services > corn > add
Then type as follows
(I'm setting cron job for every 5 mins, as I have set iterations: 5, timeInSeconds: 60)
This will ping the healthchecks.io once every 5 mins, but the CPU temp check will occur every 1 minute.- Minute - */5 - Hour - * - Day of the month - * - Month of the year - * - Day of the week - * - User - root - Command - ``` bash /usr/local/bin/PfCPU_temp_alert_hc.sh ```
- Click on Save.
We have completed the setup. You will receive a Telegram notification if your system surpasses a specified temperature threshold, allowing prompt action to save your system. In addition, you will be able to monitor cron job ping via healthchecks.io
Feedback is always welcome.