AnsweredAssumed Answered

EPAgent Printmetric

Question asked by bhanley on Feb 11, 2014
Latest reply on Jan 28, 2016 by Hiko_Davis

Hi All,

 

I am writing an epagent plugin that checks the state of a Windows service to report to an Enterprise Manager. I am by no means a developer, but thanks to some Google-ing, I have a script that does most of what I need. The script as it is so far checks the server for all services, searches through the list for anything matching "Introscope" and prints out that services status

Here is the script:

--------------------------

use warnings;
use Win32::Service qw( GetServices GetStatus );
use Data::Dumper;
 
my $serverName = shift or die "***Err: $0 expects a server name.";
my ($key, %services, %status);
 
GetServices($serverName,\%services);
print '\\%services: ',Dumper(\%services);
 
foreach $key (keys %services){
    if ($key=~ /^Introscope/i) {
        GetStatus($serverName, $services{$key}, \%status);
        print "$key: \\%status: ", Dumper(\%status);
    } 
}
--------------------------
 
And the output (I have limited the list of services for this posting):
 
--------------------------
\%services: $VAR1 = {
          'Diagnostic Service Host' => 'WdiServiceHost',
          'Diagnostic Policy Service' => 'DPS',
          'Windows Audio' => 'AudioSrv',
          'Portable Device Enumerator Service' => 'WPDBusEnum',
          'Microsoft .NET Framework NGEN v4.0.30319_X86' => 'clr_optimization_v4.0.30319_32',
          'Microsoft .NET Framework NGEN v2.0.50727_X64' => 'clr_optimization_v2.0.50727_64',
          'Net.Tcp Port Sharing Service' => 'NetTcpPortSharing',
          'Secondary Logon' => 'seclogon',
          'Internet Connection Sharing (ICS)' => 'SharedAccess',
          'Routing and Remote Access' => 'RemoteAccess',
          'Windows Update' => 'wuauserv',
          'Interactive Services Detection' => 'UI0Detect',
          'System Center Audit Forwarding' => 'AdtAgent',
          'Remote Desktop Services' => 'TermService',
          'Software Protection' => 'sppsvc',
          'Net.Tcp Listener Adapter' => 'NetTcpActivator',
          'Volume Shadow Copy' => 'VSS',
          'Introscope EM AF' => 'IScopeAF',
          'Power' => 'Power',
          'Windows Installer' => 'msiserver',          
        };
Introscope EM AF: \%status: $VAR1 = {
          'ServiceSpecificExitCode' => 0,
          'CurrentState' => 4,
          'ServiceType' => 16,
          'CheckPoint' => 0,
          'ControlsAccepted' => 69,
          'WaitHint' => 0,
          'Win32ExitCode' => 0
        };
--------------------------
 
Using this output, I would like the epagent to send each of the Introscope specific data to the EM, similar to what is seen in the scripts output. For example:
 
Introscope EM AF
          'ServiceSpecificExitCode' => 0,
          'CurrentState' => 4,
          'ServiceType' => 16,
          'CheckPoint' => 0,
          'ControlsAccepted' => 69,
          'WaitHint' => 0,
          'Win32ExitCode' => 0
 
Any assistance in this would be greatly appreciated.
 
Cheers!

Outcomes