#!/usr/bin/perl
#
# Simple perl script to parse the output of /usr/sbin/vxdisk list.
# vxdisk requires root privileges to run, in order for this to
# happen, I put the following in /etc/sudoers:
# 
# nagios  <HOSTNAME HERE> = NOPASSWD: /usr/sbin/vxdisk list
#
# This allows the nagios user to run only what it needs
#
#
# Mike Adams 
# Tue Nov 23 09:56:08 PST 2004
#
#
#


@vxlist = `/usr/local/bin/sudo /usr/sbin/vxdisk list`;
for $line (@vxlist) {
  chomp($line);
  $line =~ s/\s+/,/g;
  ($device, $type, $vxname, $group, $status) = split(/,/,"$line");
  if($status =~ /(online|STATUS)/) {
    next;
  }
  else {
   $exit = 2; 
  }
  if($exit == 2) {
   print "CRITICAL: $vxname ($device) status is: $status\n";
   exit 2;
  }
}
if($exit == 0) {
  print "OK: All Veritas disks are okay\n";
  exit 0;
}
