SSI Tags

 



 

Overview

 

Server-side includes (SSIs) applied to an HTML document, provide for interactive real-time features, such as echoing current time, conditional execution based on logical comparisons, retrieving the current data from the device, etc. without the need for programming or using CGI bin. An SSI consists of a special sequence of characters (tokens) on an HTML page.

 

The WebNMS proprietary HTML tags will be understood by the WebNMS HTML parser which is a part of the HTML run-time agent. These tags will be encapsulated in the HTML comment tags and will not be affected by any other HTML parsers, for example Netscape.

 

The format of a SSI Tag is as follows :

 

<!--#'<tag><variable set> '--> where :

 

<!--# is the opening identifier, a SSI Tag always starts with this.

 

<tag> is one of the following: echo, var, exec, if, goto, label, break etc.

 

<variable set> is a set of one or more variables and their values. The values allowed here are dependent on the tag. The format of a variable set is as follows : <variable name> = variable data.

 

"-->" is the closing identifier, a SSI Tag always ends with this.

 

Supported SSI Tags

 

The WebNMS HTTP Adapter supports the following SSI tags. All the below mentioned tags can be used only in GET operation of HTTP. For POST operation these tags will not be used and they will be handled separately. The basic syntax of each SSI is, <!--# SSI Tag -->

1. Var Tag

 

The Var Tag is used to assign/copy the value of "var" to VARIABLE_NAME. It will be used in "if" tag for comparison.

 

Syntax<!--# var VARIABLE_NAME="xxx" -->

 

Example :

 

<!--# var hello="Hi" --> This stores the value "Hi", to the variable hello.

<!--# var num=10 --> This stores the value 10, to the variable num.

      Note: If the value is a string, it has to be provided within quotes as shown in the example. If the value is an integer, it should not be provided within quotes.

2. Echo Tag

 

The echo tag provides for inserting the data of certain variables into an HTML page. The data in an echo token is translated into a string that depends on the value in the variable and that string is inserted into the HTML page at the location of the echo token in the HTML page. Following are the list of variable names supported in Echo Tag:

Syntax : < !--# echo DOCUMENT_URL -->

 

Example : Providing the following tags in the file "tags.shtml", will give the output as shown in the image below:

 

<!--# echo DOCUMENT_NAME-->

<!--# echo FILE_LAST_MODIFIED -->

<!--# echo REMOTE_ADDRESS -->

<!--# echo REMOTE_HOST -->

<!--# echo SERVER_NAME -->

<!--# echo DOCUMENT_URI -->

 

3. Exec Tag

 

The Exec Tag is used to run an external executable system command and substitute the result in the html file. The CMD variable is used to specify the name and command line parameters of any shell executable command.

 

Syntax : <!--# exec command -->

where "command" is the name of the executable command.

 

Example:

 

<!--# exec ls -->

<!--# exec netstat -an -->

<!--# exec dir -->

 

4. GET Tag

 

The Get Tag is used to retrieve the given attribute value for a scalar/ table column from the agent instrumentation. In case of table, the instance value has to be specified.

 

Syntax : <!--# GET var/val="ATTRIBUTE_NAME" "INDEX_LIST" -->

 

where, "Attribute name" is the name of a scalar/table column object and "Index List" refers to the table column name and the index value, separated by a space. For a scalar object, the Index_List need not be specified.

 

Example :  

<!--# GET val=agentDescr --> This will return the value of the scalar object "agentDescr" of the AGENT-SAMPLE-MIB.

 

<!--# GET val=adiskName 1 --> This will return the value of the table column "adiskName" with the index value "1".

There are three forms of specifying the attribute name. Each form differs with performance in terms of the time taken to execute the command.

 

1. Mib Name: ModuleName:attributeName

 

Example, if the attribute name is specified as AGENT-SAMPLE-MIB:AdiskTable:adiskID, the agent will search for the specified string and return the value..

 

2. ModuleName:attributeName

 

Example, if the attribute name is specified as AdiskTable:adiskID , the agent will search for the specified key-string and return the value.

 

3. attributeName

 

Example, if the attribute name is specified as adiskID, the agent will search for the specified key-string and return the value. The argument list specifies the index value

 

5. GET-NEXT Tag

 

The GET-NEXT Tag is similar to the GET Tag, but used to retrieve the next attribute in the tree from the specified attribute for a scalar/ table column from the agent instrumentation. In case of table, the instance value has to be specified

SYNTAX :


<!--# GET-NEXT var/val="ATTRIBUTE_NAME" "INDEX_LIST" -->

 

It is used to retrieve the next attribute value of the given attribute name from the agent instrumentation.

 

Example :

