LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lpsla.Compute - Compute the statistical data of a service level agreement

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax

value = lpsla.Compute('id', 'sla_rep', Syear, Smonth, Sday, Eyear, Emonth, Eday, STime, ETime, RTT_Threshold, Avaibility, Performance, 'array')

Description

The lpsla.Compute LUA function compute the statistical data of a service level agreement according to the provided parameters.

See the chapter Quality of Service control (availability and performance - SLA) for more informations.

Parameters

‘id’                      The LoriotPro ID (see the license file bin/licence.ini)

‘sla_rep’             The directory where data are stored (ID/SLA)

Syear                  The year of the beginning of analysis period of the SLA

Smonth              The month of the beginning of analysis period of the SLA (1 – 12)

Sday                   The dayr of the beginning of analysis period of the SLA (1 – 31)

Eyear   The year of the end of analysis period of the SLA

Emonth              The mont of the end of analysis period of the SLA

Eday                     The day of the end of analysis period of the SLA

STime                  A timestamp on the beginning of analysis period of the SLA

       os.time{year=2006,month=5,day=30,hour=0}

ETime                   A timestamp on the end of analysis period of the SLA

       os.time{year=2006,month=6,day=30,hour=0}

RTT_Threshold               The threshold of expected response time for the calculation

Avaibility                         The threshold of expected availability for the calculation

Performance     The threshold of expected performance for the calculation

'array'                   A table of the calculated results

Return Values

Value                   1 if the operation is successful

nil                        if an erro occurs

‘array’

Retruned value in the array

 

Description

array.ip

The IP addres of the host use for the SLA calculation

array.name

The host name

array.polling_type

The type of polling  

1 = icmp

2 = snmp

X = autre

array.periode

In percent

The percentage of samples collected over the theoritical number of samples to collect for the calculation period. 

Warning ! In the case of host in double polling the percentage can be greater than 100 %

array.avaibility

The percentage of good responses to polling requests over the calculation period. This is based only on the number of samples collected and not on the the theoritical number of samples to collect

array.performance

 

The percentage of samples in the expected performance threshold over the calculation period (This is based only on the number of samples collected and not on the the theoritical number of samples to collect).

The RTT_Threshold is used to claculate this percentage. 

Percentage = percentage of response < RTT

array.total_collected

 

The total number of polling over the calculation period. 

array.total_waited

 

The expected number of polling over the calculation period.

Warning ! In the case of host in double polling the percentage can be greater than 100 %

 

Example

lua logoLoriotPro WEB site Documentation scripting LoriotPro
Extensions du language LUA

Table des matières    Liste de fonctions

Imprimer la page en cours Mail this  link UTUBE Channel

Example of SLA calcuation for the LoriotPro host

-- sample

if (lp.IsDebugMode()==1) then

lib,init=lp.LoadLibrary(lp.GetPath().."/lua_lp_slad.dll","libinit");

else

lib,init=lp.LoadLibrary(lp.GetPath().."/lua_lp_sla.dll","libinit");

end 

if (lib) then

init(); 

id="1002";

k=lpsla.GetLoriotProIDList("a"); 

for l=0,k-1 do

            lp.Print(a[l]," LoriotPro ID \n"); 

i=lpsla.GetSLAList(a[l],"aa"); 

      if i then     

            for j=0,i-1 do

            lp.Print("\t",aa[j]," SLA \n");  

--Compute('id' ,'sla_rep', Syear,Smonth, Sday, Eyear, Emonth, Eday, STime, ETime, RTT_Threshold, Avaibility, Performance, 'array')

            if lpsla.Compute(a[l],aa[j],2005,5,1,2006,6,30,os.time{year=2005,month=5,day=1,hour=0},os.time{year=2006,month=6,day=30,hour=0},50,90,90,'array') then

            lp.Print("\t\tip : ",array.ip,"\n");

            lp.Print("\t\tname : ",array.name,"\n");

            lp.Print("\t\tpolling_type : ",array.polling_type,"%\n");

            lp.Print("\t\tperiode : ",array.periode,"%\n");

            lp.Print("\t\tavaibility : ",array.avaibility,"%\n");

            lp.Print("\t\tperformance : ",array.performance,"%\n");

            lp.Print("\t\tgood_polling : ",array.good_polling,"\n");

            lp.Print("\t\ttotal_collected : ",array.total_collected,"\n");

            lp.Print("\t\ttotal_waited : ",array.total_waited,"\n");

            end

            end

      end

