techcorsair

upsmanagement

Dec 21st, 2022 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 29.67 KB | Source Code | 0 0
  1. <?xml version="1.0" encoding="utf-8"?><ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.1" xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsl=http://www.w3.org/1999/XSL/Transform>
  2.  
  3.   <Manifest>
  4.  
  5.     <Identity>
  6.  
  7.       <ID>MYCOMPANYUPSSolution</ID>
  8.  
  9.       <Version>1.0.0.3</Version>
  10.  
  11.     </Identity>
  12.  
  13.     <Name>MYCOMPANY.UPS.Solution</Name>
  14.  
  15.     <References>
  16.  
  17.       <Reference Alias="MicrosoftWindowsLibrary7585010">
  18.  
  19.         <ID>Microsoft.Windows.Library</ID>
  20.  
  21.         <Version>7.5.8501.0</Version>
  22.  
  23.         <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  24.  
  25.       </Reference>
  26.  
  27.       <Reference Alias="MicrosoftSystemCenterInstanceGroupLibrary7585010">
  28.  
  29.         <ID>Microsoft.SystemCenter.InstanceGroup.Library</ID>
  30.  
  31.         <Version>7.5.8501.0</Version>
  32.  
  33.         <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  34.  
  35.       </Reference>
  36.  
  37.       <Reference Alias="SystemLibrary7585010">
  38.  
  39.         <ID>System.Library</ID>
  40.  
  41.         <Version>7.5.8501.0</Version>
  42.  
  43.         <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  44.  
  45.       </Reference>
  46.  
  47.       <Reference Alias="PowerShellMonitoring">
  48.  
  49.         <ID>Community.PowerShellMonitoring</ID>
  50.  
  51.         <Version>1.1.1.2</Version>
  52.  
  53.         <PublicKeyToken>3aa540324b898d3c</PublicKeyToken>
  54.  
  55.       </Reference>
  56.  
  57.       <Reference Alias="SystemCenter">
  58.  
  59.         <ID>Microsoft.SystemCenter.Library</ID>
  60.  
  61.         <Version>7.0.8438.6</Version>
  62.  
  63.         <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  64.  
  65.       </Reference>
  66.  
  67.       <Reference Alias="Health">
  68.  
  69.         <ID>System.Health.Library</ID>
  70.  
  71.         <Version>7.0.8438.6</Version>
  72.  
  73.         <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
  74.  
  75.       </Reference>
  76.  
  77.     </References>
  78.  
  79.   </Manifest>
  80.  
  81.   <TypeDefinitions>
  82.  
  83.     <EntityTypes>
  84.  
  85.       <ClassTypes>
  86.  
  87.         <ClassType ID="Typed0679834bbee48c18cd4137ed27b757e" Accessibility="Public" Abstract="false" Base="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Server.Computer" Hosted="false" Singleton="false" Extension="false">
  88.  
  89.           <Property ID="AttributeDiscoveryGeneratedByUI005ef803a104460d8febfb990102ed1c" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" />
  90.  
  91.         </ClassType>
  92.  
  93.         <ClassType ID="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group" Accessibility="Public" Abstract="false" Base="MicrosoftSystemCenterInstanceGroupLibrary7585010!Microsoft.SystemCenter.InstanceGroup" Hosted="false" Singleton="true" Extension="false" />
  94.  
  95.       </ClassTypes>
  96.  
  97.     </EntityTypes>
  98.  
  99.     <SecureReferences>
  100.  
  101.       <SecureReference ID="RunAsProfile_d47a0ecf95aa403db2916803fc08ae03" Accessibility="Internal" />
  102.  
  103.     </SecureReferences>
  104.  
  105.   </TypeDefinitions>
  106.  
  107.   <Monitoring>
  108.  
  109.     <Discoveries>
  110.  
  111.       <Discovery ID="AttributeDiscoveryGeneratedByUIc89c107cd90343869878a3a3d0234924" Enabled="true" Target="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Server.Computer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
  112.  
  113.         <Category>PerformanceCollection</Category>
  114.  
  115.         <DiscoveryTypes>
  116.  
  117.           <DiscoveryClass TypeID="Typed0679834bbee48c18cd4137ed27b757e">
  118.  
  119.             <Property TypeID="Typed0679834bbee48c18cd4137ed27b757e" PropertyID="AttributeDiscoveryGeneratedByUI005ef803a104460d8febfb990102ed1c" />
  120.  
  121.           </DiscoveryClass>
  122.  
  123.         </DiscoveryTypes>
  124.  
  125.         <DataSource ID="AttributeDiscoveryGeneratedByUIe084411c4fa84b0f86f70f86ef9d96a0" TypeID="MicrosoftWindowsLibrary7585010!Microsoft.Windows.RegistryDiscoverySingleProvider">
  126.  
  127.           <ComputerName>$Target/Property[Type="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
  128.  
  129.           <AttributeName>AttributeDiscoveryRuleb4382a69d21c4c8e982d879b8adaf797</AttributeName>
  130.  
  131.           <Path>SOFTWARE\CommVault Systems</Path>
  132.  
  133.           <PathType>0</PathType>
  134.  
  135.           <AttributeType>0</AttributeType>
  136.  
  137.           <Frequency>43200</Frequency>
  138.  
  139.           <ClassId>$MPElement[Name="Typed0679834bbee48c18cd4137ed27b757e"]$</ClassId>
  140.  
  141.           <InstanceSettings>
  142.  
  143.             <Settings>
  144.  
  145.               <Setting>
  146.  
  147.                 <Name>$MPElement[Name="Typed0679834bbee48c18cd4137ed27b757e"]/AttributeDiscoveryGeneratedByUI005ef803a104460d8febfb990102ed1c$</Name>
  148.  
  149.                 <Value>$Data/Values/AttributeDiscoveryRuleb4382a69d21c4c8e982d879b8adaf797$</Value>
  150.  
  151.               </Setting>
  152.  
  153.               <Setting>
  154.  
  155.                 <Name>$MPElement[Name="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/PrincipalName$</Name>
  156.  
  157.                 <Value>$Target/Property[Type="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/PrincipalName$</Value>
  158.  
  159.               </Setting>
  160.  
  161.             </Settings>
  162.  
  163.           </InstanceSettings>
  164.  
  165.         </DataSource>
  166.  
  167.       </Discovery>
  168.  
  169.       <Discovery ID="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group.DiscoveryRule" Enabled="true" Target="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group" ConfirmDelivery="false" Remotable="true" Priority="Normal">
  170.  
  171.         <Category>Discovery</Category>
  172.  
  173.         <DiscoveryTypes>
  174.  
  175.           <DiscoveryRelationship TypeID="MicrosoftSystemCenterInstanceGroupLibrary7585010!Microsoft.SystemCenter.InstanceGroupContainsEntities" />
  176.  
  177.         </DiscoveryTypes>
  178.  
  179.         <DataSource ID="GroupPopulationDataSource" TypeID="SystemCenter!Microsoft.SystemCenter.GroupPopulator">
  180.  
  181.           <RuleId>$MPElement$</RuleId>
  182.  
  183.           <GroupInstanceId>$MPElement[Name="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group"]$</GroupInstanceId>
  184.  
  185.           <MembershipRules>
  186.  
  187.             <MembershipRule>
  188.  
  189.               <MonitoringClass>$MPElement[Name="Typed0679834bbee48c18cd4137ed27b757e"]$</MonitoringClass>
  190.  
  191.               <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary7585010!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
  192.  
  193.               <Expression>
  194.  
  195.                 <And>
  196.  
  197.                   <Expression>
  198.  
  199.                     <RegExExpression>
  200.  
  201.                       <ValueExpression>
  202.  
  203.                         <Property>$MPElement[Name="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/PrincipalName$</Property>
  204.  
  205.                       </ValueExpression>
  206.  
  207.                       <Operator>ContainsSubstring</Operator>
  208.  
  209.                       <Pattern>CMA</Pattern>
  210.  
  211.                     </RegExExpression>
  212.  
  213.                   </Expression>
  214.  
  215.                   <Expression>
  216.  
  217.                     <SimpleExpression>
  218.  
  219.                       <ValueExpression>
  220.  
  221.                         <Property>$MPElement[Name="Typed0679834bbee48c18cd4137ed27b757e"]/AttributeDiscoveryGeneratedByUI005ef803a104460d8febfb990102ed1c$</Property>
  222.  
  223.                       </ValueExpression>
  224.  
  225.                       <Operator>Equal</Operator>
  226.  
  227.                       <ValueExpression>
  228.  
  229.                         <Value>True</Value>
  230.  
  231.                       </ValueExpression>
  232.  
  233.                     </SimpleExpression>
  234.  
  235.                   </Expression>
  236.  
  237.                   <Expression>
  238.  
  239.                     <RegExExpression>
  240.  
  241.                       <ValueExpression>
  242.  
  243.                         <Property>$MPElement[Name="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/PrincipalName$</Property>
  244.  
  245.                       </ValueExpression>
  246.  
  247.                       <Operator>DoesNotContainSubstring</Operator>
  248.  
  249.                       <Pattern>DCAZU</Pattern>
  250.  
  251.                     </RegExExpression>
  252.  
  253.                   </Expression>
  254.  
  255.                 </And>
  256.  
  257.               </Expression>
  258.  
  259.             </MembershipRule>
  260.  
  261.           </MembershipRules>
  262.  
  263.         </DataSource>
  264.  
  265.       </Discovery>
  266.  
  267.     </Discoveries>
  268.  
  269.     <Monitors>
  270.  
  271.       <UnitMonitor ID="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc" Accessibility="Public" Enabled="false" Target="Typed0679834bbee48c18cd4137ed27b757e" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="PowerShellMonitoring!Community.PowerShellMonitoring.UnitMonitors.PowerShellTwoState" ConfirmDelivery="false">
  272.  
  273.         <Category>Custom</Category>
  274.  
  275.         <AlertSettings AlertMessage="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc_AlertMessageResourceID">
  276.  
  277.           <AlertOnState>Warning</AlertOnState>
  278.  
  279.           <AutoResolve>true</AutoResolve>
  280.  
  281.           <AlertPriority>Normal</AlertPriority>
  282.  
  283.           <AlertSeverity>MatchMonitorHealth</AlertSeverity>
  284.  
  285.           <AlertParameters>
  286.  
  287.             <AlertParameter1>$Data/Context/Property[@Name='MessageText']$</AlertParameter1>
  288.  
  289.           </AlertParameters>
  290.  
  291.         </AlertSettings>
  292.  
  293.         <OperationalStates>
  294.  
  295.           <OperationalState ID="UIGeneratedOpStateId43dc4c8c4cb9486887c6b8b31cef0a07" MonitorTypeStateID="Healthy" HealthState="Success" />
  296.  
  297.           <OperationalState ID="UIGeneratedOpStateId33ad00466f85440ba855093dad7651a3" MonitorTypeStateID="Unhealthy" HealthState="Warning" />
  298.  
  299.         </OperationalStates>
  300.  
  301.         <Configuration>
  302.  
  303.           <IntervalSeconds>43200</IntervalSeconds>
  304.  
  305.           <SyncTime>00:00</SyncTime>
  306.  
  307.           <ScriptName>UPSSolution.ps1</ScriptName>
  308.  
  309.           <ScriptBody> &lt;#
  310.  
  311.             This script checks some important prerequisites for IPP solution
  312.  
  313.             In case some of them is missing, it will report a warning
  314.  
  315.  
  316.  
  317.     Script name: UPSSolution.ps1
  318.  
  319.  
  320.  
  321.     Author: myself
  322.  
  323.     Date:   20221124
  324.  
  325.     Version: 1.0.0.1
  326.  
  327.  
  328.  
  329.     History:
  330.  
  331.         20221124 - 1.0.0.1 - Preliminary version
  332.  
  333. #&gt;
  334.  
  335.  
  336.  
  337. # Any Arguments specified will be sent to the script as a single string.
  338.  
  339. # If you need to send multiple values, delimit them with a space, semicolon or other separator and then use split.
  340.  
  341. param([string]$Arguments)
  342.  
  343.  
  344.  
  345. $ScomAPI = New-Object -comObject "MOM.ScriptAPI"
  346.  
  347. $PropertyBag = $ScomAPI.CreatePropertyBag()
  348.  
  349.  
  350.  
  351. $err = $false
  352.  
  353. $folder = "D:\scripts"
  354.  
  355. $errstr = ""
  356.  
  357.  
  358.  
  359. try
  360.  
  361. {
  362.  
  363.      $res = Get-Service -ErrorAction Stop | Where-Object { $_.Name -like "Eaton*" }
  364.  
  365.  
  366.  
  367.      if($null -eq $res)
  368.  
  369.      {
  370.  
  371.          continue leave
  372.  
  373.      }
  374.  
  375.  
  376.  
  377.     Write-Host "Service OK"
  378.  
  379.  
  380.  
  381.             #verify the PowerCLI update state
  382.  
  383.             $pcli = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "VMware PowerCLI"}
  384.  
  385.  
  386.  
  387.             if( $null -eq $pcli )
  388.  
  389.             {
  390.  
  391.                         #verify if we have the new version
  392.  
  393.                         $newcli = $a=Get-Module -Name "*PowerCLI" -ListAvailable
  394.  
  395.                         if($null -eq $newcli)
  396.  
  397.                         {
  398.  
  399.                                     $errstr += "VMWare PowerCLI is NOT installed - "
  400.  
  401.                                     $err = $true
  402.  
  403.                         }
  404.  
  405.             }
  406.  
  407.             else
  408.  
  409.             {
  410.  
  411.                         #we have the old version that needs to be updated
  412.  
  413.                         $errstr += "VMWare PowerCLI needs to be updated - "
  414.  
  415.                         $err = $true
  416.  
  417.             }
  418.  
  419.  
  420.  
  421.             if($res.Status -eq "Running")
  422.  
  423.             {
  424.  
  425.                 Write-Host "Service is running"
  426.  
  427.             }
  428.  
  429.             else
  430.  
  431.             {
  432.  
  433.                 $errstr += "Service NOT running - "
  434.  
  435.                 $err = $true
  436.  
  437.             }
  438.  
  439.  
  440.  
  441.        if ($res.Name -ne "Eaton IntelligentPowerProtector") #last official name
  442.  
  443.        {
  444.  
  445.           $errstr += "Eaton service could be outdated - "
  446.  
  447.           $err = $true
  448.  
  449.        }
  450.  
  451.  
  452.  
  453.             if( Test-Path $folder )
  454.  
  455.             {
  456.  
  457.                 Write-Host "Folder OK"
  458.  
  459.             }
  460.  
  461.             else
  462.  
  463.             {
  464.  
  465.                 $errstr += "No folder - "
  466.  
  467.                 $err = $true
  468.  
  469.             }
  470.  
  471.  
  472.  
  473.             if( Test-Path -Path "$folder\AES.key"  -PathType Leaf )
  474.  
  475.             {
  476.  
  477.                 Write-Host "File AES key OK"
  478.  
  479.             }
  480.  
  481.             else
  482.  
  483.             {
  484.  
  485.                 $errstr += "No AES key file"
  486.  
  487.                 $err = $true
  488.  
  489.             }
  490.  
  491.  
  492.  
  493.             #test scheduled task - it is outside the main process because I need to use try..catch
  494.  
  495.             try
  496.  
  497.             {
  498.  
  499.                         $Task = Get-ScheduledTask -TaskName 'UPS-Updater' -ErrorAction Stop
  500.  
  501.             }
  502.  
  503.             catch
  504.  
  505.             {
  506.  
  507.                         $errstr += "Scheduled task for update is not present - "
  508.  
  509.                         $err = $true
  510.  
  511.             }
  512.  
  513.  
  514.  
  515.             #test .Net version (for PowerCLI)
  516.  
  517.             $DotNetVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Version
  518.  
  519.  
  520.  
  521.             if($DotNetVersion -lt 4.7)
  522.  
  523.             {
  524.  
  525.                         #
  526.  
  527.                         $errstr += ".Net Framework version - $DotNetVersion - is lower than 4.7 (needed for PowerCLI) - "
  528.  
  529.                         $err = $true
  530.  
  531.             }
  532.  
  533. }
  534.  
  535. catch #in this case no service = there is no solution installed
  536.  
  537. {
  538.  
  539.     #$errstr += "IPP service not installed."
  540.  
  541.     $err = $false
  542.  
  543. }
  544.  
  545.  
  546.  
  547. :leave
  548.  
  549.  
  550.  
  551. $PropertyBag.AddValue("MessageText",$errstr)
  552.  
  553.  
  554.  
  555. if($err) {
  556.  
  557.   $PropertyBag.AddValue("State","BAD")
  558.  
  559. }
  560.  
  561. else
  562.  
  563. {
  564.  
  565.   $PropertyBag.AddValue("State","OK")
  566.  
  567. }
  568.  
  569.  
  570.  
  571. # Send output to SCOM
  572.  
  573. $PropertyBag
  574.  
  575. </ScriptBody>
  576.  
  577.           <Arguments />
  578.  
  579.           <TimeoutSeconds>300</TimeoutSeconds>
  580.  
  581.           <UnhealthyExpression>
  582.  
  583.             <SimpleExpression>
  584.  
  585.               <ValueExpression>
  586.  
  587.                 <XPathQuery>Property[@Name='State']</XPathQuery>
  588.  
  589.               </ValueExpression>
  590.  
  591.               <Operator>Equal</Operator>
  592.  
  593.               <ValueExpression>
  594.  
  595.                 <Value>BAD</Value>
  596.  
  597.               </ValueExpression>
  598.  
  599.             </SimpleExpression>
  600.  
  601.           </UnhealthyExpression>
  602.  
  603.           <HealthyExpression>
  604.  
  605.             <SimpleExpression>
  606.  
  607.               <ValueExpression>
  608.  
  609.                 <XPathQuery>Property[@Name='State']</XPathQuery>
  610.  
  611.               </ValueExpression>
  612.  
  613.               <Operator>Equal</Operator>
  614.  
  615.               <ValueExpression>
  616.  
  617.                 <Value>OK</Value>
  618.  
  619.               </ValueExpression>
  620.  
  621.             </SimpleExpression>
  622.  
  623.           </HealthyExpression>
  624.  
  625.         </Configuration>
  626.  
  627.       </UnitMonitor>
  628.  
  629.       <UnitMonitor ID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148" Accessibility="Public" Enabled="false" Target="Typed0679834bbee48c18cd4137ed27b757e" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="PowerShellMonitoring!Community.PowerShellMonitoring.UnitMonitors.PowerShellThreeState" ConfirmDelivery="false">
  630.  
  631.         <Category>Custom</Category>
  632.  
  633.         <AlertSettings AlertMessage="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148_AlertMessageResourceID">
  634.  
  635.           <AlertOnState>Warning</AlertOnState>
  636.  
  637.           <AutoResolve>true</AutoResolve>
  638.  
  639.           <AlertPriority>High</AlertPriority>
  640.  
  641.           <AlertSeverity>MatchMonitorHealth</AlertSeverity>
  642.  
  643.           <AlertParameters>
  644.  
  645.             <AlertParameter1>$Data/Context/Property[@Name='UpsName']$</AlertParameter1>
  646.  
  647.             <AlertParameter2>$Data/Context/Property[@Name='MessageText']$</AlertParameter2>
  648.  
  649.           </AlertParameters>
  650.  
  651.         </AlertSettings>
  652.  
  653.         <OperationalStates>
  654.  
  655.           <OperationalState ID="UIGeneratedOpStateId262315817d204b72b902cc96a995fecd" MonitorTypeStateID="Healthy" HealthState="Success" />
  656.  
  657.           <OperationalState ID="UIGeneratedOpStateIddc6fc6951ac24d0ba4bdb2739bb943a1" MonitorTypeStateID="Warning" HealthState="Warning" />
  658.  
  659.           <OperationalState ID="UIGeneratedOpStateId419103a160794c2eb1b4166c0b6d7b75" MonitorTypeStateID="Unhealthy" HealthState="Error" />
  660.  
  661.         </OperationalStates>
  662.  
  663.         <Configuration>
  664.  
  665.           <IntervalSeconds>300</IntervalSeconds>
  666.  
  667.           <SyncTime>00:00</SyncTime>
  668.  
  669.           <ScriptName>upsonbattery.ps1</ScriptName>
  670.  
  671.           <ScriptBody>  # Any Arguments specified will be sent to the script as a single string.
  672.  
  673. # If you need to send multiple values, delimit them with a space, semicolon or other separator and then use split.
  674.  
  675. param([string]$Arguments)
  676.  
  677.  
  678.  
  679. $ScomAPI = New-Object -comObject "MOM.ScriptAPI"
  680.  
  681. $PropertyBag = $ScomAPI.CreatePropertyBag()
  682.  
  683.  
  684.  
  685. # Example of use below, in this case return the length of the string passed in and we'll set health state based on that.
  686.  
  687. # Since the health state comparison is string based in this template we'll need to create a state value and return it.
  688.  
  689. # Ensure you return a unique value per health state (e.g. a service status), or a unique combination of values.
  690.  
  691.  
  692.  
  693. &lt;#
  694.  
  695.     Script: ups-on-battery.ps1
  696.  
  697.  
  698.  
  699.     Purpose: Checks if Eaton UPS is on battery
  700.  
  701.  
  702.  
  703.     Author: myself
  704.  
  705.     Team:   Windows Hosting
  706.  
  707.  
  708.  
  709.     Version: 1.0
  710.  
  711.     Date: 20221202
  712.  
  713.  
  714.  
  715.     History:
  716.  
  717.         1.0 - 20221202 - Preliminary version
  718.  
  719.  
  720.  
  721. #&gt;
  722.  
  723. $upsBatteryVoltage            = '.1.3.6.1.4.1.534.1.2.2.0'
  724.  
  725. $upsBatteryCapacityPerc       = '.1.3.6.1.4.1.534.1.2.4.0'
  726.  
  727. $upsEstimatedMinutesRemaining = '.1.3.6.1.2.1.33.1.2.3.0'
  728.  
  729. $upsBatteryABMStatus          = '.1.3.6.1.4.1.534.1.2.5.0' #(Charging(1),Discharging(2),Floating(3),Resting(4),unknown(5),Disconnected(6),Under Test(7),Check Battery(8))
  730.  
  731.  
  732.  
  733. $upsBatteryReplacementIndicator = '.1.3.6.1.4.1.705.1.5.11.0' # 1=yes 2=no
  734.  
  735. $upsBatteryFaultIndicator       = '.1.3.6.1.4.1.705.1.5.9.0'  # 1=yes 2=no
  736.  
  737. $upsInternalFailure             = '.1.3.6.1.4.1.705.1.5.15.0' # 1=yes 2=no
  738.  
  739. $upsOverloadIndicator           = '.1.3.6.1.4.1.705.1.7.10.0' # 1=yes 2=no
  740.  
  741.  
  742.  
  743. $UpsSysDescription              = '.1.3.6.1.4.1.534.1.1.2.0' # system description
  744.  
  745.  
  746.  
  747. $upsOnBypass  = '.1.3.6.1.4.1.705.1.7.4.0' # 1=yes 2=no
  748.  
  749. $upsOnBattery = '.1.3.6.1.4.1.705.1.7.3.0' # 1=yes 2=no
  750.  
  751.  
  752.  
  753. $upsAlarms     = '.1.3.6.1.4.1.534.1.7.1.0' #number of alerts
  754.  
  755. $upsAlarmsTree = '.1.3.6.1.4.1.534.1.7.2'
  756.  
  757.  
  758.  
  759. $upsSerialNumberNew = '.1.3.6.1.4.1.534.1.14.5.0' #only for new model (Network MS NIC)
  760.  
  761. $upsSerialNumberOld = '.1.3.6.1.4.1.705.1.1.7.0'  #only for old model (Network MS NIC)
  762.  
  763.  
  764.  
  765. $upsBatteryAged     = '.1.3.6.1.4.1.534.1.2.9.0' # 1=yes 2=no (new UPS only with Gigabit Ethernet card)
  766.  
  767.  
  768.  
  769. &lt;#
  770.  
  771. xupsOnBattery               1.3.6.1.4.1.534.1.7.3
  772.  
  773. xupsLowBattery              1.3.6.1.4.1.534.1.7.4
  774.  
  775. xupsUtilityPowerRestored  1.3.6.1.4.1.534.1.7.5
  776.  
  777. xupsReturnFromLowBattery          1.3.6.1.4.1.534.1.7.6
  778.  
  779. xupsOutputOverload                          1.3.6.1.4.1.534.1.7.7
  780.  
  781. xupsInternalFailure                        1.3.6.1.4.1.534.1.7.8
  782.  
  783. xupsBatteryDischarged                 1.3.6.1.4.1.534.1.7.9
  784.  
  785. xupsInverterFailure                        1.3.6.1.4.1.534.1.7.10
  786.  
  787. xupsOnBypass                                            1.3.6.1.4.1.534.1.7.11
  788.  
  789. xupsBypassNotAvailable              1.3.6.1.4.1.534.1.7.12
  790.  
  791. xupsOutputOff                                             1.3.6.1.4.1.534.1.7.13
  792.  
  793. xupsInputFailure                     1.3.6.1.4.1.534.1.7.14
  794.  
  795. xupsBuildingAlarm                         1.3.6.1.4.1.534.1.7.15
  796.  
  797. xupsShutdownImminent                 1.3.6.1.4.1.534.1.7.16
  798.  
  799. xupsOnInverter                                           1.3.6.1.4.1.534.1.7.17
  800.  
  801. ifDescr                     1.3.6.1.2.1.33.1.1.4.0
  802.  
  803. #&gt;
  804.  
  805.  
  806.  
  807. # To get the IPP install location read value InstallPath from HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Eaton\IntelligentPowerProtector
  808.  
  809. # then add "configs" to the path
  810.  
  811.  
  812.  
  813. get-date | Out-File -FilePath "C:\temp\upsonbatt.log"
  814.  
  815.  
  816.  
  817. $CurrentUser = ([Security.Principal.WindowsIdentity]::GetCurrent()).name
  818.  
  819.  
  820.  
  821. "User is $CurrentUser" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  822.  
  823.  
  824.  
  825. if(!(test-path -path "HKLM:\SOFTWARE\Wow6432Node\Eaton\IntelligentPowerProtector"))
  826.  
  827. {
  828.  
  829.     Write-Host "No IPP solution installed here" -ForegroundColor Yellow
  830.  
  831.     "NOIPP" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  832.  
  833.     exit
  834.  
  835. }
  836.  
  837.  
  838.  
  839. $IPPPath = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Eaton\IntelligentPowerProtector").InstallPath
  840.  
  841. $IPPPath += "\configs"
  842.  
  843.  
  844.  
  845. #debug
  846.  
  847. $IPPPath
  848.  
  849.  
  850.  
  851. try
  852.  
  853. {
  854.  
  855.     $ConfigIPP = Get-Content -Path "$IPPPath\config.js" -ErrorAction Stop
  856.  
  857. }
  858.  
  859. catch
  860.  
  861. {
  862.  
  863.     Write-Host "Error $($_.Exception.Message)" -ForegroundColor Red
  864.  
  865.     "ERRCFG - $($_.Exception.Message)" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  866.  
  867.     exit
  868.  
  869. }
  870.  
  871.  
  872.  
  873. #"powerSource": (\S{1,},)
  874.  
  875. $UPSExtract = ($ConfigIPP -match '"powerSource": (\S{1,},)') -replace """", ""
  876.  
  877. $UpsName = $UPSExtract -replace ",", ""
  878.  
  879. $UpsName = ($UpsName.Split(":")[1]).Trim()
  880.  
  881.  
  882.  
  883. #debug
  884.  
  885. $UpsName
  886.  
  887.  
  888.  
  889. try
  890.  
  891. {
  892.  
  893.     $SNMP = New-Object -ComObject olePrn.OleSNMP
  894.  
  895.     "SNMP object $SNMP created correctly" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  896.  
  897. }
  898.  
  899. catch
  900.  
  901. {
  902.  
  903.     Write-Debug "Error creating SNMP object"
  904.  
  905.     "Error creating SNMP object - $($_.Exception.Message)" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  906.  
  907.     exit
  908.  
  909. }
  910.  
  911.  
  912.  
  913. try
  914.  
  915. {
  916.  
  917.     $UPSIPAddress = [System.Net.Dns]::GetHostAddresses($UpsName).IPAddressToString
  918.  
  919.     $SNMP.open($UPSIPAddress, "communityname", 10, 3000)
  920.  
  921. }
  922.  
  923. catch
  924.  
  925. {
  926.  
  927.     Write-Debug "Error opening SNMP connection"
  928.  
  929.     "SNMPERR opening $UpsName with IP $UPSIPAddress - $($_.Exception.Message)" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  930.  
  931.     exit
  932.  
  933. }
  934.  
  935.  
  936.  
  937. $OnBatt = $SNMP.get($upsOnBattery)
  938.  
  939. #Write-Host "On battery: $RESULT (1 yes | 2 no)" -ForegroundColor Cyan
  940.  
  941.  
  942.  
  943. $MinRem = $SNMP.get($upsEstimatedMinutesRemaining)
  944.  
  945. #Write-Host "Estimated battery remaining (minutes): $RESULT" -ForegroundColor Cyan
  946.  
  947.  
  948.  
  949. $OnBypass = $SNMP.get($upsOnBypass)
  950.  
  951. #Write-Host "UPS on bypass: $RESULT (1 yes | 2 no)" -ForegroundColor Cyan
  952.  
  953.  
  954.  
  955. if ($OnBatt -eq 1)
  956.  
  957. {
  958.  
  959.             $Message = "UPS is on battery - remaining time: $MinRem minutes"
  960.  
  961.             $State = "BATT"
  962.  
  963.             "BATT" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  964.  
  965. }
  966.  
  967. elseif ($OnByPass -eq 1)
  968.  
  969. {
  970.  
  971.             $Message = "UPS is on ByPass"
  972.  
  973.             $State = "BPS"
  974.  
  975.             "BPS" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  976.  
  977. }
  978.  
  979. else
  980.  
  981. {
  982.  
  983.             $State = "OK"
  984.  
  985.             "OK" | out-file -FilePath "C:\temp\upsonbatt.log" -append
  986.  
  987. }
  988.  
  989. $PropertyBag.AddValue("MessageText",$Message)
  990.  
  991. $PropertyBag.AddValue("UpsName",$UpsName)
  992.  
  993. $PropertyBag.AddValue("State",$State)
  994.  
  995.  
  996.  
  997. $Message | out-file -FilePath "C:\temp\upsonbatt.log" -append
  998.  
  999. $UpsName | out-file -FilePath "C:\temp\upsonbatt.log" -append
  1000.  
  1001. $State | out-file -FilePath "C:\temp\upsonbatt.log" -append
  1002.  
  1003.  
  1004.  
  1005. $SNMP.Close() #close SNMP instance
  1006.  
  1007.  
  1008.  
  1009. # Send output to SCOM
  1010.  
  1011. $PropertyBag
  1012.  
  1013.  
  1014.  
  1015. </ScriptBody>
  1016.  
  1017.           <Arguments />
  1018.  
  1019.           <TimeoutSeconds>300</TimeoutSeconds>
  1020.  
  1021.           <UnhealthyExpression>
  1022.  
  1023.             <SimpleExpression>
  1024.  
  1025.               <ValueExpression>
  1026.  
  1027.                 <XPathQuery>Property[@Name='State']</XPathQuery>
  1028.  
  1029.               </ValueExpression>
  1030.  
  1031.               <Operator>Equal</Operator>
  1032.  
  1033.               <ValueExpression>
  1034.  
  1035.                 <Value Type="String">BATT</Value>
  1036.  
  1037.               </ValueExpression>
  1038.  
  1039.             </SimpleExpression>
  1040.  
  1041.           </UnhealthyExpression>
  1042.  
  1043.           <WarningExpression>
  1044.  
  1045.             <SimpleExpression>
  1046.  
  1047.               <ValueExpression>
  1048.  
  1049.                 <XPathQuery>Property[@Name='State']</XPathQuery>
  1050.  
  1051.               </ValueExpression>
  1052.  
  1053.               <Operator>Equal</Operator>
  1054.  
  1055.               <ValueExpression>
  1056.  
  1057.                 <Value Type="String">BPS</Value>
  1058.  
  1059.               </ValueExpression>
  1060.  
  1061.             </SimpleExpression>
  1062.  
  1063.           </WarningExpression>
  1064.  
  1065.           <HealthyExpression>
  1066.  
  1067.             <SimpleExpression>
  1068.  
  1069.               <ValueExpression>
  1070.  
  1071.                 <XPathQuery>Property[@Name='State']</XPathQuery>
  1072.  
  1073.               </ValueExpression>
  1074.  
  1075.               <Operator>Equal</Operator>
  1076.  
  1077.               <ValueExpression>
  1078.  
  1079.                 <Value Type="String">OK</Value>
  1080.  
  1081.               </ValueExpression>
  1082.  
  1083.             </SimpleExpression>
  1084.  
  1085.           </HealthyExpression>
  1086.  
  1087.         </Configuration>
  1088.  
  1089.       </UnitMonitor>
  1090.  
  1091.     </Monitors>
  1092.  
  1093.     <Overrides>
  1094.  
  1095.       <MonitorPropertyOverride ID="Alias731d3cfe1fba42f2b515812cb7b7049fOverrideForMonitorUIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148ForContextUINameSpace0d432e9bcd884d42bf5983f27ad952f8Group" Context="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group" ContextInstance="9c306548-985c-7eef-0255-f19c4700e6b1" Enforced="false" Monitor="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148" Property="Enabled">
  1096.  
  1097.         <Value>true</Value>
  1098.  
  1099.       </MonitorPropertyOverride>
  1100.  
  1101.       <SecureReferenceOverride ID="SecureOverride197c23cf_be00_2a41_76db_9f8c491e74a5" Context="SystemLibrary7585010!System.Entity" ContextInstance="9c306548-985c-7eef-0255-f19c4700e6b1" Enforced="false" SecureReference="RunAsProfile_d47a0ecf95aa403db2916803fc08ae03">
  1102.  
  1103.         <Value>002FAB78342CF8117D9C45D1E077AF24216B05509800000000000000000000000000000000000000</Value>
  1104.  
  1105.       </SecureReferenceOverride>
  1106.  
  1107.     </Overrides>
  1108.  
  1109.   </Monitoring>
  1110.  
  1111.   <Presentation>
  1112.  
  1113.     <Folders>
  1114.  
  1115.       <Folder ID="Folder_b774a06cf78343e1b5c2d0e9a6e72b8b" Accessibility="Public" ParentFolder="SystemCenter!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
  1116.  
  1117.     </Folders>
  1118.  
  1119.     <StringResources>
  1120.  
  1121.       <StringResource ID="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc_AlertMessageResourceID" />
  1122.  
  1123.       <StringResource ID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148_AlertMessageResourceID" />
  1124.  
  1125.     </StringResources>
  1126.  
  1127.   </Presentation>
  1128.  
  1129.   <LanguagePacks>
  1130.  
  1131.     <LanguagePack ID="ENU" IsDefault="false">
  1132.  
  1133.       <DisplayStrings>
  1134.  
  1135.         <DisplayString ElementID="MYCOMPANYUPSSolution">
  1136.  
  1137.           <Name>MYCOMPANY.UPS.Solution</Name>
  1138.  
  1139.           <Description>Classes, groups and monitors for UPS solution (IPP). Also contains the monitor for UPS on battery.</Description>
  1140.  
  1141.         </DisplayString>
  1142.  
  1143.         <DisplayString ElementID="Folder_b774a06cf78343e1b5c2d0e9a6e72b8b">
  1144.  
  1145.           <Name>MYCOMPANY.UPS.Solution</Name>
  1146.  
  1147.         </DisplayString>
  1148.  
  1149.         <DisplayString ElementID="AttributeDiscoveryGeneratedByUIc89c107cd90343869878a3a3d0234924">
  1150.  
  1151.           <Name>CMA ServerDiscovery</Name>
  1152.  
  1153.         </DisplayString>
  1154.  
  1155.         <DisplayString ElementID="Typed0679834bbee48c18cd4137ed27b757e">
  1156.  
  1157.           <Name>Windows Server_Extended_UPSSolution</Name>
  1158.  
  1159.         </DisplayString>
  1160.  
  1161.         <DisplayString ElementID="Typed0679834bbee48c18cd4137ed27b757e" SubElementID="AttributeDiscoveryGeneratedByUI005ef803a104460d8febfb990102ed1c">
  1162.  
  1163.           <Name>CMA Server</Name>
  1164.  
  1165.           <Description>Identifies CMA servers</Description>
  1166.  
  1167.         </DisplayString>
  1168.  
  1169.         <DisplayString ElementID="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group">
  1170.  
  1171.           <Name>All CMA Servers</Name>
  1172.  
  1173.           <Description>All servers where CommVault is installed</Description>
  1174.  
  1175.         </DisplayString>
  1176.  
  1177.         <DisplayString ElementID="UINameSpace0d432e9bcd884d42bf5983f27ad952f8.Group.DiscoveryRule">
  1178.  
  1179.           <Name>Populate All CMA Servers</Name>
  1180.  
  1181.           <Description>This discovery rule populates the group 'All CMA Servers'</Description>
  1182.  
  1183.         </DisplayString>
  1184.  
  1185.        <DisplayString ElementID="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc">
  1186.  
  1187.           <Name>UPS Solution misconfigured</Name>
  1188.  
  1189.           <Description>Monitors all servers where IPP is installed to verify if the configuration is correct.</Description>
  1190.  
  1191.         </DisplayString>
  1192.  
  1193.         <DisplayString ElementID="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc" SubElementID="UIGeneratedOpStateId43dc4c8c4cb9486887c6b8b31cef0a07">
  1194.  
  1195.           <Name>Healthy</Name>
  1196.  
  1197.         </DisplayString>
  1198.  
  1199.         <DisplayString ElementID="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc" SubElementID="UIGeneratedOpStateId33ad00466f85440ba855093dad7651a3">
  1200.  
  1201.           <Name>Unhealthy</Name>
  1202.  
  1203.         </DisplayString>
  1204.  
  1205.         <DisplayString ElementID="UIGeneratedMonitor85e984d8b2e64f0c9b90b366bdf86dfc_AlertMessageResourceID">
  1206.  
  1207.           <Name>UPS Solution misconfigured</Name>
  1208.  
  1209.           <Description>UPS Solution is misconfigured. See below for details:
  1210.  
  1211.  
  1212.  
  1213. Additional error(s): {0}</Description>
  1214.  
  1215.         </DisplayString>
  1216.  
  1217.         <DisplayString ElementID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148">
  1218.  
  1219.           <Name>UPS On Battery</Name>
  1220.  
  1221.           <Description>Checks if the UPS is on battery or it's on bypass</Description>
  1222.  
  1223.         </DisplayString>
  1224.  
  1225.         <DisplayString ElementID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148" SubElementID="UIGeneratedOpStateId262315817d204b72b902cc96a995fecd">
  1226.  
  1227.           <Name>Healthy</Name>
  1228.  
  1229.         </DisplayString>
  1230.  
  1231.         <DisplayString ElementID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148" SubElementID="UIGeneratedOpStateIddc6fc6951ac24d0ba4bdb2739bb943a1">
  1232.  
  1233.           <Name>Warning</Name>
  1234.  
  1235.         </DisplayString>
  1236.  
  1237.         <DisplayString ElementID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148" SubElementID="UIGeneratedOpStateId419103a160794c2eb1b4166c0b6d7b75">
  1238.  
  1239.           <Name>Unhealthy</Name>
  1240.  
  1241.         </DisplayString>
  1242.  
  1243.         <DisplayString ElementID="UIGeneratedMonitor6aeaee060c3c495ca2220b648f6fa148_AlertMessageResourceID">
  1244.  
  1245.           <Name>UPS On Battery</Name>
  1246.  
  1247.           <Description>UPS is on battery or on ByPass. Please see the alert context for details.
  1248.  
  1249.  
  1250.  
  1251. UPS name: {0}
  1252.  
  1253.  
  1254.  
  1255. Additional informations: {1}</Description>
  1256.  
  1257.         </DisplayString>
  1258.  
  1259.         <DisplayString ElementID="RunAsProfile_d47a0ecf95aa403db2916803fc08ae03">
  1260.  
  1261.           <Name>UPS Solution SNMP</Name>
  1262.  
  1263.           <Description>Profile to be used for UPS Solution MP on CMA group</Description>
  1264.  
  1265.         </DisplayString>
  1266.  
  1267.       </DisplayStrings>
  1268.  
  1269.     </LanguagePack>
  1270.  
  1271.   </LanguagePacks>
  1272.  
  1273. </ManagementPack>
  1274.  
  1275.  
Tags: xml SCOM MP
Advertisement
Add Comment
Please, Sign In to add comment