Hi there, i have been trying to get this to work, but with no success and hope someone can share some info.
I am trying to remove a user from ppp where it is like xyz
this is what i have, but obviously its not working…
curl -k -u x:y -X POST http://abc.com/rest/ppp/active/remove [/ppp/active/ find name=“xyz”]
thanks
chris
hey there, just checking if this is possible via curl command?
also to get last 50 entries filtered by a specific ppp user from the log from memory - is that possible with curl?
tx
chris
I am trying to remove a user from ppp where it is like xyz
When you are certain that only one entry exists for the user (ppp profile only-one=yes), you can DELETE by name:
curl -s -u x:y -X DELETE http://abc.com/rest/ppp/active/xyz
When multiple entries exist for the user (or could exist, e.g. only-one=no), you will have to query and run DELETE for every result:
for id in $(curl -s -u x:y http://abc.com/rest/ppp/active?name=xyz | jq -r '.[] | .".id"')
do
curl -s -u x:y -X DELETE http://abc.com/rest/ppp/active/$id
done
also to get last 50 entries filtered by a specific ppp user from the log from memory - is that possible with curl?
From the documentation - https://help.mikrotik.com/docs/display/ROS/REST+API
And further: https://help.mikrotik.com/docs/display/ROS/API#API-Queries
Regular expressions are not supported in API, so do not try to send a query with the ~ symbol
So filtering has to be done client side, to fetch the last 50 lines from log:
curl -s -u x:y http://abc.com/rest/log \
| jq -r '.[] | select (.topics | contains("ppp")) | select (.message | (contains("xyz logged in") or contains("xyz logged out"))) | .message' \
| tail -n 50