Vmware plugin not working as Nagios User

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ksafa
Posts: 91
Joined: Wed Jan 15, 2014 3:05 pm

Vmware plugin not working as Nagios User

Post by ksafa »

Hello All,
When running the following vmware check it works as root user but not as Nagios user:

/usr/local/nagios/libexec/check_esx3.pl -f /usr/local/nagiosxi/etc/components/vmware/ESX1_auth.txt -H ESX1 -l CPU

Sounds like some sort of permission issue with perl modules but can't pin it down. Any help would be appreciated.

Thanks,
Khaled
ksafa
Posts: 91
Joined: Wed Jan 15, 2014 3:05 pm

Re: Vmware plugin not working as Nagios User

Post by ksafa »

This is the error I get. Missing VMware::RIRuntime but i see the module is there.

ESX3 UNKNOWN - Missing perl module VMware::VIRuntime. Download and install 'VMware vSphere SDK for Perl', available at https://my.vmware.com/group/vmware/downloads


# ls -ltr /usr/share/perl5/VMware/
total 3720
-r--r--r-- 1 root root 277883 Dec 21 13:46 VIM25Runtime.pm
-r--r--r-- 1 root root 87988 Dec 21 13:46 VIM2Runtime.pm
-r--r--r-- 1 root root 27760 Dec 21 13:46 VIExt.pm
-r--r--r-- 1 root root 741859 Dec 21 13:46 VIM2Stub.pm
-r-xr-xr-x 1 root root 11478 Dec 21 13:46 SSOConnection.pm
-r--r--r-- 1 root root 2463318 Dec 21 13:46 VIM25Stub.pm
-r--r--r-- 1 root root 41509 Dec 21 13:46 VICredStore.pm
-r--r--r-- 1 root root 505 Dec 21 13:46 VIRuntime.pm
-r--r--r-- 1 root root 15116 Dec 21 13:46 LookupService.pm
-r--r--r-- 1 root root 90245 Dec 21 13:46 VICommon.pm
-r--r--r-- 1 root root 2150 Dec 21 13:46 VIMRuntime.pm
-r--r--r-- 1 root root 23885 Dec 21 13:46 VILib.pm
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Vmware plugin not working as Nagios User

Post by tgriep »

First, lets make sure the permissions are set on the plugin correctly by running the following commands as root.

Code: Select all

chown apache.nagios /usr/local/nagios/libexec/check_esx3.pl
chmod 775 /usr/local/nagios/libexec/check_esx3.pl
Then, change to the nagios user account and see if the plugin executes.

Code: Select all

su - nagios
/usr/local/nagios/libexec/check_esx3.pl -f /usr/local/nagiosxi/etc/components/vmware/ESX1_auth.txt -H ESX1 -l CPU
If it does, then see if the XI GUI shows the correct status for the check.
If not, post all of the output of the above commands so we can see what the issue is.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ksafa
Posts: 91
Joined: Wed Jan 15, 2014 3:05 pm

Re: Vmware plugin not working as Nagios User

Post by ksafa »

Permission are good but still did not work. Output below.

$ /usr/local/nagios/libexec/check_esx3.pl -f /usr/local/nagiosxi/etc/components/vmware/ESX1_auth.txt -H ESX1 -l CPU
ESX3 UNKNOWN - Missing perl module VMware::VIRuntime. Download and install 'VMware vSphere SDK for Perl', available at https://my.vmware.com/group/vmware/downloads

Download the latest version of the vSphere SDK for Perl from VMware.
In this example we use VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz,
but the instructions should apply to other versions as well.

You may need to install additional packages and Perl modules on your server,
see https://kb.op5.com/x/pYEK for
more information and package names for op5 APS / CentOS 6 / RHEL 6.

Upload the .tar.gz file to your op5 Monitor server's /root dir and execute:

cd /root
tar xvzf VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz
cd vmware-vsphere-cli-distrib/
./vmware-install.pl

