Monit is a great plugin.

Started by dcol, February 05, 2018, 12:00:53 AM

Previous topic - Next topic
February 05, 2018, 12:00:53 AM Last Edit: February 05, 2018, 04:14:26 PM by dcol
Monit is just another example and reason why OPNsense is the choice of firewalls. I highly recommend this plugin because of the built-in system monitoring capability. This plugin gives us a heads up on stressed or failing hardware which is crucial for me since some of my firewalls are very remote. It can also alert when the network has issues. Just one of many reasons I forked over to OPNsense.

I'm still trying to wrap my head around monit :) It seems quite simple, but meh.. Something new to play with hehe.

Thank you for the feedback.
And yes, it's better to see problems before the customers do.  :)

Looks pretty nice, Is there a guide to add more metrics to watch? Or is it what you see is what you get? CPUtemp would be nice.

I second that. CPU temp along with CPU Usage would be a good alert for a failing CPU or fan. CPU Usage is already in monit, but if CPU temp was up and CPU Usage was not, that would tell you that maybe a fan was going out.

You could write a script that to check the CPU temp and add it to Monit as described in the Monit HowTo (look for the CheckIPMI.sh script).

CheckCPUTemp.sh
#!/bin/csh

set MaxCPUTemp = 75

set NumCPUs = `sysctl -n kern.smp.cpus`
set CurrentCPU = 0

while ( $CurrentCPU < $NumCPUs )
   set CPUTemp = `sysctl dev.cpu.$CurrentCPU.temperature | awk '{print $2}' | awk -F. '{print $1}'`
   echo "CPU $CurrentCPU temp: $CPUTemp"
   if ( $CPUTemp >= $MaxCPUTemp ) then
      exit 1
   endif
   @ CurrentCPU = $CurrentCPU + 1
end
exit 0


would be nice to have monin too
apu2c4 / wle200nx / 240 Disk --> Firewall | FW-03
---
OPNsense 22.1.6-amd64
FreeBSD 13.0-STABLE
OpenSSL 1.1.1n 15 Mar 2022

If we had a Munin expert here...
Writing OPNsense plugins is such a simple thing.  :D


@fanusen
how a plugin have to look like?
apu2c4 / wle200nx / 240 Disk --> Firewall | FW-03
---
OPNsense 22.1.6-amd64
FreeBSD 13.0-STABLE
OpenSSL 1.1.1n 15 Mar 2022

Monit is very nice plugin.
I have one case, i want to receive email notification for WAN IP, on change or just every day report. How can do this?
Thanks!

March 03, 2018, 12:24:19 AM #11 Last Edit: March 03, 2018, 05:42:56 PM by dcol
The CPU temp plugin did not work. Followed the How-To
I get 'Status Failed' response.

Is there a driver I need to install?

What condition should I use?

I did the following

#!/bin/csh

set MaxCPUTemp = 60
set status = 0
set NumCPUs = `sysctl -n kern.smp.cpus`
set CurrentCPU = 0

while ( $CurrentCPU < $NumCPUs )
   set CPUTemp = `sysctl dev.cpu.$CurrentCPU.temperature | awk '{print $2}' | awk -F. '{print $1}'`
   echo "CPU $CurrentCPU temp: $CPUTemp"
   if ( $CPUTemp >= $MaxCPUTemp ) then
      set status = 1
      exit 1
   endif
   @ CurrentCPU = $CurrentCPU + 1
end
exit 0

if ( $Status == 0 ) then
   echo "System Health: OK
endif

exit $Status


And used condition - status notequal 0

This code delivers a 'status failed' error?
I am not a coder, can anyone help out?

March 03, 2018, 05:43:58 PM #12 Last Edit: March 03, 2018, 07:55:41 PM by dcol
Quote from: faunsen on February 12, 2018, 09:29:58 AM
You could write a script that to check the CPU temp and add it to Monit as described in the Monit HowTo (look for the CheckIPMI.sh script).

CheckCPUTemp.sh
#!/bin/csh

set MaxCPUTemp = 75

set NumCPUs = `sysctl -n kern.smp.cpus`
set CurrentCPU = 0

while ( $CurrentCPU < $NumCPUs )
   set CPUTemp = `sysctl dev.cpu.$CurrentCPU.temperature | awk '{print $2}' | awk -F. '{print $1}'`
   echo "CPU $CurrentCPU temp: $CPUTemp"
   if ( $CPUTemp >= $MaxCPUTemp ) then
      exit 1
   endif
   @ CurrentCPU = $CurrentCPU + 1
end
exit 0


What is the condition to set in the 'Service Test Settings'?
Also, if I try and run this script from the shell I get a 'Command not found' error. This is a csh script. Should work with FreeBSD. How can I test this script from the shell?

[UPDATE]
OMG, figured it out. when I copied/pasted the file into FreeBSD I was using Windows line endings. File worked  in the shell after I changed to UNIX (LF) line endings. Linux is a PIA.