![]() ![]() |
LoriotPro
scripting documentation |
![]() ![]() ![]() |
![]() |
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
‘uid’,level = lp.GetNextDirectoryUID('uid');
Description
The lp.GetNextDirectoryUID LUA function retrieve the next UID of an item of the directory tree. This is very useful to browse the tree for finding information about an object.
see also : lp.GetChildUID(‘uid’,’array’);
Parameters
‘uid’ A UID, a unique number representing an unsigned 64 bits but stored as a character string.
Return Values
‘uid’ A UID, a unique number representing an unsigned 64 bits but stored as a character string.
level The level of the next object in the tree
If = 0 next
If = 1 one level down (enter a branch)
If = -1 one level up (leave a branch)
If = -x x level up (leave x branches)
Return nil if an error occurs
Example
Example of browse from the root (see also : lp.GetChildUID(‘uid’,’array’);).
uid=lp.GetFirstDirectoryUID();
if uid then
while (uid ~= nil) do
lp.Print(uid);
a=lp.GetUIDInformation(uid,"b");
if (a) then
lp.Print(" ",b.name," ",b.plugin_name,"\n");
end
uid=lp.GetNextDirectoryUID(uid);
end
end
Un exemple plus complet avec une gestion des niveaux dans l’arbre.
dofile(lp.GetPath().."/config/script/loriotinit.lua");
-- init the tree position
level=0;
pos=0;
uid=lp.GetFirstDirectoryUID();
if uid then
while (uid ~= nil) do
a=lp.GetUIDInformation(uid,"b");
if (a) then
-- compute the tree position
pos=pos+level;
marge="";
for i=0,pos do
marge=marge.."\t";
end
-- compute the tree position
if b.object_type==LP_LUA_DT_COUNTRY then
elseif b.object_type==LP_LUA_DT_ORGANIZATION then
lp.Print(marge,"LP_LUA_DT_ORGANIZATION ","\n");
elseif b.object_type==LP_LUA_DT_ORGANIZATION_UNIT then
lp.Print(marge,"LP_LUA_DT_ORGANIZATION_UNIT ","\n");
elseif b.object_type==LP_LUA_DT_NETWORK then
lp.Print(marge,"LP_LUA_DT_NETWORK ","\n");
elseif b.object_type==LP_LUA_DT_FACTORY then
lp.Print(marge,"LP_LUA_DT_FACTORY ","\n");
elseif b.object_type==LP_LUA_DT_HOST then
lp.Print(marge,"LP_LUA_DT_HOST ","\n");
elseif b.object_type==LP_LUA_DT_HOST_FUNCTION then
lp.Print(marge,"LP_LUA_DT_HOST_FUNCTION ","\n");
elseif b.object_type==LP_LUA_DT_HOST_ALIAS then
lp.Print(marge,"LP_LUA_DT_HOST_ALIAS ","\n");
elseif b.object_type==LP_LUA_DT_HOST_EXECLINK then
lp.Print(marge,"LP_LUA_DT_HOST_EXECLINK ","\n");
elseif b.object_type==LP_LUA_DT_HOST_MRTG then
lp.Print(marge,"LP_LUA_DT_HOST_MRTG ","\n");
elseif b.object_type==LP_LUA_DT_HOST_PLUGIN then
lp.Print(marge,"LP_LUA_DT_HOST_PLUGIN ","\n");
elseif b.object_type==LP_LUA_DT_HOST_ADVPOLLING then
lp.Print(marge,"LP_LUA_DT_HOST_ADVPOLLING ","\n");
end
lp.Print(marge,level," ",uid);
lp.Print(" ",b.name," ",b.plugin_name,"\n");
end
uid,level=lp.GetNextDirectoryUID(uid);
end
end
![]() |
|