Follow the on screen instructions, described below:

"Creating a new vSphere CLI installer database using the tar4 format.

Installing vSphere CLI 5.1.0 build-780721 for Linux.

You must read and accept the vSphere CLI End User License Agreement to
continue.
Press enter to display it."

<ENTER>

"Read through the License Agreement"
"Do you accept? (yes/no)

yes

"In which directory do you want to install the executable files? [/usr/bin]"

<ENTER>

"Please wait while copying vSphere CLI files...

The installation of vSphere CLI 5.1.0 build-780721 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command:
"/usr/bin/vmware-uninstall-vSphere-CLI.pl".

This installer has successfully installed both vSphere CLI and the vSphere SDK
for Perl.

The following Perl modules were found on the system but may be too old to work
with vSphere CLI:

Compress::Zlib 2.037 or newer
Compress::Raw::Zlib 2.037 or newer
version 0.78 or newer
IO::Compress::Base 2.037 or newer
IO::Compress::Zlib::Constants 2.037 or newer
LWP::Protocol::https 5.805 or newer

Enjoy,

--the VMware team"

Note: None of the Perl modules mentioned as "may be too old" are needed for check_vmware_api to work.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Vmware plugin not working as Nagios User

Post by tgriep »

Did the installation of the VMWare Perl SDK finish installing on the server?
Try following this document and reinstall the VMWare Perl SDK module on the nagios server again.
https://assets.nagios.com/downloads/nag ... ios_XI.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
ksafa
Posts: 91
Joined: Wed Jan 15, 2014 3:05 pm

Re: Vmware plugin not working as Nagios User

Post by ksafa »

Reran install. Output below. Still does not work as nagios user. Works as root user.

Code: Select all

Creating a new vSphere CLI installer database using the tar4 format.

Installing vSphere CLI 6.7.0 build-8156551 for Linux.

You must read and accept the vSphere CLI End User License Agreement to
continue.
Press enter to display it.

VMware(r) vSphere Software Development Kit License Agreement

VMware, Inc. ("VMware") provides the VMware vSphere Software
Development Kit (collectively the "Software") to you subject to the
following terms and conditions.  By downloading, installing, or using
the Software, you (the individual or legal entity) agree to be bound by
the terms of this license agreement (the "Agreement"). If you disagree
with any of the following terms, then do not use the Software.

1.  The Software contains a variety of materials, interface definitions,
documentation, sample utility applications and sample code regarding
programming interfaces to one or more VMware products that are referenced
in such materials (the referenced products, "VMware Products").  This
Software is intended to be used to develop software that interacts with the
VMware Products.

2.  USE RIGHTS:  Subject to the restrictions below, you may download and
make a reasonable number of copies of the Software for your use solely for
the purpose of creating software that communicates with VMware Products
(your software, "Developer Software").  Some code may be designated as
"distributable code" and/or "modifiable code" at
http://www.vmware.com/go/vwssdk-redistribution-info. You may use and
merge all or portions of the "distributable code" with your Developer
Software.
Any merged portion of any "distributable code" is subject to this Agreement.

Additionally, you may modify or create derivative works of all or portions
of
the "modifiable code." You are permitted to re-distribute the "distributable

code" and the modified or derivative works of the "modifiable code" only as
part of your Developer Software for non-commercial or commercial use;
provided that you shall only distribute such code subject to a license
agreement that protects VMware's and its licensors' interests consistent
with
the terms contained in this Agreement.  Open source software components
provided with the Software are licensed to you under the terms of the
applicable license agreements included with such open source software
components. The open source software licenses can be found in the
open_source_licenses.txt file, other materials accompanying the Software,
the documentation or corresponding source files available at
http://www.vmware.com/download/open_source.html.

