Linux Fragments

April 20, 2020

By Silect

Silect’s Support team often gets requests for samples demonstrating how to get started authoring management packs to monitor Linux systems.  Ever since the concept of fragments was introduced to the authoring community a number years ago, we’ve felt rather strongly that the best way to do so is through reusable fragments.  MP Author Pro and MP Studio both have built-in native support for fragments that makes working with such files a breeze – visit https://silect.com/fragments to learn more.

Today Silect would like to share with you a number of fragments we’ve put together to help you get started monitoring Linux systems.  Below is a short description of the fragments:

Class.And.Discovery.Unix.InstalledPackageDPKG.mpx.  This fragment creates a discovery for packages installed on Debian-based Linux distributions.  It can be used as a starting point to monitor any system reporting that a given package has been installed.  This fragment demonstrates how to create a discovery by running a shell command, and parse its output using a regular expression.

Class.And.Discovery.Unix.InstalledPackageRPM.mpx.  This fragment is the RPM (RedHat) packaged-based version of the fragment described above; as such, they’re nearly identical.  The most notable differences are in the shell command and regular expressions used to perform the discovery.

Class.And.Discovery.Unix.ProcessExists.mpx.  This fragment demonstrates how to use a shell command in a discovery to determine whether a given process, identified by its name, is running.

Monitor.Unix.Daemon.mpx.  This fragment demonstrates how to use a shell command inside a two-state monitor to determine whether a daemon, identified by its name, is running.

Monitor.Unix.Script.mpx.  This fragment demonstrates how to use a script, with arguments customizable as fragment parameters, in a monitor.  Note that the script must be base64-encoded so it can be embedded in final management pack.  When importing the script from a file on disk, MP Studio/MP Author Pro reads it and performs this conversion automatically.

Rule.Unix.Event.Script.mpx.  This fragment demonstrates how to define a rule that compares the output of a script that accepts parameters with a given value.  It also demonstrates how to assign elements such as StdOut, StdErr, a return code and error value as alert parameters.  As is the case with the fragment described above, the script body needs to be base64-encoded.

Rule.Unix.Event.ShellCommand.mpx.  This fragment is mostly identical to the one described above, and only differs in the fact that a single shell command is used rather than a script.

Fragments on their own won’t provide a complete solution to your monitoring needs, but as these demonstrate some fundamental building blocks, such as how to run individual shell commands as well as script that can take in customizable parameters, and read back StdOut and StdErr output, we hope they provide you with some inspiration and save you time in putting together your own solutions.

To request your free copy of the Linux fragments please visit https://silect.com/download-fragments

Please note that these free fragments are provided on an “as-is” basis, with no guarantee or support from Silect.