How to obtain the state of ADAP process?
Download
|
|
Operating System periodically runs AutoDiscovery/AutoPurge (ADAP) process.
The process transfers performance libraries into WMI classes.
When a new performance library is installed into the system, ADAP process creates appropriate WMI classes.
Once ADAP processed is finished, the performance data becomes available via WMI. This example utilizes TWmiPerformanceMonitor component. The source code below creates and destroys the components on the fly, so this function may be easily adopted for console- or UI-type applications. |
// This procedure reports the state of ADAP process
// on the target computer.
// When used for local host, all the parameters must be empty.
// For remote compupter, the parameters must be:
// TargetHost: name or IP address of the host, like '10.8.36.54'
// UserName: name of the user, may include domain, like 'MOON\Administrator';
// Password: the user's password.
procedure PrintAutoDiscoveryState(TargetHost, UserName, Password: string);
var
vMonitor: TWmiPerformanceMonitor;
vStatus: string;
begin
vMonitor := TWmiPerformanceMonitor.Create(nil);
try
vMonitor.MachineName := TargetHost;
vMonitor.Credentials.UserName := UserName;
vMonitor.Credentials.Password := Password;
// try to connect. It may fail if the destination computer does not have
// WMI (like windows 95, 98, NT without WMI core installed), or
// if the provided credentials are not valid
try
vMonitor.Active := true;
except
Exit;
end;
writeln('Last start: ' + DateTimeToStr(vMonitor.AutoDiscovery.LastStart));
writeln('Last stop: ' + DateTimeToStr(vMonitor.AutoDiscovery.LastStop));
case vMonitor.AutoDiscovery.Status of
ADAP_NEVER_STARTED: vStatus := 'Never started';
ADAP_RUNNING: vStatus := 'Running';
ADAP_PROCESSING_PERF_LIBRARY : vStatus := 'Processing performance library';
ADAP_COMITTING : vStatus := 'Commiting';
ADAP_FINISHED : vStatus := 'Finished';
end;
writeln('Status: ', vStatus);
finally
vMonitor.Free;
end;
end;
|