vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
757 stars 603 forks source link

vCware.Alarms #189

Open smcneice opened 6 years ago

smcneice commented 6 years ago

This is a great module, my current issue with vcenter 6.5 it the reporting frequency being set to 5 minutes by default, and vmware seems to have no easy way to fix it, your module allows me to set it to 0, the only issue I am having at the moment is the entity, I cannot find a way to enter a folder under the VMs and Templates for -Entity, can you please tell me if there is a way around this in your module?

CajunBard commented 6 years ago

Can you share a bit of your code that you're having a problem with? I assume you're talking about the vCenter.Alarms module?

smcneice commented 6 years ago

Yes and thanks for the quick response,

I am just doing the simplest script to get started and testing, If I use the entity name from vmware I get an error,

Connect-VIServer -server vcenter25 -user 'username' -password 'password'

  Import-Module -Name vCenter.Alarms

  $trigger = New-AlarmTrigger -StateType runtime.connectionState -StateOperator isEqual -YellowStateCondition disconnected -RedStateCondition notResponding -ObjectType HostSystem
  New-AlarmDefinition -Name 'Scott Report Frequency Test' -Description 'Scott Report Frequency Test' -Entity 'Folder-group-s5' -Trigger $trigger -ActionRepeatMinutes 10 -ReportingFrequency 0

Disconnect-viserver -server * -force -Confirm:$false

New-AlarmDefinition : 5/1/2018 10:15:36 AM Get-Inventory Inventory with name 'Folder-group-s5' was not found using the specified filter(s). At C:\Users\sa-flvmw\AppData\Local\Temp\2\4c06bfec-4034-4f57-8806-0df8abe5d0b2.ps1:6 char:2

If I use the simple folder name I get Connect-VIServer -server vcenter25 -user 'username ' -password 'password'

  Import-Module -Name vCenter.Alarms

  $trigger = New-AlarmTrigger -StateType runtime.connectionState -StateOperator isEqual -YellowStateCondition disconnected -RedStateCondition notResponding -ObjectType HostSystem
  New-AlarmDefinition -Name 'Scott Report Frequency Test' -Description 'Scott Report Frequency Test' -Entity 'Virtualization and Storage' -Trigger $trigger -ActionRepeatMinutes 10 -ReportingFrequency 0

Disconnect-viserver -server * -force -Confirm:$false

New-AlarmDefinition : Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct: " At C:\Users\sa-flvmw\AppData\Local\Temp\2\4c06bfec-4034-4f57-8806-0df8abe5d0b2.ps1:6 char:2

This is the folder I am trying to add to, [cid:image001.png@01D3E139.F5ED9550]

From: Matt Frey [mailto:notifications@github.com] Sent: Tuesday, May 01, 2018 10:30 AM To: vmware/PowerCLI-Example-Scripts PowerCLI-Example-Scripts@noreply.github.com Cc: Scott McNeice Scott.McNeice@dfcufinancial.com; Author author@noreply.github.com Subject: Re: [vmware/PowerCLI-Example-Scripts] vCware.Alarms (#189)

DFCU Financial Security Advisory: This email was received from an external source. DO NOT open attachments, click on links, or trust the content from an unknown, unexpected, or suspicious sender.

Can you share a bit of your code that you're having a problem with? I assume you're talking about the vCenter.Alarms module?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/vmware/PowerCLI-Example-Scripts/issues/189#issuecomment-385684370, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlFZP2aG4v2b8Ghd8RhJRD3SCnhb8oixks5tuHFOgaJpZM4Tt_DH.

This E-mail and attachments are intended for designated recipients. If you are not the addressee or the addressee's agent, please destroy all copies. If you obtained this via electronic eavesdropping, you violated the Electronic Communications Privacy Act. Disclosure, duplication, distribution or actions taken in reliance on contents herein is prohibited without explicit consent of DFCU Financial.

CajunBard commented 6 years ago

I see. Thanks for clarifying. The New-AlarmDefinition cmdlet uses Get-Inventory to find the -Entity as seen here.

Can you try finding your desired folder like this, then using the name that is returned?

Get-Inventory -Name "Virtualization and Storage"

The screenshot didn't come through, but I assume that's what it shows as the name of the folder.

smcneice commented 6 years ago

Whenever I try using the ID which is 'Folder-group-s5' it crashes on $Object creation and returns, Inventory with name 'Folder-group-s5' was not found using the specified filter(s). Whan I do it with the actual name, the $Object.Id value is correct just before doing $AlarmMgr.CreateAlarm($Object.Id, $Alarm), I am starting to think it’s a vmware API limitation, it works on the vcenter, Datacenter, and cluster level for sure, but so far I cannot get it to work in other objects,

From: Matt Frey [mailto:notifications@github.com] Sent: Tuesday, May 01, 2018 12:10 PM To: vmware/PowerCLI-Example-Scripts PowerCLI-Example-Scripts@noreply.github.com Cc: Scott McNeice Scott.McNeice@dfcufinancial.com; Author author@noreply.github.com Subject: Re: [vmware/PowerCLI-Example-Scripts] vCware.Alarms (#189)

DFCU Financial Security Advisory: This email was received from an external source. DO NOT open attachments, click on links, or trust the content from an unknown, unexpected, or suspicious sender.

I see. Thanks for clarifying. The New-AlarmDefinition cmdlet uses Get-Inventory to find the -Entity as seen herehttps://github.com/vmware/PowerCLI-Example-Scripts/blob/e83d70081caede8bcdef2971957d8a34f6e0a783/Modules/vCenter.Alarms/vCenter.Alarms.psm1#L125-L131.

Can you try finding your desired folder like this, then using the name that is returned?

Get-Inventory -Name "Virtualization and Storage"

The screenshot didn't come through, but I assume that's what it shows as the name of the folder.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/vmware/PowerCLI-Example-Scripts/issues/189#issuecomment-385710991, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlFZP6MvudakAG_ycZ4J_Hl0oISM0r1tks5tuIjggaJpZM4Tt_DH.

This E-mail and attachments are intended for designated recipients. If you are not the addressee or the addressee's agent, please destroy all copies. If you obtained this via electronic eavesdropping, you violated the Electronic Communications Privacy Act. Disclosure, duplication, distribution or actions taken in reliance on contents herein is prohibited without explicit consent of DFCU Financial.