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.InsertNewHost - Insert a new host in the LoriotPro directory

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”=lp.InsertNewHost(“ip”,”name”,”uid”,putinnetwork);

Description

Insert a new host object in the directory under the object specified by its UID number.

Parameters

ip - The IP address in a charater string format.

name - A name for the host object in a charater string format.

uid - A 64 bits value in a character string format that identify the father object in the directory tree. « 0 » if you want to insert it under the root object.

Putinnetwork - If this value is set to 0 the host will be inserted under the specified UID. If this value is set to 1 the host will be inserted in the network container that fits with its IP address.

Return Values

uid - the UID of the created object

nil - if an error occurs

Exemple

-- Loriotpro V4
-- 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";
dofile(lp.GetPath().."/config/script/loriotinit.lua");

uid=lp.FindName("MyOrganisation")
lp.Print(uid,"\n");
uid2=lp.InsertNewContainer("Container 1",uid,2);

if uid2 then
lp.Print(uid2,"\n");

uid3=lp.InsertNewHost("1.1.1.1","new host",uid2,0);
if uid3 then
lp.SetIPOption("1.1.1.1",LP_LUA_COMMUNITYRO,"public");
lp.SetIPOption("1.1.1.1",LP_LUA_POLLING_PING,1);
end

lp.Print(uid3,"\n");
end


Script for inserting a host

Host inserted in the directory


 



www.loriotpro.com