OpQL
From ISPWiki
Description
OpQL is a micro language for oProxy managing. Its syntax is similar to that of SQL.
Program syntax
The program consists of the queries, semicolon separated (semicolon is not obligatory after the last query).
Commands
stop daemon
The stop daemon query stops the oProxy running process. It may not be the last on the list of queries.
show workers
This query shows statuses of all the worker processes.
show nodes http
The query shows the status of HTTP backend node.
show nodes mysql
The query shows the status of MySQL backend node.
show traffic http
The query allows to get traffic per HTTP hosts that has not been included into logs yet.
show traffic mysql
The query allows to get traffic per MySQL user that has not been included into logs yet.
reset traffic
Allows to reset traffic statistics.
set param "value"
Sets the "Param" value of the configuration file to "value" without rebooting the proxy server. For example, in order to change the value of KeepAlive time out in HTTP:
set keepalive_http "1.5"
show param <name>
Shows the value of a specified parameter, where <name> is the name of the required parameter.
show params
Shows the values of all parameters.
start SAVE_QUERY
Start logging the information concerning certain queries to HTTP/MySQL into a specified log file (see #SAVE_QUERY syntax ).
All the queries that meet the requirements will be specified in a certain log file.
stop SAVE_QUERY
Stops logging the information about certain queries (see #SAVE_QUERY syntax). Specified query will be removed from the queue.
show queries
Shows the list of active SAVE_QUERY queries.
start reset RESET_RULE
Declines requests that meet the specified requirements. The requirements are specified via RESET_RULE. The syntax is given below.
stop reset RESET_RULE
Stops declining requests that meet the specified requirements.
show resets
The query shows the list of active rules that are use for resetting connections.
dump into file "path"
Backs up all current 'reset' and 'query' rules into the file, where "path" is the path to the dump file.
load from file "path"
Restores the backed up 'reset' and 'query' rules from the "path" file.
SAVE_QUERY syntax
SAVE_QUERY := LINES_LIST from <http|mysql> [where CONDITION] into file FILE_NAME
FIELDS_LIST:= EXPRESSION [, FIELDS_LIST]
EXPRESSION:=
EXPRESSION OPERAND EXPRESSION
| ( EXPRESSION )
| FUNCTION ( ARGUMENT_LIST)
| FIELD
| NUMBER
| LINE
OPERAND := + | - | * | /
FIELD:= current_time | time | received | sent | host | uri | client_ip | user | query | header "Header-Name"
CONDITION:=
CONDITION LOGICAL_OPERAND CONDITION
| ( CONDITION )
| not CONDITION
| EXPRESSION
LOGICAL_OPERAND := > | < | = | >= | <= | <> | !=
FILE_NAME:= LINE
LINE:= " line" | ' line '
NUMBER:=
figures
| figures . figures
| . figures
| figures .
FUNCTION:= line
ARGUMENTS_LIST:= EXPRESSION[, EXPRESSION]
FIELD information
FIELD is a datum that oProxy will get from the query.
- current_time
- local time when the query was finished
- time
- time in seconds that passed from sending a query to backend until receiving the data (query processing time)
- received
- number of bites that were received from client
- sent
- number of bites that were sent to client
- host
- name of the requested site. Can be used only for "from http" queries
- uri
- Requested URI. Can be used only for "from http" queries
- user
- Name of the authorized MySQL-user. Can be used only for "from mysql" queries
- query
- First N bytes of the MySQL-query (N is not more than the max_mysql_query_length_save value of the configuration file). Can be used only for "from mysql" queries
- header "Header-Name"
- HTTP-header value. A blank line is a header for a not found header.
Available functions
concat (separator, argument1, argumanet2, ...)
Integrates all the arguments into one line and sets <separator> between them.
replace (regexp, replace, line)
Replaces all the <line> lines that match the <regexp> regular expression into <replace>
RESET_RULE syntax
RESET_RULE := http [where УСЛОВИЕ]
The reset rule has the same syntax as SAVE_QUERY.
Examples of the queries
- Get information about workers:
show workers
- Get information about workers, then stop oProxy:
show workers; stop daemon
- Start logging the requested URL and server response time into the /tmp/test.com file:
start save uri, time from http into file '/tmp/test.com'
- Start logging the requested URL and server response time in minutes into the /tmp/test.comfile:
start save uri, time/60 from http into file '/tmp/test.com'
- Start logging current time, number of bytes sent and MySQL-query into the /tmp/root file, only if the response time was less than one second.
start save current_time, sent, query from mysql where time > 1 into file "/tmp/root"
- Start logging MySQL queries that were processed for more than 10 hours and the MySQL user was not root, or if less than 100 bytes were sent
start save query from mysql where (time > 10*3600 and user!="root") or sent<100 into file '/tmp/not_root'
- Add the "save uri, time from http into file '/tmp/test.com'" query and delete "save uri, time/60 from http into file '/tmp/test.com'":
start save uri, time from http into file '/tmp/test.com'; stop save uri, time/60 from http into file '/tmp/test.com'
