Script to send email to what value if too hight

Hi all

Search I want to send email when the value is too high.

for example, we script runs and show kmoy of esx, when this value on avegrage 1 min is more that the preset e-mail is sent.

is it possible with powercli?

TKS in advance

This should create the alarm in order to capture opportunities where the latency of reading on any HBA on the host exceeds a certain threshold.

First of all, you need get the metric ID for the measurement of the storageAdapter.totalReadLatency.average.

You can use something like this to get this ID. This is a Lite version of the script that you can find in the blog.

function Get-PerfCounterList{
  param($pm)

  $list = @{}
  $pm.PerfCounter | % {
    $obj = "" | Select Name, Level, Summary
    $obj.Name = $_.GroupInfo.key + "." + $_.NameInfo.key + "." + $pm.Description.CounterType[$_.RollupType].Key

    $obj.Level = $_.Level
    $obj.Summary = $_.NameInfo.Summary
    $list[$_.Key] = $obj
  }
  $list
}

function Get-StatId {
param($entity, $pm, $perfCounterList)

$result = @()

$perfProvider = $pm.QueryPerfProviderSummary($entity.MoRef)

if($perfProvider.SummarySupported){
  $perfMetrics = $pm.QueryAvailablePerfMetric($entity.MoRef,$null,$null,$null)
  if($perfMetrics){
    foreach($metric in $perfMetrics){
      $row = "" | Select Entity, Interval, CounterId, Stat, Instance, Level, Summary
      $row.Entity = $entity.GetType().Name
      $row.Interval = "Aggregate"
      $row.CounterId = $metric.CounterId
      $row.Stat = $perfCounterList[$metric.CounterId].Name
      $row.Instance = $metric.Instance
      $row.Level = $perfCounterList[$metric.CounterId].Level
      $row.Summary = $perfCounterList[$metric.CounterId].Summary
      $result += $row
    }
  }
}

if($perfProvider.CurrentSupported){
  $perfMetrics = $pm.QueryAvailablePerfMetric($entity.MoRef,$null,$null,$perfProvider.refreshRate)
  foreach($metric in $perfMetrics){
    $row = "" | Select Entity, Interval, CounterId, Stat, Instance, Level, Summary
    $row.Entity = $entity.GetType().Name
    $row.Interval = "RealTime"
    $row.CounterId = $metric.CounterId
    $row.Stat = $perfCounterList[$metric.CounterId].Name
    $row.Instance = $metric.Instance
    $row.Level = $perfCounterList[$metric.CounterId].Level
    $row.Summary = $perfCounterList[$metric.CounterId].Summary
    $result += $row
  }
}
$result
}

$pm = Get-View (Get-View ServiceINstance).Content.PerfManager
$perfCounterList = Get-PerfCounterList $pm

$report = @()

# HostSystem
$vmhost = Get-VmHost MyEsx | Get-View
if($vmhost){
  $report += (Get-StatId $vmhost $pm $perfCounterList)
}

$report | Export-Csv "C:\Stat-Ids.csv" -NoTypeInformation -UseCulture

Then, you will have a good idea of the thresholds to be used in the alarm. Remember that the metric returns the average in milliseconds over a period of 20 seconds.

This little script should give you an idea what latency, you can see in your environment.

$esx = Get-VMHost MyEsx

Get-Stat -Entity $esx -Stat "storageadapter.totalreadlatency.average" -Realtime -MaxSamples 1 |
Select @{N="Adapter";E={$_.Instance}},
@{N="Latency";E={$_.Value}},
@{N="Latency %";E={$_.Value/($_.IntervalSecs*10)}}

Once you know the thresholds you want to use, we can create the real alarm.
Like this

$esxName = "MyEsx"
$mailTo = "[email protected]"

$alarmMgr = Get-View AlarmManager
$entity = Get-VmHost $esxName | Get-View

# AlarmSpec
$alarm = New-Object VMware.Vim.AlarmSpec
$alarm.Name = "Read Latency"
$alarm.Description = "Send email when read latency exceeds the threshold"
$alarm.Enabled = $TRUE

# Action - Send email
$alarm.action = New-Object VMware.Vim.GroupAlarmAction

$trigger = New-Object VMware.Vim.AlarmTriggeringAction
$trigger.action = New-Object VMware.Vim.SendEmailAction
$trigger.action.ToList = $mailTo
$trigger.action.Subject = "Net received alarm"
$trigger.Action.CcList = ""
$trigger.Action.Body = ""

