VMware Horizon Community
six4rm
Enthusiast
Enthusiast

Monitoring View with Nagios

Hi,

I thought I'd post this in here as I've searched high and low and found barely any information on this particular topic.

I've recently deployed Nagios within our company in order to monitor key hosts and services. In doing so this got me thinking how I could use Nagios to monitor certain things within VMware View. Having played around with Exchange PowerShell scripts and Nagios I started to look at VMware PowerCLI. I couldn’t work out a way to pull the information I wanted using the default PowerCLI commands so I started to have a dig around online. During my investigations I then came across the Unofficial VMware View PowerShell cmdlets.

http://cliffdavies.com/blog/vmware/unofficial-advanced-vmware-view-powershell-cmdlets/

Using the above I was able to extract the very information I was after, which I could then run through a script and ultimately report this back to Nagios. So with this in mind I set about writing some scripts for VMware View monitoring.

Having just experienced a major issue where all 350 View VMs went into an ‘already used’ state, meaning no one could logon, I thought what better place to start than to write a script to count the number of ‘problem desktops’ and then report this back to Nagios for alerting and notification purposes.

Using Get-Desktops within the unofficial cmdlets I was able to pull out the ‘state’ of each VM Desktop. This is then run through an ‘if’ statement to find ‘problem’ desktops and a count is produced. The count is then compared to the warning and critical levels defined within the script and then the script exits with the relevant code, 0, 1 or 2, to pass this back to Nagios along with the current number of problem desktops.

The script is executed on the View Connection Server itself using NSClient++ which is initiated by Nagios using a check_nrpe command. There is a great article on telnetport25.com about executing PowerShell scripts using check_nrpe & NSClient++. - http://www.telnetport25.com/2012/01/installing-nagios-on-ubuntu-server-11-10-then-monitoring-windows... - In fact I followed the tutorials from that site for my entire Nagios build, they really are great.

One thing I also had to do was to amend the uadv_vmware_view.psm1 file included with the unofficial cmdlets so that it doesn’t print to screen when a successful connection is made to the View Connection Server. I just amended the ‘if’ statement within the psm1 file to achieve this, pretty simple. I have attached this below too.

So now I will get alerted by email and visually on our IT monitor when we hit a certain amount of ‘problem’ desktops, which is great as I don’t want to have to check the View Admin console every hour or so.

If anyone wants any further information please feel free to let me know and I’ll be happy to oblige.

This also leads me to think what else can be monitored within View using these cmdlets?

Reply
0 Kudos
15 Replies
mittim12
Immortal
Immortal

Just a FYI that I converted this discussion into a document available in the VIew Manager document section.     Thanks for posting this.

Reply
0 Kudos
six4rm
Enthusiast
Enthusiast

Awesome, thanks!

Hopefully someone will find it useful as there really isn't much out there on monitoring View with Nagios.

Reply
0 Kudos
AngstNU
Contributor
Contributor

Hello,

here is my script thanks to six4rm fo his ProblemDesktops.ps1 , I was able monitor my view active session using nagios.

# This script will count the connected Desktops within a VMware View environment.

# Define Critical & Warning levels to alert back to Nagios.
$Critical = 10
$Warning = 8

###############################################################################################

# Set variables to 0
$Count = 0
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2

# Add VMware View PowerShell Snapin.
add-PSSnapin "VMware.View.Broker"

# Collect Desktop Information
ForEach ($Result in Get-RemoteSession -pool_id DS7 | Select state)
{
if ($Result.state -eq "CONNECTED")
{
  $Count = $Count + 1
}
elseif ($Result.state -eq "Error")
{
  $Count = $Count + 1
}
elseif ($Result.state -eq "Agent unreachable")
{
  $Count = $Count + 1
}
}

### PerformanceData Output
$NagiosPerfData = "|Active sessions=" + $Count + ";8;10"
$NagiosPerfData = $NagiosPerfData -replace " ", ""
$Users = ((Get-RemoteSession -pool_id DS7)|Where-Object{$_.state -eq "CONNECTED"}) | select duraTion, username #starTime
$Users = $Users -replace "", ""
#############################################################

if ($Count -ge $Critical)
{
#CRITICAL
Write-Host "Activesessions="$Count" "$Users" "$NagiosPerfData
     exit $returnStateCritical
}
elseif ($Count -ge $Warning)
{
#WARNING
Write-Host "Activesessions="$Count" "$Users" "$NagiosPerfData
     exit $NagiosStatus = 1
}
else
{
#OK
  Write-Host "Activesessions="$Count" "$Users" "$NagiosPerfData
  }
