Send email alert from Performance Monitor using PowerShell script (检测windows服务器的cpu 硬盘 服务等性能,发email的方法) -摘自网络
|
I have created an alert in Performance Monitor (Windows Server 2008 R2) that should be triggered whenever \Processor(_Total)\% Processor Time is Above 10 (a small value just to guarantee that the condition for sending the alert is always met). You can see the Alert Task properties in the image.
In addition, I have also created a new task in the Task Scheduler that will run whether the user is logged on or not, and it will run with highest privileges. The trigger for this task has the following properties:
The Actions (and this is the part I don't know if it's correct) has the following settings:
The PowerShell code is the following ($name, $date, $counter, $threshold, $value are supposed to come from the Performance Monitor data collector set alert task properties, as in the image above):
Once the task is started, I have the following in the History: Task Started, Action Started, and Created ask Process. The email is never sent though. I tried sending an email using the Action: Send an email, and it worked fine. Does anyone know what could be wrong? |
|||||||||||||||
|
|
|
There are basically two things to address that should make this work for you.
We'll start with the parameters. On the Alert Task tab of your alert (pictured above), edit the Task Arguments field and replace:
with:
Your parameters are basically being parsed as a space-separated string value, so we add double-quotes around each individual parameter token to handle values that include spaces, and we add a space between each individual parameter token so that we'll be able to tell one parameter from the next. Then, for the action of your scheduled task (named "Processor Monitoring") you have to tell it to expect parameters from the alert and to pass those parameters to the PowerShell script.
Your Action is correct, i.e. "Start a program". For the Program/script field, enter "powershell.exe" (or browse for the full path). And for the Add Arguments field, enter this:
Where This bit was kind of finicky, so there may be other ways to set this up, but explicitly using the So that should make the Alert parameters available to your PowerShell script. Now all you have to do is actually call the function you've already defined. Add the following to the end of your script (after the function definition):
Since we know the alert will always send the same values in the same order, i.e. name, date, counter, threshold, and value, we can just pull them from the command line arguments based on position and pass them to the SendMail() function. Note that there are more robust ways to process command line arguments, but this should be sufficient for your purposes. |
Send email alert from Performance Monitor using PowerShell script (检测windows服务器的cpu 硬盘 服务等性能,发email的方法) -摘自网络的更多相关文章
- 如何利用PowerShell完成的Windows服务器系统安全加固实践和基线检测
0x00 前言简述 最近单位在做等保测评,由本人从事安全运维方面的工作(PS:曾经做过等保等方面的安全服务),所以自然而然的与信安的测评人员一起对接相关业务系统的检查,在做主机系统测评检查时发现了系统 ...
- Azure Powershell script检测登陆并部署ARM Template
本文简单提供了一个Azure powershell脚本,能实现如下功能 Azure (China)账户是否已经登陆了,如果没登陆,会提示你登陆. 要创建的资源组是否存在,存在的话不再创建,直接部署te ...
- 使用performance monitor 查看 每一个cpu core的cpu time
使用performance monitor 查看 每一个cpu core的cpu time: 打开performance monitor,添加 counter 如下 运行一段cpu bound 的代码 ...
- nginx performance monitor
nginx performance monitor Nginx中的stub_status模块主要用于查看Nginx的一些状态信息 示例 Active connections: 2 server acc ...
- Orion Network Performance Monitor 软件在网络管理中的应用
Orion Network Performance Monitor 软件在网络管理中的应用 Orion Network Performance Monitor是完全的带宽性能和故障管理软件 ...
- Performance Monitor采集性能数据
Performance Monitor采集性能数据 Windows本身为我们提供了很多好用的性能分析工具,大家日常都使用过资源管理器,在里面能即时直观的看到CPU占用率.物理内存使用量等信息.此外新系 ...
- 实战Performance Monitor监测EnyimMemcached
首先要将EnyimMemcached安装至Windows Performance Counters中. 将Enyim.Caching.dll复制到一个文件夹中 在命令行中进入.NET Framewor ...
- OA|DOAJ|Highwire press|Springeropen|Plos journal|电子印本|中国科技论文在线|arxiv|chinaxiv|MIT机构知识库|中科院机构知识库|Email alert|Citeseer|RSS|F1000 prime
信息检索 OA:open access开放获取 金色OA:出版社主导, 开放出版,全部都可以下载. 开放论文:只有部分可以下载. 绿色OA:作者主导,发表后放在机构知识库中,排版不同,但是内容一致.E ...
- 【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
前提条件 当我们观察到SF中某一个节点出现CPU不正常的情况,但是由于不能肉眼长期观察,所以可以通过开启Performance Monitor的方式来获取每一个进程的%Processer Time的方 ...
随机推荐
- PHP 7 值得期待的新特性(下)
这是我们期待已久的 PHP 7 系列文章的第二篇.点此阅读 第一篇本文系 OneAPM 工程师编译整理. 也许你已经知道,重头戏 PHP 7 的发布将在今年到来!现在,让我们来了解一下,新版本有哪些新 ...
- Nagios : Verifying Your Configuration
Every time you modify your configuration files, you should run a sanity check on them. It is importa ...
- Linux---弹球游戏
ReadMe: 弹球游戏按键说明(注意大小写): Q End Up Game 游戏停止 P Play Again 再玩一次 f 速度x轴方向减速 s 速度x轴方向加速 F 速度y轴方向减速 S 速度 ...
- ECNU1104-BFS
简单的BFS题意:多起点多终点 /* 简单的BFS 题意:多起点多终点 */ #include<stdio.h> #include<string.h> #include< ...
- 【转】PostgreSQL IP地址访问配置
原文:http://blog.csdn.net/shuaiwang/article/details/1793294 1.PostgreSQL的安装目录,进入data文件夹,打开postgresql.c ...
- QT5.7交叉编译安装到arm(好多系列文章)
以下采用的系统为ubuntu16.04,开发板为迅为iTOP4412,4.3寸屏. 下载qt5.7源码qt-everywhere-opensource-src-5.7.0.tar.xz http:// ...
- 基于redis实现的分布式锁
基于redis实现的分布式锁 我们知道,在多线程环境中,锁是实现共享资源互斥访问的重要机制,以保证任何时刻只有一个线程在访问共享资源.锁的基本原理是:用一个状态值表示锁,对锁的占用和释放通过状态值来标 ...
- JavaScript DOM高级程序设计 3.6 实例 将HTML代码转换成DOM代码(附源码)--我要坚持到底!
作为一名Web开发者,最讨厌的事情就是重复性任务,摆脱乏味的日常重复性事物的一种方法,是借助可重用的对象或者说与你现在建立的ADS库类似的库,另外一种让事情变得有意思,且能够加速开发进程的方式是编写能 ...
- struts2的action中获得request response session 对象
在struts2中有两种方式可以得到这些对象 1.非IoC方式 要获得上述对象,关键Struts 2中com.opensymphony.xwork2.ActionContext类.我们可以通过它的静态 ...
- Struts1和Struts2都有什么区别?
总的来说,Struts1 的 Action 是单例模式,因此开发者必须保证它是线程安全的或是同步的,因为Struts 1中每个Action仅有一个实例来处理所有的请求. 但是在用Struts ...

