Guest User

Untitled

a guest
Apr 7th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.43 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  3. <Manifest>
  4. <Identity>
  5. <ID>ApiMP</ID>
  6. <Version>1.0.0.19</Version>
  7. </Identity>
  8. <Name>ApiMP</Name>
  9. <References>
  10. <Reference Alias="Windows">
  11. <ID>Microsoft.Windows.Library</ID>
  12. <Version>7.5.8501.0</Version>
  13. <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  14. </Reference>
  15. <Reference Alias="System">
  16. <ID>System.Library</ID>
  17. <Version>7.5.8501.0</Version>
  18. <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  19. </Reference>
  20. <Reference Alias="Health">
  21. <ID>System.Health.Library</ID>
  22. <Version>7.0.8443.6</Version>
  23. <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  24. </Reference>
  25. <Reference Alias="SC">
  26. <ID>Microsoft.SystemCenter.Library</ID>
  27. <Version>7.0.8427.0</Version>
  28. <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  29. </Reference>
  30. </References>
  31. </Manifest>
  32. <TypeDefinitions>
  33. <EntityTypes>
  34. <ClassTypes>
  35. <ClassType ID="CI.API.Country.Class" Base="System!System.LocalApplication" Accessibility="Public" Abstract="false" Singleton="false" Extension="false" Hosted="false">
  36. <Property ID="Name" Type="string" Key="true"/>
  37. <Property ID="Region" Type="string"/>
  38. <Property ID="Independent" Type="string"/>
  39. <!-- We choose Microsoft.Windows.LocalApplication as our generic base class -->
  40. </ClassType>
  41. </ClassTypes>
  42. </EntityTypes>
  43. <ModuleTypes>
  44. <DataSourceModuleType ID="CI.API.Country.Class.Discovery.DS" Accessibility="Internal" Batching="false">
  45. <Configuration>
  46. <xsd:element name="IntervalSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  47. <xsd:element name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  48. <xsd:element name="TimeoutSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  49. <xsd:element name="DebugLogging" type="xsd:boolean" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  50. <xsd:element name="Exclusions" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  51. </Configuration>
  52. <OverrideableParameters>
  53. <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
  54. <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
  55. <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
  56. <OverrideableParameter ID="DebugLogging" Selector="$Config/DebugLogging$" ParameterType="bool" />
  57. <OverrideableParameter ID="Exclusions" Selector="$Config/Exclusions$" ParameterType="string" />
  58. </OverrideableParameters>
  59. <ModuleImplementation Isolation="Any">
  60. <Composite>
  61. <MemberModules>
  62. <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
  63. <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
  64. <SyncTime>$Config/SyncTime$</SyncTime>
  65. <ScriptName>CI.API.Country.Class.Discovery.DS.ps1</ScriptName>
  66. <ScriptBody>
  67. #=================================================================================
  68. # Describe Script Here
  69. #
  70. # Author:
  71. # v1.0
  72. #=================================================================================
  73. param($SourceId,$ManagedEntityId,$MGName,$DebugLogging,$Exclusions)
  74.  
  75.  
  76. # Manual Testing section - put stuff here for manually testing script - typically parameters:
  77. #=================================================================================
  78. # $SourceId = '{00000000-0000-0000-0000-000000000000}'
  79. # $ManagedEntityId = '{00000000-0000-0000-0000-000000000000}'
  80. # $MGName = "MGNAME"
  81. # $DebugLogging = "false"
  82. # $Exclusions = "foo"
  83. #=================================================================================
  84.  
  85.  
  86. # Constants section - modify stuff here:
  87. #=================================================================================
  88. # Assign script name variable for use in event logging.
  89. # ScriptName should be the same as the ID of the module that the script is contained in
  90. $ScriptName = "CI.API.Country.Class.Discovery.DS.ps1"
  91. $EventID = "777"
  92. #=================================================================================
  93.  
  94.  
  95. # Starting Script section - All scripts get this
  96. #=================================================================================
  97. # Gather the start time of the script
  98. $StartTime = Get-Date
  99. #Set variable to be used in logging events
  100. $whoami = whoami
  101. # Load MOMScript API
  102. $momapi = New-Object -comObject MOM.ScriptAPI
  103. #Log script event that we are starting task
  104. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script is starting. `n Running as ($whoami). `n Management Group: ($MGName).")
  105. #=================================================================================
  106.  
  107.  
  108. # Discovery Script section - Discovery scripts get this
  109. #=================================================================================
  110. # Load SCOM Discovery module
  111. $DiscoveryData = $momapi.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)
  112. #=================================================================================
  113.  
  114.  
  115. # Begin MAIN script section
  116. #=================================================================================
  117. # API Credentials
  118.  
  119. $restUrl = "https://restcountries.com/v3.1/all"
  120.  
  121. # Exclude devicetype InputOutput
  122. $Results = Invoke-RestMethod -Uri $restUrl
  123.  
  124. #Log script event that shows we passed some custom text as a parameter
  125. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Exclusions: ($Exclusions)")
  126.  
  127. #Show concept of additional debug logging
  128. IF ($DebugLogging.ToUpper() -eq "TRUE")
  129. {
  130. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n This event is being logged because debug Logging was set to: ($DebugLogging)")
  131. }
  132.  
  133. # If any returned results from API
  134. If ($Results)
  135. {
  136. $Results | Foreach-Object {
  137. $Name = "NA"
  138. $Region = "NA"
  139. $Independent = "NA"
  140. $Name = $_.name.common
  141. $Region = $_.region
  142. $Independent = $_.independent
  143. $instance = $DiscoveryData.CreateClassInstance("$MPElement[Name='CI.API.Country.Class']$")
  144. $instance.AddProperty("$MPElement[Name='CI.API.Country.Class']/Name$", $Name)
  145. $instance.AddProperty("$MPElement[Name='CI.API.Country.Class']/Region$", $Region)
  146. $instance.AddProperty("$MPElement[Name='CI.API.Country.Class']/Independent$", $Independent)
  147. $DiscoveryData.AddInstance($instance)
  148. }
  149. # Log an event that objects were discovered
  150. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Discovery script is returning objects. $($Results.count)")
  151. }
  152. Else
  153. {
  154. # Log an event for no objects discovered
  155. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Discovery script returned no discovered objects")
  156. }
  157.  
  158. # Return Discovery Items Normally
  159. $DiscoveryData
  160. # Return Discovery Bag to the command line for testing (does not work from ISE)
  161. # $momapi.Return($DiscoveryData)
  162. #=================================================================================
  163. # End MAIN script section
  164.  
  165.  
  166. # End of script section
  167. #=================================================================================
  168. #Log an event for script ending and total execution time.
  169. $EndTime = Get-Date
  170. $ScriptTime = ($EndTime - $StartTime).TotalSeconds
  171. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script Completed. `n Script Runtime: ($ScriptTime) seconds.")
  172. #=================================================================================
  173. # End of script
  174. </ScriptBody>
  175. <Parameters>
  176. <Parameter>
  177. <Name>SourceId</Name>
  178. <Value>$MPElement$</Value>
  179. </Parameter>
  180. <Parameter>
  181. <Name>ManagedEntityId</Name>
  182. <Value>$Target/Id$</Value>
  183. </Parameter>
  184. <Parameter>
  185. <Name>MGName</Name>
  186. <Value>$Target/ManagementGroup/Name$</Value>
  187. </Parameter>
  188. <Parameter>
  189. <Name>DebugLogging</Name>
  190. <Value>$Config/DebugLogging$</Value>
  191. </Parameter>
  192. <Parameter>
  193. <Name>Exclusions</Name>
  194. <Value>$Config/Exclusions$</Value>
  195. </Parameter>
  196. </Parameters>
  197. <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
  198. </DataSource>
  199. </MemberModules>
  200. <Composition>
  201. <Node ID="DS" />
  202. </Composition>
  203. </Composite>
  204. </ModuleImplementation>
  205. <OutputType>System!System.Discovery.Data</OutputType>
  206. </DataSourceModuleType>
  207. <DataSourceModuleType ID="CI.API.CountryState.Monitor.DS" Accessibility="Internal" Batching="false">
  208. <Configuration>
  209. <xsd:element minOccurs="1" type="xsd:integer" name="IntervalSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  210. <xsd:element minOccurs="0" type="xsd:string" name="SyncTime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  211. <xsd:element minOccurs="1" type="xsd:integer" name="TimeoutSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  212. </Configuration>
  213. <OverrideableParameters>
  214. <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
  215. <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
  216. <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
  217. </OverrideableParameters>
  218. <ModuleImplementation Isolation="Any">
  219. <Composite>
  220. <MemberModules>
  221. <DataSource ID="Scheduler" TypeID="System!System.Scheduler">
  222. <Scheduler>
  223. <SimpleReccuringSchedule>
  224. <Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
  225. <SyncTime>$Config/SyncTime$</SyncTime>
  226. </SimpleReccuringSchedule>
  227. <ExcludeDates />
  228. </Scheduler>
  229. </DataSource>
  230. <ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
  231. <ScriptName>CI.API.CountryState.Monitor.DS.ps1</ScriptName>
  232. <ScriptBody>
  233. #=================================================================================
  234. # Describe Script Here
  235. #
  236. # Author:
  237. # v1.0
  238. #=================================================================================
  239. param([string]$Independent)
  240.  
  241.  
  242. # Manual Testing section - put stuff here for manually testing script - typically parameters:
  243. #=================================================================================
  244. # $Independent = "true"
  245. #=================================================================================
  246.  
  247.  
  248. # Constants section - modify stuff here:
  249. #=================================================================================
  250. # Assign script name variable for use in event logging.
  251. $ScriptName = "CI.API.CountryState.Monitor.DS.ps1"
  252. $EventID = "778"
  253. #=================================================================================
  254.  
  255.  
  256. # Starting Script section - All scripts get this
  257. #=================================================================================
  258. # Gather the start time of the script
  259. $StartTime = Get-Date
  260. #Set variable to be used in logging events
  261. $whoami = whoami
  262. # Load MOMScript API
  263. $momapi = New-Object -comObject MOM.ScriptAPI
  264. # Load PropertyBag function
  265. $bag = $momapi.CreatePropertyBag()
  266. #Log script event that we are starting task
  267. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script is starting. `n Running as ($whoami).")
  268. #=================================================================================
  269.  
  270.  
  271. # Begin MAIN script section
  272. #=================================================================================
  273. #Log script parameters we received
  274. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`nScript parameters passed into datasource")
  275.  
  276. #$Result = Get-SCOMClass -Name CI.API.Country.Class | Get-ScomClassInstance | ?{$_.Displayname -eq "Jordan"}
  277. $strCondition = $independent
  278.  
  279. #Check the value of $strCondition
  280. IF ($strCondition -eq "true")
  281. {
  282. $momapi.LogScriptEvent($ScriptName,$EventID,0,"Good Condition Found")
  283. $bag.AddValue('Result','GoodCondition')
  284. }
  285. ELSE
  286. {
  287. $momapi.LogScriptEvent($ScriptName,$EventID,0,"Bad Condition Found")
  288. $bag.AddValue('Result','BadCondition')
  289. }
  290.  
  291. # Return all bags
  292. $bag
  293. #=================================================================================
  294. # End MAIN script section
  295.  
  296.  
  297. # End of script section
  298. #=================================================================================
  299. #Log an event for script ending and total execution time.
  300. $EndTime = Get-Date
  301. $ScriptTime = ($EndTime - $StartTime).TotalSeconds
  302. $momapi.LogScriptEvent($ScriptName,$EventID,0,"`n Script Completed. `n Script Runtime: ($ScriptTime) seconds.")
  303. #=================================================================================
  304. # End of script
  305. </ScriptBody>
  306. <Parameters>
  307. <Parameter>
  308. <Name>Independent</Name>
  309. <Value>$Target/Property[Type="CI.API.Country.Class"]/Independent$</Value>
  310. </Parameter>
  311. </Parameters>
  312. <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
  313. </ProbeAction>
  314. </MemberModules>
  315. <Composition>
  316. <Node ID="PA">
  317. <Node ID="Scheduler" />
  318. </Node>
  319. </Composition>
  320. </Composite>
  321. </ModuleImplementation>
  322. <OutputType>System!System.PropertyBagData</OutputType>
  323. </DataSourceModuleType>
  324. </ModuleTypes>
  325. <MonitorTypes>
  326. <UnitMonitorType ID="CI.API.CountryState.Monitor.MonitorType" Accessibility="Internal">
  327. <MonitorTypeStates>
  328. <MonitorTypeState ID="GoodCondition" NoDetection="false" />
  329. <MonitorTypeState ID="BadCondition" NoDetection="false" />
  330. </MonitorTypeStates>
  331. <Configuration>
  332. <xsd:element minOccurs="1" type="xsd:integer" name="IntervalSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  333. <xsd:element minOccurs="0" type="xsd:string" name="SyncTime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  334. <xsd:element minOccurs="1" type="xsd:integer" name="TimeoutSeconds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  335. <xsd:element minOccurs="1" type="xsd:integer" name="MatchCount" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  336. </Configuration>
  337. <OverrideableParameters>
  338. <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
  339. <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
  340. <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
  341. <OverrideableParameter ID="MatchCount" Selector="$Config/MatchCount$" ParameterType="int" />
  342. </OverrideableParameters>
  343. <MonitorImplementation>
  344. <MemberModules>
  345. <DataSource ID="DS" TypeID="CI.API.CountryState.Monitor.DS">
  346. <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
  347. <SyncTime>$Config/SyncTime$</SyncTime>
  348. <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
  349. </DataSource>
  350. <ConditionDetection ID="GoodConditionFilter" TypeID="System!System.ExpressionFilter">
  351. <Expression>
  352. <SimpleExpression>
  353. <ValueExpression>
  354. <XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
  355. </ValueExpression>
  356. <Operator>Equal</Operator>
  357. <ValueExpression>
  358. <Value Type="String">GoodCondition</Value>
  359. </ValueExpression>
  360. </SimpleExpression>
  361. </Expression>
  362. </ConditionDetection>
  363. <ConditionDetection ID="BadConditionFilter" TypeID="System!System.ExpressionFilter">
  364. <Expression>
  365. <SimpleExpression>
  366. <ValueExpression>
  367. <XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
  368. </ValueExpression>
  369. <Operator>Equal</Operator>
  370. <ValueExpression>
  371. <Value Type="String">BadCondition</Value>
  372. </ValueExpression>
  373. </SimpleExpression>
  374. </Expression>
  375. <SuppressionSettings>
  376. <MatchCount>$Config/MatchCount$</MatchCount>
  377. </SuppressionSettings>
  378. </ConditionDetection>
  379. </MemberModules>
  380. <RegularDetections>
  381. <RegularDetection MonitorTypeStateID="GoodCondition">
  382. <Node ID="GoodConditionFilter">
  383. <Node ID="DS" />
  384. </Node>
  385. </RegularDetection>
  386. <RegularDetection MonitorTypeStateID="BadCondition">
  387. <Node ID="BadConditionFilter">
  388. <Node ID="DS" />
  389. </Node>
  390. </RegularDetection>
  391. </RegularDetections>
  392. <OnDemandDetections>
  393. <OnDemandDetection MonitorTypeStateID="GoodCondition">
  394. <Node ID="GoodConditionFilter">
  395. <Node ID="DS" />
  396. </Node>
  397. </OnDemandDetection>
  398. <OnDemandDetection MonitorTypeStateID="BadCondition">
  399. <Node ID="BadConditionFilter">
  400. <Node ID="DS" />
  401. </Node>
  402. </OnDemandDetection>
  403. </OnDemandDetections>
  404. </MonitorImplementation>
  405. </UnitMonitorType>
  406. </MonitorTypes>
  407. </TypeDefinitions>
  408. <Monitoring>
  409. <Discoveries>
  410. <Discovery ID="CI.API.Country.Class.Discovery" Target="SC!Microsoft.SystemCenter.AllManagementServersPool" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
  411. <!-- 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 -->
  412. <Category>Discovery</Category>
  413. <DiscoveryTypes>
  414. <DiscoveryClass TypeID="CI.API.Country.Class">
  415. <Property PropertyID="Name" />
  416. <Property PropertyID="Region" />
  417. <Property PropertyID="Independent" />
  418. </DiscoveryClass>
  419. </DiscoveryTypes>
  420. <DataSource ID="DS" TypeID="CI.API.Country.Class.Discovery.DS">
  421. <IntervalSeconds>60</IntervalSeconds>
  422. <SyncTime></SyncTime>
  423. <TimeoutSeconds>120</TimeoutSeconds>
  424. <DebugLogging>true</DebugLogging>
  425. <Exclusions>foo</Exclusions>
  426. </DataSource>
  427. </Discovery>
  428. </Discoveries>
  429. <Monitors>
  430. <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">
  431. <Category>AvailabilityHealth</Category>
  432. <AlertSettings AlertMessage="CI.API.CountryState.Monitor.AlertMessage">
  433. <AlertOnState>Warning</AlertOnState> <!-- Warning or Error should match OperationalStates below -->
  434. <AutoResolve>true</AutoResolve>
  435. <AlertPriority>Normal</AlertPriority>
  436. <AlertSeverity>MatchMonitorHealth</AlertSeverity> <!-- Common options for AlertSeverity are MatchMonitorHealth, Information, Warning, Error -->
  437. <AlertParameters>
  438. <AlertParameter1>$Data/Context/Property[@Name='Result']$</AlertParameter1> <!-- This is an example of passing property output from the script into the alert description -->
  439. </AlertParameters>
  440. </AlertSettings>
  441. <OperationalStates>
  442. <OperationalState ID="GoodCondition" MonitorTypeStateID="GoodCondition" HealthState="Success" />
  443. <OperationalState ID="BadCondition" MonitorTypeStateID="BadCondition" HealthState="Warning" /> <!-- HealthState = Warning or Error -->
  444. </OperationalStates>
  445. <Configuration>
  446. <IntervalSeconds>3600</IntervalSeconds>
  447. <SyncTime></SyncTime>
  448. <TimeoutSeconds>120</TimeoutSeconds>
  449. <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. -->
  450. </Configuration>
  451. </UnitMonitor>
  452. </Monitors>
  453. </Monitoring>
  454. <Presentation>
  455. <StringResources>
  456. <StringResource ID="CI.API.CountryState.Monitor.AlertMessage" />
  457. </StringResources>
  458. </Presentation>
  459. <LanguagePacks>
  460. <LanguagePack ID="ENU" IsDefault="true">
  461. <DisplayStrings>
  462. <DisplayString ElementID="CI.API.Country.Class">
  463. <Name>CI API Country Class</Name>
  464. </DisplayString>
  465. <DisplayString ElementID="CI.API.Country.Class" SubElementID="Name">
  466. <Name>Name</Name>
  467. </DisplayString>
  468. <DisplayString ElementID="CI.API.Country.Class" SubElementID="Region">
  469. <Name>Region</Name>
  470. </DisplayString>
  471. <DisplayString ElementID="CI.API.Country.Class" SubElementID="Independent">
  472. <Name>Independent</Name>
  473. </DisplayString>
  474. <DisplayString ElementID="CI.API.Country.Class.Discovery">
  475. <Name>CI API Country Class Discovery</Name>
  476. </DisplayString>
  477. <DisplayString ElementID="CI.API.CountryState.Monitor">
  478. <Name>CI API CountryState Monitor</Name>
  479. <Description></Description>
  480. </DisplayString>
  481. <DisplayString ElementID="CI.API.CountryState.Monitor" SubElementID="GoodCondition">
  482. <Name>Good Condition</Name>
  483. </DisplayString>
  484. <DisplayString ElementID="CI.API.CountryState.Monitor" SubElementID="BadCondition">
  485. <Name>Bad Condition</Name>
  486. </DisplayString>
  487. <DisplayString ElementID="CI.API.CountryState.Monitor.AlertMessage">
  488. <Name>CI API CountryState Monitor: Failure</Name>
  489. <Description>CI API CountryState Monitor: detected a bad condition
  490. Result: {0}</Description>
  491. </DisplayString>
  492. </DisplayStrings>
  493. <KnowledgeArticles></KnowledgeArticles>
  494. </LanguagePack>
  495. </LanguagePacks>
  496. </ManagementPack>
Add Comment
Please, Sign In to add comment