#!/usr/bin/perl -w # #This Perl Nagios/Icinga plugin retrieves all alarms from VMWare vSphere. #You can filter the alarms with various options for ex- and including items. #If you're already using alarm rules in vSphere this plugin may help you to have #your monitoring in one place instead of two. # #The pluging needs the VMWare Perl SDK to be installed on your monitoring server. #This plugin has been tested with the SDK v5.0, v5.5 and 6.0. # # #Copyright (c) 2016 www.usolved.net #Published under https://github.com/usolved/check_usolved_vsphere_alarms # # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty #of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program. If not, see . # #--------------------------------------------------------------------------------------- # # v1.5 2020-11-10 # - Fixed exclude filters not working without include filters (thanks to @araujorm) # # v1.4 2019-03-04 # - Added the option of setting credentials directly from authfile (thanks to @mjtrangoni) # # v1.3 2017-01-12 # - Added possibility to filter for the name of the alarm message # # v1.2 2016-12-06 # - Removed unnecessary function for accessing the "alarmManager" # # v1.1 2016-09-12 # - Acknowledged alarms won't count as warning or critical anymore # - Number of acknowledged alarms in the status info output # # v1.0 2015-07-02 # - Initial release # use strict; use warnings; #--------------------------------------------------------------------------------------- # Load modules use Net::SSL; use VMware::VIRuntime; #To access the VMWare SDK use Getopt::Long; #Parse the parameters use File::Spec; #For splitting the path to get the filename #--------------------------------------------------------------------------------------- # Define variables my $output_nagios = ""; my $output_nagios_extended = ""; my $output_return_code = 0; my $count_warning = 0; my $count_critical = 0; my $count_acknowledged = 0; my ($option_host, $option_username, $option_password, $option_authfile, $option_check); my %checks; my ($volume, $directory, $file) = File::Spec->splitpath(__FILE__); my $scriptname = $file; #--------------------------------------------------------------------------------------- # Define functions #Print out the help information sub output_usage { print < password= -C, --check=CHECK Specify what you want to check. By default the plugin checks all alarms. Syntax: :