Improve RESTAPI example scripts 'kill_idle_backend_conns.py' and doc

pull/3882/head
Javier Jaramago Fernández 4 years ago
parent 691c19a0b1
commit a443e3ded0

@ -7,7 +7,7 @@ This is a set of example scripts to show the capabilities of the RESTAPI interfa
1. Launch ProxySQL:
```
./src/proxysql -M --sqlite3-server --idle-threads -f -c $PATH/restapi_examples/datadir/proxysql.cnf -D $PATH/restapi_examples/datadir
./proxysql -M --sqlite3-server --idle-threads -f -c $PROXYSQL_PATH/scripts/datadir/proxysql.cnf -D $PROXYSQL_PATH/scripts/datadir
```
2. Configure ProxySQL:
@ -67,8 +67,13 @@ cd $RESTAPI_EXAMPLES_DIR/requirements
```
curl -i -X POST -d '{ "admin_host": "127.0.0.1", "admin_port": 6032, "admin_user": "radmin", "admin_pass": "radmin", "table": "stats_mysql_users" }' http://localhost:6070/sync/scrap_stats
```
- Provoke script failure (non-existing table):
```
curl -i -X POST -d '{ "admin_host": "127.0.0.1", "admin_port": 6032, "admin_user": "radmin", "admin_pass": "radmin", "table": "stats_mysql_servers" }' http://localhost:6070/sync/scrap_stats
```
### Scripts doc
- All scripts allows to perform the target operations on a local or remote ProxySQL instance.
- Notice how the unique 'GET' request is for 'QUERY CACHE' flushing, since it doesn't require any parameters.
- Script 'stats_scrapper.py' fails when a table that isn't present in 'stats' schema is queried. This is left as an example of the behavior of a failing script and ProxySQL log output.

@ -114,7 +114,12 @@ if __name__ == "__main__":
print(json.dumps({"err_code": 1, "res": "Invalid resulset received for query `" + s_free_query + "`"}))
exit(0)
else:
free_conns = int(my_rows[0]['SUM(ConnFree)'])
conn_free_field = my_rows[0]['SUM(ConnFree)']
if conn_free_field is not None:
free_conns = int(conn_free_field)
else:
free_conns = 0
time.sleep(1)

Loading…
Cancel
Save