# Transition a - yellow --> red
$transa = New-Object VMware.Vim.AlarmTriggeringActionTransitionSpec
$transa.StartState = "yellow"
$transa.FinalState = "red"

# Transition b - red --> yellow
$transb = New-Object VMware.Vim.AlarmTriggeringActionTransitionSpec
$transb.StartState = "red"
$transb.FinalState = "yellow"

$trigger.TransitionSpecs += $transa
$trigger.TransitionSpecs += $transb

$alarm.action.action += $trigger

# Expression - Network data receive rate
$expression = New-Object VMware.Vim.MetricAlarmExpression
$expression.Metric = New-Object VMware.Vim.PerfMetricId
$expression.Metric.CounterId = 327
$expression.Metric.Instance = ""
$expression.Operator = "isAbove"
$expression.Red = 75
$expression.Yellow = 35
$expression.Type = "HostSystem"

$alarm.expression = New-Object VMware.Vim.OrAlarmExpression
$alarm.expression.expression += $expression

$alarm.setting = New-Object VMware.Vim.AlarmSetting
$alarm.setting.reportingFrequency = 0
$alarm.setting.toleranceRange = 0

# Create alarm.
$alarmMgr.CreateAlarm($entity.MoRef, $alarm)

I would like to know how it works.

Tags: VMware

