The Admin-lua-script in Mysql-proxy

Source: Internet
Author: User

[Email protected] lua]#Cat Admin.lua--[[$%beginlicense%$ Copyright (c), the Oracle and/or its affiliates. All rights reserved. This program was free software; You can redistribute it and/or modify it under the terms of the GNU general public License as published by the free Softwa Re Foundation; Version 2 of the License. This program was distributed in the hope that it'll be useful, but without any WARRANTY; Without even the implied warranty of merchantability or FITNESS for A particular PURPOSE. See the GNU general public License for more details. You should has received a copy of the GNU general public License along and this program; If not, write to the Free Software Foundation, Inc., Wuyi Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $%endlicense% $ --]]functionset_error (errmsg) proxy.response= {                type=Proxy. Mysqld_packet_err, ErrMsg= ErrMsgor "Error"        }Endfunctionread_query (packet)ifPacket:byte () ~= proxy.com_query ThenSet_error ("[admin] we only handle text-based queries (com_query)")                returnProxy. Proxy_send_resultEnd        Localquery = Packet:sub (2)        Localrows = { }        LocalFields = { }        ifQuery:lower () = ="SELECT * from Backends"  Then Fields={{Name="Backend_ndx",                           type=Proxy. Mysql_type_long}, {name="Address",                          type=Proxy. Mysql_type_string}, {name=" State",                          type=Proxy. Mysql_type_string}, {name="type",                          type=Proxy. Mysql_type_string}, {name="UUID",                          type=Proxy. Mysql_type_string}, {name="connected_clients",                           type=Proxy. Mysql_type_long},} fori =1, #proxy. global.backends Do                        Localstates = {                                "Unknown",                                " up",                                " Down"                        }                        LocalTypes = {                                "Unknown",                                "RW",                                "ro"                        }                        Localb =Proxy.global.backends[i] rows[#rows +1] ={i, B.dst.name,--Configured Backend AddressStates[b.state +1],--The C-id is pushed under starting at 0Types[b.type+1],--The C-id is pushed under starting at 0B.uuid,--The MySQL Server ' s UUID if it is managedB.connected_clients--currently connected clients                        }                End        ElseIfQuery:lower () = ="SELECT * from Help"  Then Fields={{Name="Command",                           type=Proxy. Mysql_type_string}, {name="Description",                           type=Proxy. Mysql_type_string},} rows[#rows +1] = {"SELECT * from Help","shows this help"} rows[#rows +1] = {"SELECT * from Backends","lists the backends and their state" }        ElseSet_error ("Use ' SELECT * from help ' to see the supported commands")                returnProxy. Proxy_send_resultEndProxy.response= {                type=Proxy. MYSQLD_PACKET_OK, ResultSet={ fields=Fields , Rows=rows}} returnProxy. Proxy_send_resultEnd

The Admin-lua-script in Mysql-proxy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.