Home » 2010 » February

Monthly Archives: February 2010

Query a database with a monitor – part two

In this post I wrote about a script that you can use to query a databas. The script in this post will count number of fields, if there are more then four, status of the monitor will be changed. It will also include number of rows in the alert description. I use the following settings on the monitor, a scripting/timed script two state monitor. In the following example I have a database on my root management server. The database is named TechDaysdb and includes a table named OpsMgrV. The name of the root management server is mobile-opsmgr.

  • General
    • Name: Contoso – query db monitor
    • Monitor Target: for Root Management Server
    • Management Pack: TechDays demo
  • Schedule
    • Run every 2 Minutes
  • Script
    • File Name: TechDaysmonitor.vbs
    • Script: see below
  • Unhealthy Expression
    • Property[@Name=’Status’] does not contain Ok
  • Healthy Expression
    • Property[@Name=’Status’] contain Ok
  • Health
    • Healthy Healthy Healthy
    • Unhealthy Unhealthy Warning
  • Alerting
    • check Generate alerts fort this monitor
    • check Automatically resolve the alert when the monitor returns to a healthy state
    • Alert Name: TechDays – db monitor
    • Alert Description: There are to many rows in the database. There are $Date/Context/Property[@Name=’Rows’]$ rows.

 

Const adOpenStatic = 3

Const adLockOptimistic = 3
Set oAPI = CreateObject(“MOM.ScriptAPI”)
Set oBag = oAPI.CreatePropertyBag()
Set objConnection = CreateObject(“ADODB.Connection”)
Set objRecordSet = CreateObject(“ADODB.Recordset”)
objConnection.Open _
“Provider=SQLOLEDB;Data Source=mobile-opsmgr;” & _
“Trusted_Connection=Yes;Initial Catalog=TechDaysdb;” & _
“User ID=domain\username;Password=password;”
objRecordSet.Open “SELECT * FROM OpsMgrV”, _
objConnection, adOpenStatic, adLockOptimistic
varNo = objRecordSet.RecordCount
If varNO > 4 Then
Rows = varNo
Call oBag.AddValue(“Status”,”Error”)
Call oBag.AddValue(“Rows”,Rows)
Call oAPI.Return(oBag)
Else
Call oBag.AddValue(“Status”,”Ok”)
Call oAPI.Return(oBag)
End If

Port 1434 UDP

Some time ago I installed a management server in a network different that the one where the Operations Manager 2007 database and root management server was installed. According to the guide I would need to open port 1434 between management server and database, 5723/5724 between management server and root management server and 1433 between management server and data warehouse.

But we also found out that when using named SQL instances you will need to open port 1434 UDP between the management server and the SQL database. In our scenario we used named instances on the data warehouse machine. The management server knew about it and tried to query the SQL Browser service on port 1434 UDP to get the correct network port for the SQL instance. Even if the instance is using the default port, the management server needs to query the SQL Browser service to get it. That query is sent on port 1434 UDP.

Importing knowledge into Service Manager 2010

This week I have tested to import knowledge into Service Manager. Knowledge can be used for example as guides in the self service portal for end-users, system documentation for engineers or troubleshooting guides for service desk personnel. One of the ways to get knowledge into Service Manager is to use the CSV import feature. The CSV import feature allows you to bulk-import instances of any class type or projection type defined in the Service Manager Configuration Management Database (SMCMDB). More info about CSV import here.

I started to map the labels on the knowledge form with properties of the knowledge class. When you use the CSV import feature you have one XML file with the properties that you will write data to and in which order they are, then you have a CSV file with the data itself.

Property Form label
Status Status (top left corner of the form)
Tag Flag article as
PrimaryLocaleID Language
Category Category
ArticleOwner ArticleOwner
Comments Comments
CreatedBy CreatedBy
VendorArticleID did not find this one
Title Title
Abstract Description
Keywords Keywords
ArticleId ArticleId
ExternalURLSource did not find this one
ExternalURL URL
AnalystContent Analyst Content
EndUserContent Internal Content

There are a couple of fields where you cant use normal display values, for example the status property, when you import knowledge articles you cant use “Draft” you will have to use “10F171DF-3AB1-648D-D151-D83A5171DD7B” in the CSV file. That is because the knowledge form use StringIds then there is a “translation table” in the database to translate the string into the correct work and language. So how do you get hold of these values?
They are all in the LocalizedText table in the Service Manager database. For example to get the StringID for draft status you can run the following query

SELECT [LTStringId]
,[LanguageCode]
,[LTStringType]
,[ManagementPackId]
,[ElementName]
,[MPElementId]
,[SubElementName]
,[LTValue]
,[TimeAdded]
,[LastModified]
,[DisplayStringId]
FROM [ServiceManager].[dbo].[LocalizedText] WHERE ElementName LIKE '%knowledge%status%draft%'

It will give you a result like this

As you can see there are different values for different languages. When you need to get StringIds for your values you will need to check in this table. During my test I found that you need to do this for status, tag and category.

There are two other intresting properties,  AnalystContent and EndUserContent. When you use these two with the CSV import feature is looking for files in the C:\Program Files\Microsoft System Center\Service Manager 2010 folder (default path). The content in these two files will be uploaded to the corresponding text field in the knowledge article form.

 
The following is a example of a CSV file and a XML file I used to import a knowledge article. If you save them to a folder and import them into Service Manager you will get a new knowledge article with some guidelines in each text field, so you easy can identify where to put your text.

10F171DF-3AB1-648D-D151-D83A5171DD7B,
F982E5B1-7864-7FC5-D0A4-8E000C91C241,75F786E2-CAA7-E7E9-47A0-BCC714BF1EDF,ArticleOwner,Comments,
CreatedBy,VendorArticleID,Title,Abstract,keyword,,
ExternalURLSource,http://www.contoso.se,
comment01.txt,comment02.txt

and the XML file used with the CSV file

Travis Wright in the Service Manager product team has written a good post with more info about this.

Asset Management MP for Service Manager 2010

In a collaborative project we, Patrik Sundqvist and Anders Bengtsson have created an embryo of an Asset Management extension for Service Manager. Our thoughts behind this management pack are to build a version one that we could extend in the future. It is not a feature complete asset management solution for enterprise organizations, but it is a foundation that could give you some ideas what you could do with Service Manager 2010.

Download management pack here and there management pack guide here. If you have any ideas or feedback, send us a e-mail.

Target software packages to a group of users

I tested to modify my announcement customization management pack from this post to extend the package class instead. It works really well, I can target packages to a group of users or to everyone. The following post can be a little bit confusing if you have not read this first, please do.

The management pack looks like this

I can configure a package for which group it will be available in the self service portal. The user can then request the software, a change request must still be approved before they get it. The result is that instead of all users see all packages from Configuration Manager in the self service portal, they only see the package assigned to their group. When I was testing it I used the same groups as in this post.

Target knowledge to a group of users

I tested to modify my announcement customization management pack from this post to extend the knowledge article class instead. It works really well, I can target knowledge articles to a group of users or to everyone. The following can be a little bit confusing if you have not read this first, please do.

  1. Added one new property to the System.Knowledge.Article class, called Group
  2. On the extension tab of the knowledge article form, I configured target group for the article, for exaple 5 for all and 2 for HR
  3. Create a new dynamic group for each department, for example the HR group
    1. Name: Contoso – Knowledge – 2 HR or Everyone
    2. Management Pack: Contoso Knowledge Extension (same as the class extension)
    3. Dynamic members 
    4. For everything else in the group wizard I use default settings
  4. Updated the security user roles from the other post to include also this new group
  5. That would do it 🙂

 

 

  

Â