3 # Veritas Cluster System monitor for Nagios.
4 # Written by Aaron Bostick (abostick@mydoconline.com)
5 # Last modified: 05-22-2002
7 # Usage: check_vcs {-g <vcs_group> | -r <vcs_resource> } -s <vcs_system> [-n]
11 # This plugin is just a perl wrapper to the vcs commands hagrp and hares.
12 # You specify what group/resource and system you want the status for, and
13 # the plugin returns a status code based on the output of either hagrp or
16 # Normal hagrp/hares status codes are ONLINE and OFFLINE depending on where the
17 # cluster service currently lives. I have added an option, -n, which makes
18 # the expected state to be OFFLINE rather than ONLINE so you can run the
19 # plugin on both sides of the cluster and will receive critical alerts when
20 # the cluster fails over i.e. a proper failover will make the standby node
21 # go from OFFLINE to ONLINE for the group, so an ONLINE status should alert
22 # you! (You do want to know when the cluster fails over, right? :))
26 # This plugin returns OK when hagrp/hares -state <grp> -sys <system> returns
27 # ONLINE (or OFFLINE if -n is specified). Any other hagrp/hares string returns
28 # CRITICAL... Would a WARNING ever be justified??? UNKNOWN is returned if
29 # hagrp/hares cannot run for some reason.
33 # Make sure group oracle is ONLINE on server dbserver1:
34 # check_vcs -g oracle -s dbserver1
36 # Make sure group oracle is OFFLINE on server dbserver2:
37 # check_vcs -g oracle -s dbserver2 -n
39 # Make sure resource oraip is ONLINE on server dbserver1:
40 # check_vcs -r oraip -s dbserver1
42 # Make sure resource oraip is OFFLINE on server dbserver2:
43 # check_vcs -r oraip -s dbserver2 -n
48 if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) {
56 use lib
$main::prog_dir
;
57 use utils
qw($TIMEOUT %ERRORS &print_revision &support);
65 $vcs_bin = '/opt/VRTSvcs/bin';
73 $vcs_expected_result = 'ONLINE';
74 $plugin_revision = '$Revision: 33 $ ';
76 # Grab options from command line
78 ("g|group:s" => \$vcs_group,
79 "r|resouce:s" => \$vcs_resource,
80 "s|system=s" => \$vcs_system,
81 "n|negate" => \$vcs_negate,
82 "v|version" => \$version,
85 (!$version) || print_version ();
86 (!$help) || print_help ();
87 (!$vcs_negate) || ($vcs_expected_result = 'OFFLINE');
89 # Make sure group and resource is not specified
90 !($vcs_group && $vcs_resource) || usage("Please specify either a group or a resource, but not both.\n");
91 # Make sure group or resource is specified
92 ($vcs_group || $vcs_resource) || usage("HA group or resource not specified.\n");
93 # Make sure system is specified
94 ($vcs_system) || usage("HA system not specified.\n");
96 # Specify proper command
98 $vcs_command = 'hagrp';
99 $vcs_arg = $vcs_group;
101 $vcs_command = 'hares';
102 $vcs_arg = $vcs_resource;
105 # Run command and save output
106 $vcs_result = `$vcs_bin/$vcs_command -state $vcs_arg -sys $vcs_system`;
109 # If empty result, return UNKNOWN
111 print "UNKNOWN: Problem running $vcs_command...\n";
112 exit $ERRORS{'UNKNOWN'};
115 # If result is expected, return OK
116 # If result is not expected, return CRITICAL
117 if ($vcs_result eq $vcs_expected_result) {
118 print "OK: $vcs_command $vcs_arg is $vcs_result\n";
121 print "CRITICAL: $vcs_command $vcs_arg is $vcs_result\n";
122 exit $ERRORS{'CRITICAL'};
137 print "\nUsage: $prog_name { -g <vcs_group> | -r <vcs_resource> } -s <vcs_system> [-n]\n";
138 print "Usage: $prog_name [ -v | --version ]\n";
139 print "Usage: $prog_name [ -h | --help ]\n";
142 sub print_version () {
143 print_revision($prog_name, $plugin_revision);
148 print_revision($prog_name, $plugin_revision);
150 print "Validate output from hagrp/hares command.\n";
154 print "-g, --group=<vcs_group>\n";
155 print " The HA group to be validated\n";
156 print "-r, --resource=<vcs_resource>\n";
157 print " The HA resource to be validated\n";
158 print "-s, --system=<vcs_system>\n";
159 print " The HA system where the group/resource lives\n";
160 print "-n, --negate=<negate>\n";
161 print " Set expected result to OFFLINE instead of ONLINE\n";