Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mysqlnd_ms_get_stats(3) [php man page]

MYSQLND_MS_GET_STATS(3) 						 1						   MYSQLND_MS_GET_STATS(3)

mysqlnd_ms_get_stats - Returns query distribution and connection statistics

SYNOPSIS
array mysqlnd_ms_get_stats (void ) DESCRIPTION
Returns an array of statistics collected by the replication and load balancing plugin. The PHP configuration setting mysqlnd_ms.collect_statistics controls the collection of statistics. The collection of statistics is dis- abled by default for performance reasons. The scope of the statistics is the PHP process. Depending on your deployment model a PHP process may handle one or multiple requests. Statistics are aggregated for all connections and all storage handler. It is not possible to tell how much queries originating from mysqli, PDO_MySQL or mysql API calls have contributed to the aggregated data values. PARAMETERS
This function has no parameters. RETURN VALUES
Returns NULL if the PHP configuration directive mysqlnd_ms.enable has disabled the plugin. Otherwise, returns array of statistics. Array of statistics +-------------------------------------+--------------------------------------+---+ | Statistic | | | | | | | | | Description | | | | | | | | Version | | | | | | +-------------------------------------+--------------------------------------+---+ | | | | | use_slave | | | | | | | | | The semantics of this statistic has | | | | changed between 1.0.1 - 1.1.0. The | | | | meaning for version 1.0.1 is as fol- | | | | lows. Number of statements consid- | | | | ered as read-only by the built-in | | | | query analyzer. Neither statements | | | | which begin with a SQL hint to force | | | | use of slave nor statements directed | | | | to a slave by an user-defined call- | | | | back are included. The total number | | | | of statements sent to the slaves is | | | | use_slave + use_slave_sql_hint + | | | | use_slave_callback. PECL/mysqlnd_ms | | | | 1.1.0 introduces a new concept of | | | | chained filters. The statistics is | | | | now set by the internal load balanc- | | | | ing filter. With version 1.1.0 the | | | | load balancing filter is always the | | | | last in the filter chain, if used. | | | | In future versions a load balancing | | | | filter may be followed by other fil- | | | | ters causing another change in the | | | | meaning of the statistic. If, in the | | | | future, a load balancing filter is | | | | followed by another filter it is no | | | | longer guaranteed that the state- | | | | ment, which increments use_slave, | | | | will be executed on the slaves. The | | | | meaning for version 1.1.0 is as fol- | | | | lows. Number of statements sent to | | | | the slaves. Statements directed to a | | | | slave by the user filter (an user- | | | | defined callback) are not included. | | | | The latter are counted by | | | | use_slave_callback. | | | | | | | | Since 1.0.0. | | | | | | | | | | | use_master | | | | | | | | | The semantics of this statistic has | | | | changed between 1.0.1 - 1.1.0. The | | | | meaning for version 1.0.1 is as fol- | | | | lows. Number of statements not con- | | | | sidered as read-only by the built-in | | | | query analyzer. Neither statements | | | | which begin with a SQL hint to force | | | | use of master nor statements | | | | directed to a master by an user- | | | | defined callback are included. The | | | | total number of statements sent to | | | | the master is use_master + use_mas- | | | | ter_sql_hint + use_master_callback. | | | | PECL/mysqlnd_ms 1.1.0 introduces a | | | | new concept of chained filters. The | | | | statictics is now set by the inter- | | | | nal load balancing filter. With ver- | | | | sion 1.1.0 the load balancing filter | | | | is always the last in the filter | | | | chain, if used. In future versions a | | | | load balancing filter may be fol- | | | | lowed by other filters causing | | | | another change in the meaning of the | | | | statistic. If, in the future, a load | | | | balancing filter is followed by | | | | another filter it is no longer guar- | | | | anteed that the statement, which | | | | increments use_master, will be exe- | | | | cuted on the slaves. The meaning | | | | for version 1.1.0 is as follows. | | | | Number of statements sent to the | | | | masters. Statements directed to a | | | | master by the user filter (an user- | | | | defined callback) are not included. | | | | The latter are counted by use_mas- | | | | ter_callback. | | | | | | | | Since 1.0.0. | | | | | | | | | | | use_slave_guess | | | | | | | | | Number of statements the built-in | | | | query analyzer recommends sending to | | | | a slave because they contain no SQL | | | | hint to force use of a certain | | | | server. The recommendation may be | | | | overruled in the following. It is | | | | not guaranteed whether the statement | | | | will be executed on a slave or not. | | | | This is how often the internal | | | | is_select function has guessed that | | | | a slave shall be used. Please, see | | | | also the user space function | | | | mysqlnd_ms_query_is_select(3). | | | | | | | | Since 1.1.0. | | | | | | | | | | | use_master_guess | | | | | | | | | Number of statements the built-in | | | | query analyzer recommends sending to | | | | a master because they contain no SQL | | | | hint to force use of a certain | | | | server. The recommendation may be | | | | overruled in the following. It is | | | | not guaranteed whether the statement | | | | will be executed on a slave or not. | | | | This is how often the internal | | | | is_select function has guessed that | | | | a master shall be used. Please, see | | | | also the user space function | | | | mysqlnd_ms_query_is_select(3). | | | | | | | | Since 1.1.0. | | | | | | | | | | | use_slave_sql_hint | | | | | | | | | Number of statements sent to a | | | | slave because statement begins with | | | | the SQL hint to force use of slave. | | | | | | | | Since 1.0.0. | | | | | | | | | | | use_master_sql_hint | | | | | | | | | Number of statements sent to a mas- | | | | ter because statement begins with | | | | the SQL hint to force use of master. | | | | | | | | Since 1.0.0. | | | | | | | | | | | use_last_used_sql_hint | | | | | | | | | Number of statements sent to server | | | | which has run the previous state- | | | | ment, because statement begins with | | | | the SQL hint to force use of previ- | | | | ously used server. | | | | | | | | Since 1.0.0. | | | | | | | | | | | use_slave_callback | | | | | | | | | Number of statements sent to a | | | | slave because an user-defined call- | | | | back has chosen a slave server for | | | | statement execution. | | | | | | | | Since 1.0.0. | | | | | | | | | | | use_master_callback | | | | | | | | | Number of statements sent to a mas- | | | | ter because an user-defined callback | | | | has chosen a master server for | | | | statement execution. | | | | | | | | Since 1.0.0. | | | | | | | | | | | non_lazy_connections_slave_success | | | | | | | | | Number of successfully opened slave | | | | connections from configurations not | | | | using lazy connections. The total | | | | number of successfully opened slave | | | | connections is non_lazy_connec- | | | | tions_slave_success + lazy_connec- | | | | tions_slave_success | | | | | | | | Since 1.0.0. | | | | | | | | | | | non_lazy_connections_slave_failure | | | | | | | | | Number of failed slave connection | | | | attempts from configurations not | | | | using lazy connections. The total | | | | number of failed slave connection | | | | attempts is non_lazy_connec- | | | | tions_slave_failure + lazy_connec- | | | | tions_slave_failure | | | | | | | | Since 1.0.0. | | | | | | | | | | |non_lazy_connections_master_success | | | | | | | | | Number of successfully opened mas- | | | | ter connections from configurations | | | | not using lazy connections. The | | | | total number of successfully opened | | | | master connections is non_lazy_con- | | | | nections_master_success + lazy_con- | | | | nections_master_success | | | | | | | | Since 1.0.0. | | | | | | | | | | |non_lazy_connections_master_failure | | | | | | | | | Number of failed master connection | | | | attempts from configurations not | | | | using lazy connections. The total | | | | number of failed master connection | | | | attempts is non_lazy_connec- | | | | tions_master_failure + lazy_connec- | | | | tions_master_failure | | | | | | | | Since 1.0.0. | | | | | | | | | | | lazy_connections_slave_success | | | | | | | | | Number of successfully opened slave | | | | connections from configurations | | | | using lazy connections. | | | | | | | | Since 1.0.0. | | | | | | | | | | | lazy_connections_slave_failure | | | | | | | | | Number of failed slave connection | | | | attempts from configurations using | | | | lazy connections. | | | | | | | | Since 1.0.0. | | | | | | | | | | | lazy_connections_master_success | | | | | | | | | Number of successfully opened mas- | | | | ter connections from configurations | | | | using lazy connections. | | | | | | | | Since 1.0.0. | | | | | | | | | | | lazy_connections_master_failure | | | | | | | | | Number of failed master connection | | | | attempts from configurations using | | | | lazy connections. | | | | | | | | Since 1.0.0. | | | | | | | | | | | trx_autocommit_on | | | | | | | | | Number of autocommit mode activa- | | | | tions via API calls. This figure may | | | | be used to monitor activity related | | | | to the plugin configuration setting | | | | trx_stickiness. If, for example, you | | | | want to know if a certain API call | | | | invokes the mysqlnd library function | | | | trx_autocommit(), which is a | | | | requirement for trx_stickiness, you | | | | may call the user API function in | | | | question and check if the statistic | | | | has changed. The statistic is modi- | | | | fied only by the plugins internal | | | | subclassed trx_autocommit() method. | | | | | | | | Since 1.0.0. | | | | | | | | | | | trx_autocommit_off | | | | | | | | | Number of autocommit mode deactiva- | | | | tions via API calls. | | | | | | | | Since 1.0.0. | | | | | | | | | | | trx_master_forced | | | | | | | | | Number of statements redirected to | | | | the master while trx_stickiness=mas- | | | | ter and autocommit mode is disabled. | | | | | | | | Since 1.0.0. | | | | | | | | | | | gtid_autocommit_injections_success | | | | | | | | | Number of successful SQL injections | | | | in autocommit mode as part of the | | | | plugins client-side global transac- | | | | tion id emulation. | | | | | | | | Since 1.2.0. | | | | | | | | | | | gtid_autocommit_injections_failure | | | | | | | | | Number of failed SQL injections in | | | | autocommit mode as part of the plug- | | | | ins client-side global transaction | | | | id emulation. | | | | | | | | Since 1.2.0. | | | | | | | | | | | gtid_commit_injections_success | | | | | | | | | Number of successful SQL injections | | | | in commit mode as part of the plug- | | | | ins client-side global transaction | | | | id emulation. | | | | | | | | Since 1.2.0. | | | | | | | | | | | gtid_commit_injections_failure | | | | | | | | | Number of failed SQL injections in | | | | commit mode as part of the plugins | | | | client-side global transaction id | | | | emulation. | | | | | | | | Since 1.2.0. | | | | | | | | | | |gtid_implicit_commit_injections_suc- | | | |cess | | | | | | | | | Number of successful SQL injections | | | | when implicit commit is detected as | | | | part of the plugins client-side | | | | global transaction id emulation. | | | | Implicit commit happens, for exam- | | | | ple, when autocommit has been turned | | | | off, a query is executed and auto- | | | | commit is enabled again. In that | | | | case, the statement will be commit- | | | | ted by the server and SQL to main- | | | | tain is injected before the autocom- | | | | mit is re-enabled. Another sequence | | | | causing an implicit commit is | | | | begin(), query(), begin(). The sec- | | | | ond call to begin() will implicitly | | | | commit the transaction started by | | | | the first call to begin(). begin() | | | | refers to internal library calls not | | | | actual PHP user API calls. | | | | | | | | Since 1.2.0. | | | | | | | | | | | gtid_implicit_commit_injec- | | | | tions_failure | | | | | | | | | Number of failed SQL injections | | | | when implicit commit is detected as | | | | part of the plugins client-side | | | | global transaction id emulation. | | | | Implicit commit happens, for exam- | | | | ple, when autocommit has been turned | | | | off, a query is executed and auto- | | | | commit is enabled again. In that | | | | case, the statement will be commit- | | | | ted by the server and SQL to main- | | | | tain is injected before the autocom- | | | | mit is re-enabled. | | | | | | | | Since 1.2.0. | | | | | | | | | | | transient_error_retries | | | | | | | | | How often an operation has been | | | | retried when a transient error was | | | | detected. See also, transient_error | | | | plugin configuration file setting. | | | | | | | | Since 1.6.0. | | | | | | | | | | |fabric_sharding_lookup_servers_suc- | | | |cess | | | | | | | | | Number of successful shard- | | | | ing.lookup_servers remote procedure | | | | calls to MySQL Fabric. A call is | | | | considered successful if the plugin | | | | could reach MySQL Fabric and got any | | | | reply. The reply itself may or may | | | | not be understood by the plugin. | | | | Success refers to the network trans- | | | | port only. If the reply was not | | | | understood or indicates a valid | | | | error condition, fabric_shard- | | | | ing_lookup_servers_xml_failure gets | | | | incremented. | | | | | | | | Since 1.6.0. | | | | | | | | | | |fabric_sharding_lookup_servers_fail- | | | |ure | | | | | | | | | Number of failed shard- | | | | ing.lookup_servers remote procedure | | | | calls to MySQL Fabric. A remote pro- | | | | cedure call is considered failed if | | | | there was a network error in con- | | | | necting to, writing to or reading | | | | from MySQL Fabric. | | | | | | | | Since 1.6.0. | | | | | | | | | | | fabric_shard- | | | | ing_lookup_servers_time_total | | | | | | | | | Time spent connecting to,writing to | | | | and reading from MySQL Fabrich dur- | | | | ing the sharding.lookup_servers | | | | remote procedure call. The value is | | | | aggregated for all calls. Time is | | | | measured in microseconds. | | | | | | | | Since 1.6.0. | | | | | | | | | | | fabric_shard- | | | | ing_lookup_servers_bytes_total | | | | | | | | | Total number of bytes received from | | | | MySQL Fabric in reply to shard- | | | | ing.lookup_servers calls. | | | | | | | | Since 1.6.0. | | | | | | | | | | | fabric_shard- | | | | ing_lookup_servers_xml_failure | | | | | | | | | How often a reply from MySQL Fabric | | | | to sharding.lookup_servers calls was | | | | not understood. Please note, the | | | | current experimental implementation | | | | does not distinguish between valid | | | | errors returned and malformed | | | | replies. | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_begin | | | | | | | | | How many XA/distributed transac- | | | | tions have been started using | | | | mysqlnd_ms_xa_begin(3). | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_commit_success | | | | | | | | | How many XA/distributed transac- | | | | tions have been successfully commit- | | | | ted using mysqlnd_ms_xa_commit(3). | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_commit_failure | | | | | | | | | How many XA/distributed transac- | | | | tions failed to commit during | | | | mysqlnd_ms_xa_commit(3). | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_rollback_success | | | | | | | | | How many XA/distributed transac- | | | | tions have been successfully rolled | | | | back using mysqlnd_ms_xa_roll- | | | | back(3). The figure does not include | | | | implict rollbacks performed as a | | | | result of mysqlnd_ms_xa_commit(3) | | | | failure. | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_rollback_failure | | | | | | | | | How many XA/distributed transac- | | | | tions could not be rolled back. This | | | | includes failures of | | | | mysqlnd_ms_xa_rollback(3) but also | | | | failured during rollback when clos- | | | | ing a connection, if roll- | | | | back_on_close is set. Please, see | | | | also xa_rollback_on_close below. | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_participants | | | | | | | | | Total number of participants in any | | | | XA transaction started with | | | | mysqlnd_ms_xa_begin(3). | | | | | | | | Since 1.6.0. | | | | | | | | | | | xa_rollback_on_close | | | | | | | | | How many XA transactions have been | | | | rolled back implicitly when a con- | | | | nection was close and roll- | | | | back_on_close is set. Depending on | | | | your coding policies, this may hint | | | | a flaw in your code as you may pre- | | | | fer to explicitly clean up | | | | resources. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_masters_total | | | | | | | | | Number of master servers (connec- | | | | tions) in the internal connection | | | | pool. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_slaves_total | | | | | | | | | Number of slave servers (connec- | | | | tions) in the internal connection | | | | pool. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_masters_active | | | | | | | | | Number of master servers (connec- | | | | tions) from the internal connection | | | | pool which are currently used for | | | | picking a connection. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_slaves_active | | | | | | | | | Number of slave servers (connec- | | | | tions) from the internal connection | | | | pool which are currently used for | | | | picking a connection. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_updates | | | | | | | | | How often the active connection | | | | list has been replaced and a new set | | | | of master and slave servers had been | | | | installed. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_master_reactivated | | | | | | | | | How often a master connection has | | | | been reused after being flushed from | | | | the active list. | | | | | | | | Since 1.6.0. | | | | | | | | | | | pool_slave_reactivated | | | | | | | | | How often a slave connection has | | | | been reused after being flushed from | | | | the active list. | | | | | | | | Since 1.6.0. | | | | | | +-------------------------------------+--------------------------------------+---+ EXAMPLES
Example #1 mysqlnd_ms_get_stats(3) example <?php printf("mysqlnd_ms.enable = %d ", ini_get("mysqlnd_ms.enable")); printf("mysqlnd_ms.collect_statistics = %d ", ini_get("mysqlnd_ms.collect_statistics")); var_dump(mysqlnd_ms_get_stats()); ?> The above example will output: mysqlnd_ms.enable = 1 mysqlnd_ms.collect_statistics = 1 array(26) { ["use_slave"]=> string(1) "0" ["use_master"]=> string(1) "0" ["use_slave_guess"]=> string(1) "0" ["use_master_guess"]=> string(1) "0" ["use_slave_sql_hint"]=> string(1) "0" ["use_master_sql_hint"]=> string(1) "0" ["use_last_used_sql_hint"]=> string(1) "0" ["use_slave_callback"]=> string(1) "0" ["use_master_callback"]=> string(1) "0" ["non_lazy_connections_slave_success"]=> string(1) "0" ["non_lazy_connections_slave_failure"]=> string(1) "0" ["non_lazy_connections_master_success"]=> string(1) "0" ["non_lazy_connections_master_failure"]=> string(1) "0" ["lazy_connections_slave_success"]=> string(1) "0" ["lazy_connections_slave_failure"]=> string(1) "0" ["lazy_connections_master_success"]=> string(1) "0" ["lazy_connections_master_failure"]=> string(1) "0" ["trx_autocommit_on"]=> string(1) "0" ["trx_autocommit_off"]=> string(1) "0" ["trx_master_forced"]=> string(1) "0" ["gtid_autocommit_injections_success"]=> string(1) "0" ["gtid_autocommit_injections_failure"]=> string(1) "0" ["gtid_commit_injections_success"]=> string(1) "0" ["gtid_commit_injections_failure"]=> string(1) "0" ["gtid_implicit_commit_injections_success"]=> string(1) "0" ["gtid_implicit_commit_injections_failure"]=> string(1) "0" ["transient_error_retries"]=> string(1) "0" } SEE ALSO
Runtime configuration, mysqlnd_ms.collect_statistics, mysqlnd_ms.enable, Monitoring. PHP Documentation Group MYSQLND_MS_GET_STATS(3)
Man Page