Archive | SCOM RSS feed for this section

O no I forgot my SCOM account passwords!!

25 May

 

Problem:

O no I forgot my SCOM account passwords!! I don’t know the password of the Data Access, Data Reader and Writer account anymore. Resetting it in AD will force me to do a lot of tweaking to correct the accounts in SCOM.

Don’t worry we will find them for you.

Analyse:

 

SCOM stores the account passwords in the “Run AS Configuration -> Accounts” section. This account information is linked to a “Run As profile”. This Run as Profile can be assigned to a SCOM Workflow (Rule/Monitor/Task…) so that this workflow is going to run under the account security context.

 

Nice but we still can’t see the password on the accounts.

 

Solution:

 

But we can also do other things with the Run As profile. We can just assign them as a parameter to for example a script. In the script we can readout the account information and find our lost password.

In SCOM we can use the secure script provider (vbscript) aka “Microsoft.Windows.ScriptWriteAction”. The secure script provider streams the run as information as an input stream to the VBScript. So if you read this input stream at top of your script you will get the account information. This can be tricky sometimes.

See an example below:

<WriteActions>

<WriteAction ID=”sc” TypeID=”Windows!Microsoft.Windows.ScriptWriteAction”>

<ScriptName>ScriptName.vbs</ScriptName>

<Arguments />

<ScriptBody><![CDATA[ Set oAPI = CreateObject(“MOM.ScriptAPI”)

Set oArgs = WScript.Arguments

 

password= WScript.StdIn.ReadLine()

Call oAPI.LogScriptEvent(“ScriptName.vbs”, 101, 2, “Debug password = ” & password)

]]></ScriptBody>

<SecureInput>$RunAs[Name=”RUNAS_PROFILE_1″]/UserName$ $RunAs[Name=” RUNAS_PROFILE_1″]/Password$</SecureInput>

<TimeoutSeconds>300</TimeoutSeconds>

</WriteAction>

</WriteActions>

 

Using the SecureInput parameter we can provide the Run as account information. For getting the UserName we use :

$RunAs[Name=”RUNAS_PROFILE_1“]/UserName$

And for the password we use

$RunAs[Name=”RUNAS_PROFILE_1“]/Password$

The RUNAS_PROFILE_1 is the internal name of the Run as profile in SCOM. You can use Powershell “Get-SCOMRunAsProfile” to get the internal names.

I hear you thinking, this is way too old, this is VBScript, we WANT PowerShell! And I agree completely.

So for PowerShell we can use the normal PowerShell script provider aka “Microsoft.Windows.PowerShellProbe”. We don’t have to apply a secureinput parameter but just very simple supply the RunAs as a normal parameter. And this will do the trick.

<ProbeAction ID=”Probe” TypeID=”Windows!Microsoft.Windows.PowerShellProbe”>

<ScriptName>DisplayCerdentials.ps1</ScriptName>

<ScriptBody><![CDATA[Param(

$USERNAME,

$PASSWORD

)

 

# output the input paramters

Write-Output “UserName: $USERNAME”

Write-Output “Password: $PASSWORD”

 

# end script

 

]]></ScriptBody>

<SnapIns />

<Parameters>

<Parameter>

<Name> USERNAME </Name>

<Value>$RunAs[Name=”MSDL!Microsoft.SystemCenter.DataWarehouse.ActionAccount”]/UserName$</Value>

</Parameter>

<Parameter>

<Name> PASSWORD </Name>

<Value>$RunAs[Name=”SC!Microsoft.SystemCenter.DatabaseWriteActionAccount”]/Password$</Value>

</Parameter>

 

</Parameters>

<TimeoutSeconds>300</TimeoutSeconds>

<StrictErrorHandling>true</StrictErrorHandling>

</ProbeAction>

 

Now we make a simple workflow for example a task and add use this probeaction.

Concussion

 

You see it’s very simple to get account information that’s stored in the run as accounts / profiles. If this is good is up to you.

To make it even easier I created a MP that will display the most important account information (so the usernames and passwords).

You simply import the MP and select the Managementserver target and press the special task “GetRunAsCredentials”.

