Magical Perfmon Alert Catch dump

Source: Internet
Author: User

Grasping dump files is often the perfect way to solve many incurable diseases. But most of the time, we can't catch it. For example

    • The number of threads in a few seconds soared 200, then quickly fell back
    • The program ran for two days, and the memory went up to a certain number.

The reason is just short time, there is no way human flesh to have been watching, and, even if staring, you hit enter to let ADPlus transfer cdb, at least a few seconds, then dump is easy to grasp the inaccurate. What to do? In fact, we can catch this dump with great perfmon.

Create alert

First open Perfmon, the way is Win+r, enter the perfmon carriage return. Then right click on User Defined

, create a new dataset, such as named Createdump, and select Create manually

Select the following alert instead of counter log, as

To the critical place! Select the perf counter you want to monitor. For example, I want to monitor some. NET process managed heap, if it is greater than 2GB, I create a dump out.

Then, select #bytes in the all heaps, such as:

After OK, go back to the previous interface, sampling time interval, set to 15 seconds.

Always press OK to know the end of the wizard.

Defining tasks

Back to the Perfmon interface, click on the tree on the left to create the Createdump, and in the right-hand listview, right-select Properties

Select the alert task, enter the name of the task and arguments. Where the former can be entered manually. The first hint, this name is your task name in the planning task! Not casually written!!! the second row of parameters, click on the right of the greater than, select the parameters you want to process

Then, modify the parameters to:

Note that the parameters are modified in the format of double quotes and then separated by a space.

Create a Windows Scheduled task

Press Win+r, enter TASKSCHD.MSC/S, start Windows scheduled task

Go to the scheduled task, click on the library node on the left, in the right margin, right-click, create new task, take care not to select Basic task

In the New Task window, first enter the name of the task. Please scroll up and look at the bold part I wrote earlier. This name is the name you entered in the alert task above, and the two must be consistent! Otherwise, it will not be called.

Also note that in general we want to choose: Run whether use are logged on or not, instead of the default logged on only

Then switch to actoin on this tab

Click New to create a new action. Note below the optional of the arguments, here is the second pit! Be sure to write $ (Arg0), otherwise your program will not accept parameters!

Take a look at this paragraph:

If the task to run was a script, you must set the task arguments with the task Scheduler to $ (Arg0); Otherwise, the arguments that's specify with this property is not being passed to the script.

The source of the source, please poke here

Write your own createdumptask program.

A simple example is written here:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.IO;

Namespace Createdumptask
{
    class program
    {
         static void Main (string[] args)
        {
 & nbsp;                       using (StreamWriter SW = new StreamWriter ("C:\\work\\1.txt", True))
             {
                 SW. WriteLine ("triggered at {0}", DateTime.Now);
                SW. WriteLine ("Length of Arguments:{0}", args. Length);

StringBuilder sb = new StringBuilder ();
foreach (String arg in args)
{
Sb. Append (ARG). Append (",");
}

Sw. WriteLine ("args:{0}", sb. ToString ());
}
}
}
}

In fact, you have to add your own logic, for example, in three minutes, triggered three times, then you can grab a dump out. The easiest way to catch the dump is to copy the WinDbg from a different server to the directory you specified, such as the c:\windbg directory.

The code then uses Process.Start to invoke Adplus.exe or adplus_old.vbs to catch the dump file.

Of course, a little more complicated, you can also use Dbgeng.dll, and then PInvoke to do. But there's no need to ...

Magical Perfmon Alert Catch dump

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.