<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Operating-Quadrant &#187; Management Packs</title>
	<atom:link href="http://operatingquadrant.com/category/system-center-operations-manager/management-packs/feed/" rel="self" type="application/rss+xml" />
	<link>http://operatingquadrant.com</link>
	<description>Living in the I.T. Operating Quadrant. Useful articles on real world solutions involving Monitoring (System Center Operations Manager), Virtualization, Reporting, Scripting (PowerShell), and much more.</description>
	<lastBuildDate>Thu, 02 Feb 2012 16:43:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='operatingquadrant.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Operating-Quadrant &#187; Management Packs</title>
		<link>http://operatingquadrant.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://operatingquadrant.com/osd.xml" title="Operating-Quadrant" />
	<atom:link rel='hub' href='http://operatingquadrant.com/?pushpress=hub'/>
		<item>
		<title>OpsMgr 2012 UNIX/Linux Authoring Templates:  More Information on the Shell Command Templates</title>
		<link>http://operatingquadrant.com/2012/02/01/opsmgr-2012-unixlinux-authoring-templates-more-information-on-the-shell-command-templates/</link>
		<comments>http://operatingquadrant.com/2012/02/01/opsmgr-2012-unixlinux-authoring-templates-more-information-on-the-shell-command-templates/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 20:22:08 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX/LInux]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=746</guid>
		<description><![CDATA[In my last post, I described the new UNIX/Linux Shell Command templates in OpsMgr 2012, and provided a walkthrough on creating a Management Pack for monitoring BIND DNS servers on Linux. In this post, I will provide more detail on the nuts and bolts of the Shell Command templates, as well as a list of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=746&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my last post, I described the new UNIX/Linux Shell Command templates in OpsMgr 2012, and provided a walkthrough on creating a Management Pack for monitoring BIND DNS servers on Linux. In this post, I will provide more detail on the nuts and bolts of the Shell Command templates, as well as a list of tips &amp; tricks to consider when using the templates.</p>
<h3><strong>Using the Shell Command Templates</strong></h3>
<p><span id="more-746"></span></p>
<ul>
<li><strong>Targeting:</strong>  The only acceptable targets for the UNIX/Linux Shell Command templates are UNIX/Linux Computer, or classes based on it.  So <em>UNIX/Linux Computer</em>, <em>Linux Computer,</em> <em>Red Hat Enterprise Linux Computer</em>, and <em>Red Hat Enterprise Linux 5 Computer</em> (for example) are all valid targets. <em>Operating System</em>, <em>Logical Disk</em>, <em>Local Application,</em> and <em>Computer Role</em> types are not valid targets.  Best practice for rules and monitors is to target the computer object but disable the rule/monitor by default, and use an override to enable it for a group. The Shell Command templates do not support object discovery. If you want to discover and target custom class types (like a UNIX/Linux Computer Role or Local Application), traditional MP Authoring (XML) can be used.<strong></strong></li>
<li><strong>Shell Command Input</strong>:  As the templates use the ExecuteShellCommand method of the agent’s script provider with a WSMan Invoke module, the command is sent to the agent on each execution. This requires that the shell command is a single line. Simple shell scripts can be condensed into a “one-liner” by replacing line breaks with semi-colons. If you want to use a complex or long script, the best approach is to distribute it as a shell script to a common path on monitored agents, then use the shell command templates to invoke the script by providing the path, such as:  <em>/opt/scripts/myscript.sh</em><strong></strong></li>
<li><strong>Synchronous Execution &amp; Command Performance:  </strong>The agent’s script provider executes scripts synchronously. For optimal server and agent performance and monitor reliability, it is important to make sure that shell commands execute quickly. If you want to use a long-running command or script in a monitor or rule, it is advisable to configure the script to execute periodically on the agent (e.g. with cron) outputting to a file, and then use the shell command monitor or rule to parse the output file. Unless all parameters for the rule or monitor (e.g. scheduler, shell command, timeout, etc) are identical, rules and monitors created by the Shell Command templates will not cookdown.</li>
<li><strong>Handling Complex Output: </strong> The agent’s script provider returns StdOut, StdErr, and ReturnCode for the shell command execution. Using the templates, it is not possible to post-process this output to split the output into multiple data items, so it is best to consider StdOut from the shell command as representative of one value.  You can always call the same shell command and use the pipeline to parse with <em>grep</em>, <em>awk</em>, <em>sed</em>, etc to filter the output to a single output value. If your shell command returns structured data representing multiple data points, you still have the option of authoring outside of the Operations Console and using a PowerShell script to parse the output.<strong></strong></li>
<li><strong>Mind the Quotes and Special Characters: </strong> The agent’s script provider executes the shell command using the default shell (for the user context of the specified Run as Account), and wraps the actual command in quotes.  So the command executed on the agent host will be something like: <em>sh –c “my shell command”</em> or <em>bash –c</em> “my shell command.” This means that double-quotes inside the shell command need special handling. If you can’t use single-quotes instead of double-quotes, escape the double-quotes with a backslash. As Management Packs are XML-based, some characters like &lt; and /&gt; can be problematic. It is not possible to embed CDATA blocks in the template wizards, so if you can’t avoid use of &lt; and /&gt; in the command and they prove to be problematic, it is advisable to distribute the script to a common file system location on the monitored agents and use the Shell Command templates to invoke the script on the file system.<strong></strong></li>
<li><strong>sudo Eevation</strong>:  If the Run As account specified via the selected Run As profile in the Shell Command templates is configured for sudo elevation, sudoers will need to be configured to authorize the user to execute the command.  For example, adding the following line through <em>visudo</em> will allow the user <em>monuser</em> to execute the command <em>service named restart</em> as input in the Shell Command task template (assuming the default shell of /bin/sh):<br />
<em>monuser ALL=(root) NOPASSWD: /bin/sh -c service named restart</em><strong></strong></li>
<li><strong>Expression Filters<br />
</strong>Valid values for Parameter Names in the template Expression Filters are:<strong></strong></p>
<ul>
<li><em>//*[local-name()=”StdErr”]</em> <em> </em>for StdErr<strong></strong></li>
<li><em>//*[local-name()=”StdOut”]</em> for StdOut<strong></strong></li>
<li><em>//*[local-name()=”ReturnCode”]</em>for ReturnCodeThe Expression Filters in the templates are pre-configured for common scenarios. However, some commands used in monitoring will return values to evaluate on StdOut while other cases will mandate evaluation of StdErr.  For example, if you wanted to run a command to check a connection to a MySQL server, any errors would be output to StdErr. Thusly, the monitor’s expression filter would need to look for the presence of the string ERROR in the StdErr output.Additionally, the default Expression Filters evaluate that ReturnCode = 0 for rules and monitors. This default behavior drops the workflow if the shell command itself fails.  However, if you want to generate an alert if a command fails, the ReturnCode may be 1 in the error state. In this case, the Expression Filter could be configured to go unhealthy when ReturnCode = 1, or StdErr could be evaluated for a string, and the ReturnCode evaluation removed.As in all OpsMgr templates, the Expression Filter dialogs assume values are strings, which can be problematic when evaluating numeric data.  Options for addressing this issue are</li>
<li>Export the MP after creating the rule or monitor, and edit the Type attribute in the Expression XM</li>
<li>Use Regular Expressions in the Expression Filter instead of greater than/less than evaluations</li>
<li>Perform numeric evaluation operations on the agent in the Shell Command and output a simple health state (OK or ERROR) from the shell command itself.And lastly, be mindful of the logical outcome of Expression Filters. For monitors, any potential value from the shell script should positively evaluate to one of the health states (Error or Healthy for two state monitors, or Error, Warning, or Healthy for three state monitors). Particularly, be mindful of AND and OR groupings on Error and Healthy states.  For example, a monitor that requires condition 1 AND condition 2 to be true to be in an Error state should require that only condition 1 OR condition 2 <em>not </em>be true to be Healthy.</li>
</ul>
</li>
</ul>
<h3>Tips, Tricks, and Best Practices</h3>
<ul>
<li><em>When creating shell command rules and monitors, test out the commands in a task first! </em> Shell Command tasks are very simple to create and provide immediate feedback.  Syntactical or authorization issues will be most quickly identified through this method.<strong><em></em></strong></li>
<li>Target “Computer” classes, but disable the rules and monitors by default.  Override the rule and monitor for a group to enable it.</li>
<li>Only use short-running shell commands in rules and monitors<strong></strong>
<ul>
<li>Long running commands or scripts can be scheduled with cron and output to file, using the Shell Command templates to parse the output file<strong></strong></li>
</ul>
</li>
<li>Avoid double quotes as well as &lt; and /&gt; characters if possible. <strong></strong>
<ul>
<li>Complex scripts can be deployed to the file system of the monitored agents and invoked by the Shell Command templates<strong></strong></li>
</ul>
</li>
<li>For optimal performance, use the largest schedule interval that makes sense (15 minutes is preferred for most cases)<strong></strong></li>
<li>Optimize the shell commands (using pipeline formatting with grep, awk, sed, etc)  to return a single, easy to parse value
<ul>
<li>For monitors, returning values like: OK, WARNING, ERROR are best<strong></strong></li>
<li>For performance rules, the value evaluated must be a single numeric value<strong></strong></li>
</ul>
</li>
<li>To troubleshoot sudo issues, tail /var/log/messages and look for the exact command that failed – to cross reference with sudoers configuration.</li>
<li>Be aware what the shell command returns for StdOut, StdErr, and ReturnCode in healthy and unhealthy scenarios. This is critical information when configuring the Expression Filters.</li>
<li>Have fun!<strong></strong></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/746/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/746/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/746/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=746&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2012/02/01/opsmgr-2012-unixlinux-authoring-templates-more-information-on-the-shell-command-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>
	</item>
		<item>
		<title>OpsMgr 2012 UNIX/Linux Authoring Templates:  Shell Command</title>
		<link>http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/</link>
		<comments>http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 15:11:38 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX/LInux]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=677</guid>
		<description><![CDATA[Many of the OpsMgr authoring examples for UNIX/Linux monitoring that I have described on this blog are based on the use of the WSMan Invoke modules to execute shell commands. This is a really powerful mechanism to extend the capabilities of Operations Manager monitoring, and the 2012 version of Operations Manager includes a new set of templates [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=677&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many of the OpsMgr authoring examples for UNIX/Linux monitoring that I have described on this blog are based on the use of the WSMan Invoke modules to execute shell commands. This is a really powerful mechanism to extend the capabilities of Operations Manager monitoring, and the 2012 version of Operations Manager includes a new set of templates allowing the creation of rules, monitors, and tasks using UNIX/Linux shell commands <em>directly from the Authoring pane of the console</em>.</p>
<p>The new templates are:</p>
<p><strong>Monitors</strong></p>
<ul>
<li>UNIX/Linux Shell Command Three State Monitor</li>
<li>UNIX/Linux Shell Command Two State Monitor</li>
</ul>
<p><strong>Rules</strong></p>
<ul>
<li>UNIX/Linux Shell Command (Alert)</li>
<li>UNIX/Linux Shell Command (Performance)</li>
</ul>
<p><strong>Tasks</strong></p>
<ul>
<li>Run a UNIX/Linux Shell Command</li>
</ul>
<p><em>Note: For the OpsMgr 2012 Release Candidate, the Shell Command Template MP needs to be <a href="http://www.microsoft.com/download/en/details.aspx?id=27974">downloaded</a> and imported.  In the final release, it will be imported by default.</em></p>
<p>Underneath the covers, all of these templates use the ExecuteShellCommand method of the agent’s script provider with the WSMan Invoke module. This method executes the command and outputs StdOut, StdErr, and ReturnCode. The command can be a path to a simple command, a command or script existing on the managed computer, or a “one-liner” script (a shell script condensed to one line with pipes and semi-colons).  The templates also allow you to select whether to run with the nonprivileged action account, or the privileged account (which also supports sudo elevation).</p>
<p>If you’ve done this kind of UNIX/Linux authoring in 2007 R2, you will quickly see how much easier and faster this can be done in 2012.</p>
<p>To show the use of these templates, I have put together an MP authoring walkthrough for monitoring BIND DNS servers on Linux. This entire MP will be created in the Operations Console, with no XML editing!</p>
<h2><strong>Walkthrough: Monitoring BIND on Linux</strong></h2>
<p><span id="more-677"></span></p>
<p>Before starting on the MP implementation, let’s have a look at what we might want to monitor to check health of a BIND DNS server.  Some basic metrics would be:</p>
<ul>
<li><strong>Daemon status:</strong>   if the <em>named</em> daemon is not running, it’s a pretty good indication that BIND is not healthy!</li>
<li><strong>DNS resolution success</strong>:  a good way to validate that BIND is functioning properly is to check that the server can resolve a hostname.  This could be the FQDN of a local host or an Internet URL (if we wanted to confirm that Internet DNS resolution was functioning properly).  This can be done easily with nslookup on the BIND server itself:
<ul>
<li><em>nslookup lx12.contoso.com 127.0.0.1</em></li>
<li><em>nslookup www.microsoft.com 127.0.0.1</em></li>
</ul>
</li>
<li><strong>Performance metrics: </strong>  we can use the shell command templates to collect or monitor numeric performance data as well.  For a BIND server, one performance metric we could collect is the time to resolve a name (in seconds):<br />
<em>/usr/bin/time -f %e nslookup lx12.contoso.com 127.0.0.1 &gt; /dev/null<br />
</em></li>
</ul>
<h3><strong>Setting up the Management Pack:</strong></h3>
<ul>
<li>The first step is to create a new Management Pack.  In the <strong>Administration</strong> pane of the Operations Console, right-click on left-hand menu and choose <strong>Create Management Pack</strong>. Input a name and description and complete the wizard:<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/createthemp/" rel="attachment wp-att-678"><img class="alignnone size-medium wp-image-678" title="Create the MP" src="http://operatingquadrant.files.wordpress.com/2012/01/createthemp.png?w=400&#038;h=333" alt="" width="400" height="333" /></a></li>
<li>We will use a group to control targeting of the rules and monitors in the MP, so the next step is to create a group. In the <strong>Authoring</strong> pane, right click on <strong>Groups</strong> and choose: <strong>Create a new Group</strong>.  Provide a name and description, and select the target Management Pack (the one created in the previous step) and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/createthegroup/" rel="attachment wp-att-679"><img class="alignnone size-medium wp-image-679" title="Create the Group" src="http://operatingquadrant.files.wordpress.com/2012/01/createthegroup.png?w=400&#038;h=315" alt="" width="400" height="315" /></a></li>
<li>In the <strong>Explicit Members</strong>, add the Bind hosts (filter by UNIX/Linux Computer or Linux Computer objects).  Note:  membership can be controlled for this group at any point in the future, so not all BIND servers have to be added at this point.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/add-group-members/" rel="attachment wp-att-680"><img class="alignnone size-medium wp-image-680" title="Add Group Members" src="http://operatingquadrant.files.wordpress.com/2012/01/add-group-members.png?w=400&#038;h=385" alt="" width="400" height="385" /></a></li>
<li>No action is needed for the <strong>Dynamic Members</strong>, <strong>Subgroups</strong>, or <strong>Excluded Members</strong> dialogs, so click next through these to complete the group creation wizard.</li>
<li>With the MP and group created, it’s on to the actual monitoring.</li>
</ul>
<h3><strong>Creating a BIND Restart Task</strong></h3>
<p>The <strong>Run a UNIX/Linux Shell Command</strong> task wizard is the simplest of the shell command templates, so it is a good place to start. These steps will result in a task that restarts the BIND daemon on a Linux computer from the Operations Console.</p>
<ul>
<li>In the <strong>Authoring</strong> pane of the console, expand <strong>Management Pack Objects</strong> and right click <strong>Tasks</strong>. Select <strong>Create a New Task</strong>.</li>
<li>Select <strong>Run a UNIX/Linux Shell Command</strong> from the <strong>Agent Tasks</strong> list, and select the target <strong>Management Pack </strong>(created in a previous step).  Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/create-a-task/" rel="attachment wp-att-685"><img class="alignnone size-medium wp-image-685" title="Create a Task" src="http://operatingquadrant.files.wordpress.com/2012/01/create-a-task.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>Input a <strong>Name</strong> for the task (<em>Restart BIND Daemon</em>), provide a <strong>Description</strong>, and select the <strong>Target</strong> (<em>Linux Computer</em>). Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/task-name-and-description/" rel="attachment wp-att-688"><img class="alignnone size-medium wp-image-688" title="Task - Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/task-name-and-description.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>The command to restart the BIND daemon is: <em>service named restart</em>.  Type this into the <strong>Shell Command</strong> entry pane.  Restarting a daemon is a privileged operation, so select the <em>UNIX/Linux Privileged Account </em><strong>Run As profile</strong>.  The default timeout of 120 seconds should be sufficient, so click <strong>Create</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/task-shell-command-details/" rel="attachment wp-att-689"><img class="alignnone size-medium wp-image-689" title="Task - Shell Command Details" src="http://operatingquadrant.files.wordpress.com/2012/01/task-shell-command-details.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>That’s all it takes to create a shell command task.  When clicking on a Linux Computer instance in the monitoring view, the <strong>Restart BIND Daemon</strong> task will be listed in the right-hand task pane and can be run directly from the console.</li>
</ul>
<h3><strong>Monitoring the BIND Daemon</strong></h3>
<ul>
<li>In the <strong>Authoring </strong>pane of the console, right-click<strong> Management Pack Templates</strong> and choose <strong>Add Monitoring Wizard</strong>.</li>
<li>Select <strong>UNIX/Linux Process Monitoring</strong> and click <strong>Next<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/process-add-monitoring-wizard/" rel="attachment wp-att-752"><img class="alignnone size-medium wp-image-752" title="Process Add Monitoring Wizard" src="http://operatingquadrant.files.wordpress.com/2012/01/process-add-monitoring-wizard.png?w=400&#038;h=315" alt="" width="400" height="315" /></a></strong></li>
<li>Input a <strong>Name </strong>for the monitor, a <strong>Description</strong>, and select the target <strong>Management Pack</strong> (created previously):<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/process-template-name-and-description/" rel="attachment wp-att-691"><img class="alignnone size-medium wp-image-691" title="Process Template Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/process-template-name-and-description.png?w=400&#038;h=315" alt="" width="400" height="315" /></a></li>
<li>This is a pretty simple process monitor, so simply input <em>named </em>for the <strong>Process name</strong>, click <strong>Select a group</strong> and select the BIND servers group created previously.  An <strong>Alert severity</strong> of Error is appropriate and process argument filtering is not required, so click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/process-template-details/" rel="attachment wp-att-692"><img class="alignnone size-medium wp-image-692" title="Process Template Details" src="http://operatingquadrant.files.wordpress.com/2012/01/process-template-details.png?w=400&#038;h=315" alt="" width="400" height="315" /></a></li>
<li>On the <strong>Settings </strong>page, accept the defaults by clicking <strong>Next</strong>. This will generate an alert if <em>named</em> is not running.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/process-template-settings/" rel="attachment wp-att-693"><img class="alignnone size-medium wp-image-693" title="Process Template Settings" src="http://operatingquadrant.files.wordpress.com/2012/01/process-template-settings.png?w=400&#038;h=315" alt="" width="400" height="315" /></a></li>
<li>Click <strong>Create<em> </em></strong>to complete the wizard.</li>
</ul>
<h3><strong>Creating the Name Resolution Monitor</strong></h3>
<p>As described above, the command <em>nslookup </em>can be used to check name resolution health from the DNS server (specifying the local host as the server in the second argument).  For example: <em>nslookup lx12.contoso.com 127.0.0.1<strong>.  </strong></em>The actual output of this command looks like:</p>
<p><em>lx11:/var/lib/named # nslookup lx12.contoso.com 127.0.0.1<br />
</em><em>Server:         127.0.0.1<br />
</em><em>Address:        127.0.0.1#53</em></p>
<p><em>Name:   lx12.contoso.com<br />
</em><em>Address: 192.168.1.76 </em></p>
<p>To make this command more monitor friendly, we can do a bit of pipeline parsing:<br />
<em>nslookup lx12.contoso.com 127.0.0.1|egrep &#8216;^Name:.*lx12.contoso.com&#8217;|wc -l</em></p>
<p>This shell command will return a value of 1 if the line: <em>Name:   lx12.contoso.com </em>is found in StdOut and a value of 0 otherwise.  Thusly, a value of 1 means that the name resolution attempt succeeded, and a value of 0 means that it failed.</p>
<p>The steps to create a monitor using this command are:</p>
<ul>
<li>In the <strong>Authoring</strong> pane of the console, expand <strong>Management Pack Objects</strong> and right click <strong>Monitors</strong>. Select <strong>Create a Monitor</strong> and <strong>Unit Monitor</strong>.</li>
<li>Expand <strong>Scripting</strong>, then <strong>Generic</strong> and select <strong>UNIX/Linux Shell Command Two State Monitor</strong> and select the target <strong>Management Pack</strong> (created previously). Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/create-a-shell-command-monitor/" rel="attachment wp-att-698"><img class="alignnone size-medium wp-image-698" title="Create a Shell Command Monitor" src="http://operatingquadrant.files.wordpress.com/2012/01/create-a-shell-command-monitor.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></li>
<li>Input a <strong>Name</strong>, <strong>Description</strong>, and <strong>Target</strong> (<em>Linux Computer</em>) for the monitor. Select a <strong>Parent monitor </strong>(<em>Availability</em>) and uncheck <strong>Monitor is enabled</strong>.  Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-monitor-name-and-description/" rel="attachment wp-att-700"><img title="Shell Command Monitor Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-name-and-description.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></li>
<li>Configure a schedule interval.  For performance optimization, this should be as large of a value as reasonable.  10 or 15 minutes should be sufficient for most purposes. Click <strong>Next</strong><br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-monitor-scheduler/" rel="attachment wp-att-701"><img class="alignnone size-medium wp-image-701" title="Shell Command Monitor Scheduler" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-scheduler.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></li>
<li>Input the <strong>Shell Command </strong>(replacing lx12.contoso.com with the hostname to resolve):<br />
<strong><br />
</strong><em>nslookup lx12.contoso.com 127.0.0.1|egrep &#8216;^Name:.*lx12.contoso.com&#8217;|wc –l<br />
</em><br />
The <em>UNIX/Linux Action Account </em><strong>Run As profile</strong><em> </em>is appropriate for this command, and 120 seconds is a sufficient value for the <strong>Timeout</strong>. Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-monitor-details/" rel="attachment wp-att-702"><img class="alignnone size-medium wp-image-702" title="Shell Command Monitor Details" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-details.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></li>
<li>The next page of the wizard is for configuring the <strong>Error Expression</strong>. If the conditions defined in this expression are matched, the monitor will go to an error state. The Expression Filter dialog is preloaded with the following values://*[local-name()="StdOut"]  <em>Contains </em> &lt;input value&gt;<br />
//*[local-name()="ReturnCode"] <em>Equals</em>  <em>0</em>With the shell command used in this example, the error state should be triggered when StdOut does not equal 1, so we can simply modify the first line to that effect.  This results in an error condition that is triggered when StdOut does not equal 1 and the nslookup command executed successfully (ReturnCode equals 0).<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-monitor-error-expression/" rel="attachment wp-att-703"><img title="Shell Command Monitor Error Expression" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-error-expression.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></li>
<li>After clicking <strong>Next</strong>, the <strong>Healthy Expression</strong> dialog is displayed. As a StdOut value of 1 indicates a successful nslookup operation using the provided shell command, simply set the first line to: //*[local-name()="StdOut"]  <em>Equals 1 </em>and click <strong>Next</strong>.<br />
<em><a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-monitor-healthy-expression/" rel="attachment wp-att-704"><img title="Shell Command Monitor Healthy Expression" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-healthy-expression.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></em></li>
<li>In the <strong>Configure Health </strong>dialog, we can choose whether we want the error state to map to a Critical or Warning event by changing the <strong>Health State</strong> drop down.   In this example, I will set the <strong>Health State</strong> to Warning.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-monitor-health-mapping/" rel="attachment wp-att-705"><img class="alignnone size-medium wp-image-705" title="Shell Command Monitor Health Mapping" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-health-mapping.png?w=400&#038;h=373" alt="" width="400" height="373" /></a></li>
<li>The next dialog is for alert configuration. Check <strong>Generate alerts for this monitor </strong>and select an appropriate <strong>Priority </strong>and <strong>Severity</strong> (<em>Match monitor’s health). <strong> </strong></em>Edit the <strong>Alert name</strong> if appropriate and provide an <strong>Alert description</strong>.Standard $Target$ variables can be embedded in the <strong>Alert description</strong> by clicking <strong>[…]</strong>.  The syntax to include data from the shell command execution is:StdOut:  $Data/Context///*[local-name()=”StdOut”]$<br />
StdErr:  $Data/Context///*[local-name()=”StdErr”]$<br />
ReturnCode: $Data/Context///*[local-name()=”ReturnCode”]$In this example, I used the following description:<em>The BIND DNS server: $Target/Property[Type="MicrosoftUnixLibrary7320040!Microsoft.Unix.Computer"]/NetworkName$ failed a name resolution test.</em><em>StdErr: $Data/Context///*[local-name()="StdErr"]$</em>Click <strong>Create</strong> to complete the monitor creation.<br />
<img class="alignnone size-medium wp-image-706" title="Shell Command Monitor Alert" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-alert.png?w=400&#038;h=373" alt="" width="400" height="373" /></li>
<li>As this monitor targets all <em>Linux Computers</em>, we created it without enabling it by default. We can enable it for the group of BIND servers with an override. In the <strong>Authoring</strong> pane, expand <strong>Management Pack Objects</strong>, and click on <strong>Monitors</strong>. In the top-right of the <strong>Monitors</strong> pane, click <strong>Change Scope</strong>, and check <em>Linux Computers </em>from the <strong>Scope Management Pack Objects</strong> dialog.  Find the monitor that was just created (<em>BIND Name Resolution Check</em>).<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/find-the-monitor-2/" rel="attachment wp-att-708"><img title="Find the Monitor" src="http://operatingquadrant.files.wordpress.com/2012/01/find-the-monitor1-e1327557772379.png?w=400&#038;h=107" alt="" width="400" height="107" /></a></li>
<li>Right-click the monitor, click <strong>Overrides</strong>, then <strong>Override the Monitor</strong>, then <strong>For a Group</strong>.  Select the BIND servers group created previously and click <strong>OK</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/select-the-group/" rel="attachment wp-att-709"><img class="alignnone size-medium wp-image-709" title="Select the group" src="http://operatingquadrant.files.wordpress.com/2012/01/select-the-group.png?w=400&#038;h=429" alt="" width="400" height="429" /></a></li>
<li>Override the <strong>Enabled </strong>property to equal <strong>True</strong> and click <strong>OK</strong><br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/monitor-override/" rel="attachment wp-att-710"><img title="Monitor override" src="http://operatingquadrant.files.wordpress.com/2012/01/monitor-override.png?w=400&#038;h=408" alt="" width="400" height="408" /></a></li>
</ul>
<h3><strong>Creating the Name Resolution Time Performance Rule</strong></h3>
<ul>
<li>In the <strong>Authoring </strong>pane of the console, right-click <strong>Rules</strong>, and select <strong>Create a new rule</strong>.</li>
<li>Under <strong>Collection Rules</strong>, <strong>Probe Based</strong>, select <strong>UNIX/Linux Shell Command (Performance) </strong>and select the target <strong>Management Pack</strong> (previously created).  Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/create-a-shell-command-rule/" rel="attachment wp-att-713"><img title="Create a Shell Command Rule" src="http://operatingquadrant.files.wordpress.com/2012/01/create-a-shell-command-rule.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>Input the <strong>Name</strong> and <strong>Description</strong> for the rule. Select the <strong>Target</strong> (<em>Linux Computer</em>) and uncheck <strong>Rule is enabled</strong>. Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-rule-name-and-description/" rel="attachment wp-att-714"><img title="Shell Command Rule Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-name-and-description.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>Configure a schedule interval.  For performance optimization, this should be as large of a value as reasonable.  10 or 15 minutes should be sufficient for most purposes. Click <strong>Next.</strong><br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-rule-scheduler/" rel="attachment wp-att-715"><img class="alignnone size-medium wp-image-715" title="Shell Command Rule Scheduler" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-scheduler.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>On the <strong>Shell Command Details</strong> page, input the <strong>Shell Command</strong>:<br />
<em>/usr/bin/time -f %e nslookup lx12.contoso.com 127.0.0.1 &gt; /dev/null<br />
</em>This command will return the time in seconds (to StdErr) that it took to complete the name resolution lookup. This is a non-privileged operation, so the <em>UNIX/Linux Action Account</em> is sufficient for the <strong>Run As profile</strong>.  Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-rule-details/" rel="attachment wp-att-716"><img title="Shell Command Rule Details" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-details.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>The next page provides the opportunity to filter the output before mapping to performance data.  Performance data mapping can only occur if the value is a valid double value, so the default expression syntax uses a RegExp to validate that StdOut is a numeric value, and also filters that the ReturnCode = 0, indicating a successful execution.  While the default configuration is valid for most scenarios, the <em>time</em> command used in this shell command actually outputs its value to StdErr.  So in this case, the first line of the filter should be modified to use a <strong>Parameter Name</strong> of <em>//*[local-name()=”StdErr”]</em>. Click <strong>Next.</strong><br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-rule-filter/" rel="attachment wp-att-717"><img class="alignnone size-medium wp-image-717" title="Shell Command Rule Filter" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-filter.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>Configure the <strong>Performance Mapper</strong>.  <strong>Object</strong>, <strong>Counter,</strong> and <strong>Instance</strong> are arbitrary values that will be used to identify the performance metric in performance views and reports. The default <strong>Value</strong> of <em>$Data///*[local-name()=”StdOut”]$ </em>is the variable syntax for the returned StdOut, which is appropriate for most cases. Again, this needs to be modified because the<em> time</em> command used in this example outputs to StdErr.  The StdErr variable is: <em>$Data///*[local-name()='StdErr']$.</em> Click <strong>Create</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/shell-command-rule-mapper/" rel="attachment wp-att-718"><img title="Shell Command Rule Mapper" src="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-mapper.png?w=400&#038;h=339" alt="" width="400" height="339" /></a></li>
<li>As this rule targets all <em>Linux Computers</em>, we created it without enabling it by default. We can enable it for the group of BIND servers with an override. In the <strong>Authoring</strong> pane, expand <strong>Management Pack Objects</strong>, and click on <strong>Rules</strong>. In the top-right of the <strong>Rules </strong>pane, click <strong>Change Scope</strong>, and check <em>Linux Computers </em>from the <strong>Scope Management Pack Objects</strong> dialog.  Find the rules that was just created (<em>BIND Name Resolution Test Time in Seconds</em>).<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/find-the-rule/" rel="attachment wp-att-719"><img title="Find the Rule" src="http://operatingquadrant.files.wordpress.com/2012/01/find-the-rule-e1327591561234.png?w=400&#038;h=65" alt="" width="400" height="65" /></a></li>
<li>Right-click the rule, click <strong>Overrides</strong>, then <strong>Override the Monitor</strong>, then <strong>For a Group</strong>.  Select the BIND servers group created previously and click <strong>OK</strong>.<br />
<img title="Select the group" src="http://operatingquadrant.files.wordpress.com/2012/01/select-the-group.png?w=400&#038;h=429" alt="" width="400" height="429" /></li>
<li>Override the <strong>Enabled </strong>property to equal <strong>True</strong> and click <strong>OK</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/override-the-rule/" rel="attachment wp-att-721"><img title="Override the Rule" src="http://operatingquadrant.files.wordpress.com/2012/01/override-the-rule.png?w=400&#038;h=408" alt="" width="400" height="408" /></a></li>
</ul>
<h3><strong>Creating a Dashboard View</strong></h3>
<p>With the monitoring pieces now in place, we can move on to creating a dashboard view to show health and performance.</p>
<ul>
<li>In the <strong>Monitoring </strong>pane of the console, find the folder for the BIND management pack. Right-click the folder and choose <strong>New</strong>, then <strong>Dashboard View</strong><br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/mp-folder/" rel="attachment wp-att-729"><img class="alignnone size-medium wp-image-729" title="MP Folder" src="http://operatingquadrant.files.wordpress.com/2012/01/mp-folder-e1327591937989.png?w=320&#038;h=80" alt="" width="320" height="80" /></a></li>
<li>Select <strong>Grid Layout </strong>and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-grid-layout/" rel="attachment wp-att-723"><img class="alignnone size-medium wp-image-723" title="Dashboard Grid Layout" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-grid-layout.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Input a <strong>Name</strong> and <strong>Description</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-name-and-description/" rel="attachment wp-att-725"><img class="alignnone size-medium wp-image-725" title="Dashboard Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-name-and-description.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Select <strong>3 Cells</strong> and pick a layout. Click <strong>Next</strong> then <strong>Create</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-cells/" rel="attachment wp-att-722"><img class="alignnone size-medium wp-image-722" title="Dashboard Cells" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-cells.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>We now have an empty dashboard view.</li>
</ul>
<h4></h4>
<ul>
<li>Click <strong>Click to add widget</strong> in the top-left rectangle. Select <strong>State Widget</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-state-widget/" rel="attachment wp-att-727"><img class="alignnone size-medium wp-image-727" title="Dashboard State Widget" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-state-widget.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Provide a <strong>Name </strong>and <strong>Description</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-state-widget-name-and-description/" rel="attachment wp-att-726"><img class="alignnone size-medium wp-image-726" title="Dashboard State Widget Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-state-widget-name-and-description.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Under <strong>Groups and objects</strong> click <strong>Add</strong>. In the search dialog, find the BIND servers group, add it to the selection list and click <strong>OK</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-group-filter/" rel="attachment wp-att-724"><img class="alignnone size-medium wp-image-724" title="Dashboard Group Filter" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-group-filter.png?w=400&#038;h=424" alt="" width="400" height="424" /></a></li>
<li>Configure the display and filtering preferences and complete the widget wizard.</li>
</ul>
<h4>Adding the Performance Widget</h4>
<ul>
<li>Click <strong>Click to add widget</strong> in the top-right rectangle. Select <strong>Performance Widget</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-performance-widget/" rel="attachment wp-att-738"><img class="alignnone size-medium wp-image-738" title="Dashboard Performance Widget" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Input a <strong>Name </strong>and <strong>Description</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-performance-widget-name-and-description/" rel="attachment wp-att-737"><img class="alignnone size-medium wp-image-737" title="Dashboard Performance Widget Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget-name-and-description.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Under <strong>Select a group or object </strong>click <strong>[…]</strong> and find the BIND servers group.  Select the group and click <strong>OK.</strong><br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-performance-widget-scope/" rel="attachment wp-att-740"><img class="alignnone size-medium wp-image-740" title="Dashboard Performance Widget Scope" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget-scope.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Under <strong>Select performance counters</strong> click <strong>Add</strong>. Select the <strong>Object</strong> (<em>BIND Server</em>), <strong>Counter </strong>(<em>Name Resolution Time (s)</em>), and select (<em>All</em>) for <strong>Instance</strong>.  Click <strong>Add</strong> to add the performance counter and click <strong>OK</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-performance-widget-counters/" rel="attachment wp-att-739"><img class="alignnone size-medium wp-image-739" title="Dashboard Performance Widget Counters" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget-counters.png?w=400&#038;h=424" alt="" width="400" height="424" /></a><br />
<em>Note: only performance counters that have been collected will show up in this list. If you created the rule in the past few minutes and don’t see it listed yet, wait a little bit longer.</em></li>
<li>Select the <strong>Time Range</strong> and <strong>Display Options</strong> and complete the wizard.</li>
</ul>
<h4>Adding the Alert Widget</h4>
<ul>
<li>Click <strong>Click to add widget</strong> in the bottom rectangle. Select <strong>Alert Widget</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-alert-widget/" rel="attachment wp-att-736"><img class="alignnone size-medium wp-image-736" title="Dashboard Alert Widget" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li> Input a <strong>Name</strong> and <strong>Description</strong> and click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-alert-widget-name-and-description/" rel="attachment wp-att-735"><img class="alignnone size-medium wp-image-735" title="Dashboard Alert Widget Name and Description" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget-name-and-description.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Under <strong>Select a group or object</strong> click <strong>[…]</strong>, find and selecd the BIND servers group and click <strong>OK</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-alert-widget-group-selection/" rel="attachment wp-att-734"><img class="alignnone size-medium wp-image-734" title="Dashboard Alert Widget Group Selection" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget-group-selection.png?w=400&#038;h=424" alt="" width="400" height="424" /></a></li>
<li>Specify the criteria.  Be sure to filter for only the <strong>New</strong> resolution state if you just want to see active alerts. Click <strong>Next</strong>.<br />
<a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/dashboard-alert-widget-criteria/" rel="attachment wp-att-733"><img class="alignnone size-medium wp-image-733" title="Dashboard Alert Widget Criteria" src="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget-criteria.png?w=400&#038;h=293" alt="" width="400" height="293" /></a></li>
<li>Configure <strong>Display Preferences</strong> and complete the wizard.</li>
</ul>
<p>The end result is a dashboard showing health and performance of monitored BIND servers:</p>
<p><a href="http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/completed-dashboard/" rel="attachment wp-att-732"><img class="alignnone size-medium wp-image-732" title="Completed Dashboard" src="http://operatingquadrant.files.wordpress.com/2012/01/completed-dashboard.png?w=400&#038;h=266" alt="" width="400" height="266" /></a></p>
<h3><strong>Summary</strong></h3>
<p>As you can see from this walkthrough, the new template wizards for UNIX/Linux monitoring in OpsMgr 2012 are a significant improvement and make custom monitoring far easier to implement!<strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/677/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/677/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=677&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2012/01/30/opsmgr-2012-unixlinux-authoring-templates-shell-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/createthemp.png?w=400" medium="image">
			<media:title type="html">Create the MP</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/createthegroup.png?w=400" medium="image">
			<media:title type="html">Create the Group</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/add-group-members.png?w=400" medium="image">
			<media:title type="html">Add Group Members</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/create-a-task.png?w=400" medium="image">
			<media:title type="html">Create a Task</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/task-name-and-description.png?w=400" medium="image">
			<media:title type="html">Task - Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/task-shell-command-details.png?w=400" medium="image">
			<media:title type="html">Task - Shell Command Details</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/process-add-monitoring-wizard.png?w=400" medium="image">
			<media:title type="html">Process Add Monitoring Wizard</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/process-template-name-and-description.png?w=400" medium="image">
			<media:title type="html">Process Template Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/process-template-details.png?w=400" medium="image">
			<media:title type="html">Process Template Details</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/process-template-settings.png?w=400" medium="image">
			<media:title type="html">Process Template Settings</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/create-a-shell-command-monitor.png?w=400" medium="image">
			<media:title type="html">Create a Shell Command Monitor</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-name-and-description.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-scheduler.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Scheduler</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-details.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Details</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-error-expression.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Error Expression</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-healthy-expression.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Healthy Expression</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-health-mapping.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Health Mapping</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-monitor-alert.png?w=400" medium="image">
			<media:title type="html">Shell Command Monitor Alert</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/find-the-monitor1-e1327557772379.png?w=400" medium="image">
			<media:title type="html">Find the Monitor</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/select-the-group.png?w=400" medium="image">
			<media:title type="html">Select the group</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/monitor-override.png?w=400" medium="image">
			<media:title type="html">Monitor override</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/create-a-shell-command-rule.png?w=400" medium="image">
			<media:title type="html">Create a Shell Command Rule</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-name-and-description.png?w=400" medium="image">
			<media:title type="html">Shell Command Rule Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-scheduler.png?w=400" medium="image">
			<media:title type="html">Shell Command Rule Scheduler</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-details.png?w=400" medium="image">
			<media:title type="html">Shell Command Rule Details</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-filter.png?w=400" medium="image">
			<media:title type="html">Shell Command Rule Filter</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/shell-command-rule-mapper.png?w=400" medium="image">
			<media:title type="html">Shell Command Rule Mapper</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/find-the-rule-e1327591561234.png?w=400" medium="image">
			<media:title type="html">Find the Rule</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/select-the-group.png?w=400" medium="image">
			<media:title type="html">Select the group</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/override-the-rule.png?w=400" medium="image">
			<media:title type="html">Override the Rule</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/mp-folder-e1327591937989.png?w=320" medium="image">
			<media:title type="html">MP Folder</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-grid-layout.png?w=400" medium="image">
			<media:title type="html">Dashboard Grid Layout</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-name-and-description.png?w=400" medium="image">
			<media:title type="html">Dashboard Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-cells.png?w=400" medium="image">
			<media:title type="html">Dashboard Cells</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-state-widget.png?w=400" medium="image">
			<media:title type="html">Dashboard State Widget</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-state-widget-name-and-description.png?w=400" medium="image">
			<media:title type="html">Dashboard State Widget Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-group-filter.png?w=400" medium="image">
			<media:title type="html">Dashboard Group Filter</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget.png?w=400" medium="image">
			<media:title type="html">Dashboard Performance Widget</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget-name-and-description.png?w=400" medium="image">
			<media:title type="html">Dashboard Performance Widget Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget-scope.png?w=400" medium="image">
			<media:title type="html">Dashboard Performance Widget Scope</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-performance-widget-counters.png?w=400" medium="image">
			<media:title type="html">Dashboard Performance Widget Counters</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget.png?w=400" medium="image">
			<media:title type="html">Dashboard Alert Widget</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget-name-and-description.png?w=400" medium="image">
			<media:title type="html">Dashboard Alert Widget Name and Description</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget-group-selection.png?w=400" medium="image">
			<media:title type="html">Dashboard Alert Widget Group Selection</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/dashboard-alert-widget-criteria.png?w=400" medium="image">
			<media:title type="html">Dashboard Alert Widget Criteria</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2012/01/completed-dashboard.png?w=400" medium="image">
			<media:title type="html">Completed Dashboard</media:title>
		</media:content>
	</item>
		<item>
		<title>Operations Manager – Extending UNIX/Linux Monitoring with MP Authoring – Part IV</title>
		<link>http://operatingquadrant.com/2011/03/27/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iv/</link>
		<comments>http://operatingquadrant.com/2011/03/27/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iv/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 23:06:10 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[SCX]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=610</guid>
		<description><![CDATA[Introduction In Part III of this series, I walked through creation of data sources, a discovery, and a rule for discovering dynamically-named log files and implementing an alert-generating rule for log file monitoring.  In this post, I will continue to expand this Management Pack to implement performance collection rules, using WSMan Invoke methods to collect [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=610&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>In Part III of this series, I walked through creation of data sources, a discovery, and a rule for discovering dynamically-named log files and implementing an alert-generating rule for log file monitoring.  In this post, I will continue to expand this Management Pack to implement performance collection rules, using WSMan Invoke methods to collect numerical performance data from a shell command. </p>
<h1>Using Shell Commands to Collect Performance Data</h1>
<p>Whether it is system performance data from the /proc or /sys file systems, or application performance metrics in other locations, performance data for UNIX and Linux systems can often be found in flat files.   In this example Management Pack, I wanted to demonstrate using a WSMan Invoke module with the script provider to gather a numeric value from a file and publish the data as performance data.   In many cases, this would be slightly more complex than is represented in this example (e.g. if the performance metric value should be the delta between data points in the file over time), but this example should provide the framework for using the contents of a file to drive performance collection rules.   The root of these workflows is a shell command using the cat command to parse the file, which could be piped to grep, awk, and sed to filter for specific lines and columns.  </p>
<p>Additionally, if the performance data (e.g. hardware temperature or fan speed, current application user or connection count) that you are looking for is not stored in a file, but available in the output of a utility command, the same method could be used by using the utility command instead of cat.</p>
<h2>Collecting Performance Data from a File</h2>
<p>In this example, the MyApp application stores three performance metrics in flat files in the subdirectory ./perf.   I have built three rules that cat these files, and map the values to performance data.  The three rules are functionally identical, so I will only describe one of them.</p>
<h3>Performance Collection Rule:  MyApp.Monitoring.Rule.CollectMyAppMem</h3>
<p><span id="more-610"></span></p>
<p>This rule collects the value from the ./perf/mem file in the application directory, which represents the current memory used by the application in KB.   The rule targets the MyApp.Monitoring.MyApp application class.</p>
<h4>Rule Data Source:</h4>
<p>The rule uses the MyApp.Monitoring.ShellCommandMonitoring data source, described in Post I of this series, with the configuration:</p>
<pre>&lt;Interval&gt;300&lt;/Interval&gt;
&lt;TargetSystem&gt;
$Target/Host/Property[Type="MicrosoftUnixLibrary!
Microsoft.Unix.Computer"]/NetworkName$&lt;/TargetSystem&gt;
&lt;ShellCommand&gt;
cat $Target/Property[Type="MyApp.Monitoring.MyApp"]
  /InstallPath$/perf/mem
&lt;/ShellCommand&gt;
&lt;Timeout&gt;120&lt;/Timeout&gt;</pre>
<p>Notice that the ShellCommand is our cat command:  <em>cat $Target/Property[Type="MyApp.Monitoring.MyApp"]/InstallPath$/perf/mem</em></p>
<h4>Rule Condition Detection:</h4>
<p>A System.Performance.DataGenericMapper is used as the condition detection module to map the StdOut to performance data, with the configuration:</p>
<pre>&lt;ObjectName&gt;
$Target/Property[Type="MyApp.Monitoring.MyApp"]
  /Name$
&lt;/ObjectName&gt;
&lt;CounterName&gt;Memory used (KB)&lt;/CounterName&gt;
&lt;InstanceName&gt;Total&lt;/InstanceName&gt;
&lt;Value&gt;
  $Data///*[local-name()="StdOut"]$
&lt;/Value&gt;</pre>
<h4>Write Actions:</h4>
<p>The rule defines two write actions:  Microsoft.SystemCenter.CollectPerformanceData and Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData to collect the data and publish it to the DW.   These require no configuration.</p>
<p><a rel="attachment wp-att-612" href="http://operatingquadrant.com/2011/03/27/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iv/writeactions/"><img class="alignnone size-medium wp-image-612" title="writeactions" src="http://operatingquadrant.files.wordpress.com/2011/03/writeactions.png?w=400&#038;h=398" alt="" width="400" height="398" /></a></p>
<p>The end result is that the scheduled rule grabs the value from the text file, maps it to performance data, collects and publishes the performance data to the OM and DW databases.  This mechanism can be used for nearly any numerical performance metric that is accessible (in a timely fashion) from a shell command pipeline or script.</p>
<p><a rel="attachment wp-att-617" href="http://operatingquadrant.com/2011/03/27/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iv/perf/"><img class="alignnone size-medium wp-image-617" title="Memory Performance" src="http://operatingquadrant.files.wordpress.com/2011/03/perf-e1300740967244.jpg?w=400&#038;h=379" alt="" width="400" height="379" /></a></p>
<h3>Stay tuned for more in this series….</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/610/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=610&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2011/03/27/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iv/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/writeactions.png?w=400" medium="image">
			<media:title type="html">writeactions</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/perf-e1300740967244.jpg?w=400" medium="image">
			<media:title type="html">Memory Performance</media:title>
		</media:content>
	</item>
		<item>
		<title>Operations Manager – Extending UNIX/Linux Monitoring with MP Authoring – Part III</title>
		<link>http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iii/</link>
		<comments>http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iii/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 03:45:10 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[SCX]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=601</guid>
		<description><![CDATA[Introduction In Part II of this series, I walked through creation of data sources, a discovery, a monitor type, and a monitor for customized &#8221;Process Count&#8221; monitoring for discovered instances of a &#8221;Service&#8221; class. In this post, I will continue to build on this example MP to implement dynamic log file discovery and monitoring. Dynamic Log File Discovery and Monitoring ﻿﻿Log file [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=601&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>In Part II of this series, I walked through creation of data sources, a discovery, a monitor type, and a monitor for customized &#8221;Process Count&#8221; monitoring for discovered instances of a &#8221;Service&#8221; class. In this post, I will continue to build on this example MP to implement dynamic log file discovery and monitoring.</p>
<h1>Dynamic Log File Discovery and Monitoring</h1>
<p>﻿﻿Log file monitoring of a single known log file can be easily implemented with the Microsoft.Unix.SCXLog modules, but in some cases, the full path to a log file isn’t static.   For example, if an application maintains multiple log files in a directory, the file name portion of the log file path may not be known ahead of time.    To handle this monitoring scenario, we can implement dynamic log file discovery – using a shell command execution, and then pass the full path of the log file to the SCXLog module for standard log file monitoring. This requires a new class instance, a discovery data source, a discovery rule, and a rule that actually implements the log file monitoring.</p>
<h2><strong>Defining the Log File Class and Hosting Relationship</strong></h2>
<p>Firstly, a new custom class is required to represent the log file objects.   Instances of this class will be discovered by the discovery rule.  </p>
<h4>Definition </h4>
<ul>
<li>ID:  MyApp.Monitoring.LogFile</li>
<li>Base Class:  Microsoft.Unix.ApplicationComponent</li>
<li>Name:  MyApp Log file</li>
</ul>
<p><strong>Properties</strong></p>
<ul>
<li>Name (String)</li>
<li>Path (String) – <em>Key</em></li>
</ul>
<p>The properties for the log file class represent the file name and full path.   The full path is assured to be unique, so I have specified that as the key property of the class.</p>
<p>The log file class needs to be hosted by the MyApp class, to maintain the relationship between the log files and the application.  </p>
<p><a rel="attachment wp-att-606" href="http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iii/relationship-2/"><img class="alignnone size-medium wp-image-606" title="Hosting Relationship" src="http://operatingquadrant.files.wordpress.com/2011/03/relationship1-e1300738052875.jpg?w=400&#038;h=390" alt="" width="400" height="390" /></a></p>
<h3>Discovery Data Source:  MyApp.Monitoring.DataSource.DiscoverLogFiles</h3>
<p>This data source will use the MyApp.Monitoring.DataSource.ShellCommandDiscovery probe action to find files in a given directory that match a pattern.   The output from this command execution will then be passed to a Microsoft.Windows.PowerShellDiscoveryProbe.   The reason that I am using a PowerShellDiscoveryProbe is that the listing of matched files will be returned as a single data item, the StdOut from the command.   Using a PowerShellDiscoveryProbe provides an easy way to split each line from the output and discover an instance per line. </p>
<h4>Configuration Parameters:</h4>
<ul>
<li>Interval (integer):  Scheduler interval in seconds &#8211; overridable</li>
<li>TargetSystem (string):  UNIX/Linux agent computer to execute the discovery</li>
<li>Appname (string):   The name of the application object (which is the key property for the hosting class instance)</li>
<li>LogFileNamePattern (string): The pattern that will be used in the grep operation to identify log files to discovery</li>
<li>LogFilepath (string):  The path to search for log files at (via an ls command)</li>
</ul>
<h4>Member Modules:</h4>
<p>The first member modules is a MyApp.Monitoring.DataSource.ShellCommandDiscovery probe action, that executes the following command:<br />
<em>ls $Config/LogFilepath$ |grep $Config/LogFileNamePattern$.  </em>This simply enumerates the contents of the specified directory path, and pipes the results to grep, to match a specified pattern, which could be a string match or regular expression.</p>
<h4>Module Configuration:</h4>
<pre>&lt;Interval&gt;$Config/Interval$&lt;/Interval&gt;
&lt;TargetSystem&gt;$Config/TargetSystem$&lt;/TargetSystem&gt;
&lt;ShellCommand&gt;ls $Config/LogFilepath$
   |grep $Config/LogFileNamePattern$&lt;/ShellCommand&gt;
&lt;Timeout&gt;120&lt;/Timeout&gt;</pre>
<p>The output of this shell command then needs to be parsed so that each valid line in the output is discovered as an instance of a log file object.   This is most easily done with a PowerShellDiscoveryProbe:</p>
<blockquote><p>param ([string]$CmdOutput,[string]$AppName,[string]$LogFilePath, [string] $TargetSystem,[string] $SourceID,[string]$ManagedEntityID)</p>
<p>$api = New-Object -comObject &#8216;Mom.ScriptAPI&#8217;<br />
$discoveryData = $api.CreateDiscoveryData(0, $SourceID, $ManagedEntityID)</p>
<p>if ($CmdOutput -ne $null){<br />
        $CmdOutput = $CmdOutput.Replace([Environment]::newline,&#8221; &#8220;)<br />
 [array]$arList = $CmdOutput.Split(&#8221; &#8220;)<br />
 $arList | ForEach-Object{<br />
  [string]$sFile = $_<br />
 if([int]$sFile.Length -ge [int]1){<br />
  $SFilePath = $LogFilePath + &#8220;/&#8221; + $sFile<br />
  $oInst = $discoveryData.CreateClassInstance(&#8220;$MPElement[Name='MyApp.Monitoring.Logfile']$&#8221;)<br />
  $oInst.AddProperty(&#8220;$MPElement[Name='MyApp.Monitoring.Logfile']/Name$&#8221;, $sFile)<br />
  $oInst.AddProperty(&#8220;$MPElement[Name='System!System.Entity']/DisplayName$&#8221;, $sFile)<br />
  $oInst.AddProperty(&#8220;$MPElement[Name='MyApp.Monitoring.Logfile']/Path$&#8221;, $sFilePath)<br />
  $oInst.AddProperty(&#8220;$MPElement[Name='MyApp.Monitoring.MyApp']/Name$&#8221;, $AppName)<br />
  $oInst.AddProperty(&#8220;$MPElement[Name='MicrosoftUnixLibrary!Microsoft.Unix.Computer']/PrincipalName$&#8221;, $TargetSystem)</p>
<p>  $discoveryData.AddInstance($oInst)<br />
 }     <br />
}<br />
 $discoveryData<br />
}</p>
<p>Remove-variable api<br />
Remove-variable discoveryData</p></blockquote>
<p>The PowerShell script loads the Mom.ScriptAPI, creates a Discovery Data instance, and then walks through each line of the ouptut.   If the file name is a valid string (not empty), a class instance is created for the MyApp.Monitoring.Logfile class, and the path and file name properties are set.   The PrincipalName property of the Microsoft.Unix.Computer object, and the AppName property of the MyApp.Monitoring.MyApp class ares included in the DiscoveryData, so that the discovery mapping process can map the hosting relationships. </p>
<p>Parameters are passed from the module configuration to the script using the Parameters XML fragment in the module configuration:</p>
<pre>&lt;Parameters&gt;
&lt;Parameter&gt;
 &lt;Name&gt;TargetSystem&lt;/Name&gt;
 &lt;Value&gt;$Config/TargetSystem$&lt;/Value&gt;
 &lt;/Parameter&gt;
&lt;Parameter&gt;
 &lt;Name&gt;AppName&lt;/Name&gt;
 &lt;Value&gt;$Config/Appname$&lt;/Value&gt;
 &lt;/Parameter&gt;
&lt;Parameter&gt;
 &lt;Name&gt;LogFilePath&lt;/Name&gt;
 &lt;Value&gt;$Config/LogFilepath$&lt;/Value&gt;
 &lt;/Parameter&gt;
&lt;Parameter&gt;
 &lt;Name&gt;CmdOutput&lt;/Name&gt;
 &lt;Value&gt;
 $Data///*[local-name()="StdOut"]$
&lt;/Value&gt;
 &lt;/Parameter&gt;
&lt;Parameter&gt;
 &lt;Name&gt;ManagedEntityID&lt;/Name&gt;
 &lt;Value&gt;$Target/Id$&lt;/Value&gt;
 &lt;/Parameter&gt;
&lt;Parameter&gt;
 &lt;Name&gt;SourceID&lt;/Name&gt;
 &lt;Value&gt;$MPElement$&lt;/Value&gt;
 &lt;/Parameter&gt;
 &lt;/Parameters&gt;</pre>
<p>This data source can then be used to discover log files matching a pattern, in a specified directory.  </p>
<h3>Discovery Rule:  MyApp.Monitoring.Discovery.LogFile</h3>
<p>This discovery will discover dynamically-named log files, in a specified path, using a regular expression to filter by file name.   It discovers instances of the MyApp.Monitoring.LogFile class, and uses the MyApp.Monitoring.DataSource.DiscoverLogFiles data source.  The discovery targets  MyApp.Monitoring.MyApp</p>
<p>Data Source Configuration:</p>
<ul>
<li>&lt;Interval&gt;14400&lt;/Interval&gt;</li>
<li>&lt;TargetSystem&gt;$Target/Host/Property[Type="MicrosoftUnixLibrary!Microsoft.Unix.Computer"]/PrincipalName$&lt;/TargetSystem&gt;</li>
<li>&lt;Appname&gt;$Target/Property[Type="MyApp.Monitoring.MyApp"]/Name$&lt;/Appname&gt;</li>
<li>&lt;LogFileNamePattern&gt;‘^log[0-9]+’&lt;/LogFileNamePattern&gt;</li>
<li>&lt;LogFilepath&gt;$Target/Property[Type="MyApp.Monitoring.MyApp"]/InstallPath$/logs&lt;/LogFilepath&gt;</li>
</ul>
<p>The two parameters to note are the LogFilepath (which is defined as the application path discovered for the MyApp application, appended with “/logs”) and the LogFileNamePattern (which is a regular expression &#8211; ‘^log[0-9]+’ – that will match log files named:  logxxx, where xxx is a number).  </p>
<h2>Monitoring the Discovered Log Files</h2>
<h3>Log File Monitoring Rule:   MyApp.Monitoring.Rule.AlertOnLogError</h3>
<p>Now that the dynamically-named log files will be discovered, we need a rule to alert when an error is found in one of the logs.   The rule will target all instances of the MyApp.Monitoring.LogFile class, so that when a new log file instance is discovered, it is automatically monitored.  The rule uses the MicrosoftUnixLibrary!Microsoft.Unix.SCXLog.Privileged.Datasource (assuming the log files require privileged credentials to access).</p>
<h4>Data source configuration:</h4>
<ul>
<li>&lt;Host&gt;$Target/Host/Host/Property[Type="MicrosoftUnixLibrary!Microsoft.Unix.Computer"]/NetworkName$&lt;/Host&gt;</li>
<li>&lt;LogFile&gt;$Target/Property[Type="MyApp.Monitoring.Logfile"]/Path$&lt;/LogFile&gt; &lt;RegExpFilter&gt;^.*(e|E)rror.*$&lt;/RegExpFilter&gt;</li>
</ul>
<p>The discovered path to the logfile instance is input as the LogFile parameter value, and a Regular Exprssion (^.*(e|E)rror.*$) is defined to match any log entries with the string:  error or Error in the message.  </p>
<h4>Condition Detection configuration:</h4>
<p>A System!System.Event.GenericDataMapper condition detection is then configured to map the data to EventData, for consumption by OpsMgr.  The configuration of this module is:</p>
<ul>
<li>&lt;EventOriginId&gt;$MPElement$&lt;/EventOriginId&gt;</li>
<li>&lt;PublisherId&gt;$MPElement$&lt;/PublisherId&gt;</li>
<li>&lt;PublisherName&gt;MyApp&lt;/PublisherName&gt;</li>
<li>&lt;Channel&gt;Application&lt;/Channel&gt;</li>
<li>&lt;LoggingComputer&gt;$Target/Host/Host/Property[Type="MicrosoftUnixLibrary!Microsoft.Unix.Computer"]/NetworkName$&lt;/LoggingComputer&gt;</li>
<li>&lt;EventNumber&gt;8001&lt;/EventNumber&gt;</li>
<li>&lt;EventCategory&gt;0&lt;/EventCategory&gt;</li>
<li>&lt;EventLevel&gt;1&lt;/EventLevel&gt;</li>
<li>&lt;UserName/&gt;</li>
<li> &lt;Params/&gt;</li>
<li> &lt;/ConditionDetection&gt;</li>
</ul>
<h4>Write Actions:</h4>
<p>In this rule, I have configured two write actions, for collecting the event, and generating an alert.  The CollectEvent (SC!Microsoft.SystemCenter.CollectEvent) module requires no additional configuration, and the alert can be configured to provide details about the logged error message:</p>
<p> <a rel="attachment wp-att-607" href="http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iii/rulealertconfig/"><img class="alignnone size-medium wp-image-607" title="Rule Alert Config" src="http://operatingquadrant.files.wordpress.com/2011/03/rulealertconfig.png?w=400&#038;h=402" alt="" width="400" height="402" /></a></p>
<h3>Stay tuned for more in this series&#8230;</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/601/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/601/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/601/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/601/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/601/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/601/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/601/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/601/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=601&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/relationship1-e1300738052875.jpg?w=400" medium="image">
			<media:title type="html">Hosting Relationship</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/rulealertconfig.png?w=400" medium="image">
			<media:title type="html">Rule Alert Config</media:title>
		</media:content>
	</item>
		<item>
		<title>Operations Manager – Extending UNIX/Linux Monitoring with MP Authoring – Part II</title>
		<link>http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-ii/</link>
		<comments>http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-ii/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 04:04:01 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[SCX]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=589</guid>
		<description><![CDATA[Introduction In Part I of this series, I walked through creation of a custom Management Pack for monitoring an application hosted on a UNIX or Linux server, as well as the creation of some base data sources and application discovery.   In this post, I will build on this MP to implement custom process monitoring &#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=589&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<div>In Part I of this series, I walked through creation of a custom Management Pack for monitoring an application hosted on a UNIX or Linux server, as well as the creation of some base data sources and application discovery.   In this post, I will build on this MP to implement custom process monitoring &#8211; monitoring the count of instances of a running daemon/process to check that the count is within a range.   While the standard process monitoring provider (SCX_UnixProcess) is the best source for process information in OpsMgr UNIX and Linux monitoring, it does not support this level of customized monitoring.</div>
<h1>Advanced Service Monitoring</h1>
<div><span style="font-size:small;"><span style="font-family:Calibri;">Continuing this custom application monitoring scenario, our hypothetical app has a single daemon associated with the app, but we will build the classes and data sources so that they could easily be extended to add more services/daemons to monitor.    In this example, we can suppose that we want to monitor a daemon that may have multiple instances running, and drive an alert if too many or too few instances of that process are running.   This monitoring will be implemented by using the <em>ps</em> command in a WSMan Invoke module.   To implement monitoring of a daemon for a discovered, custom application, there are two approaches that are viable: </span></span></div>
<div><span style="font-size:small;"><span style="font-family:Calibri;"> </span></span></div>
<ol>
<li>
<div>Define a custom service class, and discover an instance of this class for each service to monitor, configure monitor types and monitors targeting this class</div>
</li>
<li>
<div>Create a monitor for each service to monitor, targeting the custom application class</div>
</li>
</ol>
<p>Both methods are completely viable, and in most cases, it is appropriate to take the simpler approach and target the custom monitors to the application, providing static inputs into the monitor.   There are some cases where discovering a class instance for the service makes sense though.  Facilitating dynamic discovery of services or thresholds (read from a config file), using the service class in a Distributed Application model in OpsMgr, or maintaining logical seperation (in terms of monitoring) between the application and its subsystems are all scenarios that would benefit from discovering the monitored services as class instances.   For the purpose of illustration, I will discover the daemon to monitor in this example Management Pack as a class instance.</p>
<h2>Class Definition</h2>
<h3>Class:  MyApp.Monitoring.Service</h3>
<h4>Definition</h4>
<ul>
<li>
<div>ID:  MyApp.Monitoring.Service</div>
</li>
<li>
<div>Base Class:  Microsoft.Unix.ApplicationComponent</div>
</li>
<li>
<div>Name:  MyApp Service</div>
</li>
</ul>
<h4>Properties</h4>
<ul>
<li>
<div>Name (String) – <em>Key</em></div>
</li>
<li>
<div>MinRunning (Integer)</div>
</li>
<li>
<div>MaxRunning (Integer)</div>
</li>
</ul>
<h2>Discovery</h2>
<p>Then we can define the data source to discover a service.   In this case, we know the name of the service and the value of the properties, so we don’t need to actually poll the agent to return data.   We can simply combine a Discovery Scheduler with a Discovery Data Mapper module to implement the data source.  However, we want to be able to override the values of MinRunning and MaxRunning, so these will need to be exposed as overridable configuration parameters.</p>
<p>Therefore, I’ve chosen to implement this data source in two parts.   The first data source, will simply combine a System.Discovery.Scheduler module and a System.Discovery.ClassSnapshotDataMapper module.   This data source will accept Interval, ClassId and InstanceSettings parameters as inputs.  The second data source will reference the first data source, but implement parameters for Service Name, MinRunning, and MaxRunning.    By breaking this into two data sources, the first data source can be used for other simple discoveries.</p>
<h3>Discovery Data Source:  MyApp.Monitoring.DataSource.DiscoverObject</h3>
<p>This is the data source that simply combines a scheduler and a discovery data mapper.  It requires that the MapperSchema be added to the Configuration:</p>
<pre>&lt;Configuration&gt;
&lt;IncludeSchemaTypes&gt;
&lt;SchemaType&gt;
 System!System.Discovery.MapperSchema
&lt;/SchemaType&gt;
&lt;/IncludeSchemaTypes&gt;
…
<span id="more-589"></span></pre>
<h4>Configuration Parameters:</h4>
<ul>
<li>Interval (integer):  Scheduler interval in seconds</li>
<li>ClassId (string):  ID of the Class to discover</li>
<li>InstanceSettings (SettingsType):  Discovery Instance Settings</li>
</ul>
<h4>Member Modules:</h4>
<p>The first member module is the System.Discovery.Scheduler module, with the configuration:</p>
<pre>&lt;Scheduler&gt;
&lt;SimpleReccuringSchedule&gt;
&lt;Interval&gt;$Config/Interval$&lt;/Interval&gt;
&lt;SyncTime/&gt;
&lt;/SimpleReccuringSchedule&gt;
&lt;ExcludeDates/&gt;
&lt;/Scheduler&gt;</pre>
<p>This is followed by a System.Discovery.ClassSnapshotDataMappermodule, with the configuration:</p>
<pre>&lt;ClassId&gt;$Config/ClassId$&lt;/ClassId&gt;
&lt;InstanceSettings&gt;
 $Config/InstanceSettings$
&lt;/InstanceSettings&gt;</pre>
<p>So this data source accepts the arbitrary Instance Settings and Class Id and maps the inputs to Discovery Data.</p>
<h3>Discovery Data Source:  MyApp.Monitoring.DataSource.DiscoverService</h3>
<p>This data source uses the MyApp.Monitoring.DataSource.DiscoverObject data source that we just created, but supports overridable inputs for the MinRunning and MaxRunning service class properties, by embedding the $Config/$ variables in the Instance Settings definition.</p>
<h4>Configuration Parameters:</h4>
<ul>
<li>Interval (integer):  Scheduler interval in seconds &#8211; overridable</li>
<li>TargetSystem (string):  UNIX/Linux agent computer to execute the discovery</li>
<li>AppName (string):   The name of the application object (which is the key property for the hosting class instance)</li>
<li>ServiceName (string): The name of the service to discover</li>
<li>MinRunning (integer):  The minimum threshold of running processes expected &#8211; overridable</li>
<li>MaxRunning (integer):  The maximum threshold of running processes expected &#8211; overridable</li>
</ul>
<h4>Member Modules</h4>
<p>This data source only has one member module:  MyApp.Monitoring.DataSource.DiscoverObject, with the configuration:</p>
<pre>&lt;Interval&gt;$Config/Interval$&lt;/Interval&gt;
&lt;ClassId&gt;
 $MPElement[Name="MyApp.Monitoring.Service"]$
&lt;/ClassId&gt;
&lt;InstanceSettings&gt;
&lt;Settings&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MyApp.Monitoring.MyApp']/Name$
&lt;/Name&gt;
&lt;Value&gt;$Config/AppName$&lt;/Value&gt;
&lt;/Setting&gt; 
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MyApp.Monitoring.Service']/Name$
&lt;/Name&gt;
&lt;Value&gt;$Config/ServiceName$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MyApp.Monitoring.Service']/MinRunning$
&lt;/Name&gt;
&lt;Value&gt;$Config/MinProcesses$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MyApp.Monitoring.Service']/MaxRunning$
&lt;/Name&gt;
&lt;Value&gt;$Config/MaxProcesses$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MicrosoftUnixLibrary!
  Microsoft.Unix.Computer']/PrincipalName$
&lt;/Name&gt;
&lt;Value&gt;$Config/TargetSystem$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
$MPElement[Name='System!System.Entity']/DisplayName$
&lt;/Name&gt;
&lt;Value&gt;$Config/ServiceName$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;/Settings&gt;
&lt;/InstanceSettings&gt;</pre>
<p>Note that the key properties for the hosting class instances (MyApp.Monitoring.MyApp, and Microsoft.Unix.Computer) are included in the Instance Settings so that the relationships can be mapped.  With the data sources in place, the next step is to configure the Discovery Rule (one for each service to discover).</p>
<h3>Discovery Rule:  MyApp.Monitoring.Discovery.MyAppDService</h3>
<p>This rule discovers the MyAppD daemon, using the data source just created.  It is targeted to instances of the MyApp class, and provides the name of the service and process count thresholds.</p>
<h4>Data Source Configuration:</h4>
<pre>&lt;Interval&gt;28800&lt;/Interval&gt;
&lt;TargetSystem&gt;
 $Target/Host/Property[Type="MicrosoftUnixLibrary!
  Microsoft.Unix.Computer"]/PrincipalName$
&lt;/TargetSystem&gt;
&lt;AppName&gt;
 $Target/Property[Type="MyApp.Monitoring.MyApp"]/Name$
&lt;/AppName&gt;
&lt;ServiceName&gt;myappd&lt;/ServiceName&gt;
&lt;MinProcesses&gt;1&lt;/MinProcesses&gt;
&lt;MaxProcesses&gt;3&lt;/MaxProcesses&gt;</pre>
<p>Once the MP is imported and the dicsovery has run, we can see the discovered service in the Discovered Inventory view in the Ops Console:</p>
<p><a rel="attachment wp-att-592" href="http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-ii/service/"><img class="alignnone size-medium wp-image-592" title="Service" src="http://operatingquadrant.files.wordpress.com/2011/03/service-e1300736559901.png?w=348&#038;h=299" alt="" width="348" height="299" /></a></p>
<h2>Building the Monitor Type</h2>
<p>In this example, we are going to monitor the process/daemon and generate an alert if the count of running instances is outside of the threshold range.   To do this, we can use the Shell Command monitoring data source to execute a  <em>ps h -e |grep &lt;process name&gt; grep -v grep |wc –l</em> command string.  This calls the <em>ps</em> command, with switches to suppress the header row, and show all processes.   Grep is used to find the process name, and exclude the grep process itself.  Finally, the results are piped to <em>wc –l</em> to return a line count.   The result of this command string is that the running count of processes matching the process name is returned as a numeric value.</p>
<h3>Monitor Type: MyApp.Monitoring.MonitorType.ProcessCount</h3>
<p>This monitor type will use the MyApp.Monitoring.DataSource.ShellCommandMonitoring data source, to call the ps command string described above.  A set of condition detection modules are used to determine if the process count is below or above the minimum and maximum thresholds.</p>
<h4>Configuration Parameters</h4>
<ul>
<li>Interval (integer):  Scheduler interval in seconds &#8211; overridable</li>
<li>TargetSystem (string):  UNIX/Linux agent computer to monitor</li>
<li>ServiceName (string): The name of the service to monitor</li>
<li>MinRunning (integer):  The minimum threshold of running processes expected</li>
<li>MaxRunning (integer):  The maximum threshold of running processes expected</li>
</ul>
<h4>Health States</h4>
<ul>
<li>ProcessCountOK</li>
<li>ProcessCountNotOK</li>
</ul>
<h4>Member Modules</h4>
<pre>The data source for this monitor type is: MyApp.Monitoring.DataSource.ShellCommandMonitoring, with the configuration:
&lt;Interval&gt;$Config/Interval$&lt;/Interval&gt;
&lt;TargetSystem&gt;
 $Config/TargetSystem$
&lt;/TargetSystem&gt;
&lt;ShellCommand&gt;
 <em>ps h -e |grep $Config/ProcessName$|grep -v grep |wc –l</em>
&lt;/ShellCommand&gt;
&lt;Timeout&gt;120&lt;/Timeout&gt;</pre>
<p>Two configuration detection modules are required to detect the OK and NotOK states, comparing the returned StdOut to the thresholds:</p>
<pre>&lt;ConditionDetection ID="CDProcessCountOK"
  TypeID="System!System.ExpressionFilter"&gt;
&lt;Expression&gt;
&lt;And&gt;
&lt;Expression&gt;
&lt;SimpleExpression&gt;
&lt;ValueExpression&gt;
 &lt;XPathQuery Type="Double"&gt;
 //*[local-name()="StdOut"]
&lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
&lt;Operator&gt;GreaterEqual&lt;/Operator&gt;
&lt;ValueExpression&gt;
&lt;Value Type="Double"&gt;$Config/MinCount$&lt;/Value&gt;
&lt;/ValueExpression&gt;
&lt;/SimpleExpression&gt;
&lt;/Expression&gt;
&lt;Expression&gt;
&lt;SimpleExpression&gt;
&lt;ValueExpression&gt;
&lt;XPathQuery Type="Double"&gt;
 //*[local-name()="StdOut"]
&lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
&lt;Operator&gt;LessEqual&lt;/Operator&gt;
&lt;ValueExpression&gt;
&lt;Value Type="Double"&gt;$Config/MaxCount$&lt;/Value&gt;
&lt;/ValueExpression&gt;
&lt;/SimpleExpression&gt;
&lt;/Expression&gt;
&lt;/And&gt;
&lt;/Expression&gt;
&lt;/ConditionDetection&gt;</pre>
<p>And</p>
<pre>&lt;ConditionDetection ID="CDProcessCountNotOK"
  TypeID="System!System.ExpressionFilter"&gt;
&lt;Expression&gt;
&lt;Or&gt;
&lt;Expression&gt;
&lt;SimpleExpression&gt;
&lt;ValueExpression&gt;
&lt;XPathQuery Type="Double"&gt;
 //*[local-name()="StdOut"]
&lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
&lt;Operator&gt;Greater&lt;/Operator&gt;
&lt;ValueExpression&gt;
&lt;Value Type="Double"&gt;$Config/MaxCount$&lt;/Value&gt;
&lt;/ValueExpression&gt;
&lt;/SimpleExpression&gt;
&lt;/Expression&gt;
&lt;Expression&gt;
&lt;SimpleExpression&gt;
&lt;ValueExpression&gt;
&lt;XPathQuery Type="Double"&gt;
 //*[local-name()="StdOut"]
&lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
&lt;Operator&gt;Less&lt;/Operator&gt;
&lt;ValueExpression&gt;
&lt;Value Type="Double"&gt;$Config/MinCount$&lt;/Value&gt;
&lt;/ValueExpression&gt;
&lt;/SimpleExpression&gt;
&lt;/Expression&gt;
&lt;/Or&gt;
&lt;/Expression&gt;
&lt;/ConditionDetection&gt;</pre>
<h4>Regular Detections</h4>
<p>The regular detections just need to be configured to map the Condition Detection member modules to the defined Health States:</p>
<pre>&lt;RegularDetections&gt;
&lt;RegularDetection
  MonitorTypeStateID="ProcessCountOK"&gt;
&lt;Node ID="CDProcessCountOK"&gt;
&lt;Node ID="DS1"/&gt;
&lt;/Node&gt;
&lt;/RegularDetection&gt;
&lt;RegularDetection
  MonitorTypeStateID="ProcessCountNotOK"&gt;
&lt;Node ID="CDProcessCountNotOK"&gt;
&lt;Node ID="DS1"/&gt;
&lt;/Node&gt;
&lt;/RegularDetection&gt;
&lt;/RegularDetections&gt;</pre>
<p>In summary, this monitor type will execute our <em>ps</em> command, for a given service name, and compare the count of running/matched process instances  to the defined thresholds (defined during service discovery).</p>
<h2>Building the Custom Process Monitor</h2>
<p>In this step, we will create a monitor, of the type that we just created: MyApp.Monitoring.MonitorType.ProcessCount</p>
<p><a rel="attachment wp-att-594" href="http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-ii/monitorservice-2/"><img class="alignnone size-medium wp-image-594" title="Service Monitor" src="http://operatingquadrant.files.wordpress.com/2011/03/monitorservice1-e1300737092706.png?w=400&#038;h=397" alt="" width="400" height="397" /></a></p>
<div>As for the monitor configuration, the service name, and minimum and maximum thresholds were discovered in the service discovery rule, so we can simply provide those target parameters to the monitor configuration.</div>
<pre>&lt;Configuration&gt;
&lt;Interval&gt;180&lt;/Interval&gt;
&lt;TargetSystem&gt;
 $Target/Host/Host/Property[Type="MicrosoftUnixLibrary!
     Microsoft.Unix.Computer"]/NetworkName$
&lt;/TargetSystem&gt;
&lt;ProcessName&gt;
 $Target/Property[Type="MyApp.Monitoring.Service"]/Name$
&lt;/ProcessName&gt;
&lt;MinCount&gt;
 $Target/Property[Type="MyApp.Monitoring.Service"]/MinRunning$
&lt;/MinCount&gt;
&lt;MaxCount&gt;
 $Target/Property[Type="MyApp.Monitoring.Service"]/MaxRunning$
&lt;/MaxCount&gt;
&lt;/Configuration&gt;</pre>
<div>For the actual alert, we can embed the parameters from the configuration and shell script output, to create an alert message detailing the current count of running processes as well as the minimum and maximum expected range.</div>
<blockquote>
<div><em>The MyApp Service: $Target/Property[Type="MyApp.Monitoring.Service"]/Name$, currently has too many or too few processes running. </em></div>
<div><em>Current process count:  $Data/Context///*[local-name()="StdOut"]$. </em></div>
<div><em>Expected range: </em><br />
<em>$Target/Property[Type="MyApp.Monitoring.Service"]/MinRunning$ &#8211; $Target/Property[Type="MyApp.Monitoring.Service"]/MaxRunning$.</em></div>
</blockquote>
<h3>Stay tuned for more in this series&#8230;</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/589/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=589&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2011/03/24/operations-manager-%e2%80%93-extending-unixlinux-monitoring-with-mp-authoring-%e2%80%93-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/service-e1300736559901.png?w=348" medium="image">
			<media:title type="html">Service</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/monitorservice1-e1300737092706.png?w=400" medium="image">
			<media:title type="html">Service Monitor</media:title>
		</media:content>
	</item>
		<item>
		<title>Operations Manager &#8211; Extending UNIX/Linux Monitoring with MP Authoring &#8211; Part I</title>
		<link>http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/</link>
		<comments>http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 16:11:56 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[SCX]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=575</guid>
		<description><![CDATA[Introduction The OpsMgr UNIX and Linux monitoring implementation can be extended through MP authoring to implement robust system and application monitoring for UNIX/Linux servers.   The most direct mechanism of extension comes in the form of the script provider, accessed with WSMan Invoke modules.   The WSMan Invoke modules support three methods of invoking actions: ExecuteCommand – [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=575&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>The OpsMgr UNIX and Linux monitoring implementation can be extended through MP authoring to implement robust system and application monitoring for UNIX/Linux servers.   The most direct mechanism of extension comes in the form of the script provider, accessed with WSMan Invoke modules.   The WSMan Invoke modules support three methods of invoking actions:</p>
<ul>
<li>ExecuteCommand – execute a command (e.g. a script already on the file system ) and return the results</li>
<li>ExecuteShellCommand – execute a command through sh (with pipeline support) and return the results</li>
<li>ExecuteScript  &#8211; download and execute an embedded script and return the results</li>
</ul>
<p>Of these three methods, I prefer to use ExecuteShellCommand in most cases, as it allows for the use of complex one-liner shell commands, embedded in the MP.</p>
<p>In a series of posts, I will describe the creation of an example Management Pack for monitoring an application, featuring dynamic application discovery, discovery of multiple log files, and advanced monitoring implementations.</p>
<h2><strong>Example Application Details</strong></h2>
<p>The example MP described in these blog posts implements monitoring for a hypothetical application (MyApp).  The application involves a daemon, a set of log files, and application performance counters where the metrics are accessible as the contents of files.</p>
<h1>Part I &#8211; Discovering an Application</h1>
<h2>Setting up the MP</h2>
<p>I am a big fan of the R2 Authoring Console and will be using it to create this example MP.   The first step then is to create a new MP in the Authoring Console (ID:  MyApp.Monitoring).    Once the MP is created and saved, references are needed.   References I am adding are:</p>
<ul>
<li>Microsoft.Unix.Library – contains UNIX/Linux classes and modules</li>
<li>Microsoft.SystemCenter.DataWarehouse.Library – required for publishing performance data to the DW</li>
<li>System.Image.Library – contains icon images referenced in class definition</li>
</ul>
<p><a rel="attachment wp-att-576" href="http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/ref/"><img class="alignnone size-medium wp-image-576" title="References" src="http://operatingquadrant.files.wordpress.com/2011/03/ref-e1300730156221.jpg?w=400&#038;h=255" alt="" width="400" height="255" /></a></p>
<h2>Configuring the Base Composite Modules<br />
<span id="more-575"></span></h2>
<p>Most monitoring and discovery workflows used in this MP example will involve the execution of a shell command through the Microsoft.Unix.WSMan.Invoke.ProbeAction ExecuteShellCommand method.   Therefore, setting up a new composite probe action and a couple of base data sources will make further module implementation much simpler.</p>
<h3>Probe Action:  MyApp.Monitoring.ProbeAction.ShellCommand</h3>
<p>This probe action simply wraps the Microsoft.Unix.WSMan.Invoke.ProbeAction in a way that makes it easier to use for shell command execution.</p>
<h5>Configuration Parameters:</h5>
<ul>
<li>TargetSystem (string)  – the UNIX/Linux agent computer that will execute the command</li>
<li>ShellCommand (string) – the shell command to execute</li>
<li>Timeout (integer) – the command timeout, in seconds</li>
</ul>
<h5>Member Modules:</h5>
<p>This probe action will only include one member module:  Microsoft.Unix.WSMan.Invoke.ProbeAction.  The configuration of the module looks like:</p>
<pre>&lt;TargetSystem&gt;$Config/TargetSystem$&lt;/TargetSystem&gt;
&lt;Uri&gt;

http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/

 SCX_OperatingSystem?__cimnamespace=root/scx
&lt;/Uri&gt;
&lt;Selector/&gt;
&lt;InvokeAction&gt;ExecuteShellCommand&lt;/InvokeAction&gt;
&lt;Input&gt;
&lt;p:ExecuteShellCommand_INPUT xmlns:p="http://schemas.
 microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem"&gt;
&lt;p:command&gt;$Config/ShellCommand$&lt;/p:command&gt;
&lt;p:timeout&gt;$Config/Timeout$&lt;/p:timeout&gt;
&lt;/p:ExecuteShellCommand_INPUT&gt;
&lt;/Input&gt;</pre>
<p>Note that the configuration parameters for ShellCommand and Timeout are embedded in the “Input” parameter XML fragment.</p>
<h3>Data Source: MyApp.Monitoring.DataSource.ShellCommandMonitoring</h3>
<p>The probe action created in the previous step will be used in a number of monitoring workflows, so creating a data source that combines the probe action with a scheduler will make monitoring workflow configuration simpler.</p>
<h5>Configuration Parameters:</h5>
<ul>
<li>Interval (integer) – timer interval in seconds</li>
<li>TargetSystem (string)  – passed to the probe action module</li>
<li>ShellCommand (string) – passed to the probe action module</li>
<li>Timeout (integer) – passed to the probe action module</li>
</ul>
<h5>Member Modules:</h5>
<p>The first module in this composite data source is a System.Scheduler module, with a basic configuration:</p>
<pre>&lt;Scheduler&gt;
&lt;SimpleReccuringSchedule&gt;
&lt;Interval&gt;$Config/Interval$&lt;/Interval&gt;
&lt;SyncTime/&gt;
&lt;/SimpleReccuringSchedule&gt;
&lt;ExcludeDates/&gt;
&lt;/Scheduler&gt;</pre>
<p>This scheduler module is followed by the ShellComand probe action, with the configuration:</p>
<pre>&lt;TargetSystem&gt;$Config/TargetSystem$&lt;/TargetSystem&gt;
&lt;ShellCommand&gt;$Config/ShellCommand$&lt;/ShellCommand&gt;
&lt;Timeout&gt;$Config/Timeout$&lt;/Timeout&gt;</pre>
<h3>Data Source: MyApp.Monitoring.DataSource.ShellCommandDiscovery</h3>
<p>This data source is identical to the MyApp.Monitoring.DataSource.ShellCommandMonitoring data source, except it features a System.Discovery.Scheduler scheduler module instead of a System.Scheduler module.  Discovery workflows must use a Discovery scheduler in order to prevent problems with cookdown (i.e. discovery workflows ‘cooking-down’ along with monitoring workflows).   So this data source combines the ShellCommand probe action with a Discovery scheduler.</p>
<p>Additionally, I have added a System.ExpressionFilter module to the ShellCommandDiscovery data source to prevent the discovery workflows from continuing if an error is encountered (either WSMan error or ShellCommand StdErr output).   The ExpressionFilter configuration is:</p>
<pre>&lt;Expression&gt;
&lt;And&gt;
&lt;Expression&gt;
&lt;RegExExpression&gt;
&lt;ValueExpression&gt;
 &lt;XPathQuery&gt;//*[local-name()="StdErr"]&lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
 &lt;Operator&gt;DoesNotMatchRegularExpression&lt;/Operator&gt;
 &lt;Pattern&gt;^.+&lt;/Pattern&gt;
 &lt;/RegExExpression&gt;
 &lt;/Expression&gt;
&lt;Expression&gt;
&lt;Not&gt;&lt;Expression&gt;&lt;Exists&gt;
&lt;ValueExpression&gt;
 &lt;XPathQuery&gt;WsManData/ErrorCode&lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
&lt;/Exists&gt; &lt;/Expression&gt; &lt;/Not&gt;
&lt;/Expression&gt;
&lt;/And&gt;
&lt;/Expression&gt;</pre>
<h2>Class Definition</h2>
<p>With the base composite modules configured, we can move on to the actual application discovery, starting with the definition of the application class.  The Microsoft.Unix.LocalApplication is an ideal base class for the application class, and already has a hosting relationship defined so that Microsoft.Unix.Computer hosts Microsoft.Unix.LocalApplication.</p>
<p><a rel="attachment wp-att-577" href="http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/classdefinition/"></a></p>
<p><a rel="attachment wp-att-578" href="http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/classdefinition-2/"><img class="alignnone size-medium wp-image-578" title="Class Definition" src="http://operatingquadrant.files.wordpress.com/2011/03/classdefinition1-e1300730705273.jpg?w=400&#038;h=397" alt="" width="400" height="397" /></a></p>
<h5>Class Definition:</h5>
<ul>
<li>ID:  MyApp.Monitoring.MyApp</li>
<li>Base Class:  Microsoft.Unix.LocalApplication</li>
<li>Name:  MyApp</li>
</ul>
<h5>Properties:</h5>
<ul>
<li>Name (String) – <em>Key</em></li>
<li>InstallPath (String)</li>
</ul>
<h2>Discovering the Application</h2>
<p>When discovering a Windows application in OpsMgr, we would typically use a registry probe.  In UNIX/Linux application discovery, probing the existence or contents of a file is typically the most effective way to identify the instance of an application.   In this example, the MyApp application has a configuration file named: myapp.conf in the installation path of /opt/myapp.  Thus, a shell command:  ls /opt/myapp/myapp.conf | wc –l would return a 1 if the file exists, or 0 if the file doesn’t exist.   We can use this logic in the application discovery.</p>
<h3>Discovery Data Source: MyApp.Monitoring.DataSource.MyAppDiscovery</h3>
<p>To implement this application discovery, I will create a new data source, building on the ShellCommandDiscovery data source previously created.</p>
<h5>Configuration Parameters:</h5>
<ul>
<li>Interval (integer):  Scheduler interval in seconds</li>
<li>TargetSystem (string):  UNIX/Linux agent computer to execute the discovery</li>
<li>AppPath (string):  File system path to the application, overrideable</li>
</ul>
<h5>Member Modules:</h5>
<p>The first module in this data source is the ShellCommandDiscovery data source (MyApp.Monitoring.DataSource.ShellCommandDiscovery).   This will be used to query the file system for the application configuration file, to determine if the app is present.  The configuration for this module is:</p>
<pre>&lt;Interval&gt;$Config/Interval$&lt;/Interval&gt;
&lt;TargetSystem&gt;$Config/TargetSystem$&lt;/TargetSystem&gt;
&lt;ShellCommand&gt;
 ls $Config/AppPath$/myapp.conf | wc -l
&lt;/ShellCommand&gt;
&lt;Timeout&gt;120&lt;/Timeout&gt;</pre>
<p>In order to return discovery data from this data source, a Discovery Mapper module is required.   In this case, I will use a System.Discovery.FilteredClassSnapshotDataMapper module to filter the results (only return discovery data if the app is found).   An output of 1 from the shell command indicates that the configuration file was found, while an output of 0 indicates that the configuration file was not found.  The configuration for the FilteredClassSnapShotDataMapperModule would be:</p>
<pre>&lt;Expression&gt;
&lt;SimpleExpression&gt;
&lt;ValueExpression&gt;
 &lt;XPathQuery Type="String"&gt;
  //*[local-name()="StdOut"]
 &lt;/XPathQuery&gt;
&lt;/ValueExpression&gt;
&lt;Operator&gt;Equal&lt;/Operator&gt;
&lt;ValueExpression&gt;
 &lt;Value Type="String"&gt;1&lt;/Value&gt;
&lt;/ValueExpression&gt;
&lt;/SimpleExpression&gt;
&lt;/Expression&gt;
&lt;ClassId&gt;
 $MPElement[Name='MyApp.Monitoring.MyApp']$
&lt;/ClassId&gt;
&lt;InstanceSettings&gt;
&lt;Settings&gt;
&lt;Setting&gt;
&lt;Name&gt;
$MPElement[Name='MyApp.Monitoring.MyApp']/Name$
&lt;/Name&gt;
&lt;Value&gt;MyApp&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MyApp.Monitoring.MyApp']/InstallPath$
&lt;/Name&gt;
&lt;Value&gt;$Config/AppPath$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='System!System.Entity']/DisplayName$
&lt;/Name&gt;
&lt;Value&gt;MyApp - $Config/TargetSystem$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;Setting&gt;
&lt;Name&gt;
 $MPElement[Name='MicrosoftUnixLibrary!
 Microsoft.Unix.Computer']/PrincipalName$
&lt;/Name&gt;
&lt;Value&gt;$Config/TargetSystem$&lt;/Value&gt;
&lt;/Setting&gt;
&lt;/Settings&gt;
&lt;/InstanceSettings&gt;</pre>
<p>Note that the Key Property (PrincipalName) for the hosting Microsoft.Unix.Computer object is included in the DiscoveryData.</p>
<h3>Discovery Rule:  MyApp.Monitoring.Discovery.MyApp</h3>
<p>With the discovery data source implemented, finishing the discovery just requires creation of the discovery rule, which targets Microsoft.Unix.Computer objects.</p>
<p><a rel="attachment wp-att-579" href="http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/myappdiscovery/"><img class="alignnone size-medium wp-image-579" title="MyApp Discovery" src="http://operatingquadrant.files.wordpress.com/2011/03/myappdiscovery-e1300731095833.png?w=400&#038;h=396" alt="" width="400" height="396" /></a></p>
<h5>Data Source Configuration:</h5>
<ul>
<li>Interval:  14400</li>
<li>TargetSystem: $Target/Property[Type="MicrosoftUnixLibrary!Microsoft.Unix.Computer"]/PrincipalName$</li>
<li>AppPath: /opt/myapp</li>
</ul>
<p>This is a good time to create the MP’s presentation folder and a state view targeting MyApp objects.   Once the discovery has executed, discovered instances of the app can be viewed in the state view or Discovered Inventory view:</p>
<p><a rel="attachment wp-att-580" href="http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/stateview/"><img class="alignnone size-medium wp-image-580" title="State View" src="http://operatingquadrant.files.wordpress.com/2011/03/stateview-e1300731358443.jpg?w=337&#038;h=339" alt="" width="337" height="339" /></a></p>
<p><em>Stay tuned for more posts on completing this example Management Pack</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/575/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=575&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2011/03/23/operations-manager-extending-unixlinux-monitoring-with-mp-authoring-part-i/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/ref-e1300730156221.jpg?w=400" medium="image">
			<media:title type="html">References</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/classdefinition1-e1300730705273.jpg?w=400" medium="image">
			<media:title type="html">Class Definition</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/myappdiscovery-e1300731095833.png?w=400" medium="image">
			<media:title type="html">MyApp Discovery</media:title>
		</media:content>

		<media:content url="http://operatingquadrant.files.wordpress.com/2011/03/stateview-e1300731358443.jpg?w=400" medium="image">
			<media:title type="html">State View</media:title>
		</media:content>
	</item>
		<item>
		<title>xSNMP Reports 1.1.1 Now Available!</title>
		<link>http://operatingquadrant.com/2010/09/11/xsnmp-reports-1-1-1-now-available/</link>
		<comments>http://operatingquadrant.com/2010/09/11/xsnmp-reports-1-1-1-now-available/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 15:15:38 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[Reporting]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=563</guid>
		<description><![CDATA[The xSNMP Reports version 1.1.1 package is now available at manage-x.net.   This suite of management pack adds value to the xSNMP suite by implementing OpsMgr reports for data collected by performance rules in the xSNMP management packs.   Reporting management packs included are: xSNMP for APC Reports xSNMP for APC NetBotz Reports xSNMP for Brocade Reports [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=563&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The xSNMP Reports version 1.1.1 package is now available at <a href="http://manage-x.net/download.aspx">manage-x.net</a>.   This suite of management pack adds value to the xSNMP suite by implementing OpsMgr reports for data collected by performance rules in the xSNMP management packs.   Reporting management packs included are:</p>
<ul>
<li>xSNMP for APC Reports</li>
<li>xSNMP for APC NetBotz Reports</li>
<li>xSNMP for Brocade Reports</li>
<li>xsNMP for Check Point Secure Platform Reports</li>
<li>xSNMP for Cisco Reports</li>
<li>xSNMP for Data Domain Reports</li>
<li>xSNMP for Dell PowerEdge Reports</li>
<li>xSNMP for HP ProCurve Reports</li>
<li>xSNMP for IBM AIX Reports</li>
<li>xSNMP for Juniper Networks Reports</li>
<li>xSNMP for Juniper-NetScreen Reports</li>
<li>xSNMP for NetApp Reports</li>
<li>xSNMP for Net-SNMP Reports</li>
<li>xSNMP for SonicWALL Reports</li>
</ul>
<p>Requirements are:   OpsMgr 2007 R2, xSNMP suite, OpsMgr reporting implementation.   Like the xSNMP suite, the reports MP&#8217;s are licensed with the GNU-GPL and unsealed versions are provided.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/563/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=563&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2010/09/11/xsnmp-reports-1-1-1-now-available/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>
	</item>
		<item>
		<title>xSNMP Verions 1.1.1(Alpha) Available Now!</title>
		<link>http://operatingquadrant.com/2010/08/30/xsnmp-verions-1-1-1alpha-available-now/</link>
		<comments>http://operatingquadrant.com/2010/08/30/xsnmp-verions-1-1-1alpha-available-now/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 19:54:22 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=560</guid>
		<description><![CDATA[I have posted the 1.1.1 (Alpha) version of the xSNMP suite at manage-x.net.   While the updates in this release are relatively minor in nature, I would still consider this to be an early test copy of this version and deploy in test environments before production.  The abbreviated change log for this release is: New Management [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=560&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have posted the 1.1.1 (Alpha) version of the xSNMP suite at <a href="http://www.manage-x.net/download.aspx">manage-x.net</a>.   While the updates in this release are relatively minor in nature, I would still consider this to be an early test copy of this version and deploy in test environments before production.  The abbreviated change log for this release is:</p>
<p><strong>New Management Packs:</strong></p>
<ul>
<li>xSNMP for APC NetBotz Management Pack</li>
<li>xSNMP for IBM AIX</li>
<li>xSNMP for Juniper Networks Management Pack</li>
<li>xSNMP for SonicWALL Management Pack</li>
</ul>
<p><strong>New Features:</strong></p>
<ul>
<li>Added support for monitoring of Net-SNMP Extend objects (xSNMP for Net-SNMP Management Pack)</li>
<li>Added a three state monitor for Net-SNMP Exec objects(xSNMP for Net-SNMP Management Pack)</li>
<li>New Cisco Firewall Subsystem monitoring for PIX and ASA firewalls</li>
<li>Added new data sources to the xSNMP MP to decrease data source redundancy</li>
<li>Individual inbound/outbound speeds can now be set through the Speed Override discovery in the xSNMP MP</li>
<li>All views are now publically accessible</li>
</ul>
<p><strong>Issues Resolved:</strong></p>
<ul>
<li>Fixed an uncommon issue with network interface utilization calculations<br />
that could result in invalid values being calculated if a previous poll returned null data</li>
<li>Updated the list of Device OID&#8217;s for APC UPS devices to include missing UPS models</li>
<li>Fixed an issue with an incorrect OID specified for HP Proliant SCSI (IDA) storage health monitoring</li>
<li>Fixed an issue with the Cisco Default Gateway Changed alert-generating rule</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/560/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=560&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2010/08/30/xsnmp-verions-1-1-1alpha-available-now/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>
	</item>
		<item>
		<title>Using PowerShell to Check for Syntax Errors in System.ExpressionFilter Modules (OpsMgr Authoring)</title>
		<link>http://operatingquadrant.com/2010/07/17/using-powershell-to-check-for-syntax-errors-in-system-expressionfilter-modules-opsmgr-authoring/</link>
		<comments>http://operatingquadrant.com/2010/07/17/using-powershell-to-check-for-syntax-errors-in-system-expressionfilter-modules-opsmgr-authoring/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 17:43:55 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=554</guid>
		<description><![CDATA[With its wide range of usefulness in implementing conditional logic, expression evaluation, and error filtering, the System.ExpressionFilter module is likely to be a frequently used module in most OpsMgr Management Pack authoring scenarios.   However, the default configuration for the System.ExpressionFilter module may lead to a potential syntax error that is quite easy to miss, in my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=554&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With its wide range of usefulness in implementing conditional logic, expression evaluation, and error filtering, the <a href="http://msdn.microsoft.com/en-us/library/ee692962.aspx">System.ExpressionFilter</a> module is likely to be a frequently used module in most OpsMgr Management Pack authoring scenarios.   However, the default configuration for the System.ExpressionFilter module may lead to a potential syntax error that is quite easy to miss, in my opinion.  This potential syntax error relates to the default configuration of the ValueExpression elements of the ExpressionFilter, in that the ValueExpression defaults to an XPathQuery value type.   If this default is not changed when evaluating a non-XPathQuery value, the workflow (as well as all workflows cooked down with the faulted workflow) will fail.</p>
<p>To illustrate an oversight resulting in this error, the following ExpressionFilter configuration would result in a workflow failure:</p>
<blockquote><p>&lt;SimpleExpression&gt;<br />
   &lt;ValueExpression&gt;<br />
        &lt;XPathQuery&gt;ErrorCode&lt;/XPathQuery&gt;<br />
   &lt;/ValueExpression&gt;<br />
   &lt;Operator&gt;Equal&lt;/Operator&gt;<br />
   &lt;ValueExpression&gt;<br />
       &lt;<strong>XPathQuer</strong>y&gt;1&lt;/<strong>XPathQuery</strong>&gt;<br />
    &lt;/ValueExpression&gt;<br />
&lt;/SimpleExpression&gt;</p></blockquote>
<p>The correct implementation of this Expression Filter module would be:</p>
<blockquote><p>&lt;SimpleExpression&gt;<br />
   &lt;ValueExpression&gt;<br />
        &lt;XPathQuery&gt;ErrorCode&lt;/XPathQuery&gt;<br />
   &lt;/ValueExpression&gt;<br />
   &lt;Operator&gt;Equal&lt;/Operator&gt;<br />
   &lt;ValueExpression&gt;<br />
       &lt;<strong>Value</strong>&gt;1&lt;/<strong>Value</strong>&gt;<br />
    &lt;/ValueExpression&gt;<br />
&lt;/SimpleExpression&gt;</p></blockquote>
<p>Unfortunately, this type of error is not caught by the MPBPA, most likely due to the difficulty in differentiating between a valid XPathQuery value and string value.  To perform some basic error checking to identify these errors when authoring, I have written a simple PowerShell script that analyzes the XML of an unsealed Management Pack and reports errors and potential errors with ValueExpression configuration in ExpressionFilter modules.  </p>
<p>The logic of the script assumes the following:</p>
<ul>
<li>Any ValueExpression configured as an XPathQuery expression and having a value that starts with a dollar sign ($) can be assumed to be a configuration error</li>
<li>Any ValueExpression configured as an XPathQuery expression and having a value that does not start with a forward slash or the strings:  Property or ErrorCode might be misconfigured</li>
</ul>
<p>The script accepts the path to the Management Pack XML file as the single input parameter and then searches the XML for RegExExpression, SimpleExpression, and DayTimeExpression XML nodes.  These nodes are evaluated for mismatches on XPathQuery expressions and mismatches are reported to the console.</p>
<p>The output of the script looks like:</p>
<blockquote><p>PS D:\Development\SCOM&gt; ./checkexpressionfilters.ps1 -MPFIle:&#8221;d:\development\scom\xsnmp\1.1.Dev\xSNMP.AIX.xml&#8221;<br />
Evaluating d:\development\scom\xsnmp\1.1.Dev\xSNMP.AIX.xml </p>
<p>Error &#8211; Found mismatched XPathQuery value with XML:<br />
&lt;XPathQuery&gt;$Target/Property[Type="xSNMP.AIX.Processor"]/Name$&lt;/XPathQuery&gt; </p>
<p>Error &#8211; Found mismatched XPathQuery value with XML:<br />
&lt;XPathQuery&gt;$Target/Property[Type="xSNMP.AIX.Processor"]/Name$&lt;/XPathQuery&gt; </p>
<p>Errors found: 2<br />
Warnings found: 0</p></blockquote>
<p>The script can be downloaded <a href="http://operatingquadrant.com/downloads/">here</a>.</p>
<p><span id="more-554"></span></p>
<p>The body of the script is:</p>
<blockquote><p>Param([string]$MPFile)</p>
<p>[xml]$XMLData = Get-Content $MPFile<br />
write-host &#8220;Evaluating $MPFile&#8221;<br />
write-host  &#8220;&#8221;<br />
 <br />
$ErrorCount=0<br />
$WarningCount=0<br />
$Nodes = $XMLData.SelectNodes(&#8220;//RegExExpression&#8221;)<br />
$Nodes| ForEach-Object{<br />
 $XPathExpressions = $_.SelectNodes(&#8220;.//XPathQuery&#8221;)<br />
 $XPathExpressions | ForEach-Object{<br />
  $ExpressionText = $_.InnerText<br />
  if([string]$ExpressionText.Substring(0,1) -eq [string]&#8220;$&#8221;){<br />
   [String]$OuterXML = $_.OuterXML<br />
   $ErrorCount += 1<br />
   $sMesg = &#8220;Error &#8211; Found mismatched XPathQuery value with XML: &#8221; `<br />
   + [environment]::NewLine + $OuterXML + [environment]::NewLine<br />
   write-host $sMesg<br />
  }<br />
  <br />
  if(($ExpressionText.Substring(0,1) -ne &#8220;/&#8221;) `<br />
   -and ($ExpressionText.Substring(0,8) -ne &#8220;Property&#8221;) `<br />
   -and ($ExpressionText.Substring(0,1) -ne &#8220;$&#8221;) `<br />
   -and ($ExpressionText.Substring(0,9) -ne &#8220;ErrorCode&#8221;)){<br />
   [String]$OuterXML = $_.OuterXML<br />
   $WarningCount += 1<br />
   $sMesg = &#8220;Warning &#8211; Found mismatched XPathQuery value with XML: &#8221; `<br />
   + [environment]::NewLine + $OuterXML + [environment]::NewLine<br />
   write-host $sMesg<br />
  }<br />
 }<br />
}</p>
<p>$Nodes = $XMLData.SelectNodes(&#8220;//SimpleExpression&#8221;)<br />
$Nodes| ForEach-Object{<br />
 $XPathExpressions = $_.SelectNodes(&#8220;.//XPathQuery&#8221;)<br />
 $XPathExpressions | ForEach-Object{<br />
  $ExpressionText = $_.InnerText<br />
  if([string]$ExpressionText.Substring(0,1) -eq [string]&#8220;$&#8221;){<br />
   [String]$OuterXML = $_.OuterXML<br />
   $ErrorCount += 1<br />
   $sMesg = &#8220;Error &#8211; Found mismatched XPathQuery value with XML: &#8221; `<br />
   + [environment]::NewLine + $OuterXML + [environment]::NewLine<br />
   write-host $sMesg<br />
  }<br />
  <br />
  if(($ExpressionText.Substring(0,1) -ne &#8220;/&#8221;) `<br />
   -and ($ExpressionText.Substring(0,8) -ne &#8220;Property&#8221;) `<br />
   -and ($ExpressionText.Substring(0,1) -ne &#8220;$&#8221;) `<br />
   -and ($ExpressionText.Substring(0,9) -ne &#8220;ErrorCode&#8221;)){<br />
   [String]$OuterXML = $_.OuterXML<br />
   $WarningCount += 1<br />
   $sMesg = &#8220;Warning &#8211; Found mismatched XPathQuery value with XML: &#8221; `<br />
   + [environment]::NewLine + $OuterXML + [environment]::NewLine<br />
   write-host $sMesg<br />
  }<br />
 }<br />
}</p>
<p>$Nodes = $XMLData.SelectNodes(&#8220;//DayTimeExpression&#8221;)<br />
$Nodes| ForEach-Object{<br />
 $XPathExpressions = $_.SelectNodes(&#8220;.//XPathQuery&#8221;)<br />
 $XPathExpressions | ForEach-Object{<br />
  $ExpressionText = $_.InnerText<br />
  if([string]$ExpressionText.Substring(0,1) -eq [string]&#8220;$&#8221;){<br />
   [String]$OuterXML = $_.OuterXML<br />
   $ErrorCount += 1<br />
   $sMesg = &#8220;Error &#8211; Found mismatched XPathQuery value with XML: &#8221; `<br />
   + [environment]::NewLine + $OuterXML + [environment]::NewLine<br />
   write-host $sMesg<br />
  }<br />
  <br />
  if(($ExpressionText.Substring(0,1) -ne &#8220;/&#8221;) `<br />
   -and ($ExpressionText.Substring(0,8) -ne &#8220;Property&#8221;) `<br />
   -and ($ExpressionText.Substring(0,1) -ne &#8220;$&#8221;) `<br />
   -and ($ExpressionText.Substring(0,9) -ne &#8220;ErrorCode&#8221;)){<br />
   [String]$OuterXML = $_.OuterXML<br />
   $WarningCount += 1<br />
   $sMesg = &#8220;Warning &#8211; Found mismatched XPathQuery value with XML: &#8221; `<br />
   + [environment]::NewLine + $OuterXML + [environment]::NewLine<br />
   write-host $sMesg<br />
  }<br />
 }<br />
}<br />
Write-Host &#8220;Errors found: $ErrorCount&#8221;<br />
Write-Host &#8220;Warnings found: $WarningCount&#8221;</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/554/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=554&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2010/07/17/using-powershell-to-check-for-syntax-errors-in-system-expressionfilter-modules-opsmgr-authoring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>
	</item>
		<item>
		<title>Development Updates</title>
		<link>http://operatingquadrant.com/2010/07/13/development-updates/</link>
		<comments>http://operatingquadrant.com/2010/07/13/development-updates/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 02:23:21 +0000</pubDate>
		<dc:creator>Kristopher Bash</dc:creator>
				<category><![CDATA[Management Packs]]></category>
		<category><![CDATA[SCX]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[System Center Operations Manager]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://operatingquadrant.com/?p=551</guid>
		<description><![CDATA[While this blog has been a bit quiet lately, it has not been for lack of efforts.   In the next two weeks, a minor update to the xSNMP suite should be ready with a few bug-fixes and feature improvements.    This update will also include three new management packs: xSNMP  for Juniper Networks xSNMP for SonicWALL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=551&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While this blog has been a bit quiet lately, it has not been for lack of efforts.   In the next two weeks, a minor update to the xSNMP suite should be ready with a few bug-fixes and feature improvements.    This update will also include three new management packs:</p>
<ul>
<li>xSNMP  for Juniper Networks</li>
<li>xSNMP for SonicWALL</li>
<li>xSNMP for APC NetBotz</li>
</ul>
<p>We&#8217;re still finishing up testing and fine-tuning on the Oracle Unix/Linux MP as well.</p>
<p>These updates will be described in more detail here and available for download on <em>manage-X.net</em> soon.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/operatingquadrant.wordpress.com/551/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/operatingquadrant.wordpress.com/551/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/operatingquadrant.wordpress.com/551/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/operatingquadrant.wordpress.com/551/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/operatingquadrant.wordpress.com/551/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/operatingquadrant.wordpress.com/551/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/operatingquadrant.wordpress.com/551/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/operatingquadrant.wordpress.com/551/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=operatingquadrant.com&amp;blog=8969466&amp;post=551&amp;subd=operatingquadrant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://operatingquadrant.com/2010/07/13/development-updates/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26f47dda05ea2d756f1f83f1164605aa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">KB</media:title>
		</media:content>
	</item>
	</channel>
</rss>
