zabbix_export: version: '6.0' date: '2021-11-21T21:44:36Z' groups: - uuid: 7df96b18c230490a9a0a9e2307226338 name: Templates templates: - uuid: 829f8d58e71c46329271071e37f1ec25 template: CoroSync-Ring-0 name: CoroSync-Ring-0 description: | ## Overview Template and script below checks the status of the corosync Ring(s) 1: Create a Script File under the zabbix scripts directory, called corosync.pl and paste the script content into it 2: Make it executable and ownd by the zabbix user 3: Add the user Parameter below to the zabbix agent on the cluster nodes **Zabbix Agent Config:** ``` **#** # Corosync Status # UserParameter=check\_corosync[*], /etc/zabbix/scripts/corosync.pl $1 ``` **Corosync Script:** #!/usr/bin/perl my $sudo = '/usr/bin/sudo'; my $cfgtool = '/usr/sbin/corosync-cfgtool -s'; $num\_args = $#ARGV + 1; if ($num\_args != 1) { print "\nUsage: corosync.pl ring number\n"; exit; } my $ringNumber = $ARGV[0]; open( $fh, "$cfgtool |" ) or die ( "Running corosync-cfgtool failed" ); foreach my $line (<$fh>) { if ( $line =~ m/status\s*=\s*(\S.+)/ ) { my $status = $1; if ( $status =~ m/^ring $ringNumber/ ) { # print "RING NUMBER $ringNumber STATUS: $status\n"; if ( $status =~ m/^ring $ringNumber active with no faults/ ) { print "0"; } else { print "1"; } exit; } } } close($fh) or die ( "Running corosync-cfgtool failed" ); ## Author Roland Käser groups: - name: Templates items: - uuid: a7ec6b24454641fca32ad3f0422b7d6a name: 'Corosync Ring 0 Status' key: 'check_corosync[0]' delay: '30' history: 30d trends: 180d description: 'Status of the Corosync Ring 0' triggers: - uuid: ab78495b70e3411ba8feacd3f5a24442 expression: 'max(/CoroSync-Ring-0/check_corosync[0],5m)<>0' name: 'Corosync Ring 0 Status on {HOST.NAME}' priority: HIGH description: 'Corosync Ring 0 Status on {HOST.NAME}'