3.  RESTRICTIONS:  You agree that you will not (1) use the Software to
create, design or develop anything other than Developer Software; (2) make
any more copies of the Software than are reasonably necessary for the
authorized use and backup and archival purposes; (3) modify, create
derivative works of, reverse engineer, reverse compile, or disassemble the
Software except as expressly permitted in Section 2; (4) distribute, sell,
lease,
rent, lend, or sublicense any part of the Software to any third party except
as
expressly permitted in Section 2; or (5) use the Software in any manner to
(a)
circumvent any technical restrictions of VMware Products or violate any
additional licensing terms applicable to VMware Products that VMware
provides through product documentation, email notification on the VMware
website or in the terms of the End User License Agreements; (b) disable,
remove, over-ride or modify the display of any VMware Product End User
License Agreements that the VMware Products present to the end customers;
or (c) upload or otherwise transmit any material containing software viruses
or
other computer code, files or programs designed to interrupt, destroy, or
limit
the functionality of any software or hardware.

The restrictions in this Section 3 shall not apply if and to the extent they

contradict mandatory local law (including, but not limited to, law
implementing
the EC Software Directive).

4.   VMware retains ownership of the Software and all intellectual property
rights embodied in the Software, including without limitation all
copyrights,
trade secrets and patents. You may not remove, delete or modify any of
VMware copyright statements in the Software.  ALL RIGHTS NOT
EXPRESSLY GRANTED HEREUNDER ARE RESERVED TO VMWARE.

5.  You may not use VMware's name, trademarks or service marks in
connection with your Developer Software in a way that suggests your
Developer Software is certified or endorsed by VMware.

6.  You are not entitled under this Agreement to receive any VMware support
or subscription services for the Software or any other services from VMware
in connection with the Software. If you have purchased support and/or
subscription services for a VMware product, such support and/or subscription

services shall not apply to the Software or your use of the Software.

7.  TERM, TERMINATION & CHANGES:  This Agreement shall continue as
long as you are in compliance with the terms specified herein or until
otherwise terminated. You or VMware each may terminate this Agreement for
any reason at any time. You agree, upon termination, to destroy all copies
of
the Software within your possession or control. The Confidential
Information,
Limitations of Warranties and Liability, and Indemnification sections set
out in
this Agreement shall survive any termination or expiration of this
Agreement.

8.  CONFIDENTIAL INFORMATION:  "Confidential Information" means any
information disclosed by VMware to you pursuant to this Agreement that is
marked "Confidential," "Proprietary," or in some similar manner and any
information which you knew or reasonably should have known to be
confidential. You shall treat as confidential all Confidential Information
of
VMware and shall not use such Confidential Information except to exercise
your rights or perform your obligations under this Agreement. You will
protect
Confidential Information from unauthorized use, access, or disclosure in the

same manner as you protect your own confidential or proprietary information
of a similar nature but with no less than reasonable care. You shall not
disclose such Confidential Information to any third party during or after
the
term of this Agreement. This paragraph will not apply to any Confidential
Information that: (a) was rightfully in your possession prior to receipt of
such
Confidential Information from VMware; (b) is or becomes a matter of public
knowledge through no fault of you; (c) is rightfully received from a third
party
without a duty of confidentiality; (d) is independently developed by you
without
breach of any confidentiality obligations; (e) is disclosed by you with
VMware's prior written approval; or (f) you are required to disclose by
applicable law or court order, provided that you notify VMware of such
required disclosure promptly in writing and cooperate with VMware in any
lawful action to contest or limit the scope of such required disclosure. You

acknowledge that breach of this Section 8 will cause irreparable damage to
VMware for which monetary damages will be an inadequate remedy.
Accordingly, VMware will be entitled to seek and obtain injunctive and any
other relief (legal or equitable) to restrain any breach or anticipated
breach of
this Section 8.

