1// Copyright (c) 1999-2018 David Muse 2// See the file COPYING for more information. 3 4#ifndef SQLRSHMDATA_H 5#define SQLRSHMDATA_H 6 7// FIXME: this is only here so the headers don't have to include defines.h 8#define USERSIZE 128 9 10// sizes... 11#define MAXCONNECTIONIDLEN 256 12#define MAXUNIXSOCKETLEN 1024 13#define MAXCONNECTIONS @ABS_MAXCONNECTIONS@ 14#define STATQPSKEEP 900 15#define STATSQLTEXTLEN 512 16#define STATCLIENTINFOLEN 512 17 18// structures... 19enum sqlrconnectionstate_t { 20 NOT_AVAILABLE=0, 21 INIT, 22 WAIT_FOR_AVAIL_DB, 23 WAIT_CLIENT, 24 SESSION_START, 25 GET_COMMAND, 26 PROCESS_SQL, 27 PROCESS_CUSTOM, 28 RETURN_RESULT_SET, 29 SESSION_END, 30 ANNOUNCE_AVAILABILITY, 31 WAIT_SEMAPHORE 32}; 33 34struct sqlrconnstatistics { 35 uint32_t processid; 36 enum sqlrconnectionstate_t state; 37 uint32_t index; 38 uint32_t nconnect; 39 uint32_t nauth; 40 uint32_t nsuspend_session; 41 uint32_t nend_session; 42 uint32_t nping; 43 uint32_t nidentify; 44 uint32_t nautocommit; 45 uint32_t nbegin; 46 uint32_t ncommit; 47 uint32_t nrollback; 48 uint32_t ndbversion; 49 uint32_t nbindformat; 50 uint32_t nserverversion; 51 uint32_t nselectdatabase; 52 uint32_t ngetcurrentdatabase; 53 uint32_t ngetlastinsertid; 54 uint32_t ndbhostname; 55 uint32_t ndbipaddress; 56 uint64_t nnewquery; 57 uint64_t nreexecutequery; 58 uint32_t nfetchfrombindcursor; 59 uint32_t nfetchresultset; 60 uint32_t nabortresultset; 61 uint32_t nsuspendresultset; 62 uint32_t nresumeresultset; 63 uint32_t ngetdblist; 64 uint32_t ngettablelist; 65 uint32_t ngetcolumnlist; 66 uint32_t ngetquerytree; 67 uint64_t nsql; 68 uint32_t ncustomsql; 69 uint32_t nrelogin; 70 uint32_t nnextresultset; 71 uint32_t nnextresultsetavailable; 72 uint64_t loggedinsec; 73 uint64_t loggedinusec; 74 uint64_t statestartsec; 75 uint64_t statestartusec; 76 uint64_t clientsessionsec; 77 uint64_t clientsessionusec; 78 char clientaddr[16]; 79 char clientinfo[STATCLIENTINFOLEN]; 80 char sqltext[STATSQLTEXTLEN]; 81 char user[USERSIZE]; 82}; 83 84// This structure is used to pass data in shared memory between the listener 85// and connection daemons. A struct is used instead of just stepping a pointer 86// through the shared memory segment to avoid alignment issues. 87struct sqlrshm { 88 89 uint32_t totalconnections; 90 char connectionid[MAXCONNECTIONIDLEN]; 91 union { 92 struct { 93 uint16_t inetport; 94 char unixsocket[MAXUNIXSOCKETLEN]; 95 } sockets; 96 pid_t connectionpid; 97 } connectioninfo; 98 99 uint32_t connectedclients; 100 101 time_t starttime; 102 103 uint32_t open_db_connections; 104 uint32_t opened_db_connections; 105 106 uint32_t open_db_cursors; 107 uint32_t opened_db_cursors; 108 109 uint32_t open_cli_connections; 110 uint32_t opened_cli_connections; 111 112 uint32_t times_new_cursor_used; 113 uint32_t times_cursor_reused; 114 115 uint32_t total_queries; 116 uint32_t total_errors; 117 118 uint32_t forked_listeners; 119 120 // below were added by neowiz... 121 122 // maximum number of listeners allowed and 123 // number of times that limit was was hit 124 uint32_t max_listeners; 125 uint32_t max_listeners_errors; 126 127 // highest count of listeners 128 // (all-time and over previous minute) 129 uint32_t peak_listeners; 130 uint32_t peak_listeners_1min; 131 time_t peak_listeners_1min_time; 132 133 // highest count of connections-in-use 134 // (all-time and over previous minute) 135 uint32_t peak_connectedclients; 136 uint32_t peak_connectedclients_1min; 137 time_t peak_connectedclients_1min_time; 138 139 time_t timestamp[STATQPSKEEP]; 140 uint32_t qps_select[STATQPSKEEP]; 141 uint32_t qps_insert[STATQPSKEEP]; 142 uint32_t qps_update[STATQPSKEEP]; 143 uint32_t qps_delete[STATQPSKEEP]; 144 uint32_t qps_create[STATQPSKEEP]; 145 uint32_t qps_drop[STATQPSKEEP]; 146 uint32_t qps_alter[STATQPSKEEP]; 147 uint32_t qps_custom[STATQPSKEEP]; 148 uint32_t qps_etc[STATQPSKEEP]; 149 150 sqlrconnstatistics connstats[MAXCONNECTIONS]; 151 152 bool disabled; 153}; 154 155#endif 156