The account information will be displayed in the task output.

 

Download link for the Management Pack:

https://onedrive.live.com/redir?resid=A6ECD6E173E79D82!137890&authkey=!AEuYWi5Z6etHxno&ithint=file%2cxml

NOTICE: Please remember that the task output is stored in the SCOM Databases so it can be traced back not very secure I think. So use this only in emergencies. Or change the PowerShell script to write it to a file!!

 

Happy SCOMMING!

Michel Kamp

Touching SCOM

https://michelkamp.wordpress.com

 

 

 

[O so Cool] Connecting your Raspberry PI (RPi) to OMS.

8 Feb

 

At my home I have a Raspberry to do all my home automation. (Light, temperature, alarm, cams etc.) . Since the OMS Linux agent is available I was wondering if I could use this agent to monitor my raspberry pi without having a SCOM environment in place.

AND guess what? YES you can!!!

First before you are accusing me of plagiarism I have to say all the credits go to the guy of this blog ( http://kentablog.cluscore.com/2015/12/raspberry-pi-iot-oms_62.html ).

So I followed the steps and it worked. You can’t use the wget described on the oms Quick install Guide ( https://github.com/Microsoft/OMS-Agent-for-Linux ) because this one will fail due to the pre check of AMD64.

Since the RPI platform isn’t AMD64 you will have to trick it a little.

So you will have to follow the steps below:

1

Install The OS on your RPI

We take the latest RASPBIAN WEEZY

https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip

2

Open a putty and log on as pi / raspberry

 

3

Now we install the Ruby , and fluent modules

sudo aptitude install ruby-dev git make

sudo gem install fluentd

sudo fluent-gem install fluent-plugin-td

     

4

Next we create a user that the OMS agent service is using for running. Remember the password you provide

sudo adduser omsagent

     

5

Now we are going to get the OMS source code for github

git clone https://github.com/Microsoft/OMS-Agent-for-Linux.git

6

Next is to create the directory structure since we can’t use the OMS installer

sudo mkdir -p /etc/opt/microsoft/omsagent/certs

sudo mkdir -p /etc/opt/microsoft/omsagent/conf/omsagent.d

sudo mkdir -p /etc/opt/microsoft/omsagent/sysconf

sudo mkdir -p /etc/opt/microsoft/scx/conf

sudo mkdir -p /opt/microsoft/omsagent/bin

sudo mkdir -p /opt/microsoft/omsagent/plugins

sudo mkdir -p /var/opt/microsoft/omsagent/tmp

sudo mkdir -p /var/opt/microsoft/omsagent/run

sudo mkdir -p /var/opt/microsoft/omsagent/log

sudo mkdir -p /var/opt/microsoft/omsconfig/log

sudo mkdir -p /var/opt/microsoft/omsconfig/run

sudo chown omsagent:omsagent -R /var/opt/microsoft/omsconfig

sudo chown omsagent:omsagent -R /var/opt/microsoft/omsagent

sudo ln -s /usr /opt/microsoft/omsagent/ruby

sudo ln -s /usr/local/bin/fluentd /opt/microsoft/omsagent/bin/omsagent

7

We setup the correct config files for the OMS agent service

sudo cp OMS-Agent-for-Linux/installer/scripts/auth_key.rb /opt/microsoft/omsagent/bin/

sudo cp OMS-Agent-for-Linux/installer/scripts/omsadmin.sh /opt/microsoft/omsagent/bin/

sudo chmod u+x /opt/microsoft/omsagent/bin/omsadmin.sh

sudo cp OMS-Agent-for-Linux/installer/scripts/service_control /opt/microsoft/omsagent/bin/

sudo cp OMS-Agent-for-Linux/installer/scripts/omsagent.ulinux /etc/init.d/omsagent

sudo chmod u+x /etc/init.d/omsagent

sudo cp -Rf OMS-Agent-for-Linux/source/code/plugins /opt/microsoft/omsagent/

8

We copy the default agent configuration files , we are going to change this later on to specify what we want to monitor

sudo cp OMS-Agent-for-Linux/installer/conf/omsagent.conf /etc/opt/microsoft/omsagent/conf/

sudo mv /etc/rsyslog.conf /etc/rsyslog.conf.default

sudo cp OMS-Agent-for-Linux/installer/conf/rsyslog.conf /etc/

9

And this is probably the trick for this all. We fake the OMS agent to believe it’s an AMD64 platform.

sudo echo “1.0.0-47 20151102 Developer_Build” > /tmp/installinfo.txt

sudo echo `date +%Y-%m-%dT%H:%M:%S` >> /tmp/installinfo.txt

sudo mv /tmp/installinfo.txt /etc/opt/icrosoft/omsagent/sysconf/

sudo echo “OSName=Ubuntu” > /tmp/scx-release

sudo echo “OSVersion=14.04” >> /tmp/scx-release

sudo echo “OSFullName=Ubuntu 14.04 (x86_64)” >> /tmp/scx-release

sudo echo “OSAlias=UniversalD” >> /tmp/scx-release

sudo echo “OSManufacturer=Canonical Group Limited” >> /tmp/scx-release

sudo mv /tmp/scx-release /etc/opt/icrosoft/scx/conf/

10

Now we are going to onboard the OMS agent to your OMS workspace.

Get your (1) <workspace id> and (20 <key> from the OMS page -> Settings -> Connected Sources

 

 

 

11

And we fill it in the omsadmin script as parameters

sudo /opt/microsoft/omsagent/bin/omsadmin.sh -w <workspace id> -s <key>

   

If everything is successful it will give you the onboard message. If not check the keys.

12

Next is to edit the OMS agent config to let it know what it should monitor.

Since the OMI agent isn’t installed on this platform we can only do the syslog stuff for now.

sudo vi /etc/opt/microsoft/omsagent/conf/omsagent.conf

13

The most important is to check if this elements exists in the file

<source>

type syslog

port 25224

bind 127.0.0.1

tag oms.syslog

</source>

 

<filter oms.syslog.**>

type filter_syslog

</filter>

14

Now we are going to let the OMS agent startup correctly as a service. We have to manipulate the init.d file a bit to have it run from of the source files we got from git hub.

sudo vi /etc/init.d/omsagent

15

Edit the file

Change this line:

START_QUALS=”-d $PIDFILE –no-supervisor -o $LOGFILE”

To:

START_QUALS=”-d $PIDFILE –no-supervisor -o $LOGFILE -p /opt/microsoft/omsagent/plugins -c /etc/opt/microsoft/omsagent/conf/omsagent.conf

16

Next we setup the syslog log levels. Just get all 😉

sudo vi /etc/rsyslog.conf

add this row

*.* @127.0.0.1:25224

17

And we startup the OMS agent

sudo service omsagent start

18

And the syslog deamon

sudo service rsyslog restart

19

Now you logon to the portal http://oms.microsoft.com

And you watch for the syslog event type messages. Could take some minutes.

Go to Search and type: “* Type=Syslog” (without the quotes)

Or you search by name if you know the PRI host name: “* HostName=raspberrypi” (without the quotes)

20

This could be the output. We see the startup syslog messages!!!

 

Cool isn’t it!!

Next step would be to get the OMI agent working so we can readout the performance data.

 

Happy OMS’ing

Michel Kamp

Touching SCOM

https://michelkamp.wordpress.com

 

 

[FOR the MP Devs] Grooming your managed objects completely from scom

8 Feb

Hi,

I some situations when you are developing a new MP you want to be sure that your discovery’s are working correctly.

The problem

Normally you would let the discovery run and watch if the managed object is created, but after the first time discovering and un-discovering the managed object it could trick you for the next discovery.

Basically we as MP devs know that we can simply manual delete a managed object from scom by using a SQL query and set the isDeleted to true. But this can be tricky. If the discovery workflow runs again and create a managed object (the same) it will just update the isDeleted to False. So basically you are getting ‘old’ discovery data. Knowing this in some cases the configuration is not updated and the workflows under this managed object just won’t get executed. So you will be stuck in having an uninitialized managed object(s). Especially when using Managed objects that are managed by a scom resource pool can be facing this issue.

Solution

Two solution could help you out. (ALL UNSUPPORTED BY MICRSOSOFT, but yhea … no guts no glory)

  1. Wait 2 days … then the normal purge will kick in
  2. Modify the purging threshold and manual run the purge

The SQL script below provides step 2. Connect to the operational DB as admin and follow the steps.

Before you run it you will have to change ‘vcenterlab.contoso.com‘ to the first parent name you want to delete. (By not including the right % in the like) In this case it’s the parent of all VMWARE monitoring managed objects.

————————————————–
— Delete a managed object completely from scom

————————————————–

— Michel Kamp

————————————————–

————- Find the object

select
*
from dbo.BaseManagedEntity where FullName like
%:vcenterlab.contoso.com’

————- delete it (hmmm okay mark it as delete)

update dbo.BaseManagedEntity set IsDeleted=1 where FullName like
%:vcenterlab.contoso.com’

— object is still in DB but now as isdeleted = true

— it will be deleted after 2 days. but we don’t want to wait.

— we force the delete by setting the purgedate delta to 0

————- Update the purge date time function

ALTER
FUNCTION [dbo].[fn_DiscoveryDataPurgeThreshold]()

RETURNS
datetime

BEGIN

    –RETURN DATEADD(dd, -2, getutcdate())

    RETURN
DATEADD(dd, 0, getutcdate())

END

— now we call the purge stp to clean it all

————- do the real purge

exec p_DiscoveryDataPurging

— we do a check if it is gone.

————- Find the object

select
*
from dbo.BaseManagedEntity where FullName like
%vcenterlab.contoso.com’

— and there should not be any (0) result.

— End script

O don’t forget to change the DiscoveryDataPurgeThreshold back to its original when you are ready …

Happy SCOMMING PURGING

Michel Kamp

TOUCHING SCOM

https://michelkamp.wordpress.com/

[FIX] Part 2. Fixing the Top n by Performance Widget now the supported way

5 Sep

 

Hi,

In May this year I posted an article on how to fix the top-n widgets. https://michelkamp.wordpress.com/2014/05/27/fix-fixing-the-top-n-by-performance-widget/

This unsupported fix worked great for SCOM 2012 CU1/6 and SCOM 2012 R2 UR1/2.

I don’t know if the SCOM product team has read my blog but it seems they have listened and responded to the community! 😉 Because now, after almost a year, by applying SCOM 2012 Sp1
CU7 or SCOM 2012 R2 Update Rollup 3 it is officially FIXED !!!

Thank you Microsoft SCOM product team for this fix !!

 

Analyze:

 

To verify you open the stored procedure “[sdk].[Microsoft_SystemCenter_Visualization_Library_TopNEntitiesByPerfGet]” from the DWH database.

The part where we had to replace the = by like is now completely rewritten. By using an extra stored procedure “[sdk].[Microsoft_SystemCenter_Visualization_Library_PerformanceCounterListByMultipleManagedEntities]

Let’s look it up:


— Use existing sprocs to narrow down the perf counter instances that are valid for the contained types. Avoids duplicating that logic here.


INSERT
INTO
#ResolvedPerfInstancesTable
(ContainerManagedEntityRowId, ObjectName, CounterName, InstanceName, PerformanceRuleInstanceRowId, ManagedEntityRowId)


EXEC
[sdk].[Microsoft_SystemCenter_Visualization_Library_PerformanceCounterListByMultipleManagedEntities]


@ManagementGroup
=
@ManagementGroup,


@ObjectNamePattern= @ObjectNamePattern,


@CounterNamePattern
=
@CounterNamePattern,


@InstanceNamePattern
=
@InstanceNamePattern

 

Looking into this extra stored procedure gives me the wanted ‘Like’ statement we were waiting for:


— Populate this table with the target types of the matching rules.


INSERT
INTO
#RuleTargetTypesAndTheirBaseTypes


SELECT
RMV.TargetManagedEntityTypeRowId, PR.ObjectName, PR.CounterName, PR.RuleRowId, METMPV.AbstractInd


FROM
vPerformanceRule
PR


JOIN
RuleManagementPackVersion
RMV
ON
RMV.RuleRowId = PR.RuleRowId


AND
EXISTS
(SELECT
ManagementPackVersionRowId
FROM
dbo.ManagementGroupManagementPackVersion
M2


WHERE
M2.ManagementPackVersionRowId = RMV.ManagementPackVersionRowId


AND
M2.LatestVersionInd=1)


JOIN
ManagedEntityTypeManagementPackVersion
METMPV
ON
METMPV.ManagedEntityTypeRowId = RMV.TargetManagedEntityTypeRowId


JOIN
dbo.ManagementGroupManagementPackVersion
MGMPV
ON
MGMPV.ManagementPackVersionRowId = METMPV.ManagementPackVersionRowId


AND
MGMPV.LatestVersionInd=1


AND
MGMPV.ManagementGroupRowId=@MGRowId


WHERE ((PR.ObjectName
LIKE
@ObjectNamePattern)


AND
(PR.CounterName
LIKE
@CounterNamePattern))

 

Solution:

 

You can download the SCOM 2012 SP1 CU7 here http://support.microsoft.com/kb/2965089

And the SCOM 2012 R2 Update Rollup 3 here http://support.microsoft.com/kb/2965445

As always I have the habit to walk on the edge of supported/unsupported scenarios so in case of you are in a situation you can’t apply the complete update package you could (haven’t tested it yet) import only the updated MPs located in the directory:

C:\Program Files\System Center 2012\Operations Manager\Server\Management Packs for Update Rollups

Especially MPs Microsoft.SystemCenter.Visualization.Component.Library.mpb and Microsoft.SystemCenter.Visualization.Library.mpb because they contain the widget fix.

 

So community keep on SCOMMING and making great dashboards!!

Michel Kamp

https://michelkamp.wordpress.com

[FIX] Fixing the Top n by Performance Widget

27 May

Update!: Fixed the run issue on SCOM 2012 R2 installations in MP version V1.0.0.6 . Thanks community for pointing out to this R2 issue.

Challenge:

First, I really LOVE the dashboard widgets included in SCOM. When making MPs I always deliver dashboards that gives the operator a one shot overview of the monitored targets. The most used and valuable widget for this is the “Objects by performance Widget”

This works perfect EXECPT when you have more instances of a performance value. Let’s say the table space free of table spaces, or disk C: D: ect from windows servers.

The problem is that most of the time you will get the situation below “Empty Widgets”

 

The problem is the Stored Procedure “Microsoft_SystemCenter_Visualization_Library_TopNEntitiesByPerfGet“. I don’t go into details because this issue is a known fact and already reported several times on the community. For example by Cameron Fuller http://blogs.catapultsystems.com/cfuller/archive/2013/06/05/issue-with-the-objects-by-performance-widget-with-and-all-performance-instances-scom-sysctr.aspx

But a fix for this in a SCOM CU was till now never released…. Till now….

 

Analyze

As I mentioned before it’s in the Stored Procedure “Microsoft_SystemCenter_Visualization_Library_TopNEntitiesByPerfGet“. We have a code part that does an exact match on the instance name. If we want to show all instances it will not return any matches. See the yellow parts below.

  •    INSERT
    INTO
    #ResolvedSeriesTable(ManagedEntityRowId, PerformanceRuleInstanceRowId)

                  SELECT
    CET.ContainedEntityRowId, PRI.PerformanceRuleInstanceRowId

                  FROM
    PerformanceRule
    PR

                  JOIN
    PerformanceRuleInstance
    PRI
    ON (PR.RuleRowId = PRI.RuleRowId)

                  JOIN
    #ContainedEntitiesTable
    CET
    ON (1=1)

            WHERE (
    (PR.ObjectName
    =
    @ObjectNamePattern)
    AND

                    (PR.CounterName
    =
    @CounterNamePattern)
    AND

                    (PRI.InstanceName
    =
    @InstanceNamePattern))

Suggestion to fix, is to use a like match. See yellow part.

       INSERT
INTO
#ResolvedSeriesTable(ManagedEntityRowId, PerformanceRuleInstanceRowId)

              SELECT
CET.ContainedEntityRowId, PRI.PerformanceRuleInstanceRowId

              FROM
PerformanceRule
PR

              JOIN
PerformanceRuleInstance
PRI
ON (PR.RuleRowId = PRI.RuleRowId)

              JOIN
#ContainedEntitiesTable
CET
ON (1=1)

        WHERE (
(PR.ObjectName
like
@ObjectNamePattern)
AND

                (PR.CounterName
like
@CounterNamePattern)
AND

                (PRI.InstanceName
like
@InstanceNamePattern))

 

To change this you will need SQL Developer knowledge. And I realize that most of the operators know a lot of backend/frontend products but aren’t developers. So it could be a bit of a challenge to change this stored procedure yourself.

 

Solution

To solve this issue I have created a Management Pack that changes this stored procedure for you. It doesn’t do this automatically, because I want you to choose to do it. So I implemented it as a SCOM task. When you import the MP and go the ManagementServer target that has the property “Is Root Health Service Emulator = True” (you can find it in the view Operations Manager -> Management Server -> Management Servers State) you will see a Task “Task Fix TopNQuery Widget“. Now you execute the task and you will see a Task output below:


And you go to the Widget dashboard you created and what do you see ????

 


Yes a working TopN Widget page.

 

NOTICE!!!

Using this task is totally unsupported. But in my opinion the negative impact is very low compared to the positive impact because this stored procedure is only used for reading data and not changing it so it wouldn’t impact the DB with incorrect data (except for some SQL performance penalty for the use of the like statement).

NOTICE!!!

When you reload the MP Microsoft.SystemCenter.Visualization.Library the stored procedure will be overwritten to the original version. This could happen if you implement an upcoming CU release. If the issue isn’t fixed in this release you must rerun the TASK again.

 

You can download this MP on my personal download site:

https://onedrive.live.com/redir?resid=A6ECD6E173E79D82!6314&authkey=!AE0rJkhRPXOcblI&ithint=file%2c.zip

Happy Scomming

Michel Kamp

Reading out PS NoteProperty’s

6 Nov

 

Case:

How do i read out the IsManagementServer property on the example below ??

$X= Get-SCOMClass -Name “Microsoft.SystemCenter.ManagementServer” | Get-SCOMMonitoringObject

The output is:

[Microsoft.SystemCenter.HealthService].AuthenticationName : SRV.stateview.nl

[Microsoft.SystemCenter.HealthService].MaximumQueueSize : 104857600

[Microsoft.SystemCenter.HealthService].MaximumSizeOfAllTransferredFiles : (null)

[Microsoft.SystemCenter.HealthService].RequestCompression : True

[Microsoft.SystemCenter.HealthService].CreateListener : True

[Microsoft.SystemCenter.HealthService].Port : 5723

[Microsoft.SystemCenter.HealthService].IsRHS : True

[Microsoft.SystemCenter.HealthService].IsManagementServer : True

 

Now I want to get the IsManagementServer value

$.[Microsoft.SystemCenter.HealthService].IsManagementServer

But it Fails

$.IsManagementServer

But it Fails

How do I read it out ??

Solution:

Running the command below..

$x | GM

pointed out it was a noteproperty

image  

So since its using [] i have to use ” to make a string of it

So the correct syntax would be

$x.'[Microsoft.SystemCenter.HealthService].IsManagementServer’.value

Happy Scomming

Michel Kamp

Starting blogging again

6 Nov

Case:

Maybe you noticed that I didn’t post no more for a couple of month.

Analyze:

Yes I bought a new home. Knipogende emoticon  So I had to renovate it all. It took(and still takes) a lot of time. But I will try to post regular again.

WP_001616 WP_001849image

Solution:

1) do not buy a new home ! it will save you time…

2) stop blogging. …. not a option

3) start again if you have time … hmmm

I prefer #3. Knipogende emoticon

Happy scomming soon

Michel Kamp