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

lp.GetUIDInformation - Get information of a directory item with its UID

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

Result=lp.GetUIDInformation(uid,"arrayname");

Description

Collecte the configuration parameters stored in the directory and associated to this directory UID. Each object in the directory has a unique UID.

Parameters

uid - This is a long value of 64 bits privided in a character string format.

arrayname - Provide an array of all the requested parameters

Return Values

Result =1 or nil if an error occurs

If result = 1 returns arrayname

arrayname['ip'] The IP address of the host in a character string format
arrayname['status'] The current Host connectivity status (value: 0,1,2,3,4)(The color of host icon)
arrayname['plugin_name'] The name of the plugin when it is a plugin
arrayname['object_type']

The object type declare in the /bin/config/script/loriotinit.lua

That can be add to the script with the line code :

dofile(lp.GetPath().."/config/script/loriotinit.lua");

--ParamType
LP_LUA_DT_COUNTRY=1;
LP_LUA_DT_ORGANIZATION =2;
LP_LUA_DT_ORGANIZATION_UNIT=3;
LP_LUA_DT_NETWORK=4;
LP_LUA_DT_FACTORY=5;
LP_LUA_DT_HOST=6;
LP_LUA_DT_HOST_FUNCTION=7;
LP_LUA_DT_HOST_ALIAS=8;
LP_LUA_DT_HOST_EXECLINK=9;
LP_LUA_DT_HOST_MRTG=10;
LP_LUA_DT_HOST_PLUGIN=11;

UID_father The UID ( unique identifier) of the father object
UID_same  
UID_child The UID ( unique identifier) of the next child object
child The number of child objects for this father object
status The current status of the Object:
UID_alias The UID ( unique identifier) of the next alias object
alias The number of alias objects for this father object
lock_http  
access_level  
arrayname['string'] The object parameter in a character string format

Example

lp_value = 0;
lp_buffer ="error";
dofile(lp.GetPath().."/config/script/loriotinit.lua");
lp_value=lp.GetIPInformation(lp_host,"a");
if lp_value~=nil then
lp_value=lp.GetUIDInformation(a.UID,"array");
if lp_value~=nil then
lp.Trace("name =",array.name);
lp.Trace("status =",array.status);
lp.Trace("objet type =",array.object_type);
if array.objet_type==LP_LUA_DT_HOST_PLUGIN then
lp.Trace("plugin name =",array.plugin_name);
end
lp_buffer ="ok";
end
end

When writing code if you need to insert the UID of an object, a wizard can be called and help you to find the UID of any object of the directory. The UIS is inserted at the cursor position.

lp_value = 0;
lp_buffer ="error";

dofile(lp.GetPath().."/config/script/loriotinit.lua");

lp_value=lp.GetUIDInformation("4809522060441157642","array");
if lp_value~=nil then
lp.Trace("name =",array.name);
lp.Trace("status =",array.status);
lp.Trace("objet type =",array.object_type);

if array.status==LP_LUA_STATUS_NONE then
lp.Trace("No status");
elseif array.status==LP_LUA_STATUS_ICMP then
lp.Trace("Ping ok");
elseif array.status==LP_LUA_STATUS_SNMP then
lp.Trace("Snmp ok");
elseif array.status==LP_LUA_STATUS_WARNING then
lp.Trace("Warning");
elseif array.status==LP_LUA_STATUS_DOWN then
lp.Trace("Object Down");
end

f=array.object_type;

if f==LP_LUA_DT_COUNTRY then
lp.Trace("Country name =",array.name);
elseif f==LP_LUA_DT_ORGANIZATION then
lp.Trace("Organization name =",array.name);
elseif f==LP_LUA_DT_ORGANIZATION_UNIT then
lp.Trace("Organization Unit name =",array.name);
elseif f==LP_LUA_DT_NETWORK then
lp.Trace("Network name =",array.name);
elseif f==LP_LUA_DT_HOST then
lp.Trace("Host name =",array.name);
elseif f==LP_LUA_DT_HOST_PLUGIN then
lp.Trace("plugin name =",array.name);
end
lp_buffer ="ok";

end





www.loriotpro.com