Similar Questions

  • Prevent the 'Send Email' dialog box until the required fields are filled

    I am new to JS and fight with a last piece of code.

    I have a form with several fields. I send the form as an attachment to e-mail and need the required fields completed before the form can be sent by e-mail.

    Currently, I have a display alert message if all of the required fields are empty, but if I cancel the box warning, the 'send Email' dialog appears immediately and I can send the form even if the required fields are empty. I want the 'Send Email' box to appear only after completing all the required text boxes.

    The problem seems to be with the if/else line (IF all fields req. are empty, send alert. OTHERWISE open the box "Send email"). What is the best way to write this? Ideally, I would like to alert to list specific areas that are empty. Here is what I have at the moment - but obviously something wrong):

    If (requiredFields.length > 0) {}
    App.Alert (Error);

    } else


    var subject = this.getField("JobNumber").value + '-application form;
    this.mailDoc({)
    cTo: "[email protected]"

    })

    (Using Acrobat XI - thanks in advance!)

    LAST UPDATED 18/12/15

    Talk with someone @ Adobe (through our IT people we actually received a CONF. call w / an Acrobat expert!)

    It turned out to be the word "subject" in our Javascript. The word
    "subject" is a reserved word in newer formats and is read-only in
    Drive.  So we had to redefine the word & read "subject".

    Works great!

  • Send emails with a custom script

    Hello

    I'm trying to get by email using customscript in FDMEE. I get email during execution of the script. (Blank email). I don't get the message that I give in the script. Here's the script. Can someone let me know what I'm you wish here:

    # Import smtplib for the actual sending function

    Import smtplib

    strSMTPServer = "XXX".

    iSMTPPort = 25

    strReceivers = "Xxx".

    strSender = "Xxx".

    #strMessage = 'this is a test e-mail.

    strMessage = "" «this is a test e-mail»»»

    Try:

    #smtpServer = smtplib. SMTP (strSMTPServer, iSMTPPort)

    smtpServer = smtplib. SMTP ("XXX", 25)

    smtpServer.set_debuglevel (1)

    smtpServer.ehlo)

    smtpServer.starttls)

    #smtpServer.login (strUserid, strPassword)

    smtpServer.sendmail (strSender, strReceivers, strMessage)

    #SendEmail (strSender, strReceivers, "Test")

    Print "sent by e-mail.

    smtpServer.quit)

    except Exception, e:

    Print ' error: cannot send email: "+ str (e).

    Thanks in advance

    Hello

    I think that you do not provide the context of the strmessage correctly.

    You can try below

    # Import smtplib for the actual sending function
    import smtplib
    strSMTPServer  = 'XXX'
    iSMTPPort = 25
    strReceivers = "XXX.com"
    strSender = "XXX.com"
    #strMessage = "This is a test e-mail message"
    strMessage ="""From: [email protected]
    To: [email protected]
    Subject: SMTP e-mail test
    
    This is a test e-mail message.
    """
    try:
        #smtpServer = smtplib.SMTP(strSMTPServer, iSMTPPort)
        smtpServer = smtplib.SMTP("XXX", 25)
        smtpServer.set_debuglevel(1)
        smtpServer.ehlo()
        smtpServer.starttls()
        #smtpServer.login(strUserid, strPassword)
        smtpServer.sendmail(strSender,strReceivers,strMessage)
        #SendEmail(strSender,strReceivers,"Test")
        print "Successfully sent email"
        smtpServer.quit()
    except Exception, e:
         print "Error: unable to send email: " + str(e)
    

    Hope this helps

    Thank you

    N.S.

  • Why doesn't my script (send email)?

    Hello guys.

    What is the problem in my script (to send mail). I want to send an e-mail via LiveCycle just message (I want opens up prospects for the user by typing, without attachment).

    var mail; 
    var address = "[email protected]"; 
    var sub = "Assunto"; 
    var corpo = "Texto do corpo do e-mail";
    mail = "mailto: " + address + "?subject=" + sub + "&body=" + corpo; 
    event.target.submitForm({ cURL: mail, bEmpty: true, cSubmitAs: "PDF", Charset: "utf-8" }); 
    

    Link to the file: https://acrobat.com/#d=1I * dJTGL1a5vNcmlJMk76g

    Thank you.

    Hello

    The script that you have is intended for sending the form as an attachment.

    If you want just one button to send an e-mail only, use the event.target.app.mailMsg. The following Javascript code should help:

    var vEmail = "[email protected]";
    var vSubject = "A Subject for your email";
    var vBody =  "Put your body message here...";
    
    event.target.app.mailMsg({
    bUI: true,
    cTo: vEmail,
    cSubject: vSubject,
    cMsg: vBody
    });
    

    For more scripts to access Acrobat menu items, take a look on: http://assure.ly/i2LBMC

    Hope that helps,

    Niall

  • Under TOOLS/Account Settings / your name / what I chose for "your name" is not displayed when you send an email. What should do? Thanks, paul

    Question: Under TOOLS/Account Settings / your name / what I chose for "your name" is not displayed when you send an email. What should do? Thank you! Paul

    This looks like a problem with your email service, not with Firefox (or Thunderbird).

    It is possible that you need to set the name sent by logging into your webmail account online (e.g., Yahoo! Mail or Gmail). Web e-mail providers like these often put sending appoint themselves, ignoring the settings of your email client.

    Unfortunately, since it is not a matter of Firefox you're unlikely to get help on these forums. I suggest that you find the support site for your e-mail provider, as they should be much more useful.

  • I have problems when sending emails on Outlook Express (Windows XP Home) told in the Outbox, even if they were sent. What can I do?

    I have problems when sending emails on Outlook Express (Windows XP Home) told in the Outbox, even if they were sent.  What can I do?

    You have apparent dbx file corruption.

    Spend most of your messages out of the Inbox and then create new folders to send and sent items box after having moved the messages you want to save to a local folder that you create.

    Tools | Options | Maintenance | Store folder will reveal the location of your Outlook Express files. Note the location and navigate on it in Explorer Windows or, copy and paste in start | Run.

    In Windows XP, Win2K & Win2K3 the OE user files (DBX and WAB) are by default marked as hidden. To view these files in Windows Explorer, you must enable Show hidden files and folders under start | Control Panel | Folder Options icon | Opinion, or in Windows Explorer. Tools | Folder options | View.

    With OE closed, find the DBX files for the items in the Outbox and sent and delete them.  New ones will be created automatically when you open OE.

    After you're done, followed by compacting your folders manually while working * off * and do it often.

    Click Outlook Express at the top of the the folder tree so no folders are open. Then: File | Work offline (or double-click on work online in the status bar). File | Folder | Compact all folders. Don't touch anything until the compacting is completed.

    General precautions for Outlook Express:

    Do not archive mail in the receipt or sent items box. Create your own user-defined folders and move messages you want to put in them. Empty the deleted items folder daily. Although the dbx files have a theoretical capacity of 2 GB, I recommend all a 300 MB max for less risk of corruption.

    Information on the maximum size of the .dbx files that are used by Outlook Express:
    http://support.Microsoft.com/?kbid=903095

    Disable analysis in your e-mail anti-virus program. It is a redundant layer of protection that devours the CPUs, slows down sending and receiving and causes a multitude of problems such as time-outs, account setting changes and has even been responsible for the loss of messages. Your up-to-date A / V program will continue to protect you sufficiently. For more information, see:
    http://www.oehelp.com/OETips.aspx#3

    Why you don't need your anti-virus to scan your email
    http://thundercloud.NET/infoave/tutorials/email-scanning/index.htm

    Note that for some AV programs, it may be necessary to uninstall the program and reinstall in custom Mode and uncheck analysis when the option is the result of e-mail messages.

    Compact often as specified above.

    And backup often.

    Outlook Express Quick Backup (OEQB Freeware)
    http://www.oehelp.com/OEBackup/default.aspx

  • Someone is sending emails with my windows live address to all my contacts without my permission, spamming other mailboxes with what looks like messages from me.

    Someone is sending emails with my windows live address to all my contacts without my permission, spamming other mailboxes with what looks like messages from me.

    Help with this!

    Apparently, someone broke your Hotmail account. Change your password immediately. For more information, visit these web pages:

    Compromised account - unauthorized account access
    Hotmail hacked? Take these steps
    Hotmail: Tips to help protect your account

    Boulder computer Maven
    Most Microsoft Valuable Professional

  • What are the best days and times to send emails to customers?

    I heard and got great results with so many different days and times of the week to sending emails to prospects and customers.  What you find works best for you and what recommendations you have?

    Only way to find out what is the best time for * your * public. Test test test...

  • What is the parameter to specify on the command line for thunderbird automatically send email.

    I do apply to using macros Calc and precise automatically send emails, I know it's possible, to inform the parameters through a command line, but Thunderbird does not send automatically receives them, only the parameters, fill in the fields, but the send command are required manually.

    Thunderbird does not authorize this transmission stripped.

  • I want to use gmail but address to receive and send emails from thunderbird. What should I do?

    I just changed my internet provider and they suggested that I set up a gmail email address so that I can keep it just in case I have change of supplier in the future. I created a gmail account that I want to see in thunderbird, rather than having to go in my Gmail every time to get my emails. What should I do? I clearly did something wrong I get no emails at all, but they go to gmail. Thank you. Julie

    Here is a link with the right info to help you:

    Through the instructions on the link and if you still have one please issue the following information.

    Please detail:
    In Thunderbird
    Help > troubleshooting information
    Click on 'copy text to the Clipboard.
    Paste the info into this issue
    can edit/delete information about fonts and printers.

    When you open Thunderbird, what do you see in the left pane of the folder?
    You see your email above with a white envelope and a padlock? Are there records below?

    Thunderbird tries to open a session on the server, this error if any, do you get... Word for Word?

  • action page that sends email

    Hello
    I have this page which is a page of the action.

    It is supposed to send email.

    I'm breaking the logic, so I need help?

    What does this do?


    < cfscript >
    {if (IsDefined ("Form.EmailAddress"))}
    variables.email = form.emailaddress;
    variables. MSG = form.message;
    variables. Location = "FORM";
    }
    else {}
    variables.email = url.emailaddress;
    variables. MSG = url.message;
    variables. Location = "URL";
    }
    < / cfscript >
    ---------
    then this
    < to = "" #variables.email # intrusion via cfmail "from ="[email protected]"subject = 'E-mail Helpdesk' >"
    #variables.msg #.
    < / intrusion via cfmail >
    -----------------------------------------

    then this

    < script >
    < cfswitch expression = "#variables.location #" >
    < cfcase value = "FORM" >
    Alert ("your message has been sent");
    < / cfcase >
    < / cfswitch >
    Window.Close ();
    < /script >




    Thank you

    The first part converts the variables form or url for local variables. The 2nd part sends mail. The third part probably does nothing because he has cf tags within script tags.

    This page will crash if it is not accessible via a form or a link.

  • Cannot send emails in Windows XP

    With the help of windows XP cannot send emails that they sit in the out box then this message appears
    M, Port: 25, secure (SSL): no, Socket error: 10051, TPr error number: 0x800CCC0E
    Anny we know what to do

    Check with your email provider that you are using the correct settings under Tools | Accounts | Mail | Properties.  Some providers to change the port number for the SMTP Protocol to another value and if you need to check with your email provider.  Make sure also that you don't have your game antivirus to scan e-mail (see www.oehelp.com/OETips.aspx#3) and if you use OE, you can try to delete the account, closing and reopeing OE and then add it again (sometimes the parameters get confused and that corrects).

    Check also via webmail to ensure that your account has no questions.

    Steve

  • Contact form not sending email

    Hello

    I have a contact form on my site: it's going to be Style - Personal Shopper Sydney

    He has worked previously, but now I only get not all submissions by email. There is no problem when a form is submitted (i.e.. RECEIPT FORM)

    I wrote a PHP check that was clear at all: http://therewillbestyle.com/scripts/form_check.php

    I did and emailtest.php that worked: http://www.therewillbestyle.com/emailtest.php

    I've been through these posts 2 previous and quite accordingly and it still does not work:

    Troubleshooting Muse form used on the servers of third party Widgets

    My contact form sends email

    I contacted the courier service provider, works at their end and they said it must be a mistake in the Muse.

    I am at a total loss as what I can do next?

    Any help would be greatly appreciated

    Here is another link that I found on another thread that may also help.

    Getting started |  reCAPTCHA |  Google developers

  • Send Email to APEX 4.2

    Hi All,
    
         This could be general question would like to know what could be best way to send email to end users for below scenario
    
       - Assuming I have a Query as "select * from emp where empname is null"
      - It means we have empty values for column empname, if there are any empty values in that column I need to send mail to end users that "there are missing data for these columns" Please back fill those data manually.
    - In this way it will help end users to they manual work to check query in back end daily, we will be sending mail to users when we found these problem.
    
    Please help on this request to send mail.
    
    Regards,
    Sruthitamiri 
    

    Sruthi Tamiri wrote:

    1. Hi all
    2. It could be general question would like to know what might be the best way to send them to end-users for scenario below
    3. -Assuming that I have a query such as "select * from emp where empname sucks."
    4. -It means that we have empty for empname column values, if there are empty values in this column, I need to send an e-mail to end users that "missing data for these columns" back fill these data manually.
    5. -In this way it will help end-users to they manual work to check the query in backend per day, we will send mail to users when we learned these problem.
    6. Please help on this application to send an e-mail.
    7. Kind regards
    8. Sruthitamiri

    Why this message is formatted as code when it does not? Is it as an attempt to align the "chips" are manually created then it failed spectacularly. Note that there is a button in the editor of the forum for the formatting of the text and bulleted unordered lists.

    Sending e-mail alerts based on the results of the query is obtained using scheduled tasks or continuous Query Notification, as advised in this previous thread: Re: request/design of the necessary Multiple INTERFACE.

  • MUSE: Adobe hosting, 123-reg URL and e-mail box, Muse/widget form will not send email.  Diagnosis step 1: form_check.php.  But this returns a "Page not found".

    I have a simple 1 page site live a reg-123 registered URL www.menitlimited.com, but using Adobe accommodation according to the directives of the packaging of Muse.  In short, the form doesn't send emails (should be sent to [email protected] - that is, I have entered the settings of the widget). Reading the forums, this test 'www.menitlimited.com/scripts/form_check.php' seems to be the first thing to do, but it returns "Page not found", rather than the ticks/crosses. What I am doing wrong or missing here please?

    Troubleshooting tips, you are referring are specific to when you are hosting on servers not Adobe. It is quite unusual to have a problem with a form when you host on Business Catalyst.

    The first thing to check are the filters of spam in your e-mail client. The most common situation is that the e-mail was sent and received, but classified as spam by your e-mail client.

    If this isn't the situation, I recommend you to contact our support Business Catalyst to Adobe Business Catalyst support>.