<!--# GET-NEXT var/val=agentDescr --> This will return the value of the next scalar in the group, i.e., agentSupportContact

 

<!--# GET-NEXT var/val=adiskID 1 --> This will return the value of the next instance of the column adiskID, i.e., adiskID 2

      Note: If the left side argument is "val", then the parser will substitute the value of the given echo variable in the HTML page. Otherwise the left-hand side argument is a variable like any programing language. So, you can use any distinct variable name. The echo value will be stored in the argument and used later with "if" tag for comparison.

 

6. GET-TABLE Tag

 

Using GET and GET-NEXT tag user can retrieve one attribute value, whereas using GET-TABLE tag user can get the value of the entire table or part of the table.

SYNTAX :

 

<!--# GET-TABLE val="TABLE_NAME" "COLUMN_LIST" "NUM_OF_ROWS" -->

 

TABLE_NAME is the name of the table. The COLUMN_LIST will have the table columns name, using this input user can customize the order, provide required columns, etc. If the value for this input is "default", then all table columns will be taken. Using "NUM_OF_ROWS" input user can say how many rows can be displayed in the HTML page. If the value is zero, then all the table rows will be returned.

 

Example :

<!--# GET-TABLE val=AdiskTable default 0 --> This will return the value of all the rows in the table.

 

<!--# GET-TABLE val=AdiskTable default 3 --> This will return the value of the first three rows of all the columns in the table.

 

<!--# GET-TABLE val=AdiskTable AdiskCapacity AdiskUsed 3 --> This will return the value of the first three rows of the columns AdiskCapacity and AdiskUsed in the table.

 

The two forms of specifying the attribute name as specified in GET tag. Each form differs with performance in terms of the time taken to execute the command :For example,

 

AGENT-SAMPLE-MIB:AdiskTable

AdiskTable

 

7. If Tag

 

The if tag provides for conditional execution of SSI operations, and conditional printing of HTML text, based on logical comparisons.

 

SYNTAX

<!--# If <Operand1> <Operator> <Operand2> <Operation> -->

where,

The operands may be any string or number (integer). In the event that both operands are numbers, the comparison will be based on the value of the numbers. In the event that one or both of the operands are not numbers, the comparison will not be done.

 

The special case of the NULL operand is defined by two quotes with no characters between them. The NULL operand may be used to check for the existence of data.

 

Example:

 

<!--# if name == "WebNMS" goto Top -->

<!--#if i == 5 goto Label-->

 

8. Goto Tag

 

The goto tag provides for jumping to a label token without executing any SSI code or printing any HTML text between the goto token and the label token. The syntax of the goto tag is

 

<!--#goto <label > -->

 

where, <label > is the name of a label defined in a sub-sequent label tag (see below).

 

Example :

 

The following document fragment demonstrates a goto to a label.

<!--#goto testlabel --> <P>This line will not print. <!--# label testlabel --> <P>This line will print.

 

9. Label Tag

 

The label tag provides a place for a goto or if..goto token to jump. When the SSI+ parser encounters a label token nothing happens, it is simply a place holder for a previous goto to jump to. Back traversing is not supported in Label Tag, (i.e.) if "label" tag is declared before to "if" tag then it will not work.  

SYNTAX :

 

<!--#label <label>-->

 

where, <label> is any string less than 51 characters long without space(' ') characters.

 

Example :

<!--# label DoAgain -->

 

10. Break Tag

 

The break tag is provided for the termination of the HTML document at any point. When the SSI+ engine encounters a break token, the HTML document is immediately truncated and transmission to the client is ended.

SYNTAX :


<!--# break -->

 

Example :

The following document fragment demonstrates a break token. <P>This line will print. <!--#break --> <P>This line will not print because the document has been truncated and transmission to the client is terminated.

 

11. Include Tag

 

The INCLUDE tag is used to include contents of a file into the existing HTML page. The included file can be files with extensions of .txt (text), .html or .shtml files. The file can be a plain text, HTML code, JavaScript and anything else composed of text. Inclusion of binary files, image files, sound / video files are not supported. Files that are specified in the INCLUDE tag can have HTML code for images and sound files.

SYNTAX :


<!--# include file="<file/content to be included>" -->
 

Example :

<!--# include file="servlets/test.txt" -->

If the above SSI tag is called from an shtml file say notifications.shtml, then  the agent will display the contents of text.txt file inside the notifications.shtml file apart from its existing contents.

<!--# include file="servlets/agent/test.html" -->

 

If the above SSI tag is called from an shtml file say protocolsinfo.shtml, then  the agent will display the contents of text.html file inside the protocolsinfo.shtml file apart from its existing contents.

 

 



Copyright © 2009, ZOHO Corp. All Rights Reserved.