This post will talk about SerioScript - the scripting engine that powers, amongst other things, the Serio Command Center. Specifically, I'm going to create a new script and use it to illustrate how you can display property values on the Command Center web pages - so you can see device values read from SNMP directly in your browser.
I'm going to assume that you know how to connect a script to a Device, and already have the web pages set-up.
1. Firstly, create a new Script using the SerioMIB (right-click on 'Validation Scripts' and select 'Add Validation Script'). Call the Script 'Blogtest'.
I'm going to get the Blogtest script to display the Free Memory (compared against an acceptable value) for a target machine on the Command Center web pages (I'll call these the CCWeb pages). Please note the standard (Default) script does this anyway, but this simple example will allow me to show you how you display a value on CCWeb.
In doing so, you'll see how to construct a script, from scratch, with your own Device Properties.
2. Click on the Device Property Definitions tab. Right-click on the page area, and select 'Add New Device Property Definition'. Use the following values.
- Display Name: Minimum Free RAM
- Description: Free RAM (Memory) available on the remote machine.
- Device Property Type: Scalar
3. In the Symbols window below, right-click and select 'Add Symbol'. Use these values:
- Display Name: Minimum Free RAM (MB)
- Property Name: gnMinFreeMem
- Description: Minimum Free RAM in Megabytes
- Type: Number
- Default: 80
4. Click OK to close the Symbol Editor window, and click OK to close the Device Property window, returning you to the Validation Script(Blogtest) window.
5. From the list of MIB variables in the left of the Validation Script window, notice that the top three are underlined? These are special places for you to attach code to. Right-click the one called 'InitializationSerioScript' and choose 'Add Validation Statements'.
6. Add this line of code.
displayPropertyAdd('gnMinFreeMem', 'gnMinFreeMem', 2, '', 1);
Don't worry too much about what the arguments mean right now (you can look them up in the SerioScript Reference). All this function says is that, from a CCWeb perspective, this is a value I want to display).
Click OK to return to the Validation Script window.
7. From the list of variables in the left of the Validation Script window, right click on the variable that hold the current free RAM setting. It is called serioVarFreeMemKB. Right-click this and add these lines of code.
// Convert free RAM to MB.
lnFreeRAMMB := serioVarFreeMemKB / 1024;
// Check it against our expected value, and update the web pages accordingly
if lnFreeRAMMB < gnMinFreeMem then
displayPropertySet('gnMinFreeMem', numToString(lnFreeRAMMB,1)+' <=== Error!');
// Display a print value as well on the console
Print("Free RAM in MB for "+serioVarDeviceName+" = "+numToString(lnFreeRAMMB, 1));
8. Now attach the script to a Device, and Go Online.
You'll see your target minimum free memory figure displayed against the current figure. When the observed value drops below the minimum for the Device (by default 80MB) you'll get a little 'error chevron displayed as well.