Maybe you are looking for

  • my SD card reader allows to use an SDHC card?

    I have a desktop PC HP Pavilion p7-1414 can my use of SD card, SDHC card reader? I have Windows 8 64-bit operating system comes with my computer.

  • Damaged BIOS on Tecra M5

    inadvertently, I updated my BIOS with an old version 1.60, I downloaded the wrong version and now the laptop won't boot at all, it will feed into, white screen and the fan is constantly on, that's all. I rang Toshiba, they said the BIOS updates are n

  • Cannot download iPhotos on Apple Retail Store or the Apple website.

    The reason or to do it is because I just upgraded my OS from 10.7 to Yosemite. The old iPhotos does not work. When I tried to download the new worm from the App Store, it prevents me from doing and motivated "update not available with this Apple ID".

  • Windows Live Mesh for Mac does not work with Mac OS 10.7 Lion

    Maybe someone could help me with this. I migrated to a disk hard again and update of Snow Leopard Lion this week Live Mesh has stopped working so I downloaded the most recent distribution of MS: 15.4.5726.23, 20/07/2011 release date, which says it's

  • Y at - it an upgrade to Outlook Express 6

    I have Windows XP Home edition is installed on this computer.  I would like to configure Outlook Express 6 for my e-mail address.  But I would first find out if there is an update for it. Thank you Ron