Product manual

Manual Writing your own monitoring functions |165
14 Writing your own monitoring functions
14.1 Introduction
GFI Support cannot assist you in the writing and debugging of custom scripts. You must
be familiar with VBscript to write your own functions and you must debug them
yourself.
GFI Network Server Monitor is designed to let operators write their own monitor functions and
use them in the product. GFI uses VBScript because it is the most popular scripting language in
Windows environments.
GFI Network Server Monitor uses VBscript itself to perform a number of checks. In fact, during
installation, five VBScript files are installed:
» ads.vbs includes monitor functions based on ADSI (Active Directory Service Interfaces);
» exchange.vbs includes monitor functions that can check Exchange 2000/2003 servers;
» hardware.vbs includes hardware related monitor functions;
» os.vbs includes Operating System related monitor functions;
» sample.vbs includes some sample functions.
14.2 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