[SOLVED] Query status of GEOM Mirror (gmirror) RAID1

Started by Werner Fischer, April 27, 2017, 01:55:43 PM

Previous topic - Next topic
Hi all,

first of all thank you for providing OPNsense :-)
I've installed OPNsense 17.1.4-amd64 on a server with two SATA SSDs, and I have set up a GEOM Mirror during installation. I have used the target "mirror/OPNSenseMirror" as you can see in this screenshot:
https://www.thomas-krenn.com/de/wikiDE/images/9/9b/OPNsense-Installation-GEOM-07-Select-a-Disk.png

I'm now looking for a way to monitor the status of the gmirror, and I have searched in the web interface for such an option (but I did not find a site or widget for that). I only found this https://github.com/mibuthu/opnsense-core/blob/master/src/sbin/gmirror_status_check.php on a GitHub fork.
In pfSense, there are options to monitor the status: https://www.thomas-krenn.com/de/wiki/PfSense_Software_RAID_1#.C3.9Cberwachung

My questions:

  • Are there currently any options to monitor the status of a gmirror?
  • If not: are there any options planned for this?
  • If there are no options planned currently: should I open a github issue here: https://github.com/opnsense/core/issues ?

Thank you & best regards,
Werner

There is a dashboard widget for disk status. You need to install the os-smart plugin to use it

Bart...

Thank you for the hint how to monitor the SMART status of the disks.

I've installed the plugin and added the widget.

Although this shows me the SMART status of the two disks, it does not show the the status of the GEOM mirror (gmirror) which should be "COMPLETE" like it is shown by pfSense here: https://www.thomas-krenn.com/de/wikiDE/images/3/30/PfSense-GEOM-02-Diagnostics-GEOM-Mirrors.png

Any other ideas if there is a way to monitor the gmirror state?

Otherwise I think a new plugin should be implemented for that. So if there are no other ideas, I'll open a GitHub issue here https://github.com/opnsense/plugins (they state: "Now we need your help to enrich the plugins. Feel free to contact us at project AT opnsense DOT org or open GitHub issue to get in touch.")

Hi Werner,

you can do that with the new os-monit plugin and a little script.
The plugin is available since 17.1.5. It's a monitoring software that can execute scripts and generate alarms according to the return value.

Create a script e.g. /usr/local/bin/check_gmirror.sh and make it executable.

#!/bin/sh
ReturnString=$(/sbin/gmirror status)
ReturnStatus=$?
echo $ReturnString
if [ $ReturnStatus -ne 0 ]; then
   exit 1
fi
exit 0


Then create a Monit Service Test (Services -> Monit -> Settings -> Service Tests Settings)
Name: ExitStatus
Condition: status notequal 0
Action: Alert


and a Service Setting
Name: GMirrorTest
Type: Custom
Path: /usr/local/bin/check_gmirror.sh
Tests: ExecStatus


You can see the output of the script at the Monit status page.


Regards
Frank

Hi Werner,

A bit late to the party. GEOM raid GUI parts were stripped a long time ago, maybe there is opportunity to bring something back, though users of this feature seem few (or silent).

At one point we also wanted to strip it from the installer, but somebody intervened, so it's still there, functioning ok it seems. :)

Just plugging old pages back may not be worth it in the long run. Monit may indeed be the way to go... we are looking for a generic notification / reporting replacement and maybe it's just that and it will be added to the core functionality in the long run. It's difficult to say yet without having started the replacement process.


Cheers,
Franco

Hi Frank, hi Franco,

sorry for my late reply - I've been out-of-office for some time :-)

Thank you for your valuable answers. I have written a wiki article (in German) and included the information regarding os-monit: https://www.thomas-krenn.com/de/wiki/OPNsense_Software_RAID_1

So thanks again for your help :-)
Best regards,
Werner

Hi,

my first post in the OPNsense Forum, thank you for your solution with monit, this is exactly what i was looking for!
But im sorry to report that the script did not work as it should, maybe something changed in the gmirror status code in the past years?

In my lab (OPNsense 20.7.3) i was testing if it works in case the mirror fails (i just remove the second drive physical). The problem is, that the command "/sbin/gmirror status" always returns the exit code 0, maybe because the command "gmirror status" works and returns always a 0 ;-)

Working mirror:
# /sbin/gmirror status
           Name    Status  Components
mirror/OPNsense  COMPLETE  ada0 (ACTIVE)
                           ada1 (ACTIVE)
# echo $?
0


Degraded mirror:
# /sbin/gmirror status
           Name    Status  Components
mirror/OPNsense  DEGRADED  ada1 (ACTIVE)
                           ada0 (SYNCHRONIZING, 56%)
# echo $?
0


So i have modified the script to search if the output of "/sbin/gmirror status" contains "COMPLETE" , and only in this case it now returns exit 0, in all other cases it retuns exit 1.

modified /usr/local/bin/check_gmirror.sh

#!/bin/sh
ReturnString=$(/sbin/gmirror status)
echo $ReturnString
if echo $ReturnString | grep -q 'COMPLETE'; then
   exit 0
fi
exit 1


Short testing... it works for me  8)

this is quite nice thing, but now it is not needed to write any sh scripts.

in most cases only need is to add service with:
Name: gmirror status
Type: Custom
Path: /sbin/gmirror status
Tests: NonZeroStatus

and that's it.
it will check `gmirror status` and trigger alerts if status is changed.