Community discussions

MikroTik App
 
Duduhandelman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 89
Joined: Wed Jan 04, 2012 5:30 pm

Text function create a tool

Wed Jan 25, 2012 9:46 pm

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.
 
fbsdmon
newbie
Posts: 29
Joined: Thu Dec 29, 2011 11:37 pm

Re: Text function create a tool

Wed Jan 25, 2012 10:07 pm

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"
 
Duduhandelman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 89
Joined: Wed Jan 04, 2012 5:30 pm

Re: Text function create a tool

Wed Jan 25, 2012 10:24 pm

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.
 
fbsdmon
newbie
Posts: 29
Joined: Thu Dec 29, 2011 11:37 pm

Re: Text function create a tool

Wed Jan 25, 2012 11:07 pm

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]"
 
Duduhandelman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 89
Joined: Wed Jan 04, 2012 5:30 pm

Re: Text function create a tool

Wed Jan 25, 2012 11:14 pm

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
 
User avatar
geoffsmith31
Member Candidate
Member Candidate
Posts: 155
Joined: Fri Nov 05, 2010 6:08 am
Location: Toowoomba, Australia

Re: Text function create a tool

Wed Jan 25, 2012 11:21 pm

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.
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: Text function create a tool

Wed Jan 25, 2012 11:40 pm

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
You do not have the required permissions to view the files attached to this post.
 
Duduhandelman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 89
Joined: Wed Jan 04, 2012 5:30 pm

Re: Text function create a tool

Thu Jan 26, 2012 8:49 pm

Thank You all,
I made a short Python script and all is working perfect.

Thanks Again.

Who is online

Users browsing this forum: No registered users and 17 guests