Page 1 of 1

Text function create a tool

Posted: Wed Jan 25, 2012 9:46 pm
by Duduhandelman
Hi All,
Maybe you have an idea on how to accomplish that.
I have servers that the ip address of them is 1.140.X.X while the IPMI ip of those servers is 192.140.X.X.
I wonder if its possible to create a tool that will open https://192.140.X.X without configuring this IP on each server.
If I understand correctly I need to create a function that will return only the number after the first dot and concatenate it with 192 at the beginning,

Many thanks for the help.

Re: Text function create a tool

Posted: Wed Jan 25, 2012 10:07 pm
by fbsdmon
Not sure if this is what you are looking for, but this

concatenate("192", string_substring(device_property("FirstAddress"), string_find(device_property("FirstAddress"), "."), 15))

will take the first address of the device and replace the everything before the first "." with "192"

Re: Text function create a tool

Posted: Wed Jan 25, 2012 10:24 pm
by Duduhandelman
Thanks fbsdmon
That's exactly what I was looking for. I was able to add it in the device appearance and it working perfect.
One last thing is how do I add this to the tool?
What should be the tool syntax
Thanks Again.

Re: Text function create a tool

Posted: Wed Jan 25, 2012 11:07 pm
by fbsdmon
Not sure if you can. I have no experience with creating tools, but from the examples and my short test to implement your idea, I can say that it is impossible :)
Looks like you can only pass device variables/information to the tools. So, no functions available.

What you could do is, set the IPMI ip address of each device in one of the custom fields of the device settings. This way, you could access the ip address from the tool as a device variable.

Tool Example:
name: https
command: "https://[Device.CustomField3]"

Re: Text function create a tool

Posted: Wed Jan 25, 2012 11:14 pm
by Duduhandelman
Thanks,
Yeh this will work, Now I should find a way to update 200 Devices.
I was unable to find a way to edit the database directly.

Many Thanks

Re: Text function create a tool

Posted: Wed Jan 25, 2012 11:21 pm
by geoffsmith31
I suggest making a tool that passes the IP address parameter into a VB script. Make a VB script that does the substitution of the first octet of the IP address and then calls whatever application you need using that address.

Re: Text function create a tool

Posted: Wed Jan 25, 2012 11:40 pm
by lebowski
Not the greatest solution but you could put the ip address in custom field 1 and put this as the command under your new tool...
http://[Device.CustomField1]
web192-Tool000160.png
I tried adding that concatenate string to a function and then putting the function into the command but it didn't seem to work. The call to a vb script or .bat from a tool would probably be the fastest.

Lebowski

Re: Text function create a tool

Posted: Thu Jan 26, 2012 8:49 pm
by Duduhandelman
Thank You all,
I made a short Python script and all is working perfect.

Thanks Again.