exit $NagiosStatus

##########################################################

right now I am looking to capture users who are trying to those Desktop Pool which is full already, the objective is to catch who are those users trying to login and send the information to the Admin... it sounds complicated.

this is the performance graph using nagios

Reply
0 Kudos
PieRSonneT
Contributor
Contributor

Hello,

Does someone try the uadv_vmware_view.psm1 with View 5.1.x ?

When i lunch the  function Connect-ViewConnServer, i have this message :

Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (404) Not Found."

At C:\Users\psonnet\Downloads\VIEWNAGIOS\uadv_vmware_view.psm1:25 char:30

+     $webclient.DownloadString <<<< ($global:defaultViewConnServer.url) | out-null

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

i think the probleme conme with this line :

$global:defaultViewConnServer.url = "https://$($viewConnServer)/admin/amf";

Reply
0 Kudos
BL460c
Contributor
Contributor

Tested it here, same issue

seems VMware changed something to do with the Action Message Format as that URL doesn't exist

Reply
0 Kudos
six4rm
Enthusiast
Enthusiast

I revisited this last week as I've just put a View 5.1.2 server into our environment. I couldn't get the unofficial plugin to work either, I got the same error.

Looking at the post by AngstNU above, monitoring for problem desktops may well be do-able natively in View 5. I will post on my findings when I get around to looking at it.

Reply
0 Kudos
NetherMark
Contributor
Contributor

Hi six4rm (and others), thanks for the helpfull posts. This thread is about the only usefull info I could find on Nagios with VMWare view.

We just started testing NagiosXI and would like to use it to monitor the "available" count in View. We have a desktop pool for about 350 desktops for which we have a powershell script that sets the number of spare desktops to 60 and after the bootstorm it sets it to 20. A few days ago the pool gave a null pointer exception and did not roll out any new machines: we only noticed when people started calling :smileysilly: You can imagine we could not get machines ready fast enough after that...

Is it possible to check the available count using Nagios? Any help is greatly appreciated!

Reply
0 Kudos
AngstNU
Contributor
Contributor

NetherMark,

you may use the powershell script posted to monitor vmware view desktop usage.

Norman

Reply
0 Kudos
NetherMark
Contributor
Contributor

Thanks for your reply AngstNU.

As I read it, the script does not work with View 5.1?

Since I am new with both powershell and Nagios I would like to know this before I start messing about. It might take me a few days to find out I am not the problem otherwise :smileysilly:

Reply
0 Kudos
jmon23
Contributor
Contributor

Hi have a pluign for this and documentation - please feel free to use:)

Here is some documentation:

http://www.op5.com/how-to/monitoring-vmware-esx-3-x-esxi-vsphere-4-and-vcenter-server/

And here is the plugin:

http://www.op5.org/community/plugin-inventory/op5-projects/check-esx-plugin

/ J

Reply
0 Kudos
six4rm
Enthusiast
Enthusiast

Thanks for the links, this plugin looks great for monitoring ESX hosts and VMs directly, I'll be sure to check it out as I'm not monitoring anything in this manner.

It's not quite what I'm after as a replacement to my above script for problem desktops, which I've still not had a chance to properly investigate since my move to View 5.1.2.

Reply
0 Kudos
crnine
Contributor
Contributor

Hey All,

are there any new Information known if the uadv is supporting vmware view 5.1 now?

pls let us know Smiley Wink

thx

cr

Reply
0 Kudos
jmon23
Contributor
Contributor

HI

Here is some updated info with more details: https://kb.op5.com/display/HOWTOs/Monitoring+VMware+ESX+3.x%2C+ESXi%2C+vSphere+4+and+vCenter+Server

Hope it helps / Jan

Reply
0 Kudos
crnine
Contributor
Contributor

Hi Jan,

I was looking more for a solution of this "I couldn't get the unofficial plugin to work either, I got the same error." with the uadv snappins on vmware view 5.1.

greets

cr

Reply
0 Kudos
Sarankal
Contributor
Contributor

I changed the settings in the uadv_vmware_view.psm1 file. execute the .PS1 file getting error


PS D:\ViewCli> $webclient.DownloadString($global:defaultViewConnServer.url)

Exception calling "DownloadString" with "1" argument(s): "The remote server ret

urned an error: (404) Not Found."

At line:1 char:26

+ $webclient.DownloadString <<<< ($global:defaultViewConnServer.url)

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

Kindly let me know what update i want to perform to excute the .PS1 file to connect the VIew Connection server.@ !



Reply
0 Kudos