Use SharePoint Wiki as SCOM Knowledge Base

This is a longer blog post, so please bear with me. Read on if you are interested in how to create a truly useful knowledge base for Operations Manager which offers a lot more than the built-in knowledge management. I’ve done this a couple of years ago for some customers based on Microsoft Office SharePoint Server 2007 and wanted to update the solution to the most recent SharePoint version 2013.

Target Audience

Just to be clear, if you are authoring management packs for a specific product (like Microsoft is authoring MPs such as Exchange or Dell is authoring MPs for their hardware) this is not for you. The target audience are admins of companies who operate and use Operations Manager to monitor their infrastructure and applications. Knowledge management in SCOM (Company Knowledge) isn’t easy and straight forward. It requires you to install a lot of pre-requisites and tools to just get started. The handling of KBs in SCOM in general isn’t very good. I can only see one advantage/feature in using company knowledge: it offers linking of tasks or views but that’s it. Using something like SharePoint offers much more…

Why SharePoint?

Frankly, it’s not really about SharePoint at all. Most other Wiki products, even in-house developed applications can be integrated and tied up together as demonstrated in this blog post. The implementation details may be different but in general this approach works with almost all products which offers you a minimum set of URLs to control whether an article should be created or displayed. I chose SharePoint for the following reasons:

  • It’s a product from Microsoft and already well established in many companies. Those companies may also have good SharePoint know how.
  • I’m not a SharePoint fan or specialist but I had a couple of situations where I needed to work with it. So it kind of felt familiar using something I already knew instead of picking something completely new.
  • Feature wise, SharePoint offers many things which are desirable for knowledge bases:
    • Integrated indexing and search.
    • Access control/permissions if you want or need.
    • Other departments can contribute and enrich knowledge base without having access to the SCOM console.
    • Versioning of articles.
    • Extensible and highly customizable. Additional metadata for your KBs like department, responsibilities, owner, etc. can be entered and used.

This example is shown with a SharePoint Enterprise Wiki Site (which requires the SharePoint Server!). Other wiki products may have similar features. You can also use SharePoint Foundation with a Wiki Page Library. In this case you cannot have any custom layouts and content types.

General Approach: High Level Overview

It all starts with an Alert Task in SCOM. The basic idea is that the user/operator selects an alert in one of the alert views and clicks on an Alert Task (which is executed on the console machine where the SCOM console is running). In general, this console task will open an URL in the default browser and passes on the name of the alert. Alternatively you can also pass in the Alert ID and access the SCOM APIs to get all the alert data needed to continue processing.

The web page which is opened by this task needs to do the following:

  • Normalize the alert name (remove all unsupported/not allowed characters)
  • Use the normalized name to see if a knowledge base article with this name already exists. If yes, just redirect to the article.
  • If the article doesn’t exist yet, redirect to a different page which ideally accepts the normalized name to pre-populate the form to enter a new KB article for the alert name.

That’s it. Easy, right? ; )
Well, back then when I used MOSS 2007 it was pretty easy because you could easily figure out what URLs you needed. Unfortunately in SharePoint 2013 things are a bit different so the approach is a bit different here and is mainly done in JavaScript on the SharePoint side.

Disclaimer

As mentioned before, I’m not a SharePoint expert by any means and I’m certainly not a JavaScript developer (yes, JavaScripts ahead!). So please forgive my ignorance and if there’s a better way to do things, let me know. I also want to mention two good friends of mine who helped me on this: Felix from lemon mojo (JavaScript guru) and Alex from timewarp (SharePoint guru, developer and consultant). Thanks for that!
Downloads and files: At the bottom of this post I provide a zip file with the JavaScript file and the management pack. Keep in mind that you need to make some modifications to get this to work. All files provided are not really tested for production environments. This is more of a proof-of-concept or inspiration which should help you to get started.

Alert Task

Let start with the easy part. First, create a management pack for the task in the Administration space. You can also import the sample MP provided in the zip file and modify the task.
In case you start from scratch, go to the Authoring space, expand the Management Pack Objects and right-click on the Tasks node. Select Create a New Task in the context menu. Select Console Task / Alert command line as the Task Type and make sure you select the previously created management pack at the bottom of the page. Specify a meaningful task name like “Open Knowledge Base”. Note that the name you enter here is the name which shows up in the Tasks panel when you select an alert.

Configure the task as above.

Application: cmd.exe 
Parameters: /c "start "" "http://sclab-sp/kb/Pages/customredirect.aspx?name=$Name$"

We need the cmd.exe /c and the start command to make sure the default browser is executed when launching the URL. The URL is also specific to my lab environment and you need to adapt the URL to match your Sharepoint server and path. Keep an eye on the double-quotes and make sure they are all set correctly. Use a command prompt window to test and debug the command.

Replace sclab-sp with the host name of your SharePoint machine/farm.

