<ManagementPack ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <Manifest>
    <Identity>
      <ID>MPAuthor.NetworkDevices</ID>
      <Version>1.0.0.1</Version>
    </Identity>
    <Name>MPAuthor.NetworkDevices</Name>
    <References>
      <Reference Alias="SCDW">
        <ID>Microsoft.SystemCenter.DataWarehouse.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="SC">
        <ID>Microsoft.SystemCenter.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Network">
        <ID>Microsoft.SystemCenter.NetworkDevice.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Windows">
        <ID>Microsoft.Windows.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="AppLog">
        <ID>System.ApplicationLog.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Hardware">
        <ID>System.Hardware.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Health">
        <ID>System.Health.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="System">
        <ID>System.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Snmp">
        <ID>System.Snmp.Library</ID>
        <Version>6.1.7221.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <TypeDefinitions>
    <EntityTypes>
      <ClassTypes>
        <ClassType ID="MPAuthor.NetworkDevices.NetworkDevice" Accessibility="Internal" Abstract="true" Base="Hardware!System.HardwareComponent" Hosted="false" Singleton="false">
          <Property ID="IPAddress" Type="string" Key="true" CaseSensitive="false" Length="256" MinLength="0" />
          <Property ID="Name" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" />
        </ClassType>
        <ClassType ID="MPAuthor.NetworkDevices.NetworkDevice.TypeA" Accessibility="Internal" Abstract="false" Base="MPAuthor.NetworkDevices.NetworkDevice" Hosted="false" Singleton="false" />
        <ClassType ID="MPAuthor.NetworkDevices.NetworkDevice.TypeB" Accessibility="Internal" Abstract="false" Base="MPAuthor.NetworkDevices.NetworkDevice" Hosted="false" Singleton="false" />
        <ClassType ID="MPAuthor.NetworkDevices.NetworkDevice.TypeC" Accessibility="Internal" Abstract="false" Base="MPAuthor.NetworkDevices.NetworkDevice" Hosted="false" Singleton="false" />
        <ClassType ID="MPAuthor.NetworkDevices.Proxy" Accessibility="Internal" Abstract="false" Base="Windows!Microsoft.Windows.ComputerRole" Hosted="true" Singleton="false">
          <Property ID="ConfigFile" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" />
        </ClassType>
        <ClassType ID="MPAuthor.NetworkDevices.SNMPDevice.TypeA" Accessibility="Internal" Abstract="false" Base="Network!Microsoft.SystemCenter.NetworkDevice" Hosted="false" Singleton="false" />
        <ClassType ID="MPAuthor.NetworkDevices.SNMPDevice.TypeB" Accessibility="Internal" Abstract="false" Base="Network!Microsoft.SystemCenter.NetworkDevice" Hosted="false" Singleton="false" />
        <ClassType ID="MPAuthor.NetworkDevices.SNMPDevice.TypeC" Accessibility="Internal" Abstract="false" Base="Network!Microsoft.SystemCenter.NetworkDevice" Hosted="false" Singleton="false" />
      </ClassTypes>
    </EntityTypes>
  </TypeDefinitions>
  <Monitoring>
    <Discoveries>
      <Discovery ID="MPAuthor.NetworkDevices.Discovery.NetworkDevices" Enabled="true" Target="MPAuthor.NetworkDevices.Proxy" ConfirmDelivery="true" Remotable="true" Priority="Normal">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryClass TypeID="MPAuthor.NetworkDevices.NetworkDevice" />
        </DiscoveryTypes>
        <DataSource ID="PSScript" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
          <IntervalSeconds>3600</IntervalSeconds>
          <SyncTime />
          <ScriptName>DiscoverNetworkDevices.ps1</ScriptName>
          <ScriptBody><![CDATA[
#
# Name:			DiscoverNetworkDevices.ps1
# Written by:	Brian Wren, Microsoft
# Date: 		April 27, 2010
# Function:		Discovers network devices from text file in the following format:  Name,IP Address,Type
#				The type of each device specified in the text file must be included in the script to determine the class of device to create.
#				

# Accept parameters defined below the script.
param($sourceId,$managedEntityId,$configFile,$proxyComputer)

# Create API object and discovery data object
$api = New-Object -comObject 'MOM.ScriptAPI' 
$api.LogScriptEvent('DiscoverNetworkDevices.ps1',810,4,$configFile + ' ' + $proxyComputer)
$discoveryData = $api.CreateDiscoveryData(0,$sourceId,$managedEntityId) 

# Create health service instance for the proxy computer.  This will be used as the source in the relationship to ensure that agent on proxy agent manages the discovered instances.
$healthServiceInstance = $discoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$" )
$healthServiceInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $proxyComputer)
$discoveryData.AddInstance($healthServiceInstance) 

# Step through each line in the config file.
foreach($line in gc($configFile))
{
	# Parse the line to gather each required piece of data.
    $arr = $line.split(',')
    $name = $arr[0]
    $ip = $arr[1]
    $type = $arr[2]

	# Create an instance of the class corresponding to the type specified in the config file.
    $api.LogScriptEvent('DiscoverNetworkDevices.ps1',811,4,$name + ' ' + $ip + ' ' + $type)    
    switch($type.toLower())
    {   
        'TypeA' {$instance = $discoveryData.CreateClassInstance("$MPElement[Name='MPAuthor.NetworkDevices.NetworkDevice.TypeA']$")}
        'TypeB' {$instance = $discoveryData.CreateClassInstance("$MPElement[Name='MPAuthor.NetworkDevices.NetworkDevice.TypeB']$")}
        'TypeC' {$instance = $discoveryData.CreateClassInstance("$MPElement[Name='MPAuthor.NetworkDevices.NetworkDevice.TypeC']$")}
    }    
  
    # Add values for the IP Address and Name to the class instance and add it to the discovery data.
	$instance.AddProperty("$MPElement[Name='MPAuthor.NetworkDevices.NetworkDevice']/IPAddress$",$ip)
    $instance.AddProperty("$MPElement[Name='MPAuthor.NetworkDevices.NetworkDevice']/Name$",$name)    
    $discoveryData.AddInstance($instance) 
    
    # Create an instance of the HealthServiceShouldManageEntity class.  This ensures that the target instance (the discovered network device) is managed on the agent of the source (the proxy computer).
	$healthServiceRelationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
    $healthServiceRelationship.Source = $healthServiceInstance
    $healthServiceRelationship.Target = $instance
    $discoveryData.AddInstance($healthServiceRelationship)
    
}
# Submit the discovery data.
$discoveryData
]]></ScriptBody>
          <Parameters>
            <Parameter>
              <Name>sourceId</Name>
              <Value>$MPElement$</Value>
            </Parameter>
            <Parameter>
              <Name>managedEntityId</Name>
              <Value>$Target/Id$</Value>
            </Parameter>
            <Parameter>
              <Name>configFile</Name>
              <Value>$Target/Property[Type="MPAuthor.NetworkDevices.Proxy"]/ConfigFile$</Value>
            </Parameter>
            <Parameter>
              <Name>proxyComputer</Name>
              <Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</Value>
            </Parameter>
          </Parameters>
          <TimeoutSeconds>30</TimeoutSeconds>
        </DataSource>
      </Discovery>
      <Discovery ID="MPAuthor.NetworkDevices.Discovery.Proxy" Enabled="true" Target="Windows!Microsoft.Windows.OperatingSystem" ConfirmDelivery="false" Remotable="true" Priority="Normal">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryClass TypeID="MPAuthor.NetworkDevices.Proxy" />
        </DiscoveryTypes>
        <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.FilteredRegistryDiscoveryProvider">
          <ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
          <RegistryAttributeDefinitions>
            <RegistryAttributeDefinition>
              <AttributeName>ProxyExists</AttributeName>
              <Path>SOFTWARE\MPAuthor\NetworkDevices</Path>
              <PathType>0</PathType>
              <AttributeType>0</AttributeType>
            </RegistryAttributeDefinition>
            <RegistryAttributeDefinition>
              <AttributeName>ConfigFile</AttributeName>
              <Path>SOFTWARE\MPAuthor\NetworkDevices\ConfigFile</Path>
              <PathType>1</PathType>
              <AttributeType>1</AttributeType>
            </RegistryAttributeDefinition>
          </RegistryAttributeDefinitions>
          <Frequency>3600</Frequency>
          <ClassId>$MPElement[Name="MPAuthor.NetworkDevices.Proxy"]$</ClassId>
          <InstanceSettings>
            <Settings>
              <Setting>
                <Name>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Name>
                <Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
              </Setting>
              <Setting>
                <Name>$MPElement[Name="MPAuthor.NetworkDevices.Proxy"]/ConfigFile$</Name>
                <Value>$Data/Values/ConfigFile$</Value>
              </Setting>
            </Settings>
          </InstanceSettings>
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="String">Values/ProxyExists</XPathQuery>
              </ValueExpression>
              <Operator>Equal</Operator>
              <ValueExpression>
                <Value Type="String">true</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
        </DataSource>
      </Discovery>
      <Discovery ID="MPAuthor.NetworkDevices.Discovery.SNMPDevices" Enabled="true" Target="Network!Microsoft.SystemCenter.NetworkDevice" ConfirmDelivery="true" Remotable="true" Priority="Normal">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryClass TypeID="MPAuthor.NetworkDevices.SNMPDevice.TypeA" />
        </DiscoveryTypes>
        <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
          <IntervalSeconds>3600</IntervalSeconds>
          <SyncTime />
          <ScriptName>DiscoverNetworkDevicesFromSNMP.ps1</ScriptName>
          <ScriptBody><![CDATA[
#
# Name:			DiscoverSNMPDevices.ps1
# Written by:	Brian Wren, Microsoft
# Date: 		April 27, 2010
# Function:		Discovers the type of SNMP device based on the name of the device.
#				The type of each device specified in the name field must be included in the script to determine the class of device to create.
#				

# Accept parameters defined below the script.
param($sourceId,$managedEntityId,$IPAddress,$Name)

# Create API object and discovery data object
$api = New-Object -comObject 'MOM.ScriptAPI' 
$api.LogScriptEvent('DiscoverSNMPDevices.ps1',809,4,'IP: ' + $IPAddress + '  Name: ' + $Name)
$discoveryData = $api.CreateDiscoveryData(0,$sourceId,$managedEntityId) 

# Create health service instance for the proxy computer.  This will be used as the source in the relationship to ensure that agent on proxy agent manages the discovered instances.
$computer = get-wmiobject -namespace root\cimv2 -class win32_computersystem
$proxyComputer = $computer.name + '.' + $computer.domain
$healthServiceInstance = $discoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$" )
$healthServiceInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $proxyComputer)
$discoveryData.AddInstance($healthServiceInstance) 

# Create an instance of the class corresponding to the value in the device's name field.
switch($name.toLower())
{   
	'TypeA' {$instance = $discoveryData.CreateClassInstance("$MPElement[Name='MPAuthor.NetworkDevices.SNMPDevice.TypeA']$")}
	'TypeB' {$instance = $discoveryData.CreateClassInstance("$MPElement[Name='MPAuthor.NetworkDevices.SNMPDevice.TypeB']$")}
	'TypeC' {$instance = $discoveryData.CreateClassInstance("$MPElement[Name='MPAuthor.NetworkDevices.SNMPDevice.TypeC']$")}
}    

# Add value for the IP Address to the class instance and add it to the discovery data.
$instance.AddProperty("$MPElement[Name='Network!Microsoft.SystemCenter.NetworkDevice']/IPAddress$",$IPAddress)
$discoveryData.AddInstance($instance) 

# Create an instance of the HealthServiceShouldManageEntity class.  This ensures that the target instance (the discovered network device) is managed on the agent of the source (the proxy computer).
$healthServiceRelationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
$healthServiceRelationship.Source = $healthServiceInstance
$healthServiceRelationship.Target = $instance
$discoveryData.AddInstance($healthServiceRelationship)

# Submit the discovery data.
$discoveryData
]]></ScriptBody>
          <Parameters>
            <Parameter>
              <Name>sourceId</Name>
              <Value>$MPElement$</Value>
            </Parameter>
            <Parameter>
              <Name>managedEntityId</Name>
              <Value>$Target/Id$</Value>
            </Parameter>
            <Parameter>
              <Name>IPAddress</Name>
              <Value>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</Value>
            </Parameter>
            <Parameter>
              <Name>Name</Name>
              <Value>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/Name$</Value>
            </Parameter>
          </Parameters>
          <TimeoutSeconds>30</TimeoutSeconds>
        </DataSource>
      </Discovery>
    </Discoveries>
    <Rules>
      <Rule ID="MPAuthor.NetworkDevices.Rule.CollectSNMPTraps" Enabled="true" Target="Network!Microsoft.SystemCenter.NetworkDevice" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
        <Category>EventCollection</Category>
        <DataSources>
          <DataSource ID="DS" TypeID="Snmp!System.SnmpTrapEventProvider">
            <IP>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</IP>
            <CommunityString>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/CommunityString$</CommunityString>
            <AllTraps>true</AllTraps>
            <Version>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/Version$</Version>
            <OIDProps />
            <EventOriginId>$Target/Id$</EventOriginId>
            <PublisherId>$Target/Id$</PublisherId>
            <PublisherName>Snmp Event</PublisherName>
            <Channel>SnmpEvent</Channel>
            <LoggingComputer />
            <EventNumber>1501</EventNumber>
            <EventCategory>5</EventCategory>
            <EventLevel>10</EventLevel>
            <UserName />
            <Params />
          </DataSource>
        </DataSources>
        <WriteActions>
          <WriteAction ID="WriteToDB" TypeID="SC!Microsoft.SystemCenter.CollectEvent" />
          <WriteAction ID="WriteToDW" TypeID="SCDW!Microsoft.SystemCenter.DataWarehouse.PublishEventData" />
        </WriteActions>
      </Rule>
      <Rule ID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Error" Enabled="true" Target="MPAuthor.NetworkDevices.NetworkDevice.TypeA" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
        <Category>Alert</Category>
        <DataSources>
          <DataSource ID="SyslogDS" TypeID="AppLog!System.ApplicationLog.SysLog.FilteredEventProvider">
            <Port>514</Port>
            <Expression>
              <And>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">HostName</XPathQuery>
                    </ValueExpression>
                    <Operator>Equal</Operator>
                    <ValueExpression>
                      <Value Type="String">$Target/Property[Type="MPAuthor.NetworkDevices.NetworkDevice"]/IPAddress$</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">Severity</XPathQuery>
                    </ValueExpression>
                    <Operator>LessEqual</Operator>
                    <ValueExpression>
                      <Value Type="String">3</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
              </And>
            </Expression>
          </DataSource>
        </DataSources>
        <WriteActions>
          <WriteAction ID="Alert" TypeID="Health!System.Health.GenerateAlert">
            <Priority>1</Priority>
            <Severity>2</Severity>
            <AlertOwner />
            <AlertMessageId>$MPElement[Name="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Error.AlertMessage"]$</AlertMessageId>
            <AlertParameters>
              <AlertParameter1>$Data/EventData/DataItem/Facility$</AlertParameter1>
              <AlertParameter2>$Data/EventData/DataItem/Severity$</AlertParameter2>
              <AlertParameter3>$Data/EventData/DataItem/Priority$</AlertParameter3>
              <AlertParameter4>$Data/EventData/DataItem/PriorityName$</AlertParameter4>
              <AlertParameter5>$Data/EventData/DataItem/TimeStamp$</AlertParameter5>
              <AlertParameter6>$Data/EventData/DataItem/HostName$</AlertParameter6>
              <AlertParameter7>$Data/EventData/DataItem/Message$</AlertParameter7>
            </AlertParameters>
            <Suppression>
              <SuppressionValue>$Data/EventData/DataItem/HostName$ </SuppressionValue>
              <SuppressionValue>$Data/EventData/DataItem/Message$ </SuppressionValue>
            </Suppression>
            <Custom1 />
            <Custom2 />
            <Custom3 />
            <Custom4 />
            <Custom5 />
            <Custom6 />
            <Custom7 />
            <Custom8 />
            <Custom9 />
            <Custom10 />
          </WriteAction>
        </WriteActions>
      </Rule>
      <Rule ID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Warning" Enabled="true" Target="MPAuthor.NetworkDevices.NetworkDevice.TypeA" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
        <Category>Alert</Category>
        <DataSources>
          <DataSource ID="SyslogDS" TypeID="AppLog!System.ApplicationLog.SysLog.FilteredEventProvider">
            <Port>514</Port>
            <Expression>
              <And>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">HostName</XPathQuery>
                    </ValueExpression>
                    <Operator>Equal</Operator>
                    <ValueExpression>
                      <Value Type="String">$Target/Property[Type="MPAuthor.NetworkDevices.NetworkDevice"]/IPAddress$</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">Severity</XPathQuery>
                    </ValueExpression>
                    <Operator>LessEqual</Operator>
                    <ValueExpression>
                      <Value Type="String">5</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">Severity</XPathQuery>
                    </ValueExpression>
                    <Operator>GreaterEqual</Operator>
                    <ValueExpression>
                      <Value Type="String">4</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
              </And>
            </Expression>
          </DataSource>
        </DataSources>
        <WriteActions>
          <WriteAction ID="Alert" TypeID="Health!System.Health.GenerateAlert">
            <Priority>1</Priority>
            <Severity>1</Severity>
            <AlertOwner />
            <AlertMessageId>$MPElement[Name="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Warning.AlertMessage"]$</AlertMessageId>
            <AlertParameters>
              <AlertParameter1>$Data/EventData/DataItem/Facility$</AlertParameter1>
              <AlertParameter2>$Data/EventData/DataItem/Severity$</AlertParameter2>
              <AlertParameter3>$Data/EventData/DataItem/Priority$</AlertParameter3>
              <AlertParameter4>$Data/EventData/DataItem/PriorityName$</AlertParameter4>
              <AlertParameter5>$Data/EventData/DataItem/TimeStamp$</AlertParameter5>
              <AlertParameter6>$Data/EventData/DataItem/HostName$</AlertParameter6>
              <AlertParameter7>$Data/EventData/DataItem/Message$</AlertParameter7>
            </AlertParameters>
            <Suppression>
              <SuppressionValue>$Data/EventData/DataItem/HostName$ </SuppressionValue>
              <SuppressionValue>$Data/EventData/DataItem/Message$ </SuppressionValue>
            </Suppression>
            <Custom1 />
            <Custom2 />
            <Custom3 />
            <Custom4 />
            <Custom5 />
            <Custom6 />
            <Custom7 />
            <Custom8 />
            <Custom9 />
            <Custom10 />
          </WriteAction>
        </WriteActions>
      </Rule>
      <Rule ID="MPAuthor.NetworkDevices.Rule.TypeA.Collection" Enabled="false" Target="MPAuthor.NetworkDevices.NetworkDevice.TypeA" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
        <Category>EventCollection</Category>
        <DataSources>
          <DataSource ID="SyslogDS" TypeID="AppLog!System.ApplicationLog.SysLog.FilteredEventProvider">
            <Port>514</Port>
            <Expression>
              <And>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">HostName</XPathQuery>
                    </ValueExpression>
                    <Operator>Equal</Operator>
                    <ValueExpression>
                      <Value Type="String">$Target/Property[Type="MPAuthor.NetworkDevices.NetworkDevice"]/IPAddress$</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
                <Expression>
                  <SimpleExpression>
                    <ValueExpression>
                      <XPathQuery Type="String">Severity</XPathQuery>
                    </ValueExpression>
                    <Operator>GreaterEqual</Operator>
                    <ValueExpression>
                      <Value Type="String">6</Value>
                    </ValueExpression>
                  </SimpleExpression>
                </Expression>
              </And>
            </Expression>
          </DataSource>
        </DataSources>
        <WriteActions>
          <WriteAction ID="WriteToDB" TypeID="SC!Microsoft.SystemCenter.CollectEvent" />
          <WriteAction ID="WriteToDW" TypeID="SCDW!Microsoft.SystemCenter.DataWarehouse.PublishEventData" />
        </WriteActions>
      </Rule>
    </Rules>
    <Monitors>
      <UnitMonitor ID="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af" Accessibility="Public" Enabled="true" Target="MPAuthor.NetworkDevices.SNMPDevice.TypeA" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Snmp!System.SnmpProbe.2SingleEvent2StateMonitorType" ConfirmDelivery="false">
        <Category>Custom</Category>
        <AlertSettings AlertMessage="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af_AlertMessageResourceID">
          <AlertOnState>Warning</AlertOnState>
          <AutoResolve>true</AutoResolve>
          <AlertPriority>Normal</AlertPriority>
          <AlertSeverity>Error</AlertSeverity>
          <AlertParameters>
            <AlertParameter1>$Data/DataItem/SnmpVarBinds/SnmpVarBind[1]/Value$</AlertParameter1>
          </AlertParameters>
        </AlertSettings>
        <OperationalStates>
          <OperationalState ID="UIGeneratedOpStateIde08ef1a3b3424f40a7e992e2e73d52e7" MonitorTypeStateID="SecondEventRaised" HealthState="Success" />
          <OperationalState ID="UIGeneratedOpStateId25b06cff2c7641519dfd6acb71fa8f0b" MonitorTypeStateID="FirstEventRaised" HealthState="Warning" />
        </OperationalStates>
        <Configuration>
          <FirstInterval>120</FirstInterval>
          <FirstIsWriteAction>false</FirstIsWriteAction>
          <FirstIP>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</FirstIP>
          <FirstCommunityString>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/CommunityString$</FirstCommunityString>
          <FirstVersion>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/Version$</FirstVersion>
          <FirstSnmpVarBinds>
            <SnmpVarBind>
              <OID>1.3.6.1.4.1.16174.1.1.1.3.1.2.0</OID>
              <Syntax>0</Syntax>
              <Value VariantType="8" />
            </SnmpVarBind>
          </FirstSnmpVarBinds>
          <FirstExpression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="String">DataItem/SnmpVarBinds/SnmpVarBind[1]/Value</XPathQuery>
              </ValueExpression>
              <Operator>GreaterEqual</Operator>
              <ValueExpression>
                <Value Type="String">20</Value>
              </ValueExpression>
            </SimpleExpression>
          </FirstExpression>
          <SecondInterval>120</SecondInterval>
          <SecondIsWriteAction>false</SecondIsWriteAction>
          <SecondIP>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</SecondIP>
          <SecondCommunityString>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/CommunityString$</SecondCommunityString>
          <SecondVersion>$Target/Property[Type="Network!Microsoft.SystemCenter.NetworkDevice"]/Version$</SecondVersion>
          <SecondSnmpVarBinds>
            <SnmpVarBind>
              <OID>1.3.6.1.4.1.16174.1.1.1.3.1.2.0</OID>
              <Syntax>0</Syntax>
              <Value VariantType="8" />
            </SnmpVarBind>
          </SecondSnmpVarBinds>
          <SecondExpression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="String">DataItem/SnmpVarBinds/SnmpVarBind[1]/Value</XPathQuery>
              </ValueExpression>
              <Operator>Less</Operator>
              <ValueExpression>
                <Value Type="String">20</Value>
              </ValueExpression>
            </SimpleExpression>
          </SecondExpression>
        </Configuration>
      </UnitMonitor>
    </Monitors>
  </Monitoring>
  <Presentation>
    <Views>
      <View ID="MPAuthor.NetworkDevices.View.NetworkDevices" Accessibility="Internal" Enabled="true" Target="MPAuthor.NetworkDevices.NetworkDevice" TypeID="SC!Microsoft.SystemCenter.StateViewType" Visible="true">
        <Category>StateCollection</Category>
        <Criteria />
      </View>
      <View ID="MPAuthor.NetworkDevices.View.Proxy" Accessibility="Internal" Enabled="true" Target="MPAuthor.NetworkDevices.Proxy" TypeID="SC!Microsoft.SystemCenter.StateViewType" Visible="true">
        <Category>StateCollection</Category>
        <Criteria />
      </View>
    </Views>
    <Folders>
      <Folder ID="MPAuthor.NetworkDevices.NetworkDevices" Accessibility="Internal" ParentFolder="SC!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
    </Folders>
    <FolderItems>
      <FolderItem ElementID="MPAuthor.NetworkDevices.View.NetworkDevices" Folder="MPAuthor.NetworkDevices.NetworkDevices" />
      <FolderItem ElementID="MPAuthor.NetworkDevices.View.Proxy" Folder="MPAuthor.NetworkDevices.NetworkDevices" />
    </FolderItems>
    <StringResources>
      <StringResource ID="MomUIGeneratedRule6a23ebaee42d4411a0d50c0606b8ef84.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.Syslog.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.SyslogOS.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Error.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Warning.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.TypeB.Alert.Error.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.TypeB.Alert.Warning.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.TypeC.Alert.Error.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.Rule.TypeC.Alert.Warning.AlertMessage" />
      <StringResource ID="MPAuthor.NetworkDevices.SimpleAlert.AlertMessage" />
      <StringResource ID="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af_AlertMessageResourceID" />
    </StringResources>
  </Presentation>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="MPAuthor.NetworkDevices">
          <Name>MPAuthor Sample - Network Devices</Name>
          <Description>This management pack provides an example of monitoring network devices.  This includes providing custom monitoring for different brands of SNMP devices and monitoring Syslog mesages from devices that do not support SNMP.

