Can you help me to write a schedules script to change Teltonika 241 LAN interface speed.
I have device connected to LAN ports and sometimes device disconnecting and “auto negotiation” not working. Setting interface to 10-half restoring connectiong, after that “auto negotiation” works again. How to write a scheduled script, that can ping to device every 5 minutes and if ping fails, changing port speed to 10-half, ping again and if ping succesfull, restoring bag interface to “auto negotiation”.
Hello,
Although we don’t write tailored custom scripts, I can help you out by giving you a head start.
You will want to set a custom script using API calls together with a condition, which in your case will be to ping your end LAN device IP address every x amount of minutes, and if the ping fails, send an API call to disable auto-negotiation. The payload will look like this:
api put /ports_settings/config '{"data":[{"enabled":"1","autoneg":"off","advert":"","duplex":"full","speed":"10","id":"_lan2"}]}'
After this API call, start pinging every 5 minutes again to check if the connection has been restored, and if it has, toggle auto-negotiation back on:
api put /ports_settings/config {"data":[{"enabled":"1","autoneg":"on","advert":["10mh","10mf","100mh","100mf","1000mf"],"duplex":"","speed":"","id":"_lan2"}]}
To avoid the script being deleted somehow, make sure to store it under /etc/
, you can even create a separate directory for it if you wish to do so. Additionally, to preserve the script, you need to add it to the /etc/sysupgrade.conf
file.
This should work as you need it to, for further custom script examples, you can find them here: User Scripts examples - Teltonika Networks Wiki
Regards,
M.
Difficult way.
Maybe you can write a “custom startup” script…
Auto reboot ping fails, Teltonika reboots, inteface speed changes to 10half, pause 10 seconds and interface speed changes to autonegotiation…
This is actually one of the simpler ways to achieve what you’re trying to do. Unfortunately, we do not write custom scripts; we can only help you get on track.
For the timings of when the script is being run, you need to utilize the crontabs file that exists in our device, more information here: Crontabs - Teltonika Networks Wiki
More so, you can edit the /etc/rc.local file with the commands to ping, send an API request, ping again, and send another API request. The contents of this file will be executed once system initialization is finished. There are a lot of ways to approach this, it depends on what you’re comfortable with.
Regards,
M.
This topic was automatically closed after 60 days. New replies are no longer allowed.