Is true, you can create the script "umts_info" that contains "/interface ppp-client info ppp-out1" and call it from scheduler.
To kill it you can use "/system script job remove [find script=umts_info ]"
Thanks for this tip alphil.
asesko, I think I have found a way to successfully use this ppp-client info command inside a script.
You have to use a counter and let the loop run at least 3 times to set the system variables properly.
After that they can be used for whatever you need. But you must "kill" the script job after you have finished.
I have created two scripts.
One named pppUptime, which uses the ppp-client monitor command to get the interface uptime.
The other is named pppInfoUPtime, which uses ppp-client info, but starts the pppUptime script as well, to allow me to get the Uptime to add to the information file and for email.
I hope these scripts are useful.
I have spent many hours on this and have learned a great deal.
Enjoy!
pppUptimeOnly:
## All this script does is set the pppUptime global variable for "wan2" in this example##
## This script name is pppUptime in this example ##
## Used in conjunction with my other pppInfo script ##
## Share, modify, improve and use as you wish ##
## Tested on RouterOS v5.12 using Huawei E367 modem #
## Peter James 2012-03-17 ##
## Set the PPP interface name for which Uptime value is required ##
:local pppName "wan2";
# loop counter #
:local k 0;
# Defined as global, so that other script can use #
:global pppUptime;
:local pppID [/interface ppp-client find name=$pppName];
:log info "PPP Uptime $pppName Script Starting";
# Start of monitor command #
/interface ppp-client monitor $pppName do={
:set k ($k+1);
# run loop twice to be sure #
:if ($k=2) do={
:set pppUptime $"uptime";
## Must now stop this script, or Monitor will run forever ##
:log info "PPP Uptime $pppName Script completed";
/system script job remove [find script=pppUptime ];
}
}
pppInfoUptime (starts the above pppUptimeOnly script):
## Script to write PPP-info to a file and send to Email ##
## For this example, my PPP name is "wan2" ##
## and my script name is "wan2PPPinfoUptime" ##
## This script makes use of the ppp-client info command ##
## with a loop counter to stop the command once the ##
## information has been acquired. ##
## Can be used in conjunction with my other pppUptime ##
## script if the Uptime is required as well. ##
## You can use the info file to extract information for other purposes ##
## Remember to set up Tools-Email ##
## Share, modify, improve and use as you wish ##
## Tested on RouterOS v5.12 using Huawei E367 modem #
## Peter James 2012-03-17 ##
# Set the PPP interface name #
:local pppName "wan2";
# Define the email address to receive PPP Info report #
:local emailAddress "your_email_address"
:local i 0;
global pppUptime;
:local pppID [/interface ppp-client find name=$pppName];
# Variables to hold PPP Info #
:local String1;
:local String2;
:local pppInfoString;
# Variable to hold PPP interface current IP address #
:local currentIP;
# Get System Identity #
:local SystemID [/system identity get name];
:local pppStatus;
:if ([/interface get [find name=$pppName ] running ]=true) do={
:set pppStatus "Running";
### Get the address of the specified wan interface ###
:set currentIP [/ip address get [find interface=$pppName] address];
:set currentIP [:pick $currentIP 0 [:find $currentIP "/"]]
} else={
:set pppStatus "Disabled";
}
# Start the pppUptime script #
# Comment out if you do not need #
/system script run pppUptime;
:log info "PPP Info $pppName Script Starting";
# Create the information File #
/file print file="$SystemID-$pppName-PPP-info";
:global SysDate [/system clock get date]
:global SysTime [/system clock get time]
# Start of info command #
/interface ppp-client info $pppID do={
:set i ($i+1);
# for some reason this loop must run at least 3 times to set the system variables #
# set to run 5 times to be sure #
:if ($i=5) do={
# non info command stuff #
:set String1 "Date: $SysDate\nTime: $SysTime\nSystem ID: $SystemID\nPPP Interface: $pppName\nPPP Interface Status: $pppStatus\nIP Address: $currentIP\nUptime: $pppUptime\n";
:set String2 "Modem Status: $"status"\nPin Status: $"pin-status"\nFunctionality: $"functionality"\nManufacturer: $"manufacturer"\nModel: $"model"\nRevision: $"revision"\nSerial Number: $"serial-number"\nCurrent Operator: $"current-operator"\nAccess Technology: $"access-technology"\nSignal Strength: $"signal-strengh"";
:set pppInfoString "$String1$String2";
:log info $pppInfoString;
# Populate file with required information #
/file set "$SystemID-$pppName-PPP-info" contents=$pppInfoString;
# Do all the other things you need to do here ???#
# Example, send Email #
:log info "Sending PPP Info email";
/tool e-mail send tls=yes subject="$SystemID $pppName PPP Info" to=$emailAddress body="$pppInfoString";
:log info "PPP Info $pppName Script Completed";
## Must now stop this script, or info will run forever ##
/system script job remove [find script=wan2PPPinfoUptime ];
}
}