Having had the problem with Daniele’s apostrophes (“ – the punctuation apostrophe (curly) rather than the vertical typewriter apostrophe) when copying his script (which he has fixed now) I thought what else could cause a problem. I had read that you had to be careful with the case for parameters so I thought I would take a look at that.
His full guide to creating a script based unit monitor is at http://www.muscetta.com/2007/05/10/create-a-script-based-unit-monitor-in-opsmgr2007-via-the-gui/.
The key part of his test script that determines whether it is a green or warning state is:
If Err.Number <> 0 Then
The key bits of that are “State” and “BAD”/”GOOD”. And in the boxes for the Unhealthy and Healthy Expression there is
Parameter Name Property[@Name=’State’]
Value BAD (for unhealthy and GOOD for healthy)
I set it up as in the post and tested it worked. I then made a change and tested that change. After that I set it back to the original to ensure that the monitor still worked.
Here is what I found.
In the Value section I tried Good and Bad. That worked showing that the Value section does not appear to be case sensitive.
As apostrophes were a problem in the script I tried it with ” instead of ‘ around State in the Parameter Name and that worked.
Then I changed Name to NAME. That did not work. I also tried name. That did not work.
Next I changed Property to PROPERTY. That did not work. Nor did using property.
I changed State to STATE. That did not work.
I went back to the script and changed both instances of State to STATE but kept State in the expression. That did not work. I then changed State to STATE in each expression box to match the case in the script and that worked.
So apart from the apostrophes you have to be very careful with case in the Parameter Name box. But you don’t have to worry about the Value box. To me, this seems back to front. If there was one box that had to be case sensitive I would have thought it would have been Value and not Parameter Name.
Looking at the Operator box I changed the operator from Contains to Equals and that worked. It also worked with Matches Wildcard. I changed the values to B* and G* with Matches Wildcard and that worked as well. So that side of it seems reasonably flexible.
The worrying thing about these changes was that not only did the monitor no longer work but there were no errors in event logs to show that monitor was not working. You do get an error if you miss off the end ] however. And there is no warning when you create the expression to tell you that it will not work. Interestingly the script carried on working as when textfile.txt did exist, the word test was appended to it every 15 seconds as per the script.
So be very careful when you are creating these expressions. To be on the safe side it is probably best to use Title case in the script, Property Name box and Value box. That way you are consistent and it seems that Title case is needed for certain bits.
- Posted in: System Center Operations Manager 2007