Tutorial - Hello World

Some things to note about VA2 Statistics:

Setup and Environment

In order to run the examples and follow along with this tutorial, you will have to have set up a basic VA2 environment. The bare minimum would be to have run the VA2 DB scripts, and installed the Central Server service, and the VA2 MMC client. Those steps are covered in the setup tutorial.
This is a basic tutorial designed for those running VA2 without a Siebel environment. If you have a VA2 Siebel environment, you may want to use the Siebel Statitstic Tutorial instead.

Step 1 - Hello World

Open VA2 MMC - Navigate to the Statitics folder. Right click and select Add from the menu. (You can also import pre-built Statistics. However, for this tutorial we will build a statistic by hand.)

2. You are now presented with a code editor for your statistic. Fill out the some properties:
Now, for the coding! We'll do a one liner, equivalant to a Hello World.
For any VA2 Rule or Statitic, the primary value is a variable called $retval. (In Perl the dollar sign ($) prefaces variable names). The purpose of a VA2 rule is to set $retval. We'll give the first example with a VA2 Statistic:

$retval = 1;

Thats it!. Since $retval is built in variable, it does not have to be declared using the "my" perl key word.

Step 2 - Debugging Statistic
We have now written a statistic. The next step is to test the code - which we do by pressing the debug button.

When you press the debug button, the code in its current state is saved. A debug window pops up, executing the code. The quickest way to check the output is to look at the debug window, which displays what the $retval variable has returned or any error messages.

In this example, $retval = 1. That means if we activate this Statistic, the VA2 Central Server will execute this satistic on interval, every minute.

To set the rule active, merely select the Active box, and press OK. The rule is saved, and VA2 will begin to execute the statistic an graph the results. Since the $retval is set statically to 1 every time it will be a pretty boring graph.

To make it a tiny bit more interesting, try changing the syntax to:
$retval = rand(10000);

rand is a perl function to create a random number,in this case between 1 - 10000, which then will be graphed as $retval. In real life, you can use any valid perl, including accessing all the open source perl modules already written, or write custom reporting routines to create Statitics for your custom systems or Siebel.