Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <Manifest>
- <Identity>
- <ID>ApiMP</ID>
- <Version>1.0.0.19</Version>
- </Identity>
- <Name>ApiMP</Name>
- <References>
- <Reference Alias="Windows">
- <ID>Microsoft.Windows.Library</ID>
- <Version>7.5.8501.0</Version>
- <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
- </Reference>
- <Reference Alias="System">
- <ID>System.Library</ID>
- <Version>7.5.8501.0</Version>
- <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
- </Reference>
- <Reference Alias="Health">
- <ID>System.Health.Library</ID>
- <Version>7.0.8443.6</Version>
- <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
- </Reference>
- <Reference Alias="SC">
- <ID>Microsoft.SystemCenter.Library</ID>
- <Version>7.0.8427.0</Version>
- <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
- </Reference>
- </References>
- </Manifest>
- <TypeDefinitions>
- <EntityTypes>
- <ClassTypes>
- <ClassType ID="CI.API.Country.Class" Base="System!System.LocalApplication" Accessibility="Public" Abstract="false" Singleton="false" Extension="false" Hosted="false">
- <Property ID="Name" Type="string" Key="true"/>
- <Property ID="Region" Type="string"/>
- <Property ID="Independent" Type="string"/>
- <!-- We choose Microsoft.Windows.LocalApplication as our generic base class -->
- </ClassType>
- </ClassTypes>
- </EntityTypes>
- <ModuleTypes>
- <DataSourceModuleType ID="CI.API.Country.Class.Discovery.DS" Accessibility="Internal" Batching="false">
- <Configuration>
- <xsd:element name="IntervalSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element name="TimeoutSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element name="DebugLogging" type="xsd:boolean" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element name="Exclusions" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- </Configuration>
- <OverrideableParameters>
- <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
- <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
- <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
- <OverrideableParameter ID="DebugLogging" Selector="$Config/DebugLogging$" ParameterType="bool" />
- <OverrideableParameter ID="Exclusions" Selector="$Config/Exclusions$" ParameterType="string" />
- </OverrideableParameters>
- <ModuleImplementation Isolation="Any">
- <Composite>
- <MemberModules>
- <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
- <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
- <SyncTime>$Config/SyncTime$</SyncTime>
- <ScriptName>CI.API.Country.Class.Discovery.DS.ps1</ScriptName>
- <ScriptBody>
- #=================================================================================
- # Describe Script Here
- #
- # Author:
- # v1.0
- #=================================================================================
- param($SourceId,$ManagedEntityId,$MGName,$DebugLogging,$Exclusions)
- # Manual Testing section - put stuff here for manually testing script - typically parameters:
- #=================================================================================
- # $SourceId = '{00000000-0000-0000-0000-000000000000}'
- # $ManagedEntityId = '{00000000-0000-0000-0000-000000000000}'
- # $MGName = "MGNAME"
- # $DebugLogging = "false"
- # $Exclusions = "foo"
- #=================================================================================
- # Constants section - modify stuff here:
- #=================================================================================
- # Assign script name variable for use in event logging.
- # ScriptName should be the same as the ID of the module that the script is contained in
- $ScriptName = "CI.API.Country.Class.Discovery.DS.ps1"
- $EventID = "777"
- #=================================================================================
- # Starting Script section - All scripts get this
- #=================================================================================
- # Gather the start time of the script
- $StartTime = Get-Date
- #Set variable to be used in logging events
- $whoami = whoami
- # Load MOMScript API
- $momapi = New-Object -comObject MOM.ScriptAPI
- #Log script event that we are starting task
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script is starting. `n Running as ($whoami). `n Management Group: ($MGName).")
- #=================================================================================
- # Discovery Script section - Discovery scripts get this
- #=================================================================================
- # Load SCOM Discovery module
- $DiscoveryData = $momapi.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)
- #=================================================================================
- # Begin MAIN script section
- #=================================================================================
- # API Credentials
- $restUrl = "https://restcountries.com/v3.1/all"
- # Exclude devicetype InputOutput
- $Results = Invoke-RestMethod -Uri $restUrl
- #Log script event that shows we passed some custom text as a parameter
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Exclusions: ($Exclusions)")
- #Show concept of additional debug logging
- IF ($DebugLogging.ToUpper() -eq "TRUE")
- {
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n This event is being logged because debug Logging was set to: ($DebugLogging)")
- }
- # If any returned results from API
- If ($Results)
- {
- $Results | Foreach-Object {
- $Name = "NA"
- $Region = "NA"
- $Independent = "NA"
- $Name = $_.name.common
- $Region = $_.region
- $Independent = $_.independent
- $instance = $DiscoveryData.CreateClassInstance("$MPElement[Name='CI.API.Country.Class']$")
- $instance.AddProperty("$MPElement[Name='CI.API.Country.Class']/Name$", $Name)
- $instance.AddProperty("$MPElement[Name='CI.API.Country.Class']/Region$", $Region)
- $instance.AddProperty("$MPElement[Name='CI.API.Country.Class']/Independent$", $Independent)
- $DiscoveryData.AddInstance($instance)
- }
- # Log an event that objects were discovered
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Discovery script is returning objects. $($Results.count)")
- }
- Else
- {
- # Log an event for no objects discovered
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Discovery script returned no discovered objects")
- }
- # Return Discovery Items Normally
- $DiscoveryData
- # Return Discovery Bag to the command line for testing (does not work from ISE)
- # $momapi.Return($DiscoveryData)
- #=================================================================================
- # End MAIN script section
- # End of script section
- #=================================================================================
- #Log an event for script ending and total execution time.
- $EndTime = Get-Date
- $ScriptTime = ($EndTime - $StartTime).TotalSeconds
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script Completed. `n Script Runtime: ($ScriptTime) seconds.")
- #=================================================================================
- # End of script
- </ScriptBody>
- <Parameters>
- <Parameter>
- <Name>SourceId</Name>
- <Value>$MPElement$</Value>
- </Parameter>
- <Parameter>
- <Name>ManagedEntityId</Name>
- <Value>$Target/Id$</Value>
- </Parameter>
- <Parameter>
- <Name>MGName</Name>
- <Value>$Target/ManagementGroup/Name$</Value>
- </Parameter>
- <Parameter>
- <Name>DebugLogging</Name>
- <Value>$Config/DebugLogging$</Value>
- </Parameter>
- <Parameter>
- <Name>Exclusions</Name>
- <Value>$Config/Exclusions$</Value>
- </Parameter>
- </Parameters>
- <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
- </DataSource>
- </MemberModules>
- <Composition>
- <Node ID="DS" />
- </Composition>
- </Composite>
- </ModuleImplementation>
- <OutputType>System!System.Discovery.Data</OutputType>
- </DataSourceModuleType>
- <DataSourceModuleType ID="CI.API.CountryState.Monitor.DS" Accessibility="Internal" Batching="false">
- <Configuration>
- <xsd:element minOccurs="1" type="xsd:integer" name="IntervalSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element minOccurs="0" type="xsd:string" name="SyncTime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element minOccurs="1" type="xsd:integer" name="TimeoutSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- </Configuration>
- <OverrideableParameters>
- <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
- <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
- <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
- </OverrideableParameters>
- <ModuleImplementation Isolation="Any">
- <Composite>
- <MemberModules>
- <DataSource ID="Scheduler" TypeID="System!System.Scheduler">
- <Scheduler>
- <SimpleReccuringSchedule>
- <Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
- <SyncTime>$Config/SyncTime$</SyncTime>
- </SimpleReccuringSchedule>
- <ExcludeDates />
- </Scheduler>
- </DataSource>
- <ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
- <ScriptName>CI.API.CountryState.Monitor.DS.ps1</ScriptName>
- <ScriptBody>
- #=================================================================================
- # Describe Script Here
- #
- # Author:
- # v1.0
- #=================================================================================
- param([string]$Independent)
- # Manual Testing section - put stuff here for manually testing script - typically parameters:
- #=================================================================================
- # $Independent = "true"
- #=================================================================================
- # Constants section - modify stuff here:
- #=================================================================================
- # Assign script name variable for use in event logging.
- $ScriptName = "CI.API.CountryState.Monitor.DS.ps1"
- $EventID = "778"
- #=================================================================================
- # Starting Script section - All scripts get this
- #=================================================================================
- # Gather the start time of the script
- $StartTime = Get-Date
- #Set variable to be used in logging events
- $whoami = whoami
- # Load MOMScript API
- $momapi = New-Object -comObject MOM.ScriptAPI
- # Load PropertyBag function
- $bag = $momapi.CreatePropertyBag()
- #Log script event that we are starting task
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script is starting. `n Running as ($whoami).")
- #=================================================================================
- # Begin MAIN script section
- #=================================================================================
- #Log script parameters we received
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`nScript parameters passed into datasource")
- #$Result = Get-SCOMClass -Name CI.API.Country.Class | Get-ScomClassInstance | ?{$_.Displayname -eq "Jordan"}
- $strCondition = $independent
- #Check the value of $strCondition
- IF ($strCondition -eq "true")
- {
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"Good Condition Found")
- $bag.AddValue('Result','GoodCondition')
- }
- ELSE
- {
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"Bad Condition Found")
- $bag.AddValue('Result','BadCondition')
- }
- # Return all bags
- $bag
- #=================================================================================
- # End MAIN script section
- # End of script section
- #=================================================================================
- #Log an event for script ending and total execution time.
- $EndTime = Get-Date
- $ScriptTime = ($EndTime - $StartTime).TotalSeconds
- $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script Completed. `n Script Runtime: ($ScriptTime) seconds.")
- #=================================================================================
- # End of script
- </ScriptBody>
- <Parameters>
- <Parameter>
- <Name>Independent</Name>
- <Value>$Target/Property[Type="CI.API.Country.Class"]/Independent$</Value>
- </Parameter>
- </Parameters>
- <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
- </ProbeAction>
- </MemberModules>
- <Composition>
- <Node ID="PA">
- <Node ID="Scheduler" />
- </Node>
- </Composition>
- </Composite>
- </ModuleImplementation>
- <OutputType>System!System.PropertyBagData</OutputType>
- </DataSourceModuleType>
- </ModuleTypes>
- <MonitorTypes>
- <UnitMonitorType ID="CI.API.CountryState.Monitor.MonitorType" Accessibility="Internal">
- <MonitorTypeStates>
- <MonitorTypeState ID="GoodCondition" NoDetection="false" />
- <MonitorTypeState ID="BadCondition" NoDetection="false" />
- </MonitorTypeStates>
- <Configuration>
- <xsd:element minOccurs="1" type="xsd:integer" name="IntervalSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element minOccurs="0" type="xsd:string" name="SyncTime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element minOccurs="1" type="xsd:integer" name="TimeoutSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- <xsd:element minOccurs="1" type="xsd:integer" name="MatchCount" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
- </Configuration>
- <OverrideableParameters>
- <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
- <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
- <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
- <OverrideableParameter ID="MatchCount" Selector="$Config/MatchCount$" ParameterType="int" />
- </OverrideableParameters>
- <MonitorImplementation>
- <MemberModules>
- <DataSource ID="DS" TypeID="CI.API.CountryState.Monitor.DS">
- <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
- <SyncTime>$Config/SyncTime$</SyncTime>
- <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
- </DataSource>
- <ConditionDetection ID="GoodConditionFilter" TypeID="System!System.ExpressionFilter">
- <Expression>
- <SimpleExpression>
- <ValueExpression>
- <XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
- </ValueExpression>
- <Operator>Equal</Operator>
- <ValueExpression>
- <Value Type="String">GoodCondition</Value>
- </ValueExpression>
- </SimpleExpression>
- </Expression>
- </ConditionDetection>
- <ConditionDetection ID="BadConditionFilter" TypeID="System!System.ExpressionFilter">
- <Expression>
- <SimpleExpression>
- <ValueExpression>
- <XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
- </ValueExpression>
- <Operator>Equal</Operator>
- <ValueExpression>
- <Value Type="String">BadCondition</Value>
- </ValueExpression>
- </SimpleExpression>
- </Expression>
- <SuppressionSettings>
- <MatchCount>$Config/MatchCount$</MatchCount>
- </SuppressionSettings>
- </ConditionDetection>
- </MemberModules>
- <RegularDetections>
- <RegularDetection MonitorTypeStateID="GoodCondition">
- <Node ID="GoodConditionFilter">
- <Node ID="DS" />
- </Node>
- </RegularDetection>
- <RegularDetection MonitorTypeStateID="BadCondition">
- <Node ID="BadConditionFilter">
- <Node ID="DS" />
- </Node>
- </RegularDetection>
- </RegularDetections>
- <OnDemandDetections>
- <OnDemandDetection MonitorTypeStateID="GoodCondition">
- <Node ID="GoodConditionFilter">
- <Node ID="DS" />
- </Node>
- </OnDemandDetection>
- <OnDemandDetection MonitorTypeStateID="BadCondition">
- <Node ID="BadConditionFilter">
- <Node ID="DS" />
- </Node>
- </OnDemandDetection>
- </OnDemandDetections>
- </MonitorImplementation>
- </UnitMonitorType>
- </MonitorTypes>
- </TypeDefinitions>
- <Monitoring>
- <Discoveries>
- <Discovery ID="CI.API.Country.Class.Discovery" Target="SC!Microsoft.SystemCenter.AllManagementServersPool" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
- <!-- We choose Microsoft.Windows.Server.OperatingSystem as the preferred target class to ensure this will run on all Windows Servers, but will not create duplicates on clusters -->
- <Category>Discovery</Category>
- <DiscoveryTypes>
- <DiscoveryClass TypeID="CI.API.Country.Class">
- <Property PropertyID="Name" />
- <Property PropertyID="Region" />
- <Property PropertyID="Independent" />
- </DiscoveryClass>
- </DiscoveryTypes>
- <DataSource ID="DS" TypeID="CI.API.Country.Class.Discovery.DS">
- <IntervalSeconds>60</IntervalSeconds>
- <SyncTime></SyncTime>
- <TimeoutSeconds>120</TimeoutSeconds>
- <DebugLogging>true</DebugLogging>
- <Exclusions>foo</Exclusions>
- </DataSource>
- </Discovery>
- </Discoveries>
- <Monitors>
- <UnitMonitor ID="CI.API.CountryState.Monitor" Accessibility="Public" Enabled="true" Target="CI.API.Country.Class" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="CI.API.CountryState.Monitor.MonitorType" ConfirmDelivery="true">
- <Category>AvailabilityHealth</Category>
- <AlertSettings AlertMessage="CI.API.CountryState.Monitor.AlertMessage">
- <AlertOnState>Warning</AlertOnState> <!-- Warning or Error should match OperationalStates below -->
- <AutoResolve>true</AutoResolve>
- <AlertPriority>Normal</AlertPriority>
- <AlertSeverity>MatchMonitorHealth</AlertSeverity> <!-- Common options for AlertSeverity are MatchMonitorHealth, Information, Warning, Error -->
- <AlertParameters>
- <AlertParameter1>$Data/Context/Property[@Name='Result']$</AlertParameter1> <!-- This is an example of passing property output from the script into the alert description -->
- </AlertParameters>
- </AlertSettings>
- <OperationalStates>
- <OperationalState ID="GoodCondition" MonitorTypeStateID="GoodCondition" HealthState="Success" />
- <OperationalState ID="BadCondition" MonitorTypeStateID="BadCondition" HealthState="Warning" /> <!-- HealthState = Warning or Error -->
- </OperationalStates>
- <Configuration>
- <IntervalSeconds>3600</IntervalSeconds>
- <SyncTime></SyncTime>
- <TimeoutSeconds>120</TimeoutSeconds>
- <MatchCount>2</MatchCount> <!-- This is the number of consecutive matches that must be met before the monitor will change state. Also a good example of passing in Integer data. -->
- </Configuration>
- </UnitMonitor>
- </Monitors>
- </Monitoring>
- <Presentation>
- <StringResources>
- <StringResource ID="CI.API.CountryState.Monitor.AlertMessage" />
- </StringResources>
- </Presentation>
- <LanguagePacks>
- <LanguagePack ID="ENU" IsDefault="true">
- <DisplayStrings>
- <DisplayString ElementID="CI.API.Country.Class">
- <Name>CI API Country Class</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.Country.Class" SubElementID="Name">
- <Name>Name</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.Country.Class" SubElementID="Region">
- <Name>Region</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.Country.Class" SubElementID="Independent">
- <Name>Independent</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.Country.Class.Discovery">
- <Name>CI API Country Class Discovery</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.CountryState.Monitor">
- <Name>CI API CountryState Monitor</Name>
- <Description></Description>
- </DisplayString>
- <DisplayString ElementID="CI.API.CountryState.Monitor" SubElementID="GoodCondition">
- <Name>Good Condition</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.CountryState.Monitor" SubElementID="BadCondition">
- <Name>Bad Condition</Name>
- </DisplayString>
- <DisplayString ElementID="CI.API.CountryState.Monitor.AlertMessage">
- <Name>CI API CountryState Monitor: Failure</Name>
- <Description>CI API CountryState Monitor: detected a bad condition
- Result: {0}</Description>
- </DisplayString>
- </DisplayStrings>
- <KnowledgeArticles></KnowledgeArticles>
- </LanguagePack>
- </LanguagePacks>
- </ManagementPack>
Add Comment
Please, Sign In to add comment