SCOM 2016 – What’s New UNIX/Linux Series: Agent Task Running Script e.g. Perl

Datetime:2016-08-22 22:45:18          Topic: Perl  Unix           Share

I assume you are familiar with creating SCOM tasks and you know there are tasks that are executed on the SCOM console side (console task) and such that are executed on the agent (agent task). In the past you had only few options, like running commands on Windows and UNIX/Linux or scripts only on Windows agents. The task options looked like this in SCOM 2012 R2…

In SCOM2016 you are now able to run scripts on UNIX/Linux agent using all kind of script languages (any), that are installed on the target machine.

To prove that it works I created a simple task called Perl Ping

…and added a Perl script that pings few times a host called DC01.masta.ad

The full script looks like this…

#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Net::Ping;
for (my $i=0;$i<=10;$i++)
{
my $p=Net::Ping->new();
my ($ret,$duration,$ip)=$p->ping(‘DC01.masta.ad’);
say (‘Duration: ‘ . $duration . ‘ IP: ‘ . $ip);
}

After I ran the task the output shows a successful output and the ping results…

As you can see it is a very useful improvement Microsoft did and I am sure this will help migrating other monitoring tools to SCOM.  Awesome!





About List