end

end

 

SLA computation with LUA

You can use the HOST bulk configuration tool to perfom SLA calculation over a set of hosts. 

SLA computation with LUA

 

SLA computation with LUA

 

 

SLA computation with LUA

 

SLA computation with LUA

 In this example, 3 hosts have not been configured for a collection of pollings (SLA) and the calculation of SLA is thus not possible. The host 127.0.0.1 is configured correctly but the number of expected pollings (total_waited) is higher than the number received, so there is no loss. This is explained by the fact that the polling interval for the host has been modified since the start of the collection and the reference time has changed (decreased time polling). 

Script used 

-- Display SLA for DAY --

-- To run correctly this file is located to bin/config/script

-- Input values

-- lp_index index for this script ".1"

-- lp_oid SNMP OID for this script "ifnumber"

-- lp_host default ip address for this script "127.0.0.1"

-- Output Values

   lp_value = 0;

   lp_buffer ="error";

-- use this to initialise the host selection

dofile(lp.GetPath().."/config/script/bulk/selection/LP_Selection.lua")

dofile(lp.GetPath().."/config/script/lib-audit/1-audit.lua");  

-----------------------------------------------------------------------------------------------

-- Start program

-----------------------------------------------------------------------------------------------

--list the ip host to scan

tabz={};

hostnumber=LP_HostsSelection(tabz); 

if hostnumber==0 then error("Not host selected\n") end  

if (lp.IsDebugMode()==1) then

lib,init=lp.LoadLibrary(lp.GetPath().."/lua_lp_slad.dll","libinit");

else

lib,init=lp.LoadLibrary(lp.GetPath().."/lua_lp_sla.dll","libinit");

end 

if (lib==nil) then error("SLA Lib Not found or not loaded\n") end;  

init();

lp.Print("Display SLA for day\n");

temp=os.date("*t",os.time());

--[[

temp.year

temp.month

temp.day

temp.hour

temp.min

--]]

lp.Print(string.format("\tyear %i month %i day %i\n",temp.year,temp.month,temp.day)); 

for i=0,table.getn(tabz) do 

         info={};

         rep=lp.GetIPInformation(tabz[i],"array"); 

            if rep then

           if array.sla==1 then            

            lp.Print(string.format("------------------------------------------\nHost %s\nIP add : [%s]\n\n",array.name,tabz[i])); 

            if lpsla.Compute(100001,tabz[i],temp.year,temp.month,temp.day,temp.year,temp.month,temp.day

,os.time{year=temp.year,month=temp.month,day=temp.day,hour=0}

,os.time{year=temp.year,month=temp.month,day=temp.day,hour=0}

,50,90,90,'array') then

            lp.Print("\t\tIP : ",array.ip,"\n");

            lp.Print("\t\tName : ",array.name,"\n");

            lp.Print("\t\tpolling_type : ",array.polling_type,"\n");

            lp.Print("\t\tCollect for periode : ",array.periode,"%\n");

            lp.Print("\t\t\tAvaibility : ",array.avaibility,"%\n");

            lp.Print("\t\t\tPerformance : ",array.performance,"%\n");

            lp.Print("\t\tGood_polling : ",array.good_polling,"\n");

            lp.Print("\t\tTotal_collected : ",array.total_collected,"\n");

            lp.Print("\t\tTotal_waited : ",array.total_waited,"\n");

            

            end

             else

             lp.Print("SLA no collected for host : ",array.ip," \n");

             end

 

            end

end

 lp.Print("Scan Ended\n");

lp_buffer ="ok";

 

            end

end

 lp.Print("Scan Ended\n");

lp_buffer ="ok";

 

 

 


www.loriotpro.com