Hi,
We have vSphere 4.1 and ESXi 4.1 in our environment. We would like to set up an alarm which will send a mail if there is any host on which tech support mode is enabled.
Please let me know how to achieve this.
Hello,
I suggest you check out a post by Alan Renouf which describes your problem at http://www.virtu-al.net/2010/03/01/powercli-technical-support-mode/
The first command is how to get it
Hi,
STEP 1 - go to the level of the vSphere infrastructure that you want to create an alarm on. If it is on a particular VM, go to the alarms tab on that VM. If it is for all hosts in the datacenter, go to the datacenter view, and then click on alarms.
STEP 2 - go to the Alarm Definitions view
STEP 3 - Right-click and click New Alarm
STEP 4 - Give the alarm a useful and descriptive name (to you and others) and select the correct alarm type
STEP 5 - Select between Monitor for conditions / state and Monitor for specific Events and go to the next tab, Triggers
STEP 6 - Add a new Trigger. Set the Trigger Type, Condition, Warning, and Alert levels. Note that this may take some tweaking over time to get the warning and alert levels correct.The reporting tab is optional but you must move on to the Actions tab.
STEP 7 - Add a new Action. This could be to email you, send a SNMP notification trap, or run a command. Let's say that you configure the alarm to email you, you would enter your email address in the configuration. When you are all done, click OK, and you should see the result of your work in the alarm definitions view.
Figure 8: Successful creation of a new vSphere Alarm
Hi,
Please note that you first need to configre your global mail settings (vCenter Server Settings --> Mail).
And which trigger do you suggest to use ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And where is the alarm part ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There is no option to monitor tech support mode or ESXi shell nor SSH
Hi Folks,
Thanks for your reply. What actually I am looking for is there any way to create a custom alarm which will sent an email notification whenever tech support mode is enabled on any host.
Try the following script:
Replace localhost in the first line with your vCenter hostname.
Next replace "User" and "Password" with a vCenter login.
Finally in the end replace the following line with the correct info:
Send-Mail -to "support@company.com" -from "vcenter@company.com" -subject "Tech mode running" -smtpserver "mail.company.com" -body $body
You'll need to replace:
"mail.company.com"
You can automate this task by running the script as a scheduled task.
$vcenter = "localhost"
# Connect to vCenter
Connect-VIServer -Server $vcenter -User "User" -Password "Password" | Out-Null
# E-mail function
function Send-Mail($to, $from, $subject, $smtpserver, $body) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from, $to, $subject, $body)
$msg.IsBodyHTML = $false
$mailer.send($msg)
}
$vmhosts = Get-VMHost | sort Name
$techmoderunning = @()
foreach ($vmhost in $vmhosts) {
$vmhost | Get-VMHostService | Where {$_.key -eq "TSM"}| %{
if ($_.running -eq $true) {
Write-Warning "Local Tech Support Mode on $vHost already started on $vmhost"
$techmoderunning += "Local Tech Support Mode on $vHost already started on " + $vmhost + " `r`n"
}
}
}
if ($techmoderunning -ne $null) {
$body += $techmoderunning | Sort-Object
# Send the e-mail
Send-Mail -to "support@company.com" -from "vcenter@company.com" -subject "Tech mode running" -smtpserver "mail.company.com" -body $body
}Disconnect-VIServer -Server $vcenter -Confirm:$false
Should have tested it first indeed, realised the post was from 2010 and got some errors so figured another way .