This time I needed to build a two-state script monitor to test several file shares for availability. The script works in multiple steps…
- Try to access the shared folder
- Create a file within the share
- Check if the file exists
- Delete the file
If one of the tests above would fail, we need to get an alert. Well, this is actually not that hard to create and don’t worry I am not going to publish another VBScript. What is more interesting is to create a meaningful alert. It makes sense to have the file share name in the alert name e.g. “Failed to access share \\server01\temp”. But how are we going to achieve this?
Some might try to do something like this…
Well this would not work, the result would look like this…
What should we try to do instead? Well, try to use place holders like this…
Depending of the position of your parameters in your alert description you need to pick the proper “place holder”. Since the first parameter is $Data/Context/Property[@Name=’Folder’]$ we choose {0}. Cool and how does it look like?
Nice! For those who are MP authors they might are familiar with this technique, but for all others I think it is a smart quick tip 😉 . I don’t know if anybody has blogged about this before, in any case it might help you improving your alerts.
Update 07.03.2014: If you author your MP’s in VSAE it is just the other way around as you can see in this example below, there you must use e.g. $Data/Context/Property[@Name=’Folder’]$ …
VSAE will convert this appropriately.
Hi Stefan,
thanks for this post !
I always wondered why Alert Name didn’t take any placeholder…now I learn it was only my lack of knowledge.
Great to hear, thank’s!
Stefan
Would like to see the script you are executing. I have an internal customer with these exact requirements. While I have hacked together a script, I’m sure yours is cleaner.
Hi
Unfortunately, I cannot share this script, sorry. Kevin has written a post which has a similar “machanic” behind, this might be useful.
http://blogs.technet.com/b/kevinholman/archive/2014/03/06/create-a-script-based-monitor-for-the-existence-of-a-file-with-recovery-to-copy-file.aspx
Cheers,
Stefan
Hi.
what will happen if two shared folder are not accessible at the same time? Will I get two alerts (Since it is a state base?.
Hi,
Thanks for the trick. But I’m facing issue when receiving mail in mailbox coming with parameter (like: Number of pending reports to upload on website Files {0}) and SCOM console is showing perfecly (like: Number of pending reports to upload on website Files 300). Please suggest why this is not coming proper in mail subject.
Hi. Thanks for the good trick. But when I receiving a mail, there is still {0}. Can you help?
Hi
There is a downside using dynamic parameters. They don’t show up as soon they “leave” SCOM like sending mail, alert connector and you will only see the placeholder {0}, . They only show in the SCOM console properly.
Bad news, I know but this is the way it is.
Cheers,
Stefan