Monday, October 13, 2008

Stock Quotes Web Part for Sharepoint 2007

Thomas Burke Holland (http://armsinfragilehands.blogspot.com/) has taken the source code from my Sharepoint 2003 Stock Quotes Web Part and created a web part that works on Sharepoint 2007. Check out his web site and download the 2007 version of the web part from the CodePlex web site:

http://www.codeplex.com/svstockticker

Tuesday, September 16, 2008

Adding a Serial port to a VM on ESXi

Back when we setup our System Center Operations Manager servers, we decided to virtualize them using VMware. Although we had an ESX cluster with datastores on our SAN, we felt that it would be counterproductive to put the monitoring system on the same hardware that we wanted to monitor. After all, an ESX or SAN outage would take the monitoring system offline so nobody would get notified.

Therefore we setup a separate Dell 2850 with Windows 2003 Server 64-bit, running the free VMware Server. At the time we setup our virtual root management server with a serial GSM modem so that it could send SMS notifications (more on that here). Since our GSM modem was serial based, all we needed to do was plug the cable into the 2850's COM1 port, then add a virtual serial port onto the virtual machine and connect it to COM1.

When VMware released their ESXi hypervisor for free, we decided to change from VMware Server to VMware ESXi. The hypervisor promised better performance and memory management and seemed like a nice upgrade. Unfortunately we soon discovered that VMware ESXi 3.5 update 2 does not support mapping a physical serial port to a virtual serial port.

To work around this problem, we purchased a Digi One SP serial over ethernet device for around $150. So now instead of connecting the modem directly to the COM1 port on the back of the Dell server, it now connects to this device which is connected to an ethernet port. The steps are pretty simple:
  1. Attach the device directly to a spare ethernet NIC on the back of our Dell server using a cross-over cable. Note that we could just connect it to our existing network infrastructure, but again we wanted the monitoring system to be self contained and able to send pages even if the network was offline.
  2. In the VMware Infrastructure Client, add a new virtual switch to the ESXi server.
  3. Shut down the RMS virtual machine to add a new virtual NIC which is assigned to the new switch we just created.
  4. Power ON the VM and configure the new NIC with an unused private address (in our case 192.168.0.1).
  5. Uninstall the existing GSM modem from the RMS virtual machine.
  6. Install the Digi One SP software on the RMS virtual machine. The software takes you through a wizard which detects the device and allows you to configure its IP address (in our case 192.168.0.2). Accept all the defaults to install a "RealPort" virtual COM3 port.
  7. Install the GSM modem through the control panel and connect it to the new COM3 port.
  8. Test using the Microsoft SMS Sender and then with Operations Manager.
On a side note, we've been extremely happy with VMware ESXi. I think the performance improvement has been noticable. Besides, I appreciate not having to install all the Microsoft patches on it every month.

Monday, August 11, 2008

Simple Cisco Router Management Pack for SCOM 2007

I've written a simple "proof-of-concept" management pack to monitor some of my Cisco routers. The MP is configured to discover a Cisco 2600, 2800, and 2801 router. Currently it will monitor up to 4 interfaces for up/down port status, errors and incoming/outgoing bps. It will also monitor some general environmental conditions (fan & temperature state).

Note that this is an extremely simple management pack. It will not discover all of your interfaces or anything like that. For my purposes, I simply hard-coded rules for interfaces 1-4 and used overrides to enable or disable them depending on the device.

Unfortunately, after going through the process of creating this SNMP management pack, I've come to the conclusion that it is really too much work. If you can afford one of the 3rd party SNMP management tools (like Quest System Center or Jalasoft Xian Network Manager), you'll find your job much easier.

For more details on writing your own SNMP management packs, check out my previous article: Example SNMP Management Pack for SCOM 2007.

Here's a screenshot of the performance view



You can download my sample Cisco management pack here:

RBH.Cisco.Routers.Management.Pack.xml

*Reminder: it is unlikely that this management pack will work on your system without tweaking the XML. This management pack also requires Raphael Burri's SNMP Discovery Provider, which I discuss in my article: Example SNMP Management Pack for SCOM 2007.

This sample management pack is licensed under the Creative Commons Attribution 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.

Wednesday, May 28, 2008

Example SNMP Management Pack for SCOM 2007

I've finished creating my first SNMP management pack for Microsoft System Center Operations Manager 2007 (SCOM/OpsMgr) using Raphael Burri's SNMP Discovery Provider. For some reason Microsoft failed to include a means of identifying different types of SNMP devices in OpsMgr (called a Discovery). Thankfully Raphael has written a quick MP to provide this functionality.

Here is a link to a simple discovery only template XML.
Here is a link to my full Ecosaire Air Conditioner SNMP Management Pack. *Note that this is provided as an example only. If you have an Ecosaire AC unit and want to use my MP, let me know and I'll give you a copy of the required SNMP config files for the Ecosaire unit.

If you take a look at the discovery only XML, you can see the following required sections:

First we see the reference to Raphael's SNMP Discovery provider. Obviously you need to have this MP installed on your OPS server.

<reference alias="CustomSNMP">

<id>Custom.SNMP.Library</id>
<version>1.0.0.1</version>
<publickeytoken>e5c80663d573f08c</publickeytoken>
</reference>


Next take a look at the ClassTypes sections. In the ClassTypes section, we identify the main class. Notice how its base class is Microsoft.SystemCenter.NetworkDevice.

<ClassTypes>
<ClassType ID="RBH.Ecosaire.AC.Management.Pack.SNMPDevice" Accessibility="Internal" Abstract="false" Base="NetLib!Microsoft.SystemCenter.NetworkDevice" Hosted="false" Singleton="false" />
</ClassTypes>

A few lines down you will find the corresponding Discovery section where we will discover our new class.

<DiscoveryTypes>
<DiscoveryClass TypeID="RBH.Ecosaire.AC.Management.Pack.SNMPDevice">
<Property TypeID="System!System.Entity" PropertyID="DisplayName" />
</DiscoveryClass>
</DiscoveryTypes>


Next you'll see the DataSource section of the discovery. Notice that the TypeID is set to use the CustomSNMP from Raphael's management pack.

<DataSource ID="DS" TypeID="CustomSNMP!Custom.SnmpQuery.FilteredOIDDiscoveryProvider">

Inside the DataSource you'll see the Interval (how often to run the discovery) along with some base SNMP properties. These base properties are set by the Microsoft Network Device management pack on any SNMP device you've added to your OpsMgr server. We can just use the previously discovered properties for those values here.

<Interval>3600</Interval>
<IP>$Target/Property[Type="NetLib!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</IP>
<CommunityString>$Target/Property[Type="NetLib!Microsoft.SystemCenter.NetworkDevice"]/CommunityString$</CommunityString>
<Version>$Target/Property[Type="NetLib!Microsoft.SystemCenter.NetworkDevice"]/Version$</Version>

The SnmpVarBinds section identifies the SNMP Object Identifier (OID) that we are going to check. If you think back to the Windows Registry based discovery wizard, you identify the registry key in one section, then create an expression to check the value of that key in a second section. We use the same concept here.

<SnmpVarBinds>
<SnmpVarBind>
<OID>1.3.6.1.2.1.1.2.0</OID>
<Syntax>0</Syntax>
<Value VariantType="8" />
</SnmpVarBind>
</SnmpVarBinds>


The OID listed above is a generic OID that will respond to an SNMP GET with the specific OID identifier of that device. For example, if I do an SNMP GET against my air conditioner it will always return 1.3.6.1.4.1.8072.3.2.10. Doing the same request against any of my Cisco 6509 switches will always return 1.3.6.1.4.1.9.1.283.

Next you will see the Expression section. This is where we perform the actual query to determine if the SNMP object is the right type. As mentioned above, we are checking to see if SNMPGET(1.3.6.1.2.1.1.2.0) == 1.3.6.1.4.1.8072.3.2.10.

<Expression>
<SimpleExpression>
<ValueExpression> <XPathQuery>/DataItem/SnmpVarBinds/SnmpVarBind[OID='1.3.6.1.2.1.1.2.0'][1]/Value</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">1.3.6.1.4.1.8072.3.2.10</Value>
</ValueExpression>
</SimpleExpression>
</Expression>


Note that if this is not specific enough for you, Raphael demonstrates how to query a specific OID and do a regex expression in his documentation. For example, if you need to distinguish between SNMP devices by some other means you might want to check some other SNMP value.

The ClassID and InstanceSettings sections round out the required sections. This is similar to the last page of the Registry Discovery wizard where you map discovered values onto properties of the class. Since this is just a demonstration, this section only includes the required DisplayName and IPAddress properties.

<ClassId>$MPElement[Name="RBH.Ecosaire.AC.Management.Pack.SNMPDevice"]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name="NetLib!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</Name>
<Value>$Target/Property[Type="NetLib!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name="System!System.Entity"]/DisplayName$</Name>
<Value>$Target/Property[Type="System!System.Entity"]/DisplayName$</Value>
</Setting>
</Settings>
</InstanceSettings>


With this discovery, I can now distinguish this SNMP device from all the other SNMP devices on my system.

Screenshots:

State View showing only my discovered SNMP device



Performance View showing only my discovered SNMP device stats



Authoring Window showing Monitors for my SNMP class



Add Rule Wizard in the Console showing the Rule target as my new class



I'm lazy and like to use the GUI to avoid working in the XML as much as possible. In my experience, once I have the base discovery added to the management pack, using the GUI tools to add rules, monitors, etc. works as expected. The functionality is different between the Authoring Console and the Operations Console, so if you can't do something in one try it in the other. For example, I was able to create an SNMP Trap Event Collection rule in the Operations Console, but I couldn't add an Alert onto that rule without using the Authoring Console.

Finally, some tips on creating your own rules/monitors.

When creating alerts for your rules and monitors, you can use the following variables (subsituting your own OIDs).

For a Rule:
$Data/EventData/DataItem/SnmpVarBinds/SnmpVarBind[OID='1.3.6.1.4.1.9839.2.1.2.2.0'][1]/Value$

For a Monitor:
$Data/Context/SnmpVarBinds/SnmpVarBind[OID='1.3.6.1.4.1.9839.2.1.2.2.0'][1]/Value$

When creating an expression inside a monitor, use this variable for the parameter name:
/DataItem/SnmpVarBinds/SnmpVarBind[1]/Value

For more help with SNMP Monitors check out David Allen's Guide to SNMP Probe Based Monitors. For examples, check out the completed management pack above.

This sample management pack is licensed under the Creative Commons Attribution 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.

Wednesday, May 14, 2008

Sharepoint Weather Web Part working again

In the last few days the Weather XML stopped working on my Sharepoint site. Coincidentally I'd received an email from Weather.com regarding their service.

Weather.com now seems to require a partner ID in addition to the key. You will want to sign in to their XOAP page to update your agreement and get a partner ID. I have updated the original post with a new URL. I have also updated the XSL template to include the promo links which are apparently required by the license agreement. If you had previously downloaded my XSL template, you should update your template to the latest version.

Wednesday, March 12, 2008

Empty Stock Quotes Problem Resolved

I have updated the Stock Quotes web part to fix the problem where the web part appears but without any visible quotes. Apparently in the last few days, Yahoo changed their code so that the CSV file returned is line delimited with a line feed (LF) instead of a carriage-return and line feed (CRLF). As a result, my code was incorrectly parsing the file.

The updated version of the file is available from the main article, or via direct download here.

If you have modified your own copy of the code, just edit this line in the RenderStockQuotes function:

Old:
Dim quotes() As String = Split(stockData, vbCRLF)
New:
Dim quotes() As String = Split(stockData, Chr(10))

Wednesday, February 20, 2008

How to configure SCOM 2007 to send SMS messages

We recently started using Microsoft System Center Operations Manager (SCOM 2007) to monitor all of our computer systems. Our previous monitoring system was setup with an old U.S. Robotics modem which used to dial Verizon's TAP modem to send pages to our cell phones whenever there was a problem with the system. A lot of companies seem to rely on SCOM's email alerts for their notifications, but I wanted to make sure that I would receive notifications even if (or especially if) our email servers or internet connection were offline.

Unfortunately I discovered that SCOM 2007 did not include built-in TAP support. I searched around for third party dialers, but found them overpriced and poorly designed. Fortunately, I discovered that Microsoft had built SMS (Short Message Service) functionality into SCOM 2007. What this means is that when properly configured, my managment server can directly send SMS alert notifications to any pager using a special wireless modem.

The first thing that you have to do to get this working is to purchase a GSM compatible wireless modem. Not knowing a lot about wireless networks, I spent a lot of time trying to get this to work with my Verizon Blackberry 8830. As I discovered, in the United States only certain wireless carriers are GSM compatible (AT&T and Cingular).

I did some research and found this great modem from MultiTech Systems: MultiModem GPRS (MTCBA-G-F4). This is a wireless serial modem that is GSM compatible (AT&T approved). It also supports SMS messaging with PDU mode (which is required for SCOM 2007 to work).

Once I received the modem, I brought it down to the AT&T wireless store near my office and signed up for service to get a SIM card. All we really wanted was unlimited text messaging, but we also ended up having to purchase a minimum data plan. Note that you do not need Data/Internet service for this to work, you only need Text Messaging. The end cost for service was around $56.00/month.

When selecting the modem, I specifically chose the serial version instead of the USB version. Since many people run SCOM on a 64-bit platform, you may run into driver related issues with the USB version. My SCOM server runs on VMWare Server, so I knew that the Serial version would be much less trouble than the USB version.

After installing the SIM card in the modem, I set it up next to my SCOM server and plugged in the included serial cable into COM1. I then downloaded the latest modem definition file (INF) from the MultiModem GPRS drivers page and went through the wizard to add the modem to my server.

Once Windows had recognized the modem, I was able to begin testing. Before testing in SCOM 2007, you will want to test using the Microsoft SMS Sender. This is a quick little utility to send SMS (Short Message Services) messages. Upon launching the program, it immediately selected my GSM modem. I typed in the number of my cell phone, a test message and clicked "Send." The program took about 5 seconds and then came back with a notice that the message was sent successfully. I received the SMS message on my phone a few seconds later.

Now that I'd confirmed that the modem worked, all that was left was to configure the Operations Manager computer to use SMS messages. To do this, launch the Operations Console. Click on the Administration tab and click on the Settings icon on the left side. Double-click on the Notifications icon on the right side, then click on the "Short Message Service" tab. Click on the "Enable short message service notifications" checkbox and click OK.

In order to receive alerts, two additional steps are required: Create a recipient and create a subscription.

To create a recipient, right-click on the Recipients icon on the left side and choose "New Notification Recipient." Enter a display name, and click on the "Notification Devices" tab. Click the Add button, then choose "Short Message Service" as the notification channel. Enter the cell phone number in the Delivery address for the selected channel section and click Next. IMPORTANT: you must enter the phone number in the format + [country] [area code] [phone number]. For example, although I used 7045551212 in my SMS sender test to specify my North Carolina based cell phone, that number will not work in Operations Manager. In OpsMgr, I had to specify: +17045551212. To continue, modify the schedule as necessary, then click Next. In the Notification device name, provide a name for the cell phone and click Finish. Click OK to close the Notification Recipient Properties window.

To create the subscription, right click on the Subscriptions icon on the left side and choose "New Notification Subscription." This is where you will decide what type of alerts will be sent to the cell phone via SMS. In the Subscription Name box, type something like "Urgent Alerts To Cell Phones." Click on the Add button to add the recipient that you selected in the previous step. Click on the Next button. Complete the rest of the wizard, identifying which alerts you want to receive on your mobile phone as a text message.

That's it! It is surprisingly easy. I was especially surprised to find that I didn't have to tell Operations Manager which modem to use to send the SMS message.

Thursday, February 07, 2008

Stock Quotes Web Part Updated

I have updated the Stock Quotes web part to fix the overflow error when certain stocks would have very high volumes:

System.OverflowException: Value was either too large or too small for an Int32. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at StockQuotes.StockQuotes.RenderStockQuotes()

I have changed the parse object to be an uInt64, so it should be a while before we see enough volume to experience this problem again.

You can download the updated version from the link in the main Stock Quotes post.

Wednesday, March 28, 2007

Updated directions for installing StockQuotes web part

I have updated the directions for installing the StockQuotes web part. The new directions include a corrected SafeControls line (previously the case was incorrect). I've also included some further directions for where to put the StockQuotes.DLL file and some additional troubleshooting steps.

http://svintinner.blogspot.com/2007/02/stockquotes-replacement-stock-quote.html

Friday, February 09, 2007

How to use Weather.com to replace the MSNBC weather web part

As most Sharepoint 2003 administrators know, Microsoft discontinued support for their MSNBC Web Parts on February 6, 2007 (KB 929197). Here are some directions for replacing the MSNBC Weather web part by using data provided by Weather.com.

If you look around the Weather.com website, you'll see a link for getting weather on your website using a "Weather Magnet." Unfortunately the weather.com "Weather Magnet" does not work in Sharepoint because of the built-in FORM tags. If you try to follow their directions to insert the script into a content-editor web part, the result is that none of the Sharepoint web part pane buttons will work.

Fortunately, Weather.com provides another means of getting data to your Sharepoint users via an XML file. Therefore you can use the built-in Microsoft XML Web Part to display this data. Here are some quick directions:

1. Sign up for the Weather Channel XML: http://www.weather.com/services/xmloap.html. As part of this process you will get a KEY to use when downloading the XML file from Weather.com.

2. Download the SDK. Unzip the images from the SDK into a folder. I saved mine to my sharepoint server's wpresources directory in a folder called weather. Example: c:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\weather\64x64
(I believe that this directory is available on any default sharepoint server via http://server/_wpresources/).

The XSL file expects to find the images in /_wpresources/weather, so if you place the images somewhere else, you should update the XSL source.

3. Add a Microsoft XML web part to your sharepoint page. Set the XML link to (text-wrapped):

http://xoap.weather.com/weather/local/28246?cc=*&link=
xoap&prod=xoap&par=yourpartnerid&key=yourkey

(substitute your weather.com key, partnerid and your zip code)

4. Download my XSL file for weather.com from below, then click on the "XSL editor" button on the web part properties page and paste in the code from the attachment.

You do NOT need to edit the XSL file. It uses variables from the XML file. For example, the variable {$zipcode} in the XSL file is replaced with the zip code in the XML file you receive from weather.com.


Here's a preview of what it looks like. Note that the blue around the image is a result of the Internet Explorer PNG transparency bug. The blue will not appear when using IE 7.0+ or Firefox. If this is a problem for you, you can convert all the images from PNG format to GIF format and simply adjust the XSL.


Download XSL Template* (last updated 5/14/2006)

*Please do not link your sharepoint sites directly to this file. Instead, cut and paste the contents into your web part settings by clicking on the "XSL Editor" button.

The XSL file and these directions are licensed under the Creative Commons Attribution 2.5 License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco,
California, 94105, USA.

The services provided by Weather.com may be changed at any time. I am not associated with Weather.com in any way and I have no idea as to the legality of your use of this code with respect to downloading data from the Weather.com website. Please refer to Weather.com for any applicable copyright or usage information.

Finally
If you find this helpful, please leave a comment here.