OPNsense Forum

English Forums => General Discussion => Topic started by: dcol on February 05, 2018, 12:00:53 am

Title: Monit is a great plugin.
Post by: dcol on February 05, 2018, 12:00:53 am
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.
Title: Re: Monit is a great plugin.
Post by: slackadelic on February 05, 2018, 02:32:03 pm
I'm still trying to wrap my head around monit :) It seems quite simple, but meh.. Something new to play with hehe.
Title: Re: Monit is a great plugin.
Post by: faunsen on February 08, 2018, 09:26:59 am
Thank you for the feedback.
And yes, it's better to see problems before the customers do.  :)
Title: Re: Monit is a great plugin.
Post by: mow4cash on February 10, 2018, 05:12:20 am
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.
Title: Re: Monit is a great plugin.
Post by: dcol on February 10, 2018, 09:02:05 pm
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.
Title: Re: Monit is a great plugin.
Post by: 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 (https://forum.opnsense.org/index.php?topic=5303.0) (look for the CheckIPMI.sh script).

CheckCPUTemp.sh
Code: [Select]
#!/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
Title: Re: Monit is a great plugin.
Post by: vikozo on February 12, 2018, 12:53:30 pm
would be nice to have monin too
Title: Re: Monit is a great plugin.
Post by: faunsen on February 12, 2018, 01:15:47 pm
If we had a Munin expert here...
Writing OPNsense plugins is such a simple thing.  :D
Title: Re: Monit is a great plugin.
Post by: dcol on February 12, 2018, 03:56:56 pm
Added this to Monit
Thanks!
Title: Re: Monit is a great plugin.
Post by: vikozo on February 13, 2018, 02:01:05 pm
@fanusen
how a plugin have to look like?
Title: Re: Monit is a great plugin.
Post by: b0n3v on March 01, 2018, 10:08:29 am
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!
Title: Re: Monit is a great plugin.
Post by: dcol on March 03, 2018, 12:24:19 am
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
Code: [Select]
#!/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?
Title: Re: Monit is a great plugin.
Post by: dcol on March 03, 2018, 05:43:58 pm
You could write a script that to check the CPU temp and add it to Monit as described in the Monit HowTo (https://forum.opnsense.org/index.php?topic=5303.0) (look for the CheckIPMI.sh script).

CheckCPUTemp.sh
Code: [Select]
#!/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.