9.  LIMITATIONS OF WARRANTIES & LIABILITY:  THE SOFTWARE IS
PROVIDED "AS IS" WITHOUT ANY WARRANTIES OF ANY KIND. TO THE
MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, VMWARE
DISCLAIMS ANY IMPLIED WARRANTIES, INCLUDING, WITHOUT
LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF
INTELLECTUAL PROPERTY RIGHTS.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
EVENT WILL VMWARE BE LIABLE FOR ANY LOST PROFITS OR
BUSINESS OPPORTUNITIES, LOSS OF USE, BUSINESS INTERRUPTION,
LOSS OF DATA, OR ANY OTHER INDIRECT, SPECIAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE SOFTWARE OR
YOUR USE OF THE SOFTWARE, UNDER ANY THEORY OF LIABILITY,
WHETHER BASED IN CONTRACT, TORT, NEGLIGENCE, PRODUCT
LIABILITY, OR OTHERWISE.  BECAUSE SOME JURISDICTIONS DO NOT
ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR
CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE PRECEDING
LIMITATION MAY NOT APPLY TO YOU.

VMWARE'S LIABILITY ARISING OUT OF THIS AGREEMENT AND THE
SOFTWARE PROVIDED HEREUNDER WILL NOT, IN ANY EVENT,
EXCEED US$100.00.

THE FOREGOING LIMITATIONS SHALL APPLY TO THE MAXIMUM
EXTENT PERMITTED BY APPLICABLE LAW, REGARDLESS OF
WHETHER VMWARE HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES AND REGARDLESS OF WHETHER ANY REMEDY
FAILS OF ITS ESSENTIAL PURPOSE.

