Hi, Mark Manty Premier Field Engineer for Microsoft here.
Many customers want an automated way to enable agents to act as proxy. Many use PowerShell scripts to perform this on a daily or weekly basis.
Kevin Holman has an excellent example of how to perform this with a PowerShell script: http://blogs.technet.com/b/kevinholman/archive/2010/11/09/how-to-set-agent-proxy-enabled-for-all-agents.aspx?Redirected=true
However, some enterprise customers may have rules in place that prevent you from running PowerShell scripts that are unsigned. While you can sign your PowerShell scripts, it can be time consuming: http://technet.microsoft.com/en-us/magazine/2008.04.powershell.aspx
This example could be scheduled to run to ensure your agents are set to allow agents to run as proxy without having to dig through your agent list or alerts to find out what agents may require this.
Let’s go.
This sample program takes one parameter:
• RMS Server name, example MyRMSServer
I ran this in a test environment and it does not have to run on a RMS or MS to work. It must meet the below requirements in order to run successfully:
• .NET 3.5 Framework
• SCOM R2 Console (User Interface installed)
• Run as account that has administrative rights to the SCOM Management Group
Open an administrative command prompt running under an account that has SCOM administrative privileges.
Change to the directory where you extracted SetAgentProxyEnabled.exe.
Run program “SetAgentProxyEnabled.exe MyRMSServer” where MyRMSServer is your RMS server name and press enter to run.
Program will list all agents that it updated and return count of updated agents. This program will also update any Management servers should they not have Proxy enabled. Below is an example of running the tool. Note that the server is not set to allow this agent to act as proxy.
Run the tool to update.
Now my agent has been updated to act as proxy.
Disclaimer:
This example is provided “AS IS” with no warranty expressed
or implied. Run at your own risk.
The opinions and views expressed in this
blog are those of the author and do not necessarily state or reflect those of
Microsoft.
Hi, I am Mark Manty Microsoft Premier Field Engineer for SCOM.
Today I wanted to touch on Orchestrator and the SCOM 2007 R2 Integration pack.
With the new version of SCOM 2012 on the horizon you may have already begun planning your migration. The Universal connector will not be supported in SCOM 2012. The recommendation for replacing this functionality is Orchestrator.
Here is an example of how you can utilize Orchestrator with the SCOM integration pack to update alerts.
Launch System Center Orchestrator Runbook Designer.
Expand Runbooks folder in Connections view and Right click to create new folder.
Enter a name for the folder.
Expand Activities – Operations Manager 2007 R2 and drag over Get Alert and Update Alert.
Select Get Alert object and drag arrow over to connect to Update Alert object to create the flow.
Select the Get Alert object and right click for properties.
Select “…” to add connection.
Choose your SCOM RMS connection.
Select “Add…” to select what alerts you want to update.
In this case I selected all alerts that have a Resolution state of AUCForward. You could refine to make much more granular to meet your requirements.
Select Arrow and right click Properties to bring up Link properties.
Change Include to AlertCount from GetAlert is Greater than 0. We only want to update alerts if we find any.
Right Click Alert Update object and select Properties.
Right click in Alert ID properties to Subscribe -> Published Data.
Select Id from GetAlert and select Ok.
Click “Select Fields…” to select fields to update.
I selected Resolution state to change to SCORCH. You can select additional fields to update as needed.
Now you can select Runbook tester to verify that the alerts are updated.
Select Run to Breakpoint and then Alerts should be updated.
See status in Log window.
Note that the resolution state was successfully updated.
See the properties on alert History tab to validate Orchestrator updated the alert.
Next add the Activity – Scheduling – Monitor Date/Time object by dragging and dropping in your runbook.
Drag arrow to create flow from Monitor Date/Time to GetAlert object.
Select Properties on Monitor Date/Time object and select for this to run every 10 seconds and select Finish.
Check In your changes.
Right click the tab of the runbook in the designer and select Properties. Note that you can override the default runbook server to select which servers to run this on.
Right click the runbook tab and select Run to start the processing of alerts runbook you created.
If you encounter this error then start Runbook service.
This is an example of how you can automate updating SCOM alerts using System Center Orchestrator 2012. Orchestrator is a very powerful resource for any tasks that you plan to automate.
In customer environments where resources are strained and agent health may have degraded over time this PowerShell cmdlet could help identify the agents in your environment that are currently not functioning. This sample cmdlet can verify if unavailable agents are responding to ping and also remotely check if the HealthService is installed, running and whether it is disabled or set to automatic startup. It also remotely gets the last five or six event log errors from the OpsMgr Event log to help with diagnosing agent issues.
Cmdlet gets all agents that are reporting to the specified Management Group (RMS Server) and returns systems that are “Unavailable” and not in maintenance mode. A System in maintenance mode returns unavailable as it is not currently monitoring, so we exclude those systems from the list returned.
This sample cmdlet takes two parameters:
• First parameter is the RMS Server name, example MyRMSServer
• Second parameter is YES or NO, where YES will perform the remote checking via ping and WMI query to get the state of the HealthService. NO will only return the system names
Below are the instructions on how to install this sample cmdlet on Windows Server 2008 R2 64 bit.
I ran this in a test environment and it does not have to run on a RMS or MS to work. It must meet the below requirements in order to run successfully:
• .NET 4.0 Framework
• PowerShell
• SCOM R2 Console (User Interface installed)
• Run as account that has administrative rights to the SCOM Management Group
• When using “YES” for second parameter: Run as account that has admin rights to systems remotely checking HealthService state OR will not return data for HealthService state
Download the ZIP file that contains PowerShell cmdlet dll file and xml help file (GetUnhealthySCOMAgent.dll and UnhealthyAgentCheck.dll-Help.xml) and save to c:\cmdlets.
PowerShell can read from Powershell.exe.config file that adjusts settings PowerShell uses. If the Powershell.exe.config file does not exist in C:\WINDOWS\system32\WindowsPowerShell\v1.0 then create a Powershell.exe.config file in that directory. If the file exists verify that it is similar to below if required add supportedRuntime v4 line to ensure the cmdlet built on v4 of .NET will work.
Copy the contents below into the config file and save:
Then you can open the file and copy and paste to Excel.
NOTE: This is the command line to use if you want to uninstall the cmdlet:
installutil /u .\GetUnhealthySCOMAgent.dll
Cmdlets can help automate many tasks to reduce workload and improve your environments health. Let me know what you think.
Disclaimer: This example is provided “AS IS” with no warranty expressed or implied. Run at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of Microsoft.
Sealing Management Packs in SCOM requires that you manually type in several paths into the commands you run. If you want to save previous versions this would cause additional changes to command line or manually copying prior versions before sealing again.
REM verify output MP file was created in output directory for new version.
You should have folders that resemble this:
Now you are ready to seal your Management Packs.
Create a folder with your application name (Example: MyWebApp) and copy your unsealed Management pack to this new folder.
Open a command prompt (run as administrator – elevated).
Change to the MPStore directory and run sealmp.cmd MyWebApp.
This will create your key by running sn.exe and will seal the FIRST xml file if finds in the MyWebApp folder.
• · Unsealed MP will be moved to the V1\input folder
. • · Key will be stored in V1\key folder.
• · Sealed MP will be created in V1\output folder.
When you need to modify that MP simply copy your unsealed MP from the V1\input folder to a working folder where you can modify and then increment the MP version. Copy the updated unsealed MP to the MPStore\MyWebApp folder and run sealmp.cmd MyWebApp.
Note the following:
• · Unsealed MP will be moved to the V2\input folder.
• · Key will be used from the V1\key folder. Uses original key from first run for each subsequent seal.
• · Sealed MP will be created in V2\output folder.
Now you have one location that will contain all of your custom Management packs along with version folders for history of each management pack sealed.
I would recommend backing up your MPStore folder to ensure you can recover your custom Management packs should the need arise.
Wanted to call out something that happened recently with a customer. When modifying registry ensure that you double or triple check any changes made: Registry Tweaks (note Kevin’s useful and handy reg add commands – that helps prevent below issue from occurring in first place). A customer had inadvertently added the dalinitiateclearpool new qword (instead of dword) and then the sdk service would not stay running.
Here are the errors you may see on your management server with incorrect keys created. 26399 and 29380 Scroll down and note in the 29380 event log description we see:
“DataAccessRegistry.ReadInitiateClearPool” tipping us off on the issue. Simply delete the qword value and create new dword value and then the sdk service runs as designed.
Log Name: Operations Manager Source: OpsMgr SDK Service Date: 2/5/2013 1:06:23 PM Event ID: 26339 Task Category: None Level: Error Keywords: Classic User: N/A Description: An exception was thrown while initializing the service container. Exception message: Initialize Full exception: Feature of type From Log Name: Operations Manager Source: OpsMgr SDK Service Date: 2/13/2017 14:25:27 Event ID: 26380 Task Category: None Level: Error Keywords: Classic User: N/A Description: The System Center Data Access service failed due to an unhandled exception. The service will attempt to restart. Exception: Microsoft.EnterpriseManagement.ConfigurationReaderException: The feature named ‘OperationsManager’ and of type ‘Microsoft.EnterpriseManagement.ServiceDataLayer.IDataAccessFeature, Microsoft.EnterpriseManagement.DataAccessService.Core, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ cannot be added to the container. —> Microsoft.EnterpriseManagement.ComponentActivationException: The constructor for the component threw an exception. Please see the inner exception for more details. —> System.TypeInitializationException: The type initializer for ‘Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry’ threw an exception. —> System.TypeInitializationException: The type initializer for ‘Microsoft.EnterpriseManagement.DataAccessLayer.GlobalDefaults’ threw an exception. —> System.InvalidCastException: Specified cast is not valid. at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry.ReadInitiateClearPool(String product) at Microsoft.EnterpriseManagement.DataAccessLayer.GlobalDefaults.Initialize(String product) at Microsoft.EnterpriseManagement.DataAccessLayer.GlobalDefaults..cctor() — End of inner exception stack trace — at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry.InitializeStateMap() at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry..cctor() — End of inner exception stack trace — at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry.StateMap(String product) at Microsoft.EnterpriseManagement.DataAccessLayer.RetryPolicy..ctor() at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureImplementation..ctor() at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureImplementation..ctor(EnterpriseManagementObjectViewName objectView) — End of inner exception stack trace — at Microsoft.EnterpriseManagement.ComponentActivator.Activate[T](ActivationContext`1 context) at Microsoft.EnterpriseManagement.SingletonLifetimeManager`1.GetComponent[K]() at Microsoft.EnterpriseManagement.FeatureContainer.GetFeatureInternal[T](Type type, String featureName) at Microsoft.EnterpriseManagement.FeatureContainer.AddFeatureInternal[T,V](ActivationContext`1 context, String featureName) — End of inner exception stack trace — at Microsoft.EnterpriseManagement.ConfigurationReaderHelper.ReadFeatures(XPathNavigator navi, IContainer container) at Microsoft.EnterpriseManagement.ConfigurationReaderHelper.Process() at Microsoft.EnterpriseManagement.ServiceDataLayer.DispatcherService.Initialize(InProcEnterpriseManagementConnectionSettings configuration) at Microsoft.EnterpriseManagement.ServiceDataLayer.DispatcherService.InitializeRunner(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart(Object obj) Event Xml: < Event xmlns=”http://schemas.microsoft.com/win/2004/08/events/event”> < System> < Provider Name=”OpsMgr SDK Service” /> < EventID Qualifiers=”49152″>26380 < Level>2 < Task>0 < Keywords>0x80000000000000 < TimeCreated SystemTime=”2017-02-13T19:25:27.000000000Z” /> < EventRecordID>4783657 < Channel>Operations Manager < Computer>MyComputer.failure.com < Security /> < /System> < EventData> < Data>Microsoft.EnterpriseManagement.ConfigurationReaderException: The feature named ‘OperationsManager’ and of type ‘Microsoft.EnterpriseManagement.ServiceDataLayer.IDataAccessFeature, Microsoft.EnterpriseManagement.DataAccessService.Core, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ cannot be added to the container. —> Microsoft.EnterpriseManagement.ComponentActivationException: The constructor for the component threw an exception. Please see the inner exception for more details. —> System.TypeInitializationException: The type initializer for ‘Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry’ threw an exception. —> System.TypeInitializationException: The type initializer for ‘Microsoft.EnterpriseManagement.DataAccessLayer.GlobalDefaults’ threw an exception. —> System.InvalidCastException: Specified cast is not valid. at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry.ReadInitiateClearPool(String product) at Microsoft.EnterpriseManagement.DataAccessLayer.GlobalDefaults.Initialize(String product) at Microsoft.EnterpriseManagement.DataAccessLayer.GlobalDefaults..cctor() — End of inner exception stack trace — at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry.InitializeStateMap() at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry..cctor() — End of inner exception stack trace — at Microsoft.EnterpriseManagement.DataAccessLayer.DataAccessRegistry.StateMap(String product) at Microsoft.EnterpriseManagement.DataAccessLayer.RetryPolicy..ctor() at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureImplementation..ctor() at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureImplementation..ctor(EnterpriseManagementObjectViewName objectView) — End of inner exception stack trace — at Microsoft.EnterpriseManagement.ComponentActivator.Activate[T](ActivationContext`1 context) at Microsoft.EnterpriseManagement.SingletonLifetimeManager`1.GetComponent[K]() at Microsoft.EnterpriseManagement.FeatureContainer.GetFeatureInternal[T](Type type, String featureName) at Microsoft.EnterpriseManagement.FeatureContainer.AddFeatureInternal[T,V](ActivationContext`1 context, String featureName) — End of inner exception stack trace — at Microsoft.EnterpriseManagement.ConfigurationReaderHelper.ReadFeatures(XPathNavigator navi, IContainer container) at Microsoft.EnterpriseManagement.ConfigurationReaderHelper.Process() at Microsoft.EnterpriseManagement.ServiceDataLayer.DispatcherService.Initialize(InProcEnterpriseManagementConnectionSettings configuration) at Microsoft.EnterpriseManagement.ServiceDataLayer.DispatcherService.InitializeRunner(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart(Object obj) < /EventData> < /Event>
This management pack has two monitors configured for monitoring the MongoDB Windows service and monitor and alert when less than 100 connections are available.
The management pack collects many performance counters from a script that runs ServerStatus query every 15 minutes. If you want to disable or add counters to be collected, you must edit the script data source.
Details on removing (disabling a collection) below:
Open the MP with notepad and cut any lines that you do not
want collected.
Move them above where the performance counters that are
disabled are located and comment out the lines that you move by putting a
single quote ‘ character at the front of the line.
Details on adding performance counter to collect that is
returned from ServerStatus:
To add counters cut them from the commented out lines and move them to the variable selection. Then uncomment out the line by removing the single quote ‘ character at front of line.
Adding threshold monitors for a given counter details below:
With Management pack already installed in your environment, select
Authoring and change Scope to MongoDB 4.x Windows Server.
Select Authoring – Management Pack Objects – Monitors and right click create a monitor – Unit Monitor.
Select Scripting – Generic – Timed Script Two State Monitor. Select the MongoDB MP and select Next.
Provide a name for the new unit monitor and select the target of MongoDB 4.x Windows Server and select Next
Select the frequency to run the monitor (default is 15minutes) and select Next.
Copy script below and paste into next screen for script.
Note at end of script if you want to change <= to >=
based on the way you want your threshold check to be less than or greater than
the value passed to the script.
‘ SCRIPT NAME: MongoDBServerStatusCheckValue.vbs
‘ PARAMETERS: 10 “asserts.rollovers”
‘ Where 10 is the
Threshold to check counter value
‘ and
“asserts.rollovers” is the counter value to check from custom perf
collection
‘ Returns: State = “Good” or “Bad”
‘ SCOM
Parameter Name: Property[@Name=’State’]
‘ Unhealthy:
Contains “Bad”
‘ Healthy:
Contains “Good”
‘ Return =
“Custom Message you want to display in the Alert Message”
‘
‘ ALERT MESSAGE: To display in Alert description
“Return” value see below example
sReturn =
“MongoDB ServerStatus Value for ” & sCounterCheck &
” was equal to or exceeded
threhsold of ” & iThreshold & “. Current value checked was
” & line & “. Command run to get value: ” & sCommand