Created
November 20, 2012 08:44
-
-
Save michaelrice/4116788 to your computer and use it in GitHub Desktop.
vsphere check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# Simple script to run from icinga/nagios to monitor the API | |
# of a vshpere host. | |
# | |
use warnings; | |
use strict; | |
BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 } | |
use VMware::VIRuntime; | |
Opts::parse(); | |
Opts::validate(); | |
eval { | |
Util::connect(); | |
my $service_instance = Vim::get_service_instance(); | |
&set_time($service_instance->CurrentTime()); | |
Util::disconnect(); | |
}; | |
if($@) { | |
print "API FAIL - error: / $!;\n"; | |
exit 2; | |
} | |
my $time; | |
sub set_time() { | |
$time = shift; | |
} | |
print "API OK - time: / $time;\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment