Writing a script/function
GFI Network Server Monitor functions should always return:
- -1 (True); Return -1 in case the Monitor Function is successful. For instance, if your function checks the existence of a certain directory, and it does exist, then return -1;
- 0 (False); Return 0 in case the Monitor Function is not successful. For instance, if your function checks the existence of a certain directory, and it does not exist, then return 0;
- 1 (Unknown); Return 1 in case the Monitor Function cannot determine True or False. For instance, if your function checks the existence of a certain directory on a server, but it cannot find the server at all (for instance because the computer is down), return 1;
It's very easy to write your own monitor functions in VBScript. Use the following guidelines when writing a new function:
- The routine must be a Function, not a Sub;
- The Function must return True (-1), False (0) or Unknown (1);
- Optionally, use the EXPLANATION system variable to add your own explanation to the result of the function; this EXPLANATION is shown in the client program each time the check is made;
- All variables must be 'dimmed', except EXPLANATION. EXPLANATION is a GFI Network Server Monitor system variable automatically dimmed by the GFI Network Server Monitor service.
The function must be written according to the following template:
Const retvalUnknown = 1
Function Function_i( var1, var2, ..., varn )
If ( Not Pre-condition ) Then
EXPLANATION = "Unable to determine..."
Function_i = retvalUnknown
Else
If( condition ) Then
EXPLANATION = "Yes it is true because ..."
Function_i = True
Else
EXPLANATION = "No it's not true because ..."
Function_i = False
End If
End If
End Function
where Function_i is an arbitrary name for the function.
You can save this function in either one of the standard VBS files (i.e. ads.vbs, exchange.vbs, hardware.vbs, os.vbs or sample.vbs), or in a new VBScript file. In case of a new file ensure that your VBS file is accessible via the GFI Network Server Monitor Share.