| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package maxscale |
| 4 | |
| 5 | // https://mariadb.com/kb/en/maxscale-24-02rest-api/ |
| 6 | |
| 7 | type maxscaleGlobalResponse struct { |
| 8 | Data *struct { |
| 9 | Attrs struct { |
| 10 | Params struct { |
| 11 | Threads int64 `json:"threads"` |
| 12 | Passive bool `json:"passive"` |
| 13 | } `json:"parameters"` |
| 14 | Uptime int64 `json:"uptime"` |
| 15 | } `json:"attributes"` |
| 16 | } `json:"data"` |
| 17 | } |
| 18 | |
| 19 | // https://github.com/mariadb-corporation/MaxScale/blob/f72af9927243f59f2b20cc835273dbe6dc158623/server/core/routingworker.cc#L3021 |
| 20 | // https://github.com/mariadb-corporation/MaxScale/blob/f72af9927243f59f2b20cc835273dbe6dc158623/maxctrl/lib/show.js#L471 |
| 21 | type maxscaleThreadsResponse struct { |
| 22 | Data []struct { |
| 23 | ID string `json:"id"` |
| 24 | Attrs struct { |
| 25 | Stats struct { |
| 26 | State string `json:"state"` |
| 27 | Reads int64 `json:"reads"` |
| 28 | Writes int64 `json:"writes"` |
| 29 | Errors int64 `json:"errors"` |
| 30 | Hangups int64 `json:"hangups"` |
| 31 | Accepts int64 `json:"accepts"` |
| 32 | Sessions int64 `json:"sessions"` |
| 33 | Zombies int64 `json:"zombies"` |
| 34 | CurrentDescriptors int64 `json:"current_descriptors"` |
| 35 | TotalDescriptors int64 `json:"total_descriptors"` |
| 36 | QCCache struct { |
| 37 | Size int64 `json:"size"` |
| 38 | Inserts int64 `json:"inserts"` |
| 39 | Hits int64 `json:"hits"` |
| 40 | Misses int64 `json:"misses"` |
| 41 | Evictions int64 `json:"evictions"` |
| 42 | } `json:"query_classifier_cache"` |
| 43 | } `json:"stats"` |
| 44 | } `json:"attributes"` |
| 45 | } `json:"data"` |
| 46 | } |
| 47 | |
| 48 | // // https://github.com/mariadb-corporation/MaxScale/blob/f72af9927243f59f2b20cc835273dbe6dc158623/server/core/routingworker.cc#L3064 |
| 49 | var threadStates = []string{ |
| 50 | "Active", |
| 51 | "Draining", |
| 52 | "Dormant", |
| 53 | } |
| 54 | |
| 55 | type serversResponse struct { |
| 56 | Data []struct { |
| 57 | ID string `json:"id"` |
| 58 | Type string `json:"type"` |
| 59 | Attrs struct { |
| 60 | Params struct { |
| 61 | Address string `json:"address"` |
| 62 | Port int `json:"port"` |
| 63 | } `json:"parameters"` |
| 64 | State string `json:"state"` |
| 65 | Statistics struct { |
| 66 | Connections int64 `json:"connections"` |
| 67 | } `json:"statistics"` |
| 68 | } `json:"attributes"` |
| 69 | } `json:"data"` |
| 70 | } |
| 71 | |
| 72 | // https://github.com/mariadb-corporation/MaxScale/blob/f72af9927243f59f2b20cc835273dbe6dc158623/system-test/maxtest/src/maxscales.cc#L43 |
| 73 | var serverStates = []string{ |
| 74 | "Master", |
| 75 | "Slave", |
| 76 | "Running", |
| 77 | "Down", |
| 78 | "Maintenance", |
| 79 | "Draining", |
| 80 | "Drained", |
| 81 | "Relay Master", |
| 82 | "Binlog Relay", |
| 83 | "Synced", |
| 84 | } |