Advanced Discoveries on Unix/Linux Computers

Recently, I had a requirement to discover a number of devices that existing on a Linux server, which got me thinking as previously I’ve only ever run a shell command that returns a status to determine whether an object is discovered or not.  In this scenario I needed to run a script to return all the devices that existed on it, and then discover an object for each device returned.  On Windows, this is pretty straightforward as you can just use a scripted discovery to discover multiple items, but on Unix/Linux computers we can’t quite do the same thing.

When thinking about it a bit further though, I realised that I could almost do the same as a Windows discovery.  Because the all workflows for UNIX/Linux computers run on the management server managing the computer, and not on the agent, I can return the data I need using a script or command from the computer, and then pass that through to a Windows Script or PowerShell module where I can use a similar discovery script as I would for a Windows discovery.

So here is a breakdown of the workflow for a custom discovery data source:

  1. System.Discovery.Scheduler – Scheduler data source to control the schedule of the discovery
  2. Microsoft.Unix.WSMan.Invoke.ProbeAction – A probe to run a Shell Command or script on the UNIX/Linux computer that returns the data required for the discovery.
  3. System.ExpressionFilter (Optional) – An expression filter to check that no errors were returned from the previous probe.
  4. Microsoft.Windows.ScriptDiscoveryProbe – A probe to run a VBS script where instances can be created based on the data inputted from the previous probe using property bags.

Note:  If the command or script that needs running requires a privileged account, you could swap the Microsoft.Unix.WSMan.Invoke.ProbeAction probe with the Microsoft.Unix.WSMan.Invoke.Privileged.ProbeAction.  And, if you would rather use PowerShell than VBS, you could always use the Microsoft.Windows.PowerShellDiscoveryProbe instead of the Microsoft.Windows.ScriptDiscovery probe.

Once the data source is created, it is just a matter of creating a new discovery that utilises the data source and specifying the relevant details, and presto, you will start discovering!

To get a good idea on building a discovery data source for Unix/Linux computers using the 2007 R2 Authoring Console, I highly recommend reading a series on extending Unix/Linux monitoring by Kris Bash.  Part 1 of the series is viewable here,

So, with the information from the blog above, and what we know about discoveries with VBS or PowerShell, we can can hook everything together to discover multiple items on a Unix/Linux Computer.

I have provided an example management pack for you, so you can see how everything works.  I have used a basic script to simply return the devices on a Linux server using ‘iostat’, and then create an object representing each device.  I know the default monitoring MP’s already discover this, I am just using it as an example.  The management pack also contains the script that gets run on the UNIX/Linux computer, it is not executing a script that is already on the computer, so this MP will work as an example if you would like to know how to embed the script and use the ExecuteScript method of the Microsoft.Unix.WSMan.Invoke.ProbeAction probe.

Hope this proves useful, and enjoy!



One thought on “Advanced Discoveries on Unix/Linux Computers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.