Replace /kb with the path to your Enterprise Wiki Site.

Don’t worry about the customredirect.aspx for now. We need to create this page in the next step in order to make this work. You can name this page differently and also host it in a different path as long as you make sure that the JavaScript from the page runs within the SharePoint web part. Talk to your SharePoint master about this!
With the $Name$ variable we pass in the alert name from the console.

Setup SharePoint Enterprise Wiki Site

As mentioned above, I’ve created an Enterprise Wiki Site. For demonstration purposes I’ve also created a new ContentType with an additional Column (Responsible Department) and also created a new template to display the new column on the Wiki page. You need to enable publishing on the site in order to create an Enterprise Wiki Site (click here for more information). The template will not be available if you do not enable it. I will not go into more details here as this is slightly out of scope – maybe I will dedicate a separate blog post about this if more people are interested. In any case, if you do not create a new content type or template, the stuff below will still work with all the defaults. I haven’t tested it but it should also work exactly the same way for standard Wiki Page libraries – even when using SharePoint Foundation.

Create and Setup the CustomRedirect.aspx Page

Once the Wiki is setup, we need to do some magic as described above. In this case a simple JavaScript which processes the alert name from the query string (URL parameter: Name). In this case, we do not really need open different URLs for wiki page display and creation. SharePoint has a JavaScript function which we hijack to do all the work.

First things first: Let’s create the CustomRedirect.aspx page.
Open the Enterprise Wiki Site (Home.aspx – which is created by default). Click on Page, Newand enter the name “CustomRedirect” (it’s important that you use the very same name you picked in the Alert Task above).

Once you are in edit mode on the CustomRedirect.aspx, insert a new Web Part and look for the Content Editor Web Part. Add the web part to the page.

Click on Edit Snippet and paste the JavaScript code below (or attached as download) into the popup:

// the path to the Enterprise Wiki Site in sharepoint
var SitePath = 'kb';

// the wiki path (usually /_layouts/15 under the site path
var WikiPath = '/' + SitePath + '/_layouts/15';

// make sure we only execute when a name is provided and when we are not in design/edit mode
var executeMain = false;
if (querystring('DisplayMode') == 'Design' || querystring('ControlMode') == 'Edit')
    executeMain = false;
else if (querystring('Name') == '' || querystring('Name') == null || querystring('Name') == undefined)
    executeMain = false;
else
    executeMain = true;

if (executeMain)
    main();

function querystring(key) {
    // helper function to access query strings
    var re=new RegExp('(?:\?|&)'+key+'=(.*?)(?=&|$)','gi');
    var r=[], m;
    while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
    return r;
}

function main()
{
  // strip " # % & * :  ?  / { } ~ | from name
  var name = querystring('name');
  name = unescape(name);
  name = name.replace(""", '-');
  name = name.replace('#', '-');
  name = name.replace('%', '-');
  name = name.replace('&', '-');
  name = name.replace('*', '-');
  name = name.replace(':', '-');
  name = name.replace('', '-');
  name = name.replace('?', '-');
  name = name.replace('/', '-');
  name = name.replace("\", '-');
  name = name.replace('{', '-');
  name = name.replace('}', '-');
  name = name.replace('~', '-');
  name = name.replace('|', '-');

  // create new wiki page or redirect to existing page
  var PopupUrl = WikiPath + '/WikiRedirect.aspx?url=/' + SitePath + '/Pages/' + name + '.aspx&Source=/' + SitePath + '/Pages/Home.aspx&IsDlg=1';
  // internal javascript function from sharepoint we hijack to open/create the wiki page
  OpenPopUpPage(PopupUrl);

}

 

You can go through the script and the comments. Essentially the script takes the alert name from the query string, forms some weird URL and executes the internal SharePoint function OpenPopUpPage. Luckily this function seems to only create a popup when the page you are trying to access doesn’t exist. If it does exist, it will just redirect you to the page. Perfect!

Result

Now that everything is set up, let’s see how it looks like.
An operator selects an alert and clicks on the task to open the knowledge base:

The operator is presented with the custom redirect page if no KB entry is available for the selected alert:

After clicking the Create button you can start using the KB entry for this alert:

Two things to note here: 
1. The name is pre-populated with the name of the alert.
2. At the very bottom you see the customization I made to the Wiki. I added a new choice column to specify the responsible department. Of course, many other useful things are possible here…
Once a KB entry for the selected alert exists., the operator will be redirected to that page immediately the next time he clicks on Open Knowledge Base:

Wrapping Up

As mentioned before, this is just a proof-of-concept and not really 100% production ready (I guess). I just want to show that there’s a good alternative when it comes to knowledge management. Using this tutorial/example as starting point should get you quickly up and running. It doesn’t hurt when you have a SharePoint guru around ; )
The files used in this example are available in this zip file.

Update:

Christoph Maresch used Media Wiki instead of SharePoint:
Link

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s