A class is created for each type of SNMP device based on Microsoft.SystemCenter.NetworkDevice.  This provides a target for monitors and rules specific to each type.  For devices that do not support SNMP, a class is created based on System.HardwareComponent.  A device for each type of device is created based on this class that provides the target for monitors and rules specific to that type.

Discovery for SNMP devices is targeted at Microsoft.SystemCenter.NetworkDevice since this represents network devices that have already been discovered.  The name of the target is used to determine the type of device and which class should be created.  Discovery for devices not supporting SNMP is performed from a text log that lists the Name, IP Address, and Type for each device to discover.  This discovery is targeted at a proxy agent that is discovered from a registry key at HKLM\SOFTWARE\MPAuthor\NetworkDevices.  This registry key must also contain a value called ConfigFIle that contains a path to the configuration file.

The classes for the devices are all unhosted.  Unhosted object are typically managed on the RMS, but the discovery scripts create a special containment relationship that causes the object to be managed on the proxy agent.  Any monitors or rules targeted at these classes are loaded on the agent computer.  The managed devices should be configured to send SNMP traps and Syslog messages to the proxy agent.</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Discovery.NetworkDevices">
          <Name>MPAuthor Discover Network Devices</Name>
          <Description />
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Discovery.Proxy">
          <Name>MMS Network Proxy</Name>
          <Description />
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Discovery.SNMPDevices">
          <Name>Discover MMS SNMP Devices</Name>
          <Description />
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevice">
          <Name>MPAuthor Network Device</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevice" SubElementID="IPAddress">
          <Name>IP Address</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevice" SubElementID="Name">
          <Name>Name</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevice.TypeA">
          <Name>MPAuthor Network Device Type A</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevice.TypeB">
          <Name>MPAuthor Network Device Type B</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevice.TypeC">
          <Name>MPAuthor Network Device Type C</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.NetworkDevices">
          <Name>MPAuthor Sample Network Devices</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Proxy">
          <Name>MPAuthor Network Device Proxy</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Proxy" SubElementID="ConfigFile">
          <Name>Config File</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.CollectSNMPTraps">
          <Name>SNMP Collection</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.Syslog.AlertMessage">
          <Name>syslog alert on network</Name>
          <Description>Event Description: {0}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.SyslogOS.AlertMessage">
          <Name>syslog alert on OS</Name>
          <Description>Event Description: {0}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Error">
          <Name>Syslog Error Alert - Type A</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Error.AlertMessage">
          <Name>Gamera Error</Name>
          <Description>Facility: {0} 
