This example assumes the use of the UNIX/Linux Authoring Library example MP. For more information on creating and building the MP authoring project, see Getting Started. This example demonstrates monitoring with a Shell Command that is run on the UNIX/Linux agent - in this case, the command is: echo 'Warning'. The output of the shell command (StdOut), is evaluated with multiple Regular Expressions to determine if the monitor is in a Healthy, Warning or Error State. For additional information about the UnitMonitorType used in this example, as well as other shell command monitor types, review the documentation of the following Monitor Types in the Unix.Authoring.Library Module Reference:
For more information about quotes and special characters in shell commands, see Commands and Script: Quotes and Special Characters.
Note: contents located between pairs of ## characters should be customized for your environment. This includes ID and property values. Be sure to remove the ## characters before building the MP.
<
ManagementPackFragment
SchemaVersion
=
"2.0"
xmlns:xsd
"http://www.w3.org/2001/XMLSchema"
>
Monitoring
Monitors
UnitMonitor
ID
"##MyMP.ShellCommand.Expression.ThreeState.Monitor##"
Accessibility
"Internal"
Enabled
"true"
Target
"##MyMP.MyCustomRole##"
ParentMonitorID
"Health!System.Health.AvailabilityState"
Remotable
Priority
"Normal"
TypeID
"UnixAuth!Unix.Authoring.ShellCommand.MatchesRegExp.ThreeState.MonitorType"
ConfirmDelivery
"false"
Category
>AvailabilityHealth</
AlertSettings
AlertMessage
"##MyMP.ShellCommand.Expression.ThreeState.Monitor.AlertMessage##"
AlertOnState
>##Warning##</
AutoResolve
>true</
AlertPriority
>Normal</
AlertSeverity
>##MatchMonitorHealth##</
AlertParameters
AlertParameter1
##$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$##
</
AlertParameter2
>##$Data/Context///*[local-name()="StdOut"]$##</
OperationalStates
OperationalState
"StatusOK"
MonitorTypeStateID
HealthState
"Success"
/>
"StatusWarning"
"Warning"
"StatusError"
"Error"
Configuration
Interval
>300</
TargetSystem
$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$
ShellCommand
>##echo 'Warning'##</
Timeout
>60</
UserName
>$RunAs[Name="##Unix!Microsoft.Unix.ActionAccount##"]/UserName$</
Password
>$RunAs[Name="##Unix!Microsoft.Unix.ActionAccount##"]/Password$</
ErrorRegExp
>##^Error##</
WarningRegExp
>##^Warning##</
Presentation
StringResources
StringResource
LanguagePacks
LanguagePack
"ENU"
IsDefault
DisplayStrings
DisplayString
ElementID
"MyMP.ShellCommand.Expression.ThreeState.Monitor"
Name
>##My shell command monitor##</
Description
>##Monitors the output of a shell command and generates an alert if the warning or error expressions are matched. ##</
>##Shell command output is not OK##</
>##The output of the shell command on the host: {0} is not OK. The output is: {1}##</
SubElementID
>StatusOK</
>StatusWarning</
>StatusError</