10.  INDEMNIFICATION: You agree to defend, indemnify and hold harmless
VMware, and any of its directors, officers, employees, affiliates and
agents,
from and against any and all claims, losses, damages, liabilities and other
expenses (including reasonable attorneys' fees), arising from your
modification of the "modifiable code," the distribution or use of your
Developer
Software by you or anyone else, and your breach of this Agreement.

11.  EXPORT CONTROL: You acknowledge that the Software is of United
States origin, is provided subject to the U.S. Export Administration
Regulations, may be subject to the export control laws of the applicable
territory, and that diversion contrary to applicable export control laws is
prohibited. You represent, warrant and covenant that (1) you are not, and
are
not acting on behalf of, (a) any person who is a citizen, national, or
resident
of, or who is controlled by the government of any country to which the
United
States has prohibited export transactions; or (b) any person or entity
listed on
the U.S. Treasury Department list of Specially Designated Nationals and
Blocked Persons, or the U.S. Commerce Department Denied Persons List or
Entity List; and (2) you will not permit the Software to be used for any
purposes prohibited by law, including, any prohibited development, design,
manufacture or production of missiles or nuclear, chemical or biological
weapons.

12.  DATA PRIVACY:

(a) Consent for Collection and Use of Technical Data. You agree
that VMware may periodically collect, process and store technical
and related information about your device, system, application,
peripherals and your use of the Software, including without
limitation: internet protocol address, hardware identification,
operating system, application software, peripheral hardware,
number of active plugins and software development kits, the
successful installation and launch of Software, and  Software usage
statistics (collectively, "Technical Data"). VMware will use Technical
Data for internal statistical and analytical purposes to facilitate
support, invoicing or online services, the provisioning of updates,
and the development of VMware products and services. VMware
may transfer Technical Data to other companies in the VMware
worldwide group of companies from time to time.

(b) Log Files. You acknowledge that correspondence and log files
generated in conjunction with a request for support services may
contain sensitive, confidential or personal information. You are
solely responsible for taking the steps necessary to protect such
data, including obfuscating the logs or otherwise guarding such
information prior to sending it to VMware.

13.  These terms are governed by the laws of the State of California and the

United States of America without regard to conflict of laws principles. The
United Nations Convention for the International Sale of Goods shall not
apply.
You may not assign this Agreement. Any attempted assignment by you shall
be void. These terms constitute the entire agreement between you and
VMware with respect to the Software and supersede all prior written or oral
communications, understandings and agreements. Any waiver of these terms
must be in writing and signed by the waiving party to be effective. If any
provision of these terms is found to be invalid or unenforceable, the
remaining
terms will continue to be valid and enforceable to the fullest extent
permitted
by law.




Do you accept? (yes/no) yes

Thank you.

WARNING: The http_proxy environment variable is not set. If your system is
using a proxy for Internet access, you must set the http_proxy environment
variable .

If your system has direct Internet access, you can ignore this warning .

WARNING: The ftp_proxy environment variable is not set.  If your system is
using a proxy for Internet access, you must set the ftp_proxy environment
variable .

If your system has direct Internet access, you can ignore this warning .

Please wait while configuring CPAN ...

Do you want to continue? (yes/no) yes

Please wait while configuring perl modules using CPAN ...

CPAN is downloading and installing pre-requisite Perl module "Time::Piece" .

CPAN is downloading and installing pre-requisite Perl module "Archive::Zip" .

CPAN is downloading and installing pre-requisite Perl module "Path::Class" .

CPAN is downloading and installing pre-requisite Perl module "UUID" .

CPAN is downloading and installing pre-requisite Perl module "Text::Template" .


CPAN is downloading and installing pre-requisite Perl module "Net::INET6Glue" .


In which directory do you want to install the executable files?
[/usr/bin]

Please wait while copying vSphere CLI files...

The installation of vSphere CLI 6.7.0 build-8156551 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command:
"/usr/bin/vmware-uninstall-vSphere-CLI.pl".

This installer has successfully installed both vSphere CLI and the vSphere SDK
for Perl.

The following Perl modules were found on the system but may be too old to work
with vSphere CLI:

Try::Tiny 0.28 or newer
Crypt::SSLeay 0.72 or newer
XML::NamespaceSupport 1.12 or newer
Socket6  0.28 or newer

Enjoy,

--the VMware team
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Vmware plugin not working as Nagios User

Post by tgriep »

Can you run the followinc command as root as post the output here so we can see where the VMWare module is installed?

Code: Select all

find / -name VIRuntime.pm
For example, if it returns this

Code: Select all

/usr/lib/vmware-vcli/VMware/share/VMware/VIRuntime.pm
We will set the permissions of the files and folder like this

Code: Select all

chmod -R a+rwx /usr/lib/vmware-vcli
If it returns the path like this

Code: Select all

/usr/share/perl5/VMware/VIRuntime.pm
Run this

Code: Select all

chmod -R a+rwx /usr/share/perl5/VMware
Be sure to check out our Knowledgebase for helpful articles and solutions!
ksafa
Posts: 91
Joined: Wed Jan 15, 2014 3:05 pm

Re: Vmware plugin not working as Nagios User

Post by ksafa »

# find / -name VIRuntime.pm
/usr/lib/vmware-vcli/VMware/share/VMware/VIRuntime.pm
/usr/share/perl5/VMware/VIRuntime.pm

# ls -ltr /usr/share/perl5/VMware/VIRuntime.pm
-rwxrwxrwx 1 root root 505 Dec 21 20:20 /usr/share/perl5/VMware/VIRuntime.pm

# ls -ltr /usr/lib/vmware-vcli/VMware/share/VMware/VIRuntime.pm
-rwxrwxrwx 1 root root 505 Dec 21 20:20 /usr/lib/vmware-vcli/VMware/share/VMware/VIRuntime.pm


Still does not work after changing the permissions as per rec.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Vmware plugin not working as Nagios User

Post by ssax »

Please run these commands as the root user and post the full output so that we can compare:

Code: Select all

perl -e "print \"@INC\""
su - nagios
perl -e "print \"@INC\""
ksafa
Posts: 91
Joined: Wed Jan 15, 2014 3:05 pm

Re: Vmware plugin not working as Nagios User

Post by ksafa »

# perl -e "print \"@INC\""
/usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .

# su - nagios
Last login: Fri Dec 21 21:06:09 GMT 2018 on pts/0
$ perl -e "print \"@INC\""
/usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .
Locked