Severity: {1} 
Priority: {2} 
PriorityName: {3} 
TimeStamp: {4} 
HostName: {5} 
Message: {6}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Warning">
          <Name>Syslog Warning Alert - Type A</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeA.Alert.Warning.AlertMessage">
          <Name>Gamera Warning</Name>
          <Description>Facility: {0} 
Severity: {1} 
Priority: {2} 
PriorityName: {3} 
TimeStamp: {4} 
HostName: {5} 
Message: {6}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeA.Collection">
          <Name>Syslog Collection - Type A</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeB.Alert.Error.AlertMessage">
          <Name>Gargantua Error</Name>
          <Description>Facility: {0} 
Severity: {1} 
Priority: {2} 
PriorityName: {3} 
TimeStamp: {4} 
HostName: {5} 
Message: {6}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeB.Alert.Warning.AlertMessage">
          <Name>Gargantua Warning</Name>
          <Description>Facility: {0} 
Severity: {1} 
Priority: {2} 
PriorityName: {3} 
TimeStamp: {4} 
HostName: {5} 
Message: {6}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeC.Alert.Error.AlertMessage">
          <Name>Godzilla Error</Name>
          <Description>Facility: {0} 
Severity: {1} 
Priority: {2} 
PriorityName: {3} 
TimeStamp: {4} 
HostName: {5} 
Message: {6}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.Rule.TypeC.Alert.Warning.AlertMessage">
          <Name>Godzilla Warning</Name>
          <Description>Facility: {0} 
