Query Script
This page allows direct script access to the traffic data. It can be used for the following purposes:
- For extracting data into a web-aware application such as Microsoft Excel.
- For extracting data into custom scripts written in other languages such as awk or perl.
- For running specialized ad-hoc queries that can not be satisfied by any of the existing report sections.
- For prototyping queries that will be used in new report templates.
The scripting API is JavaScript(v1.6 with E4X), with predefined classes for accessing data stored by this application, such as traffic history, address mappings, host locations and interface counters.
Running a script
To run a script, simply type or paste it into the Script window, then click Submit. If the query executes successfully, you will see the results, with the following options above:
- Back - return to the Script page.
- TXT - run the query again, but this time return the results in a separate window. This window now has the query URL that can be bookmarked, or copied to another application.
- IQY - show the query in Microsoft Internet Query (.iqy) format, for use with Microsoft Excel (see below)
Querying data from Microsoft Excel
To load data into the cells of an Excel spreadsheet, follow these steps:
- Ensure that the "format" variable in the script is set to "html" rather than "csv", so that tabular output appears as HTML tables, rather than comma-separated values.
- Click Submit, then on the results page click IQY and save to a file such as "query.iqy".
- Open this file in Excel.
Note that it will often be easier to schedule the report to run on the server in the normal way, and then use the URL that points to the HTML view of the results. If you open that url in your Excel spreadsheet, then Excel will find the tabular data that is embedded in the page.
User Authentication
If the access permissions configured under File,Users for the Report,Run page are not set to "Guest" then a login and password must be supplied with the query. Basic authentication can be used in this case.