Monitis-Top… an open-source command-line interface for Monitis Agents and Monitors

 In this article we’ll discuss creating a command line interface to query the Monitis Agents and Monitors you have activated for your systems. We’ll provide the source code for the utility in VBScript and we will also be working on a C# version.  We’ll keep things simple for now and start with VBScript and provide a link to the complete source at the end of this article.

To get started we need to identify what information we want to display from our Monitors, what can be easily supported, and what is not supported.  The main parts are the different types of agents that Monitis offers, which are the Internal,
External, and custom monitors.

In this article we’ll focus on the basic ‘framework’ of the utility that deals with the definition of some classes to make working with the various agents and monitors easier, accepting and processing command-line arguments, and a small function library to keep our main script very clean. We’ll introduce a neat little feature of VBScript showing you how to work with include files.

Let’s take a look at the functionality and output we like to get from Monitis-Top.

Querying Internal Monitors

We want to be able to display the latest performance counters from our internal, external, and custom monitors by entering commands like:

MonitisTop /cmd:listagents /type:internal /monitor:all

Which would return the performance counters for all
supported monitors of the internal agents, or

MonitisTop /cmd:listagents /type:internal /monitor:cpu,memory,drive

This returns the Cpu, Memory, and Drive monitors for the internal agents.

Querying Process Monitors

We can enter query the process monitors that we’ve configured in our Monitis dashboard like so:

MonitisTop /cmd:listagents /type:int  /process:outlook,search

This will return any process monitors containing the phrases ‘outlook’ and ‘search’. MonitisTop will automatically wildcard any processes listed on the command line.

Querying External Monitors

Monitis Top can also be used to query external monitors. You can specify the parameter /type:ext or /type:all, where ext will only return the external monitors and all returns both internal and external monitor results. For example, the command:

MonitisTop /cmd:listagents /type:all /monitor:cpu

will return both the internal CPU monitor result and the external monitors.

The results will show by each location that you have specified for a monitor.

Managing API and Secret Keys

We want similar commands for the external and custom agents.  In addition, it would also be nice if there was some functionality to maintain our APIKeys, so we’ll add a function that allows you to set and display these keys by entering:

MonitisTop /cmd:setkeys  /apikey:<yourapikey> /secretkey:<yoursecretkey>

Similar, you can display the keys with the command:

 MonitisTop /cmd:getkeys


VBScript Include Files

We’ll use VBScript to program the code for MonitisTop  initially. In the next phase of this project we’ll use C#. If you’re not  familiar with the possibility of using include files in VBScript, take a look  at the code snippet below.


Class Definitions

To make working with the various agents and monitors more manageable, we’ll create a few classes that we use to store the performance counter results we get back from the Monitis server. To start we’ll create a few classes; one for the agents, one for the monitors belonging to an agent, and one for the various metrics and values in a monitor. We want the Agent class to maintain a list of Monitors, and the Monitor class in its turn maintains a list of Metrics.


In the class_InternalAgent we create a list of monitor objects that is initialized in the constructor of the class. Notice that in VBScript the methods Class_Initialize and Class_Terminate are automatically called if they are defined and these methods compare to your C# constructor and Dispose methods.

Retrieving the Internal Agents

Once we have parsed the list of monitors that we want to show (specified on the command line), we can call the function GetInternalAgents. In the function below aObjHttp, aShowMonitors, and aShowProcesses  are input values, while aObjAgents is an output value. It returns the list of internal agents retrieved from the API.


The main part of this function is the creation of the Agent class, retrieving the ‘loadTests’ from the API and cycling through the list of returned Monitors for each Agent.

Because we want to build in support for querying process monitors as well as global drive, memory, and cpu monitors, we’ve included the list ‘aShowProcesses’. This list contains the processes entered on the command line that we want to query. If
this list contains zero elements, the program defaults to collecting and returning the global monitors.

After GetGlobalMonitors (or GetAgentProcessMonitors) have returned, we’ll add the Internal Agent object to aObjAgents; the list of Internal Agents.

In the GetAgentMonitors function we’ll collect all the monitors of an agent and make a call to GetResults to retrieve all the metric


In GetGlobalMonitors we create a Monitor object for each required monitor we want to return and call the function GetResult to retrieve the metric values for each monitor.


The GetResult function loops through all the result values of a monitor, creates a Metric object for each monitor and adds it to the Monitor object, and finally the function ShowInternalAgents writes all results to the screen.


The function GetExternalMonitors gathers all the external monitors, the locations, and the monitor results.


The complete code of this article is available for download at GitHub.