Severity: {1} 
Priority: {2} 
PriorityName: {3} 
TimeStamp: {4} 
HostName: {5} 
Message: {6}</Description>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.SNMPDevice.TypeA">
          <Name>MPAuthor SNMP Device Type A</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.SNMPDevice.TypeB">
          <Name>MPAuthor SNMP Device Type B</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.SNMPDevice.TypeC">
          <Name>MPAuthor SNMP Device Type C</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.View.NetworkDevices">
          <Name>Network Devices</Name>
        </DisplayString>
        <DisplayString ElementID="MPAuthor.NetworkDevices.View.Proxy">
          <Name>Proxies</Name>
        </DisplayString>
        <DisplayString ElementID="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af">
          <Name>Type A SNMP Probe</Name>
        </DisplayString>
        <DisplayString ElementID="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af" SubElementID="UIGeneratedOpStateId25b06cff2c7641519dfd6acb71fa8f0b">
          <Name>First Event Raised</Name>
        </DisplayString>
        <DisplayString ElementID="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af" SubElementID="UIGeneratedOpStateIde08ef1a3b3424f40a7e992e2e73d52e7">
          <Name>Second Event Raised</Name>
        </DisplayString>
        <DisplayString ElementID="UIGeneratedMonitorb9a9d3310a4a460dbde5cd7dba4fc8af_AlertMessageResourceID">
          <Name>Type A SNMP Probe</Name>
          <Description>Probe value: {0}</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>
