pax_global_header 0000666 0000000 0000000 00000000064 13107067151 0014513 g ustar 00root root 0000000 0000000 52 comment=21860fe39546c827dfb9b6a9162984cea79b1d22
MySQLTuner-perl-1.7.2/ 0000775 0000000 0000000 00000000000 13107067151 0014445 5 ustar 00root root 0000000 0000000 MySQLTuner-perl-1.7.2/.gitignore 0000664 0000000 0000000 00000000141 13107067151 0016431 0 ustar 00root root 0000000 0000000 build/mysqltuner-*
build/mysqltuner.spec
build/build.log
build/cve*
build/vulnerabilities*
*.bak
MySQLTuner-perl-1.7.2/.perltidy 0000664 0000000 0000000 00000000742 13107067151 0016305 0 ustar 00root root 0000000 0000000 --backup-and-modify-in-place
--backup-file-extension=beforeTidy
--block-brace-tightness=2
--brace-tightness=2
--closing-token-indentation=1
--continuation-indentation=4
--indent-columns=4
--maximum-line-length=134
--cuddled-else
--opening-sub-brace-on-new-line
--noopening-brace-on-new-line
--nooutdent-labels
--paren-tightness=2
--square-bracket-tightness=2
--vertical-tightness=0
--vertical-tightness-closing=0
--break-at-old-comma-breakpoints
--entab-leading-whitespace=4
--tabs
MySQLTuner-perl-1.7.2/.travis.yml 0000664 0000000 0000000 00000001474 13107067151 0016564 0 ustar 00root root 0000000 0000000 sudo: false
language: perl
perl:
- "5.24"
- "5.22"
- "5.20"
- "5.18"
- "5.16"
- "5.14"
- "5.12"
- "5.10"
- "5.8"
matrix:
include:
- addons:
mariadb: "5.5"
perl: "5.20"
- addons:
mariadb: "10.0"
perl: "5.20"
- addons:
mariadb: "10.1"
perl: "5.20"
- addons:
mariadb: "10.2"
perl: "5.20"
before_install:
- git clone git://github.com/haarg/perl-travis-helper
- source perl-travis-helper/init
- build-perl
- perl -V
install:
- cpanm --quiet --notest Data::Dumper
- cpanm --quiet --notest JSON
- cpanm --quiet --notest Perl::Critic
- cpanm --quiet --notest Text::Template
before_script:
- echo -e "[client]\nuser=root\npassword=\"\"" > .my.cnf
- chmod 600 .my.cnf
script:
- perlcritic mysqltuner.pl
- ./mysqltuner.pl --idxstat --dbstat
MySQLTuner-perl-1.7.2/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000002616 13107067151 0017251 0 ustar 00root root 0000000 0000000 # Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
MySQLTuner-perl-1.7.2/CONTRIBUTING.md 0000664 0000000 0000000 00000017417 13107067151 0016710 0 ustar 00root root 0000000 0000000 # Contributing to this project
Please take a moment to review this document in order to make the contribution
process easy and effective for everyone involved.
Following these guidelines will help us get back to you more quickly, and will
show that you care about making MySQLTuner better just like we do. In return, we'll
do our best to respond to your issue or pull request as soon as possible with
the same respect.
_**Please Note:** These guidelines are adapted from [@necolas](https://github.com/necolas)'s
[issue-guidelines](https://github.com/necolas/issue-guidelines) and serve as
an excellent starting point for contributing to any open source project._
## Using the issue tracker
The [issue tracker](https://github.com/major/MySQLTuner-perl/issues) is the
preferred channel for [bug reports](#bugs), [features requests](#features)
and [submitting pull requests](#pull-requests), but please respect the
following restrictions:
* Support issues or usage question that are not bugs should be posted on
[Stack Overflow, using the `mysqltuner`](http://stackoverflow.com/questions/tagged/mysqltuner) tag.
* Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
## Before submitting an issue
1. Upgrade to the latest version of MySQLTuner and see if the problem remains
2. Look at the [closed issues](https://github.com/major/mysqltuner-perl/issues?state=closed), we may have already answered a similar problem.
3. Post new features or bugs you have found at [Issue tracker](https://github.com/major/mysqltuner-perl/issues)
4. [Read the doc](https://github.com/major/mysqltuner-perl/). It is short and useful.
5. [Read the internal doc](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md). It is a complete and detailed documentation of all checks performed by this tool and this organization.
## Bug reports
A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful — thank you!
Guidelines for bug reports:
1. **Use the [GitHub issue search]** — check if the issue has already been
reported.
2. **Check if the bug has already been fixed** — try to reproduce it using the
repository's latest `master` changes.
3. **Isolate the problem** — ideally create a [reduced test
case](http://css-tricks.com/6263-reduced-test-cases/) and a live example
(perhaps a [fiddle](http://jsfiddle.net)).
A good bug report shouldn't leave others needing to contact you for more
information. Please try to be as detailed as possible in your report. What is
your environment? What steps will reproduce the issue? What browser(s) and OS
experience the problem? What outcome did you expect, and how did it differ from
what you actually saw? All these details will help people to fix any potential
bugs.
Example:
> Short and descriptive example bug report title
>
> A summary of the issue and the browser/OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>
> `` - a link to the reduced test case
>
> Any other information you want to share that is relevant to the issue being
> reported. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).
**Note:** In an effort to keep open issues to a manageable number, we will close any issues
that do not provide enough information for us to be able to work on a solution.
You will be encouraged to provide the necessary details, after which we will reopen the issue.
## Feature requests
Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.
Building something great means choosing features carefully especially because it
is much, much easier to add features than it is to take them away. Additions
to MySQLTuner will be evaluated on a combination of scope (how well it fits into the
project), maintenance burden and general usefulness.
Creating something great often means saying no to seemingly good ideas. Don't
despair if your feature request isn't accepted, take action! Fork the
repository, build your idea and share it with others. We released MySQLTuner under
the MIT License for this purpose precisely. Open source works best when smart
and dedicated people riff off of each others' ideas to make even greater things.
## New feature request
You can find Enhancement asked by community at [Enhancement issue]
## Pull requests
Good pull requests — patches, improvements, new features — are a fantastic help.
They should remain focused in scope and avoid containing unrelated commits.
**Please ask first** before embarking on any significant pull request (e.g.
implementing features, refactoring code, porting to a different language),
otherwise you risk spending a lot of time working on something that the
project's developers might not want to merge into the project. You can solicit
feedback and opinions in an open feature request thread or create a new one.
Please use the [git flow for pull requests](#git-flow) and follow MySQLTuner's
[code conventions](#code-conventions) before submitting your work. Adhering to
these guidelines is the best way to get your work included in MySQLTuner.
#### Git Flow for pull requests
1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:
```bash
# Clone your fork of the repo into the current directory
git clone git@github.com:/MySQLTuner-perl.git
# Navigate to the newly cloned directory
cd MySQLTuner-perl
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/major/MySQLTuner-perl
```
2. If you cloned a while ago, get the latest changes from upstream:
```bash
git checkout master
git pull upstream master
```
3. Create a new topic branch (off the main project development branch) to
contain your feature, change, or fix:
```bash
git checkout -b
```
4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines]
or your code is unlikely be merged into the main project. Use Git's
[interactive rebase](https://help.github.com/articles/interactive-rebase)
feature to tidy up your commits before making them public.
5. Locally merge (or rebase) the upstream development branch into your topic branch:
```bash
git pull [--rebase] upstream master
```
6. Push your topic branch up to your fork:
```bash
git push origin
```
7. [Open a Pull Request] with a clear title and description.
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
license your work under the [GPLv3 License].
Copy of the license is available at [LICENSE]
## MySQLTuner Code Conventions
1. Check code convention using **perltidy** and **perlcritic**
2. Don't manually update the version number in `mysqltuner.pl`.
[Enhancement issue]:https://github.com/major/MySQLTuner-perl/labels/enhancement
[GitHub issue search]:https://github.com/major/MySQLTuner-perl/search?type=Issues
[git commit message guidelines]:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[Open a Pull Request]:https://help.github.com/articles/using-pull-requests/
[GPLv3 License]:https://en.wikipedia.org/wiki/GNU_General_Public_License
[LICENSE]:https://github.com/major/MySQLTuner-perl/blob/master/LICENSE
MySQLTuner-perl-1.7.2/INTERNALS.md 0000664 0000000 0000000 00000032573 13107067151 0016340 0 ustar 00root root 0000000 0000000 ## MySQLTuner Internals
## Table of contents
* [MySQLTuner steps](#mysqltuner-steps)
* [Get login information steps](#mysqltuner-get-login-information-steps)
* [System checks](#mysqltuner-system-checks)
* [Server version checks](#mysqltuner-server-version-checks)
* [MySQL Storage engine general information](#mysql-storage-engine-general-information)
* [Security checks](#mysqltuner-security-checks)
* [CVE checks](#mysqltuner-cve-checks)
* [Database information](#mysqltuner-database-information)
* [Index information](#mysqltuner-index-information)
* [Connections information](#mysqltuner-connections-information)
* [Server information](#mysqltuner-server-information)
* [Sort, join and temp table information](#mysqltuner-sort-join-and-temp-table-information)
* [Global buffer information](#mysqltuner-global-buffer-information)
* [Query cache checks](#mysqltuner-query-cache-checks)
* [Slow queries checks](#mysqltuner-slow-queries-checks)
* [ThreadPool information](#mysqltuner-threadpool-information)
* [Replication checks](#mysqltuner-replication-checks)
* [InnoDB information](#mysqltuner-innodb-information)
* [MYISAM information](#mysqltuner-myisam-information)
* [ARIADB information](#mysqltuner-ariadb-information)
* [XTRADB information](#mysqltuner-xtradb-information)
* [TOKUDB information](#mysqltuner-tokudb-information)
* [ROCKDB information](#mysqltuner-rockdb-information)
* [CONNECT information](#mysqltuner-connect-information)
* [SPIDER information](#mysqltuner-spider-information)
* [GALERA information](#mysqltuner-galera-information)
* [Performance Schema information](#mysqltuner-performance-schema-and-sysschema-information)
## MySQLTuner steps
* Header Print
* Get login information
* Set up some OS variables
* Toss variables/status into hashes
* Get information about the tuning connexion
* Check current MySQL version
* Suggest 64-bit upgrade
* Show enabled storage engines
* Show informations about databases (option: --dbstat)
* Show informations about indexes (option: --idxstat)
* Display some security recommendations
* Calculate everything we need
* Print the server stats
* Print MyISAM stats
* Print InnoDB stats
* Print AriaDB stats
* Print replication info
* Make recommendations based on stats
* Close reportfile if needed
* Dump result if debug is on
## MySQLTuner get login information steps
* Is a login possible?
* Force socket?
* Remote connection?
* _Specifying available RAM is required_
* Got user/pass on command line?
* mysql-quickbackup credentials available?
* Plesk credentials available?
* DirectAdmin credentials available?
* Debian maintenance account credentials available?
* Just try a login
* If working, and .my.cnf isn't there, **WARNING**
* If working, and .my.cnf is there, okay
* Prompt for creds on the console
## MySQLTuner system checks
* 32-bit w/>2GB RAM check
* Check number of opened ports (warning if more than 9 ports opened)
* Check 80, 8080, 443 and 8443 ports if warning are raised if there are opened
* Check if some banned ports are not opened (option --bannedports separated by comma)
* Check if non kernel and user process except mysqld are not using more than 15% of total physical memory)
* Check vm.swapiness
* Check /etc/security/limit.conf
* Check sysctl entries: sunrpc.tcp_slot_entries, vm.swappiness, fs.aio-fs-nr
* Check mount point
* Check Ethernet card
* Check load average
## MySQLTuner Server version checks
* EOL MySQL version check
* Currently MySQL < 5.1 are EOF considerated.
* Using 5.5+ version of MySQL for performance issue (asynchronous IO).
## MySQL Storage engine general information
* Get storage engine counts/stats
* Check for DB engines that are enabled but unused
* Look for fragmented tables
* Look for auto-increments near capacity
* Look for table with autoincrement with value near max capacity
## MySQLTuner security checks
* Is anonymous user present?
* Users without passwords
* Users w/username as password
* Users w/o host restriction
* Weak password check (possibly using cracklib later?)
* Using basic_passwords.txt as password database
* Password list checks can be avoid (option: --skippassword)
## MySQLTuner CVE vulnerabilities detection
* option: --cvefile
* Check if your MariaDB or MySQL version contains CVE bulletins.
## MySQLTuner database information
* Per database information
* Tables number
* Rows number
* Total size
* Data size
* Percentage of data size
* Index size
* Percentage of index size
* Collation number
* Check that there is only one collation for all table in a database
* Check that there is only one collation for ll table columns in a database
* Check that there is only one storage engine per user database
## MySQLTuner index information
* Top 10 worth selectivity index
* Per index information
* Index Cardinality
* Index Selectivity
* Misc information about index definition
* Misc information about index size
## MySQLTuner Connections information
* Highest usage of available connections
* Percentage of used connections (<85%)
* Percentage of aborted connections (<3%)
## MySQLTuner server information
* Uptime: If MySQL started within last 24 hours
* Bytes received and sent
* Number of connections
* Percentage between reads and writes
* Is binary log activated ?
* Is GTID mode activated ?
## MySQLTuner sort, join and temp table information
* Max memory temporary table size allowed.
* Percentage of sort using temporary table (<10%)
* Number of join performed without using indexes (<250)
* Percentage of temporary table written on disk(<25%)
* Thread cache (=4)
* Thread cache hit ratio (>50%) if thread_handling is different of pools-of-threads
* Table cache hit ratio(>2°%)
* Percentage of open file and open file limit(<85%)
* Percentage of table locks (<95%)
* Percentage of binlog cache lock (<90%)
## MySQLTuner global buffer information
* Key Buffer
* Max Tmp Table
* Per Thread Buffer
* Read Buffer
* Read RND Buffer
* Sort Buffer
* Thread stack
* Join Buffer
* Binlog Cache Buffers size if activated
## MySQLTuner query cache checks
* Is Query cache activated ?
* Query Cache Buffers
* Query Cache DISABLED, ALL REQUEST or ON DEMAND
* Query Cache Size
* Query cache hit ratio (cache efficienty)
## MySQLTuner memory checks
* Get total RAM/swap
* Is there enough memory for max connections reached by MySQL ?
* Is there enough memory for max connections allowed by MySQL ?
* Max percentage of memory used(<85%)
## MySQLTuner slow queries checks
* Percentage of Slow queries (<5%)
## MySQLTuner replication checks
* Is server replication configuarted as slave ?
* SQL replacation thread running ?
* IO replacation thread running ?
* Replication lag in seconds
* Is Slave configuratedd in read only ?
## MySQLTuner InnoDB information
* InnoDB Buffer Pool Size
* If possible, innodb_buffer_pool_size should be greater data and index size for Innodb Table
* Innodb_buffer_pool_size should around 75 to 80 % of the available system memory.
* InnoDB Buffer Pool Instances
* MySQL needs 1 instanes per 1Go of Buffer Pool
* innodb_buffer_pool instances = round(innodb_buffer_pool_size / 1Go)
* innodb_buffer_pool instances must be equals or lower than 64
* InnoDB Buffer Pool Usage
* If more than 20% of InnoDB buffer pool is not used, MySQLTuner raise an alert.
* InnoDB Read effiency
* Ratio of read without locks
* InnoDB Write effiency
* Ratio of write without locks
* InnoDB Log Waits
* Checks that no lock is used on Innodb Log.
* InnoDB Chunk Size
* Check InnoDB Buffer Pool size is a multiple of InnoDB Buffer Pool chunk size * InnoDB Buffer Pool instances
## MySQLTuner ARIADB information
* Is Aria indexes size is greater than page cache size ?
* Page cache read hit ratio (>95%)
* Page cache write hit ratio (>95%)
## MySQLTuner MYISAM information
* Key buffer usage (>90%)
* Is MyISAM indexes size is greater than key buffer size ?
* Key buffer read hit ratio (>95%)
* Key buffer write hit ratio (>95%)
## MySQLTuner Galera information
* wsrep_ready cluster is ready
* wsrep_connected node is connected to other nodes
* wsrep_cluster_name is defined.
* wsrep_node_name is defined.
* Check thet notification script wsrep_notify_cmd is defined
* wsrep_cluster_status PRIMARY /NON PRIMARY.
* PRIMARY : Coherent cluster
* NO PRIMARY : cluster gets several states
* wsrep_ local_state_comment: Node state
* SYNCED (uptodate),
* DONOR(sending information to another node)
* Joiner(Try to reach cluster group)
* SYNCED state able to read/write
* wsrep_cluster_conf_id configuration level must be identical in all nodes
* wsrep_slave_thread is between 3 or 4 times number of CPU core.
* gcs.limit should be equal to wsrep_slave_threads * 5
* gcs.fc_factor should be equal to 0.8
* Flow control fraction should be lower than 0.02 (wsrep_flow_control_paused < 0.02)
* wsrep_last_commited committed level must be identical in all nodes
* Look for tables without primary keys
* Look for non InnoDB tables for Galera
* Variable innodb_flush_log_at_trx_commit should be set to 0.
* Check that there is 3 or 5 members in Galera cluster.
* Check that xtrabackup is used for SST method with wsrep_sst_method variable.
* Check variables wsrep_OSU_method is defined to TOI for updates.
* Check that there is no certification failures controlling wsrep_local_cert_failures status.
## MySQLTuner TokuDB information
* tokudb_cache_size
* tokudb_directio
* tokudb_empty_scan
* tokudb_read_block_size
* tokudb_commit_sync
* tokudb_checkpointing_period
* tokudb_block_size
* tokudb_cleaner_iterations
* tokudb_fanout
## MySQLTuner XtraDB information
* Nothing for the moment
## MySQLTuner Connect information
* Nothing for the moment
## MySQLTuner Spider information
* Nothing for the moment
## MySQLTuner RocksDb information
* Nothing for the moment
## MySQLTuner Thread pool information
* thread_pool_size between 16 to 36 for Innodb usage
* thread_pool_size between 4 to 8 for MyIsam usage
## MySQLTuner performance schema and sysschema information
* Check that Performance schema is activated for 5.6+ version
* Check that Performance schema is disactivated for 5.5- version
* Check that Sys schema is installed
* sys Schema version
* Top user per connection
* Top user per statement
* Top user per statement latency
* Top user per lock latency
* Top user per full scans
* Top user per row_sent
* Top user per row modified
* Top user per io
* Top user per io latency
* Top host per connection
* Top host per statement
* Top host per statement latency
* Top host per lock latency
* Top host per full scans
* Top host per rows sent
* Top host per rows modified
* Top host per io
* Top 5 host per io latency
* Top IO type order by total io
* Top IO type order by total latency
* Top IO type order by max latency
* Top Stages order by total io
* Top Stages order by total latency
* Top Stages order by avg latency
* Top host per table scans
* InnoDB Buffer Pool by schema
* InnoDB Buffer Pool by table
* Process per allocated memory
* InnoDB Lock Waits
* Threads IO Latency
* High Cost SQL statements
* Top 5% slower queries
* Top 10 nb statement type
* Top statement by total latency
* Top statement by lock latency
* Top statement by full scans
* Top statement by rows sent
* Top statement by rows modified
* Use temporary tables
* Unused Indexes
* Full table scans
* Latest file IO by latency
* File by IO read bytes
* File by IO written bytes
* File per IO total latency
* File per IO read latency
* File per IO write latency
* Event Wait by read bytes
* Event Wait by write bytes
* Event per wait total latency
* Event per wait read latency
* Event per wait write latency
* TOP 15 most read indexes
* TOP 15 most modified indexes
* TOP 15 high select latency index
* TOP 15 high insert latency index
* TOP 15 high update latency index
* TOP 15 high delete latency index
* TOP 15 most read tables
* TOP 15 most modified tables
* TOP 15 high select latency tables
* TOP 15 high insert latency tables
* TOP 15 high update latency tables
* TOP 15 high delete latency tables
* Redundant indexes
* Tables not using InnoDb buffer
* Top 15 Tables using InnoDb buffer
* Top 15 Tables with InnoDb buffer free
* Top 15 Most executed queries
* Latest SQL queries in errors or warnings
* Top 20 queries with full table scans
* TOP 15 reader queries (95% percentile)
* TOP 15 row look queries (95% percentile)
* TOP 15 total latency queries (95% percentile)
* TOP 15 max latency queries (95% percentile)
* TOP 15 average latency queries (95% percentile)
* Top 20 queries with sort
* Last 50 queries with sort
* TOP 15 row sorting queries with sort
* TOP 15 total latency queries with sort
* TOP 15 merge queries with sort
* TOP 15 average sort merges queries with sort
* TOP 15 scans queries with sort
* TOP 15 range queries with sort
* Top 20 queries with temp table
* Last 50 queries with temp table
* TOP 15 total latency queries with temp table
* TOP 15 queries with temp table to disk
* TOP 15 class events by number
* TOP 30 events by number
* TOP 15 class events by total latency
* TOP 30 events by total latency
* TOP 15 class events by max latency
* TOP 30 events by max latency MySQLTuner-perl-1.7.2/LICENSE 0000664 0000000 0000000 00000104513 13107067151 0015456 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will 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 have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
MySQLTuner-perl-1.7.2/README.fr.md 0000664 0000000 0000000 00000027254 13107067151 0016344 0 ustar 00root root 0000000 0000000 MySQLTuner-perl
====
[](https://travis-ci.org/major/MySQLTuner-perl)
[](http://opensource.box.com/badges)
[](http://opensource.box.com/badges)
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue")
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open")
[](https://opensource.org/licenses/GPL-3.0/)
**MySQLTuner** est un script écrit en Perl qui permet d'effectuer une revue de configuration pour MySQL/MAriaDB/PerconaDB rapidement et propose des ajustements pour améliorer la performance et la stabilité du serveur. L'état des variables et statuts est analysé et présenté de manière synthétique et structurée ainsi que plusieurs suggestions basiques concernant la performance.
**MySQLTuner** supporte dans a dernière version plus de ~300 indicators pour MySQL/MariaDB/Percona Server.
**MySQLTuner** is maintained and indicator collect is increasing week after week supporting a lot of configuration sush as , , , Linux OS metrics, , , , ...
You can found more details on this indicators
.

MySQLTuner needs you:
===
**MySQLTuner** needs contributors for documentation, code and feedbacks..
* Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Contribution guide is avalaible following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
Compatibility:
====
* MySQL 5.7 (full support)
* MySQL 5.6 (full support)
* MySQL 5.5 (full support)
* MariaDB 10.1 (full support)
* MariaDB 10.0 (full support)
* Percona Server 5.6 (full support)
* Percona XtraDB cluster (full support)
* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version)
* Perl 5.6 or later (with [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod) package)
* Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants)
* Windows is not supported at this time (Help wanted !!!!!)
* Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1)
* CVE vulnerabilites detection support from [https://cve.mitre.org](https://cve.mitre.org)
***WARNING***
--
It is **extremely important** for you to fully understand each change
you make to a MySQL database server. If you don't understand portions
of the script's output, or if you don't understand the recommendations,
**you should consult** a knowledgeable DBA or system administrator
that you trust. **Always** test your changes on staging environments, and
always keep in mind that improvements in one area can **negatively affect**
MySQL in other areas.
**Seriously - please review the FAQ section below.**
What MySQLTuner is checking exactly ?
--
All checks done by **MySQLTuner** are documented in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) documentation.
Download/Installation
--
You can download the entire repository by using 'git clone' followed by the cloning URL above. The simplest and shortest method is:
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
perl mysqltuner.pl
Of course, you can add the execute bit (`chmod +x mysqltuner.pl`) so you can execute it without calling perl directly.
Specific usage
--
__Usage:__ Minimal usage locally
perl mysqltuner.pl
__Usage:__ Minimal usage remotely
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
__Usage:__ Enable maximum output information around MySQL/MariaDb without debugging
perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat
__Usage:__ Enable CVE vulnerabilities check for your MariaDB or MySQL version
perl mysqltuner.pl --cvefile=vulnerabilities.csv
__Usage:__ Write your result in a file with information displayed
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Write your result in a file **without outputting information**
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Using template model to customize your reporting file based on [Text::Template](https://metacpan.org/pod/Text::Template) syntax.
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
__Usage:__ Enable debugging information
perl mysqltuner.pl --debug
FAQ
--
**Question: Will MySQLTuner fix my slow MySQL server?**
**No.** MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance and make some basic recommendations about improvements that you can make after it completes. *Make sure you read the warning above prior to following any recommendations.*
**Question: Can I fire my DBA now?**
**MySQLTuner will not replace your DBA in any form or fashion.** If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call.
**Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?**
The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains:
[client]
user=someusername
pass=thatuserspassword
Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a [T-1000 shows up in a LAPD uniform](https://en.wikipedia.org/wiki/T-1000) and demands your database credentials, you won't have much of an option.
**Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?**
You could use mysql_config_editor utilities.
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter passord: ********
$
At this time, ~/.mylogin.cnf has been written with appropriated rigth access.
To get information about stored credentials, use the following command:
$mysql_config_editor print
[client]
user = someusername
password = *****
host = localhost
**Question: What's minimum privileges needed by a specific mysqltuner user in database ?**
mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* FOR 'mysqltuner'@'localhost' identified by pwd1234;
**Question: It's not working on my OS! What gives?!**
These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly:
* OS and OS version
* Architecture (x86, x86_64, IA64, Commodore 64)
* Exact MySQL version
* Where you obtained your MySQL version (OS package, source, etc)
* The full text of the error
* A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible)
**Question: How to perform a CVE vulneralibity checks ?**
* Download vulnerabilities.csv from this repository.
* use option --cvefile to perform CVE checks
**Question: How to use mysqltuner from remote host ?**
Thanks to [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba)
* You will still have to connect like a mysql client:
Connection and Authentication
--host Connect to a remote host to perform tests (default: localhost)
--socket Use a different socket for a local connection
--port Port to use for connection (default: 3306)
--user Username to use for authentication
--pass Password to use for authentication
--defaults-file defaulfs file for credentials
Since you are using a remote host, use parameters to supply values from the OS
--forcemem Amount of RAM installed in megabytes
--forceswap Amount of swap memory configured in megabytes
* You may have to contact your remote SysAdmin to ask how much RAM and swap you have
If the database has too many tables, or very large table, use this:
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
MySQLTuner and Vagrant
--
**MySQLTuner** contains following Vagrant configurations:
* Fedora Core 23 / MariaDB 10.0
* Fedora Core 23 / MariaDB 10.1
* Fedora Core 23 / MySQL 5.6
* Fedora Core 23 / MySQL 5.7
**Vagrant File** are stored in Vagrant subdirectory.
* Follow this 2 steps after vagrant installation:
* Rename VagrantFile_for_Mxxx into Vagrantfile
* vagrant up
**MySQLTuner** contains a Vagrant configurations for test purpose and development
* Install VirtualBox and Vagrant
* https://www.virtualbox.org/wiki/Downloads
* https://www.vagrantup.com/downloads.html
* Clone repository
* git clone https://github.com/major/MySQLTuner-perl.git
* Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest
* vagrant plugin install vagrant-hostmanager
* vagrant plugin install vagrant-vbguest
* Add Fedora Core 23 box for official Fedora Download Website
* vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box
* Create a data directory
* mkdir data
* Rename Vagrantfile_MariaDB10.0 into Vagrantfile
* cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile
* Start vagrant
* vagrant up
MySQLTuner a besoin de vous
--
**MySQLTuner** a besoin de contributeurs pour la documentation, le code, des tests et des retours d'expérience.
* Rejoignez-nous sur le suivi de ticket à [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Le guide de contribution en anglais est disponible ici [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Ajouter une étoile à **MySQLTuner project** ici [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
MySQLTuner-perl-1.7.2/README.it.md 0000664 0000000 0000000 00000027707 13107067151 0016354 0 ustar 00root root 0000000 0000000 MySQLTuner-perl
====
[](https://travis-ci.org/major/MySQLTuner-perl)
[](http://opensource.box.com/badges)
[](http://opensource.box.com/badges)
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue")
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open")
[](https://opensource.org/licenses/GPL-3.0/)
**MySQLTuner** è uno script Perl che permette di analizzare velocemente una installazione di MySQL, nonché di apportare modifiche per migliorare le prestazioni e la stabilità. In modo coinciso sono riportati lo stato attuale delle variabili di configurazione e i dati sullo stato del sistema, corredati da suggerimenti di base per il miglioramento delle prestazioni.
**MySQLTuner** supporta, in quest'ultima versione, circa 250 indicatori per i server MySQL/MariaDB/Percona.
**MySQLTuner** è attivamente manutenuto e nuovi indicatori sono aggiunti di settimana in settimana, supportando un gran numero di configurazioni tra le quali , , , metriche relative al SO Linux, , , , ...
Maggiori dettagli sugli indicatori
.

MySQLTuner ha bisogno di te:
===
**MySQLTuner** ha bisogno di collaboratori per documentazione, codice e suggerimenti ..
* Problemi e suggerimenti possono essere riportati su [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* La guida per contribuire è disponibile in inglese: [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Dai un Stella a **MySQLTuner project** su [GitHub](https://github.com/major/MySQLTuner-perl)
Compatibilità:
====
* MySQL 5.7 (pieno supporto)
* MySQL 5.6 (pieno supporto)
* MySQL 5.5 (pieno supporto)
* MariaDB 10.1 (pieno supporto)
* MariaDB 10.0 (pieno supporto)
* Percona Server 5.6 (pieno supporto)
* Percona XtraDB cluster (pieno supporto)
* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (supporto parziale - versione deprecata)
* Perl 5.6 o successivi (col pacchetto [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod))
* Sistemi operativi basati su Unix/Linux (testato su Linux, varianti di BSD e di Solaris)
* Windows non è supportato al momento (gradito aiuto!!!!!)
* Accesso completo in lettura al server MySQL (accesso root a livello di SO raccomandato per MySQL < 5.1)
* supporto al rilevamento di vulnerabilità CVE da [https://cve.mitre.org](https://cve.mitre.org)
***ATTENZIONE***
--
È **estremamente importante** che tu capisca appieno ogni singola modifica apportata alla configurazione del server MySQL.
Qualora non capissi appieno qualche parte dell'output dello script o se non capissi quanto raccomandato **dovresti consultare** un DBA esperto o un amministratore di sistema di cui hai fiducia.
Testa **sempre** le modifiche su ambienti ad hoc e tieni sempre presente che miglioramenti in un settore potrebbero **influenzare negativamente** MySQL in altri settori.
**Seriamente - consulta la sezione FAQ che segue.**
Cosa verifica esattamente MySQLTuner ?
--
Tutti i controlli effettuati da **MySQLTuner** sono documentati in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md).
Download/Installazione
--
Si può semplicemente scaricare l'intero codice utilizzando `git clone` seguito dalla URL riportata sopra.
Il modo più semplice è il seguente:
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
perl mysqltuner.pl
Ovviamente è possibile assegnare il permesso di esecuzione in modo da poter lanciare il comando senza chiamare l'interprete `perl` (`chmod +x mysqltuner.pl`).
Casi d'uso
--
__Uso:__ Minimale locale
perl mysqltuner.pl
__Uso:__ Minimale da remoto
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
__Uso:__ Abilitando il massimo livello di informazione in output su MySQL/MariaDb senza usare l'optione di debug
perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat
__Uso:__ Abilitando la verifica delle vulnerabilità CVE per la versione di MariaDB o MySQL installata
perl mysqltuner.pl --cvefile=vulnerabilities.csv
__Uso:__ Salvando i risultati su un file con le stesse informazione mostrate a video
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
__Uso:__ Salvando i risultati su un file **senza mostrare nulla a video**
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
__Uso:__ Utilizzando un modello per personalizzare il file di output, con la sintassi di [Text::Template](https://metacpan.org/pod/Text::Template).
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
__Uso:__ Abilitando la modalità di debug
perl mysqltuner.pl --debug
FAQ
--
**Domanda: MySQLTuner sistemerà il mio server MySQL lento?**
**No.** MySQLTuner è uno script che legge solamente. Non scriverà alcun file di configurazione, non modificherà lo stato di alcun demone né chiamerà tua madre per augurarle buon compleanno.
Ti darà una panoramica delle prestazioni del tuo server, facendo alcune raccomandazioni basilari circa i miglioramenti che tu puoi apportare. *assicurati di leggere l'avviso precedente prima di seguire qualsiasi raccomandazione.*
**Domanda: Posso eliminare il mio DBA ora?**
**MySQLTuner non sostituirà il tuo DBA in alcun modo.** Se il tuo DBA continuamente occupa il tuo parcheggio e ruba il tuo cibo dal frigo puoi considerare l'opzione - ma resta una tua scelta.
**Domanda: Perché MySQLTuner continua a chiedermi ogni volta le credenziali di login di MySQL?**
Lo script cerca di arguirle in ogni modo possibile. Cercando file `~/.my.cnf`, file di password di Plesk e provando il login di root con password vuota.
Se nessuno di questi modi ha successo, allora la password viene richiesta. Se preferisci che lo script giri in modo automatico, senza interazione con l'utente, allora crea un file `.my.cnf` nella tua cartella home che contenga:
[client]
user=someusername
pass=thatuserspassword
Una volta creato, assicurati che tu sia il proprietario (owner) e che i permessi siano 0600. Questo dovrebbe preservare le tue credenziali di login per i database da occhi indiscreti, in condizioni normali.
Se un [Terminator modello T-1000 apparisse vestito da Carabiniere](https://it.wikipedia.org/wiki/T-1000) e chiedesse le tue credenziali non avresti poi tante scelte.
**Domanda: C'è qualche altro modo per rendere sicure le credenziali sulle ultime versioni di MySQL e MariaDB ?**
Potresti utilizzare il comando `mysql_config_editor`.
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter passord: ********
$
Che crea il file `~/.mylogin.cnf` con i prmessi di accesso appropriati.
Per avere informazioni sulle credenziali salvate, si usi ilseguente comando:
$mysql_config_editor print
[client]
user = someusername
password = *****
host = localhost
**Domanda: Quali sono i privilegi minimi, nel database, necessari per un utente *mysqltuner* ad hoc ?**
mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* FOR 'mysqltuner'@'localhost' identified by pwd1234;
**Domanda: Non funziona sul mio SO! Che succede?!**
Questo genere di cose sono destinate ad accadere. Ecco i dettagli di cui ho bisogno per indagare sul problema:
* SO e versione del SO
* Architettura (x86, x86_64, IA64, Commodore 64)
* Versione esatta di MySQL
* Da dove viene la tua versione di MySQL (pacchetto del SO, sorgenti, etc.)
* Il testo completo dell'errore
* L'output dei comandi `SHOW VARIABLES;` e `SHOW GLOBAL STATUS;`(se possibile)
**Domanda: Come eseguo il check per le vulnerabilità CVE ?**
* Scarica il file `vulnerabilities.csv`da questo repository.
* Usa l'opzione `--cvefile` per eseguire i test delle CVE
**Domanda: Come uso mysqltuner da un altro computer ?**
Grazie a [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba)
* You will still have to connect like a mysql client:
* Ti dovrai collegare come un client mysql:
Connessione e Autenticazione
--host Si connette a un host remoto per eseguire i test (default: localhost)
--socket Usa un socket per effettuare una connessione locale
--port Porta per la connessione (default: 3306)
--user Username per l'autenticazione
--pass Password per l'autenticazione
--defaults-file defaults file per le credenziali
Poiché si sta utilizzando un host remoto, si utilizzino i seguenti parametri per fornire allo script i valori del SO
--forcemem Valore della RAM installata, in megabyte
--forceswap Valore della memoria di swap configurata, in megabyte
* Potresti dover contattare il sistemista del server remoto per conoscere i valori di RAM e swap
Se il database ha troppe tabelle, o tabelle veramente grandi, si usi:
--skipsize Non elenca le tabelle ed i rispettivi tipi e dimensioni (default: on)
(Raccomandato per server con molte tabelle)
MySQLTuner e Vagrant
--
**MySQLTuner** contiene le seguenti configurazioni per Vagrant:
* Fedora Core 23 / MariaDB 10.0
* Fedora Core 23 / MariaDB 10.1
* Fedora Core 23 / MySQL 5.6
* Fedora Core 23 / MySQL 5.7
**Vagrant File** sono collocati nella sotto-directory di Vagrant.
* Segui questi due passaggi dopo l'installazione di Vagrant:
* Rinominare `VagrantFile_for_Mxxx` in `Vagrantfile`
* `vagrant up`
**MySQLTuner** contiene una configurazione Vagrant a scopo di test e sviluppo
* Installare VirtualBox e Vagrant
* https://www.virtualbox.org/wiki/Downloads
* https://www.vagrantup.com/downloads.html
* Clone del repository
* git clone https://github.com/major/MySQLTuner-perl.git
* Installare i plugin di Vagrant `vagrant-hostmanager` e `vagrant-vbguest`
* `vagrant plugin install vagrant-hostmanager`
* `vagrant plugin install vagrant-vbguest`
* Aggiungere un box Fedora Core 23 dal sito ufficiale di Fedora
* `vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box`
* Creare una directory `data`
* `mkdir data`
* Rinominare `Vagrantfile_MariaDB10.0` in `Vagrantfile`
* `cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile`
* Start vagrant
* `vagrant up`
MySQLTuner ha bisogno di te:
--
**MySQLTuner** ha bisogno di collaboratori per documentazione, codice e suggerimenti ..
* Problemi e suggerimenti possono essere riportati su [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* La guida per contribuire è disponibile in inglese: [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Dai un Stella a **MySQLTuner project** su [GitHub](https://github.com/major/MySQLTuner-perl)
MySQLTuner-perl-1.7.2/README.md 0000664 0000000 0000000 00000027255 13107067151 0015737 0 ustar 00root root 0000000 0000000 MySQLTuner-perl
====
[](https://travis-ci.org/major/MySQLTuner-perl)
[](http://opensource.box.com/badges)
[](http://opensource.box.com/badges)
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue")
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open")
[](https://opensource.org/licenses/GPL-3.0/)
**MySQLTuner** is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions.
**MySQLTuner** supports in this last version ~300 indicators for MySQL/MariaDB/Percona Server.
**MySQLTuner** is maintained and indicator collect is increasing week after week supporting a lot of configuration such as [Galera Cluster](http://galeracluster.com/), [TokuDB](https://www.percona.com/software/mysql-database/percona-tokudb), [Performance schema](https://github.com/mysql/mysql-sys), Linux OS metrics, [InnoDB](http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html), [MyISAM](http://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html), [Aria](https://mariadb.com/kb/en/mariadb/aria/), ...
You can find more details on these indicators here:
[Indicators description](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md).

MySQLTuner needs you:
===
**MySQLTuner** needs contributors for documentation, code and feedbacks..
* Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Contribution guide is available following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
Compatibility:
====
* MySQL 5.7 (full support)
* MySQL 5.6 (full support)
* MySQL 5.5 (full support)
* MariaDB 10.1 (full support)
* MariaDB 10.0 (full support)
* Percona Server 5.6 (full support)
* Percona XtraDB cluster (full support)
* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version)
* Perl 5.6 or later (with [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod) package)
* Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants)
* Windows is not supported at this time (Help wanted !!!!!)
* Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1)
* CVE vulnerabilites detection support from [https://cve.mitre.org](https://cve.mitre.org)
***WARNING***
--
It is **extremely important** for you to fully understand each change
you make to a MySQL database server. If you don't understand portions
of the script's output, or if you don't understand the recommendations,
**you should consult** a knowledgeable DBA or system administrator
that you trust. **Always** test your changes on staging environments, and
always keep in mind that improvements in one area can **negatively affect**
MySQL in other areas.
**Seriously - please review the FAQ section below.**
Security recommandations
--
Hi directadmin user!
We detected that you run mysqltuner with da_admin's credentials taken from /usr/local/directadmin/conf/my.cnf, which might bring to a password discovery!
Read link for more details [Issue #289](https://github.com/major/MySQLTuner-perl/issues/289).
What MySQLTuner is checking exactly ?
--
All checks done by **MySQLTuner** are documented in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) documentation.
Download/Installation
--
You can download the entire repository by using 'git clone' followed by the cloning URL above. The simplest and shortest method is:
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
perl mysqltuner.pl
Of course, you can add the execute bit (`chmod +x mysqltuner.pl`) so you can execute it without calling perl directly.
Specific usage
--
__Usage:__ Minimal usage locally
perl mysqltuner.pl
__Usage:__ Minimal usage remotely
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
__Usage:__ Enable maximum output information around MySQL/MariaDb without debugging
perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat
__Usage:__ Enable CVE vulnerabilities check for your MariaDB or MySQL version
perl mysqltuner.pl --cvefile=vulnerabilities.csv
__Usage:__ Write your result in a file with information displayed
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Write your result in a file **without outputting information**
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Using template model to customize your reporting file based on [Text::Template](https://metacpan.org/pod/Text::Template) syntax.
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
__Usage:__ Enable debugging information
perl mysqltuner.pl --debug
FAQ
--
**Question: Will MySQLTuner fix my slow MySQL server?**
**No.** MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance and make some basic recommendations about improvements that you can make after it completes. *Make sure you read the warning above prior to following any recommendations.*
**Question: Can I fire my DBA now?**
**MySQLTuner will not replace your DBA in any form or fashion.** If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call.
**Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?**
The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains:
[client]
user=someusername
pass=thatuserspassword
Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a [T-1000 shows up in a LAPD uniform](https://en.wikipedia.org/wiki/T-1000) and demands your database credentials, you won't have much of an option.
**Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?**
You could use mysql_config_editor utilities.
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter passord: ********
$
At this time, ~/.mylogin.cnf has been written with appropriated rigth access.
To get information about stored credentials, use the following command:
$mysql_config_editor print
[client]
user = someusername
password = *****
host = localhost
**Question: What's minimum privileges needed by a specific mysqltuner user in database ?**
mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* FOR 'mysqltuner'@'localhost' identified by pwd1234;
**Question: It's not working on my OS! What gives?!**
These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly:
* OS and OS version
* Architecture (x86, x86_64, IA64, Commodore 64)
* Exact MySQL version
* Where you obtained your MySQL version (OS package, source, etc)
* The full text of the error
* A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible)
**Question: How to perform CVE vulnerability checks?**
* Download vulnerabilities.csv from this repository.
* use option --cvefile to perform CVE checks
**Question: How to use mysqltuner from a remote host?**
Thanks to [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba)
* You will still have to connect like a mysql client:
Connection and Authentication
--host Connect to a remote host to perform tests (default: localhost)
--socket Use a different socket for a local connection
--port Port to use for connection (default: 3306)
--user Username to use for authentication
--pass Password to use for authentication
--defaults-file defaulfs file for credentials
Since you are using a remote host, use parameters to supply values from the OS
--forcemem Amount of RAM installed in megabytes
--forceswap Amount of swap memory configured in megabytes
* You may have to contact your remote SysAdmin to ask how much RAM and swap you have
If the database has too many tables, or very large table, use this:
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
MySQLTuner and Vagrant
--
**MySQLTuner** contains following Vagrant configurations:
* Fedora Core 23 / MariaDB 10.0
* Fedora Core 23 / MariaDB 10.1
* Fedora Core 23 / MySQL 5.6
* Fedora Core 23 / MySQL 5.7
**Vagrant File** are stored in Vagrant subdirectory.
* Follow this 2 steps after vagrant installation:
* Rename VagrantFile_for_Mxxx into Vagrantfile
* vagrant up
**MySQLTuner** contains a Vagrant configurations for test purpose and development
* Install VirtualBox and Vagrant
* https://www.virtualbox.org/wiki/Downloads
* https://www.vagrantup.com/downloads.html
* Clone repository
* git clone https://github.com/major/MySQLTuner-perl.git
* Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest
* vagrant plugin install vagrant-hostmanager
* vagrant plugin install vagrant-vbguest
* Add Fedora Core 23 box for official Fedora Download Website
* vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box
* Create a data directory
* mkdir data
* Rename Vagrantfile_MariaDB10.0 into Vagrantfile
* cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile
* Start vagrant
* vagrant up
MySQLTuner needs you
--
**MySQLTuner** needs contributors for documentation, code and feedbacks..
* Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Contribution guide is avalaible following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
MySQLTuner-perl-1.7.2/README.ru.md 0000664 0000000 0000000 00000040120 13107067151 0016346 0 ustar 00root root 0000000 0000000 MySQLTuner-perl
====
[](https://travis-ci.org/major/MySQLTuner-perl)
[](http://opensource.box.com/badges)
[](http://opensource.box.com/badges)
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue")
[](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open")
[](https://opensource.org/licenses/GPL-3.0/)
**MySQLTuner** - это скрипт, написанный на Perl, который позволяет быстро произвести осмотр текущего состояния сервера баз данных MySQL
и составить рекомендации для увеличения производительности и стабильности работы. Выводятся текущие параметры конфигурации
и информация о состоянии в формате отчета с основными подсказками по оптимизации.
**MySQLTuner** поддерживает порядка 300 показателей для MySQL/MariaDB/Percona Server последних версий.
**MySQLTuner** поддерживает сбор показателей для множества таких конфигураций, как , , , Linux OS metrics, , , , ...
Вы можете найти больше информации об этих показателях на
.

MySQLTuner нуждается в вас:
===
**MySQLTuner** нуждается в вашем вкладе в документацию и код, а так же ждёт обратную связь.
* Присоединяйтесь, пожалуйста, к нашему трекеру ошибок [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Руководство по поддержке проекта доступно на [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Ставьте "звезды" **проекту MySQLTuner** на [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
Совместимость:
====
* MySQL 5.7 (полная поддержка)
* MySQL 5.6 (полная поддержка)
* MySQL 5.5 (полная поддержка)
* MariaDB 10.1 (полная поддержка)
* MariaDB 10.0 (полная поддержка)
* Percona Server 5.6 (полнлая поддержка)
* Percona XtraDB cluster (полная поддержка)
* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (частичная поддержка - устаревшие версии)
* Perl 5.6 или более поздний (с пакетом [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod))
* Операционная система семейства Unix/Linux (протестировано на Linux, различных вариациях BSD и Solaris)
* Windows не поддерживается на данное время (Необходима помощь!!!!!)
* Неограниченный доступ на чтение для MySQL-сервера (Для работы с MySQL < 5.1 требуется root-доступ к серверу)
* Поддержка детектирования CVE уязвимостей из [https://cve.mitre.org](https://cve.mitre.org)
Пожалуйста, прочитайте раздел ЧаВо, который расположен чуть ниже.
***ПРЕДУПРЕЖДЕНИЕ***
--
Очень важно, чтобы вы имели представление о том, какие изменения вы
вносите в параметры сервера баз данных MySQL. Если вы даже частично
не понимаете вывод отчета скрипта, или не понимаете рекомендации,
которые делает скрипт, то вам лучше всего обратиться за помощью либо
к документации к серверу баз данных, либо ближайшему системному
администратору. Всегда проверяйте ваши изменения на тестовом сервере
и всегда будьте готовы к тому, что улучшения в одной области могут иметь
отрицательный эфект в работе MySQL в другой области.
**Серьезно - прочитайте раздел ЧаВо, который расположен чуть ниже.**
Что именно проверяет MySQLTuner?
--
Все проверки, что выполняет **MySQLTuner**, задокументированы в [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md)
Загрузка/Установка
--
Вы можете скачать весь репозиторий с помощью 'git clone' c URL текущего репозитория. Самый простой и короткий метод:
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
perl mysqltuner.pl
Конечно, вам нужно будет добавить права на выполнение скрипта (chmod +x mysqltuner.pl), если вы хотите запускать его напрямую, без указания perl.
Примеры использования
--
__Пример:__ Минимальный локальный запуск
perl mysqltuner.pl
__Пример:__ Минимальный удаленный запуск
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
__Пример:__ Включение максимамльного вывода информации о MySQL/MariaDb без отладочной информации
perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat
__Пример:__ Включение проверки на CVE уязвимости для MariaDB или MySQL
perl mysqltuner.pl --cvefile=vulnerabilities.csv
__Пример:__ Запись результата в файл с отображением информации
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
__Пример:__ Запись результата в файл **без вывода информации**
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
__Пример:__ Использование шаблона для кастомизации отчетов, сохраняющихся в файл на базе синтаксиса [Text::Template](https://metacpan.org/pod/Text::Template).
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
__Пример:__ Включение вывода отладочной информации
perl mysqltuner.pl --debug
ЧаВо
--
**Вопрос: MySQLTuner починит мой медленный MySQL сервер?**
**Нет.** MySQLTuner работает только на чтение. Он не будет записывать какие-либо конфигурационные файлы, изменять статус каких-либо демонов или звонить вашей маме, чтобы поздравить её с днём рождения. Он только даст обзор производительности вашего сервера и предложит несколько базовых рекомендаций, которые вы можете выполнить. *Убедитесь, что вы прочитали предупреждения до следования рекомендациям.*
**Вопрос: Теперь я могу уволить моего DBA?**
**MySQLTuner не заменяет вашего DBA никоим образом.** Однако, если ваш DBA постоянно занимает ваше парковочное место и крадёт ваш обед из холодильника, вы можете попробовать сделать это - но это будет ваш выбор.
**Вопрос: Почему MySQLTuner каждый раз запрашивает доступы в MySQL?**
Скрипт пытается использовать лучшие способы войти из возможных. Он проверяет ~/.my.cnf файлы, файлы паролей Plesk и пробует пустой пароль для пользователя root. Если ни один из этих способов не сработал, то запрашивается ввод пароля. Если вы хотите, чтобы скрипт работал автоматически, создайте в своей домашней директории файл .my.cnf, содержащий:
[client]
user=distributions
pass=thatuserspassword
Сразу после создания файла убедитесь, что его владельцем является ваш пользователь, а права на файл - 0600. Это защитит ваш логин и пароль от базы данных от любопытных глаз в нормальных условиях. Но у вас не будет выбора, если появится [T-1000 в униформе полицейского из Лос-Анджелеса](https://ru.wikipedia.org/wiki/T-1000) и потребует доступы от вашей базы данных.
**Вопрос: Есть ли другой способ безопасно сохранить данные для входа в последних версиях MySQL и MariaDB?**
Вы можете использовать утилиту mysql_config_editor.
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter passord: ********
$
Она создаст ~/.mylogin.cnf с корректными правами доступа.
Чтобы получить информацию о сохраненных данных для входа, выполните:
$mysql_config_editor print
[client]
user = someusername
password = *****
host = localhost
**Вопрос: Какие минимальные привелегии нужны для специального пользователя базы данных mysqltuner?**
mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* FOR 'mysqltuner'@'localhost' identified by pwd1234;
**Вопрос: Это не работает на моей ОС! Что делать?!**
Иногда такое случается. Чтобы тщательно исследовать проблему, необходимы следующие данные:
* ОС и версия ОС
* Архитектура (x86, x86_64, IA64, Commodore 64)
* Точная версия MySQL
* Где вы взяли данную версию MySQL(OS package, source, etc)
* Полный текст ошибки
* Копия вывода SHOW VARIABLES и SHOW GLOBAL STATUS (если это возможно)
**Вопрос: Как выполнить проверку на CVE уязвимости?**
* Скачать vulnerabilities.csv с этого репозитория.
* Использовать опцию --cvefile для проверки
**Вопрос: Как использовать mysqltuner с удалённого хоста?**
Спасибо [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba)
* Вы можете подключиться так же, как для обычного mysql-клиета:
Подключение и аутентификация.
--host Connect to a remote host to perform tests (default: localhost)
--socket Use a different socket for a local connection
--port Port to use for connection (default: 3306)
--user Username to use for authentication
--pass Password to use for authentication
--defaults-file defaulfs file for credentials
Так как вы используете удалённый хост, используйте параметры для указания данных об ОС
--forcemem Количество оперативной памяти в мегабайтах
--forceswap Количество swap памяти в мегабайтах
* Вы можете обратиться к вашему системному администратору, чтобы спросить, сколько оперативной памяти и swap'а вам доступно
Если у баз слишком много таблиц, или есть очень большие таблицы, используйте опцию
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
MySQLTuner и Vagrant
--
**MySQLTuner** содержится в следующих конфигурациях Vagrant:
* Fedora Core 23 / MariaDB 10.0
* Fedora Core 23 / MariaDB 10.1
* Fedora Core 23 / MySQL 5.6
* Fedora Core 23 / MySQL 5.7
**Vagrant File** are stored in Vagrant subdirectory.
* Follow this 2 steps after vagrant installation:
* Rename VagrantFile_for_Mxxx into Vagrantfile
* vagrant up
**MySQLTuner** contains a Vagrant configurations for test purpose and development
* Install VirtualBox and Vagrant
* https://www.virtualbox.org/wiki/Downloads
* https://www.vagrantup.com/downloads.html
* Clone repository
* git clone https://github.com/major/MySQLTuner-perl.git
* Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest
* vagrant plugin install vagrant-hostmanager
* vagrant plugin install vagrant-vbguest
* Add Fedora Core 23 box for official Fedora Download Website
* vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box
* Create a data directory
* mkdir data
* Rename Vagrantfile_MariaDB10.0 into Vagrantfile
* cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile
* Start vagrant
* vagrant up
MySQLTuner нуждается в Вас:
===
**MySQLTuner** нуждается в вашем вкладе в документацию и код, а так же ждёт обратную связь.
* Присоединяйтесь, пожалуйста, к нашему трекеру ошибок [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Руководство по поддержке проекта доступно на [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Ставьте "звезды" **проекту MySQLTuner** на [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
MySQLTuner-perl-1.7.2/USAGE.md 0000664 0000000 0000000 00000012171 13107067151 0015635 0 ustar 00root root 0000000 0000000 # NAME
MySQLTuner 1.7.2 - MySQL High Performance Tuning Script
# IMPORTANT USAGE GUIDELINES
To run the script with the default options, run the script without arguments
Allow MySQL server to run for at least 24-48 hours before trusting suggestions
Some routines may require root level privileges (script will provide warnings)
You must provide the remote server's total memory when connecting to other servers
# CONNECTION AND AUTHENTIFICATION
--host Connect to a remote host to perform tests (default: localhost)
--socket Use a different socket for a local connection
--port Port to use for connection (default: 3306)
--user Username to use for authentication
--userenv Name of env variable which contains username to use for authentication
--pass Password to use for authentication
--passenv Name of env variable which contains password to use for authentication
--mysqladmin Path to a custom mysqladmin executable
--mysqlcmd Path to a custom mysql executable
--defaults-file Path to a custom .my.cnf
=head1 PERFORMANCE AND REPORTING OPTIONS
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
--skippassword Don't perform checks on user passwords(default: off)
--checkversion Check for updates to MySQLTuner (default: don't check)
--updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check)
--forcemem Amount of RAM installed in megabytes
--forceswap Amount of swap memory configured in megabytes
--passwordfile Path to a password file list(one password by line)
# OUTPUT OPTIONS
--silent Don't output anything on screen
--nogood Remove OK responses
--nobad Remove negative/suggestion responses
--noinfo Remove informational responses
--debug Print debug information
--dbstat Print database information
--idxstat Print index information
--sysstat Print system information
--pfstat Print Performance schema
--bannedports Ports banned separated by comma(,)
--maxportallowed Number of ports opened allowed on this hosts
--cvefile CVE File for vulnerability checks
--nocolor Don't print output in color
--json Print result as JSON string
--buffers Print global and per-thread buffer values
--outputfile Path to a output txt file
--reportfile Path to a report txt file
--template Path to a template file
--verbose Prints out all options (default: no verbose)
=head1 PERLDOC
You can find documentation for this module with the perldoc command.
perldoc mysqltuner
## INTERNALS
[https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md)
Internal documentation
# AUTHORS
Major Hayden - major@mhtx.net
# CONTRIBUTORS
- Matthew Montgomery
- Paul Kehrer
- Dave Burgess
- Jonathan Hinds
- Mike Jackson
- Nils Breunese
- Shawn Ashlee
- Luuk Vosslamber
- Ville Skytta
- Trent Hornibrook
- Jason Gill
- Mark Imbriaco
- Greg Eden
- Aubin Galinotti
- Giovanni Bechis
- Bill Bradford
- Ryan Novosielski
- Michael Scheidell
- Blair Christensen
- Hans du Plooy
- Victor Trac
- Everett Barnes
- Tom Krouper
- Gary Barrueto
- Simon Greenaway
- Adam Stein
- Isart Montane
- Baptiste M.
- Cole Turner
- Major Hayden
- Joe Ashcraft
- Jean-Marie Renouard
- Stephan GroBberndt
- Christian Loos
# SUPPORT
Bug reports, feature requests, and downloads at http://mysqltuner.com/
Bug tracker can be found at https://github.com/major/MySQLTuner-perl/issues
Maintained by Major Hayden (major\\@mhtx.net) - Licensed under GPL
# SOURCE CODE
[https://github.com/major/MySQLTuner-perl](https://github.com/major/MySQLTuner-perl)
git clone https://github.com/major/MySQLTuner-perl.git
# COPYRIGHT AND LICENSE
Copyright (C) 2006-2017 Major Hayden - major@mhtx.net
For the latest updates, please visit http://mysqltuner.com/
Git repository available at http://github.com/major/MySQLTuner-perl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will 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 have received a copy of the GNU General Public License
along with this program. If not, see .
MySQLTuner-perl-1.7.2/Vagrant/ 0000775 0000000 0000000 00000000000 13107067151 0016047 5 ustar 00root root 0000000 0000000 MySQLTuner-perl-1.7.2/Vagrant/Vagrantfile_for_MariaDB10.0 0000664 0000000 0000000 00000010574 13107067151 0022727 0 ustar 00root root 0000000 0000000 # -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "fc23-mariadb10-0"
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
config.vbguest.auto_update = true
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.0.115"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network"
config.vm.hostname = 'dev.app'
config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local)
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "./data", "/data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = false
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo yum -y update
echo "secret" | sudo passwd --stdin root
sudo cp -pr ~vagrant/.ssh /root
sudo chown -R root.root /root/.ssh
sudo yum -y install git python
sudo pip install --upgrade pip
if [ ! -d "/data/MySQLTuner-perl" ]; then
cd /data
sudo git clone https://github.com/major/MySQLTuner-perl.git
fi
sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils
sudo cpanm install File::Util
sudo yum -y install mariadb mariadb-server wget
sudo systemctl start mariadb.service
mysql -e 'select version();'
cd /data
sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2"
sudo tar xvjf employees_db-full-1.0.6.tar.bz2
cd employees_db
cat employees.sql | mysql
cd ..
cd MySQLTuner-perl
perl mysqltuner.pl --idxstat --dbstat
SHELL
config.vm.provision :hostmanager
end
MySQLTuner-perl-1.7.2/Vagrant/Vagrantfile_for_MariaDB10.1 0000664 0000000 0000000 00000011270 13107067151 0022722 0 ustar 00root root 0000000 0000000 # -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "fc23-mariadb10-1"
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
config.vbguest.auto_update = true
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.0.115"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network"
config.vm.hostname = 'dev.app'
config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local)
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "./data", "/data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = false
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo yum -y update
echo "secret" | sudo passwd --stdin root
sudo cp -pr ~vagrant/.ssh /root
sudo chown -R root.root /root/.ssh
sudo yum -y install git python
sudo pip install --upgrade pip
if [ ! -d "/data/MySQLTuner-perl" ]; then
cd /data
sudo git clone https://github.com/major/MySQLTuner-perl.git
fi
echo "# MariaDB 10.1 Fedora repository list - created 2016-01-25 13:11 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/fedora23-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1" >> /etc/yum.repos.d/mariadb.repo
sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils
sudo cpanm install File::Util
sudo yum -y install MariaDB-server MariaDB-client wget
sudo systemctl start mariadb.service
mysql -e 'select version();'
cd /data
sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2"
sudo tar xvjf employees_db-full-1.0.6.tar.bz2
cd employees_db
cat employees.sql | mysql
cd ..
cd MySQLTuner-perl
perl mysqltuner.pl --idxstat --dbstat
SHELL
config.vm.provision :hostmanager
end
MySQLTuner-perl-1.7.2/Vagrant/Vagrantfile_for_MySQL5-6 0000664 0000000 0000000 00000011252 13107067151 0022360 0 ustar 00root root 0000000 0000000 # -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "fc23-mysql5-6"
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
config.vbguest.auto_update = true
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.0.115"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network"
config.vm.hostname = 'dev.app'
config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local)
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "./data", "/data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = false
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo yum -y update
echo "secret" | sudo passwd --stdin root
sudo cp -pr ~vagrant/.ssh /root
sudo chown -R root.root /root/.ssh
sudo yum -y install git python yum-utils
sudo pip install --upgrade pip
if [ ! -d "/data/MySQLTuner-perl" ]; then
cd /data
sudo git clone https://github.com/major/MySQLTuner-perl.git
fi
sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm
sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils
sudo cpanm install File::Util
sudo yum-config-manager --disable mysql57-community
sudo yum-config-manager --enable mysql56-community
sudo yum -y install mysql-community-server mysql-community-client wget
sudo systemctl start mysqld.service
mysql -uroot -e 'select version();'
cd /data
[ -f "employees_db-full-1.0.6.tar.bz2" ] || sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2"
sudo tar xvjf employees_db-full-1.0.6.tar.bz2
cd employees_db
cat employees.sql | mysql
cd ..
cd MySQLTuner-perl
perl mysqltuner.pl --idxstat --dbstat
SHELL
config.vm.provision :hostmanager
end
MySQLTuner-perl-1.7.2/Vagrant/Vagrantfile_for_MySQL5-7 0000664 0000000 0000000 00000011554 13107067151 0022366 0 ustar 00root root 0000000 0000000 # -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "fc23-mysql5-7"
config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
config.vbguest.auto_update = true
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.0.115"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network"
config.vm.hostname = 'dev.app'
config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local)
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "./data", "/data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = false
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo yum -y update
echo "secret" | sudo passwd --stdin root
sudo cp -pr ~vagrant/.ssh /root
sudo chown -R root.root /root/.ssh
sudo yum -y install git python
sudo pip install --upgrade pip
if [ ! -d "/data/MySQLTuner-perl" ]; then
cd /data
sudo git clone https://github.com/major/MySQLTuner-perl.git
fi
sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm
sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils
sudo cpanm install File::Util
sudo yum -y install mysql-community-server mysql-community-client wget
sudo systemctl start mysqld.service
PASSWORD=$(sudo grep -i "temporary password" /var/log/mysqld.log | cut -d':' -f4 | xargs -n 1 echo)
echo "PASSWORD: $PASSWORD"
mysql -uroot -p$PASSWORD --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySqlSecr3t#'"
mysql -uroot -psecret -e 'select version();'
cd /data
[ -f "employees_db-full-1.0.6.tar.bz2" ] || sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2"
sudo tar xvjf employees_db-full-1.0.6.tar.bz2
cd employees_db
cat employees.sql | mysql -uroot -pMySqlSecr3t#
cd ..
cd MySQLTuner-perl
#perl mysqltuner.pl --user root --pass MySqlSecr3t# --idxstat --dbstat
SHELL
config.vm.provision :hostmanager
end
MySQLTuner-perl-1.7.2/Vagrant/prepare.sh 0000664 0000000 0000000 00000000553 13107067151 0020044 0 ustar 00root root 0000000 0000000 #!/bin/sh
rm -f Vagrantfile
cp Vagrantfile_for_MariaDB10.0 Vagrantfile
mkdir data
vagrant plugin install vagrant-hostmanager
vagrant plugin install vagrant-vbguest
vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box
vagrant up
MySQLTuner-perl-1.7.2/basic_passwords.txt 0000664 0000000 0000000 00000007505 13107067151 0020403 0 ustar 00root root 0000000 0000000 1
123456
porsche
firebird
prince
rosebud
2
pa#sword
guitar
butter
beach
jaguar
3
12345678
chelsea
united
amateur
great
4
1234
black
turtle
7777777
cool
5
p#ssy
diamond
steelers
muffin
cooper
6
12345
nascar
tiffany
redsox
1313
7
dragon
jackson
zxcvbn
star
scorpio
8
qwerty
cameron
tomcat
testing
mountain
9
696969
654321
golf
shannon
madison
10
mustang
computer
bond007
murphy
987654
11
letmein
amanda
bear
frank
brazil
12
baseball
wizard
tiger
hannah
lauren
13
master
xxxxxxxx
doctor
dave
japan
14
michael
money
gateway
eagle1
naked
15
football
phoenix
gators
11111
squirt
16
shadow
mickey
angel
mother
stars
17
monkey
bailey
junior
nathan
apple
18
abc123
knight
thx1138
raiders
alexis
19
pa#s
iceman
porno
steve
aaaa
20
f#ckme
tigers
badboy
forever
bonnie
21
6969
purple
debbie
angela
peaches
22
jordan
andrea
spider
viper
jasmine
23
harley
horny
melissa
ou812
kevin
24
ranger
dakota
booger
jake
matt
25
iwantu
aaaaaa
1212
lovers
qwertyui
26
jennifer
player
flyers
suckit
danielle
27
hunter
sunshine
fish
gregory
beaver
28
f#ck
morgan
porn
buddy
4321
29
2000
starwars
matrix
whatever
4128
30
test
boomer
teens
young
runner
31
batman
cowboys
scooby
nicholas
swimming
32
trustno1
edward
jason
lucky
dolphin
33
thomas
charles
walter
helpme
gordon
34
tigger
girls
c#mshot
jackie
casper
35
robert
booboo
boston
monica
stupid
36
access
coffee
braves
midnight
shit
37
love
xxxxxx
yankee
college
saturn
38
buster
bulldog
lover
baby
gemini
39
1234567
ncc1701
barney
c#nt
apples
40
soccer
rabbit
victor
brian
august
41
hockey
peanut
tucker
mark
3333
42
killer
john
princess
startrek
canada
43
george
johnny
mercedes
sierra
blazer
44
sexy
gandalf
5150
leather
c#mming
45
andrew
spanky
doggie
232323
hunting
46
charlie
winter
zzzzzz
4444
kitty
47
superman
brandy
gunner
beavis
rainbow
48
a#shole
compaq
horney
bigc#ck
112233
49
f#ckyou
carlos
bubba
happy
arthur
50
dallas
tennis
2112
sophie
cream
51
jessica
james
fred
ladies
calvin
52
panties
mike
johnson
naughty
shaved
53
pepper
brandon
xxxxx
giants
surfer
54
1111
fender
tits
booty
samson
55
austin
anthony
member
blonde
kelly
56
william
blowme
boobs
f#cked
paul
57
daniel
ferrari
donald
golden
mine
58
golfer
cookie
bigdaddy
0
king
59
summer
chicken
bronco
fire
racing
60
heather
maverick
penis
sandra
5555
61
hammer
chicago
voyager
pookie
eagle
62
yankees
joseph
rangers
packers
hentai
63
joshua
diablo
birdie
einstein
newyork
64
maggie
sexsex
trouble
dolphins
little
65
biteme
hardcore
white
redwings
66
enter
666666
topgun
chevy
smith
67
ashley
willie
bigtits
winston
sticky
68
thunder
welcome
bitches
warrior
cocacola
69
cowboy
chris
green
sammy
animal
70
silver
panther
super
slut
broncos
71
richard
yamaha
qazwsx
8675309
private
72
f#cker
justin
magic
zxcvbnm
skippy
73
orange
banana
lakers
nipples
marvin
74
merlin
driver
rachel
power
blondes
75
michelle
marine
slayer
victoria
enjoy
76
corvette
angels
scott
asdfgh
girl
77
bigdog
fishing
2222
vagina
apollo
78
cheese
david
asdf
toyota
parker
79
matthew
maddog
video
travis
qwert
80
121212
hooters
london
hotdog
time
81
patrick
wilson
7777
paris
sydney
82
martin
butthead
marlboro
rock
women
83
freedom
dennis
srinivas
xxxx
voodoo
84
ginger
f#cking
internet
extreme
magnum
85
bl#wjob
captain
action
redskins
juice
86
nicole
bigdick
carter
erotic
abgrtyu
87
sparky
chester
jasper
dirty
777777
88
yellow
smokey
monster
ford
dreams
89
camaro
xavier
teresa
freddy
maxwell
90
secret
steven
jeremy
arsenal
music
91
dick
viking
11111111
access14
rush2112
92
falcon
snoopy
bill
wolf
russia
93
taylor
blue
crystal
nipple
scorpion
94
111111
eagles
peter
iloveyou
rebecca
95
131313
winner
p#ssies
alex
tester
96
123123
samantha
c#ck
florida
mistress
97
bitch
house
beer
eric
phantom
98
hello
miller
rocket
legend
billy
99
scooter
flower
theman
movie
6666
100
please
jack
oliver
success
albert
mysql
MySQL
dba
mypass
MyNewPass
some_pass
admin_pass
obscure
password
new_password
new_password1
new_password2
root-password
MySQLTuner-perl-1.7.2/build/ 0000775 0000000 0000000 00000000000 13107067151 0015544 5 ustar 00root root 0000000 0000000 MySQLTuner-perl-1.7.2/build/build_rpm.sh 0000775 0000000 0000000 00000001445 13107067151 0020064 0 ustar 00root root 0000000 0000000 #!/bin/sh
BUILD_DIR=`dirname $(readlink -f $0)`
VERSION=$(grep -Ei 'my \$tunerversion' $BUILD_DIR/../mysqltuner.pl | grep = | cut -d\" -f2)
cd $BUILD_DIR
sh ./clean.sh
perl -pe "s/%VERSION%/$VERSION/g" mysqltuner.spec.tpl > mysqltuner.spec
mkdir -p $BUILD_DIR/mysqltuner-$VERSION
cp $BUILD_DIR/../mysqltuner.pl mysqltuner.spec $BUILD_DIR/../LICENSE $BUILD_DIR/../basic_passwords.txt $BUILD_DIR/../*.csv $BUILD_DIR/mysqltuner-$VERSION
pod2man $BUILD_DIR/../mysqltuner.pl | gzip > $BUILD_DIR/mysqltuner-$VERSION/mysqltuner.1.gz
tar czf $BUILD_DIR/mysqltuner-${VERSION}.tgz mysqltuner-$VERSION
rpmbuild -ta mysqltuner-${VERSION}.tgz 2>&1 | tee -a ./build.log
set -x
grep --color=never -E '(Wrote|crit)\S*:' $BUILD_DIR/build.log | cut -d: -f2 | xargs -I{} mv {} .
#rm -rf mysqltuner-$VERSION ./build.log
MySQLTuner-perl-1.7.2/build/clean.sh 0000775 0000000 0000000 00000000065 13107067151 0017166 0 ustar 00root root 0000000 0000000 #!/bin/sh
rm -rf mysqltuner-* mysqltuner.spec *.log
MySQLTuner-perl-1.7.2/build/mysqltuner.spec.tpl 0000664 0000000 0000000 00000003156 13107067151 0021446 0 ustar 00root root 0000000 0000000 Summary: High Performance MySQL Tuning Script
Name: mysqltuner
Version: %VERSION%
Release: 1
License: GPL v3+
Group: Applications
Source0: https://github.com/build/MySQLTuner-perl/build/%{name}-%{version}.tgz
URL: https://github.com/major/MySQLTuner-perl
Requires: mysql
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
MySQLTuner is a high-performance MySQL tuning script written in Perl
that will provide you with a snapshot of a MySQL server's health.
Based on the statistics gathered, specific recommendations will be
provided that will increase a MySQL server's efficiency and
performance. The script gives you automated MySQL tuning that is on
the level of what you would receive from a MySQL DBA.
This script has been derived from many of the ideas in Matthew
Montgomery's MySQL tuning primer script.
%prep
%setup -q
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_bindir}
install -d $RPM_BUILD_ROOT%{_datarootdir}
install -d $RPM_BUILD_ROOT/%{_mandir}/man1
install -p %{name}.pl $RPM_BUILD_ROOT%{_bindir}/%{name}
install -d $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p LICENSE $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p basic_passwords.txt $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p vulnerabilities.csv $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p %{name}.1.gz $RPM_BUILD_ROOT/%{_mandir}/man1
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
%doc %{_datarootdir}/%{name}
%attr(755,root,root) %{_bindir}/%{name}
%{_mandir}/man1/*
%changelog
* Thu Apr 14 2016 Jean-Marie RENOUARD %VERSION%-1
- Initial RPM release
MySQLTuner-perl-1.7.2/build/updateCVElist.pl 0000664 0000000 0000000 00000005377 13107067151 0020631 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
use warnings;
use strict;
use WWW::Mechanize::GZip;
use File::Util;
use Data::Dumper;
use List::MoreUtils qw(uniq);
my $verbose;
sub AUTOLOAD {
use vars qw($AUTOLOAD);
my $cmd = $AUTOLOAD;
$cmd=~s/.*:://;
print "\n","*" x 60, "\n* Catching system call : $cmd \n", "*"x60 if defined $verbose;
print "\nExecution : \t", $cmd, " ", join " ", @_ if defined $verbose;
my $outp=`$cmd @_ 2>&1`;
my $rc=$?;
print "\nResult : \t$outp", if defined $verbose;
print "Code : \t", $rc, "\n" if defined $verbose;
return $rc;
}
my $mech = WWW::Mechanize->new();
$mech->agent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0');
#$mech->proxy( ['http'], 'http://XXX.XXX.XXX.XXX:3128' );
#$mech->proxy( ['https'], 'http://XXX.XXX.XXX.XXX:3128' );
$mech->env_proxy;
$mech->ssl_opts( 'verify_hostname' => 0 );
$mech->requests_redirectable(['GET', 'POST', 'HEAD']);
$mech->add_handler("request_send", sub { print '#'x80,"\nSEND REQUEST:\n"; shift->dump; print '#'x80,"\n";return } ) if defined $verbose;
$mech->add_handler("response_done", sub { print '#'x80,"\nDONE RESPONSE:\n"; shift->dump; print '#'x80,"\n"; return }) if defined $verbose;
$mech->add_handler("response_redirect" => sub { print '#'x80,"\nREDIRECT RESPONSE:\n"; shift->dump; print '#'x80,"\n"; return }) if defined $verbose;
my $url = 'http://cve.mitre.org/data/downloads/allitems.csv';
my $resp;
unlink ('cve.csv') if (-f 'cve.csv');
$resp=$mech->get($url);
$mech->save_content( "cve.csv" );
my $f=File::Util->new('readlimit' => 100000000, 'use_flock'=>'false');
my(@lines) = $f->load_file('cve.csv', '--as-lines');
my @versions;
my $temp;
unlink '../vulnerabilities.csv' if -f '../vulnerabilities.csv';
foreach my $line (@lines) {
if ($line =~ /(mysql|mariadb)/i
and $line =~ /server/i
and $line =~ /CANDIDATE/i
and $line !~ /MaxDB/i
and $line !~ /\*\* REJECT \*\* /i
and $line !~ /\*\* DISPUTED \*\* /i
and $line !~ /(Radius|Proofpoint|Active\ Record|XAMPP|TGS\ Content|e107|post-installation|Apache\ HTTP|Zmanda|pforum|phpMyAdmin|Proxy\ Server|on\ Windows|ADOdb|Mac\ OS|Dreamweaver|InterWorx|libapache2|cisco|ProFTPD)/i) {
$line =~ s/,/;/g;
@versions = $line =~/(\d{1,2}\.\d+\.[\d]+)/g;
foreach my $vers (uniq(@versions)) {
my @nb=split('\.', $vers);
$nb[2]-- if ($line =~ /before/i);
#print $vers."\n".Dumper @nb;
#print "$line";
#exit 0 if ($line =~/before/i) ;
$f->write_file('file' => '../vulnerabilities.csv', 'content' => "$nb[0].$nb[1].$nb[2];$nb[0];$nb[1];$nb[2];$line\n", 'mode' => 'append');
}
}
}
unlink ('cve.csv') if (-f 'cve.csv');
exit(0);
MySQLTuner-perl-1.7.2/build/updateStaff.sh 0000664 0000000 0000000 00000000513 13107067151 0020345 0 ustar 00root root 0000000 0000000 #!/bin/sh
(cd ..
echo "* GENERATING USAGE FILE"
pod2markdown mysqltuner.pl >USAGE.md
echo "* TIDYFY SCRIPT"
perltidy -b mysqltuner.pl
)
echo "* Udate CVE list"
perl updateCVElist.pl
git add ../vulnerabilities.csv ../mysqltuner.pl ./USAGE.md
git commit -m 'Update Vulnerabilities list
Identing mysqltuner
Update Usage information' MySQLTuner-perl-1.7.2/mysqltuner.pl 0000775 0000000 0000000 00000640475 13107067151 0017250 0 ustar 00root root 0000000 0000000 #!/usr/bin/env perl
# mysqltuner.pl - Version 1.7.2
# High Performance MySQL Tuning Script
# Copyright (C) 2006-2017 Major Hayden - major@mhtx.net
#
# For the latest updates, please visit http://mysqltuner.com/
# Git repository available at http://github.com/major/MySQLTuner-perl
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will 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 have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# This project would not be possible without help from:
# Matthew Montgomery Paul Kehrer Dave Burgess
# Jonathan Hinds Mike Jackson Nils Breunese
# Shawn Ashlee Luuk Vosslamber Ville Skytta
# Trent Hornibrook Jason Gill Mark Imbriaco
# Greg Eden Aubin Galinotti Giovanni Bechis
# Bill Bradford Ryan Novosielski Michael Scheidell
# Blair Christensen Hans du Plooy Victor Trac
# Everett Barnes Tom Krouper Gary Barrueto
# Simon Greenaway Adam Stein Isart Montane
# Baptiste M. Cole Turner Major Hayden
# Joe Ashcraft Jean-Marie Renouard Christian Loos
# Julien Francoz
#
# Inspired by Matthew Montgomery's tuning-primer.sh script:
# http://forge.mysql.com/projects/view.php?id=44
#
package main;
use 5.005;
use strict;
use warnings;
use diagnostics;
use File::Spec;
use Getopt::Long;
use File::Basename;
use Cwd 'abs_path';
use Data::Dumper;
$Data::Dumper::Pair = " : ";
# for which()
#use Env;
# Set up a few variables for use in the script
my $tunerversion = "1.7.2";
my ( @adjvars, @generalrec );
# Set defaults
my %opt = (
"silent" => 0,
"nobad" => 0,
"nogood" => 0,
"noinfo" => 0,
"debug" => 0,
"nocolor" => 0,
"forcemem" => 0,
"forceswap" => 0,
"host" => 0,
"socket" => 0,
"port" => 0,
"user" => 0,
"pass" => 0,
"password" => 0,
"skipsize" => 0,
"checkversion" => 0,
"updateversion" => 0,
"buffers" => 0,
"passwordfile" => 0,
"bannedports" => '',
"maxportallowed" => 0,
"outputfile" => 0,
"dbstat" => 0,
"idxstat" => 0,
"sysstat" => 0,
"pfstat" => 0,
"skippassword" => 0,
"noask" => 0,
"template" => 0,
"json" => 0,
"prettyjson" => 0,
"reportfile" => 0,
"verbose" => 0,
"defaults-file" => '',
);
# Gather the options from the command line
my $getOptionsCheck = GetOptions(
\%opt, 'nobad',
'nogood', 'noinfo',
'debug', 'nocolor',
'forcemem=i', 'forceswap=i',
'host=s', 'socket=s',
'port=i', 'user=s',
'pass=s', 'skipsize',
'checkversion', 'mysqladmin=s',
'mysqlcmd=s', 'help',
'buffers', 'skippassword',
'passwordfile=s', 'outputfile=s',
'silent', 'dbstat',
'json', 'prettyjson',
'idxstat', 'noask',
'template=s', 'reportfile=s',
'cvefile=s', 'bannedports=s',
'updateversion', 'maxportallowed=s',
'verbose', 'sysstat',
'password=s', 'pfstat',
'passenv=s', 'userenv=s',
'defaults-file=s'
);
#If params are incorrect return help
if ( $getOptionsCheck ne 1 ) {
usage();
}
if ( defined $opt{'help'} && $opt{'help'} == 1 ) { usage(); }
sub usage {
# Shown with --help option passed
print " MySQLTuner $tunerversion - MySQL High Performance Tuning Script\n"
. " Bug reports, feature requests, and downloads at http://mysqltuner.com/\n"
. " Maintained by Major Hayden (major\@mhtx.net) - Licensed under GPL\n"
. "\n"
. " Important Usage Guidelines:\n"
. " To run the script with the default options, run the script without arguments\n"
. " Allow MySQL server to run for at least 24-48 hours before trusting suggestions\n"
. " Some routines may require root level privileges (script will provide warnings)\n"
. " You must provide the remote server's total memory when connecting to other servers\n"
. "\n"
. " Connection and Authentication\n"
. " --host Connect to a remote host to perform tests (default: localhost)\n"
. " --socket Use a different socket for a local connection\n"
. " --port Port to use for connection (default: 3306)\n"
. " --user Username to use for authentication\n"
. " --userenv Name of env variable which contains username to use for authentication\n"
. " --pass Password to use for authentication\n"
. " --passenv Name of env variable which contains password to use for authentication\n"
. " --defaults-file Path to a custom .my.cnf\n"
. " --mysqladmin Path to a custom mysqladmin executable\n"
. " --mysqlcmd Path to a custom mysql executable\n" . "\n"
. " --noask Don't ask password if needed\n" . "\n"
. " Performance and Reporting Options\n"
. " --skipsize Don't enumerate tables and their types/sizes (default: on)\n"
. " (Recommended for servers with many tables)\n"
. " --skippassword Don't perform checks on user passwords(default: off)\n"
. " --checkversion Check for updates to MySQLTuner (default: don't check)\n"
. " --updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check)\n"
. " --forcemem Amount of RAM installed in megabytes\n"
. " --forceswap Amount of swap memory configured in megabytes\n"
. " --passwordfile Path to a password file list(one password by line)\n"
. " Output Options:\n"
. " --silent Don't output anything on screen\n"
. " --nogood Remove OK responses\n"
. " --nobad Remove negative/suggestion responses\n"
. " --noinfo Remove informational responses\n"
. " --debug Print debug information\n"
. " --dbstat Print database information\n"
. " --idxstat Print index information\n"
. " --sysstat Print system information\n"
. " --pfstat Print Performance schema information\n"
. " --bannedports Ports banned separated by comma(,)\n"
. " --maxportallowed Number of ports opened allowed on this hosts\n"
. " --cvefile CVE File for vulnerability checks\n"
. " --nocolor Don't print output in color\n"
. " --json Print result as JSON string\n"
. " --prettyjson Print result as human readable JSON\n"
. " --buffers Print global and per-thread buffer values\n"
. " --outputfile Path to a output txt file\n" . "\n"
. " --reportfile Path to a report txt file\n" . "\n"
. " --template Path to a template file\n" . "\n"
. " --verbose Prints out all options (default: no verbose) \n"
. "\n";
exit 0;
}
my $devnull = File::Spec->devnull();
my $basic_password_files =
( $opt{passwordfile} eq "0" )
? abs_path( dirname(__FILE__) ) . "/basic_passwords.txt"
: abs_path( $opt{passwordfile} );
# Username from envvar
if ( exists $opt{userenv} && exists $ENV{ $opt{userenv} } ) {
$opt{user} = $ENV{ $opt{userenv} };
}
# Related to password option
if ( exists $opt{passenv} && exists $ENV{ $opt{passenv} } ) {
$opt{pass} = $ENV{ $opt{passenv} };
}
$opt{pass} = $opt{password} if ( $opt{pass} eq 0 and $opt{password} ne 0 );
# for RPM distributions
$basic_password_files = "/usr/share/mysqltuner/basic_passwords.txt"
unless -f "$basic_password_files";
# check if we need to enable verbose mode
if ( $opt{verbose} ) {
$opt{checkversion} = 1; #Check for updates to MySQLTuner
$opt{dbstat} = 1; #Print database information
$opt{idxstat} = 1; #Print index information
$opt{sysstat} = 1; #Print index information
$opt{buffers} = 1; #Print global and per-thread buffer values
$opt{pfstat} = 1; #Print performance schema info.
$opt{cvefile} = 'vulnerabilities.csv'; #CVE File for vulnerability checks
}
# for RPM distributions
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv"
unless ( defined $opt{cvefile} and -f "$opt{cvefile}" );
$opt{cvefile} = '' unless -f "$opt{cvefile}";
$opt{cvefile} = './vulnerabilities.csv' if -f './vulnerabilities.csv';
$opt{'bannedports'} = '' unless defined( $opt{'bannedports'} );
my @banned_ports = split ',', $opt{'bannedports'};
#
my $outputfile = undef;
$outputfile = abs_path( $opt{outputfile} ) unless $opt{outputfile} eq "0";
my $fh = undef;
open( $fh, '>', $outputfile )
or die("Fail opening $outputfile")
if defined($outputfile);
$opt{nocolor} = 1 if defined($outputfile);
# Setting up the colors for the print styles
my $me = `whoami`;
$me =~ s/\n//g;
# Setting up the colors for the print styles
my $good = ( $opt{nocolor} == 0 ) ? "[\e[0;32mOK\e[0m]" : "[OK]";
my $bad = ( $opt{nocolor} == 0 ) ? "[\e[0;31m!!\e[0m]" : "[!!]";
my $info = ( $opt{nocolor} == 0 ) ? "[\e[0;34m--\e[0m]" : "[--]";
my $deb = ( $opt{nocolor} == 0 ) ? "[\e[0;31mDG\e[0m]" : "[DG]";
my $cmd = ( $opt{nocolor} == 0 ) ? "\e[1;32m[CMD]($me)" : "[CMD]($me)";
my $end = ( $opt{nocolor} == 0 ) ? "\e[0m" : "";
# Checks for supported or EOL'ed MySQL versions
my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro );
# Super structure containing all information
my %result;
$result{'MySQLTuner'}{'version'} = $tunerversion;
$result{'MySQLTuner'}{'options'} = \%opt;
# Functions that handle the print styles
sub prettyprint {
print $_[0] . "\n" unless ( $opt{'silent'} or $opt{'json'} );
print $fh $_[0] . "\n" if defined($fh);
}
sub goodprint { prettyprint $good. " " . $_[0] unless ( $opt{nogood} == 1 ); }
sub infoprint { prettyprint $info. " " . $_[0] unless ( $opt{noinfo} == 1 ); }
sub badprint { prettyprint $bad. " " . $_[0] unless ( $opt{nobad} == 1 ); }
sub debugprint { prettyprint $deb. " " . $_[0] unless ( $opt{debug} == 0 ); }
sub redwrap {
return ( $opt{nocolor} == 0 ) ? "\e[0;31m" . $_[0] . "\e[0m" : $_[0];
}
sub greenwrap {
return ( $opt{nocolor} == 0 ) ? "\e[0;32m" . $_[0] . "\e[0m" : $_[0];
}
sub cmdprint { prettyprint $cmd. " " . $_[0] . $end; }
sub infoprintml {
for my $ln (@_) { $ln =~ s/\n//g; infoprint "\t$ln"; }
}
sub infoprintcmd {
cmdprint "@_";
infoprintml grep { $_ ne '' and $_ !~ /^\s*$/ } `@_ 2>&1`;
}
sub subheaderprint {
my $tln = 100;
my $sln = 8;
my $ln = length("@_") + 2;
prettyprint " ";
prettyprint "-" x $sln . " @_ " . "-" x ( $tln - $ln - $sln );
}
sub infoprinthcmd {
subheaderprint "$_[0]";
infoprintcmd "$_[1]";
}
# Calculates the number of phyiscal cores considering HyperThreading
sub cpu_cores {
my $cntCPU = `awk -F: '/^core id/ && !P[\$2] { CORES++; P[\$2]=1 }; /^physical id/ && !N[\$2] { CPUs++; N[\$2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo`;
return ( $cntCPU == 0 ? `nproc` : $cntCPU );
}
# Calculates the parameter passed in bytes, then rounds it to one decimal place
sub hr_bytes {
my $num = shift;
return "0B" unless defined($num);
return "0B" if $num eq "NULL";
if ( $num >= ( 1024**3 ) ) { #GB
return sprintf( "%.1f", ( $num / ( 1024**3 ) ) ) . "G";
}
elsif ( $num >= ( 1024**2 ) ) { #MB
return sprintf( "%.1f", ( $num / ( 1024**2 ) ) ) . "M";
}
elsif ( $num >= 1024 ) { #KB
return sprintf( "%.1f", ( $num / 1024 ) ) . "K";
}
else {
return $num . "B";
}
}
sub hr_raw {
my $num = shift;
return "0" unless defined($num);
return "0" if $num eq "NULL";
if ( $num =~ /^(\d+)G$/ ) {
return $1 * 1024 * 1024 * 1024;
}
if ( $num =~ /^(\d+)M$/ ) {
return $1 * 1024 * 1024;
}
if ( $num =~ /^(\d+)K$/ ) {
return $1 * 1024;
}
if ( $num =~ /^(\d+)$/ ) {
return $1;
}
return $num;
}
# Calculates the parameter passed in bytes, then rounds it to the nearest integer
sub hr_bytes_rnd {
my $num = shift;
return "0B" unless defined($num);
return "0B" if $num eq "NULL";
if ( $num >= ( 1024**3 ) ) { #GB
return int( ( $num / ( 1024**3 ) ) ) . "G";
}
elsif ( $num >= ( 1024**2 ) ) { #MB
return int( ( $num / ( 1024**2 ) ) ) . "M";
}
elsif ( $num >= 1024 ) { #KB
return int( ( $num / 1024 ) ) . "K";
}
else {
return $num . "B";
}
}
# Calculates the parameter passed to the nearest power of 1000, then rounds it to the nearest integer
sub hr_num {
my $num = shift;
if ( $num >= ( 1000**3 ) ) { # Billions
return int( ( $num / ( 1000**3 ) ) ) . "B";
}
elsif ( $num >= ( 1000**2 ) ) { # Millions
return int( ( $num / ( 1000**2 ) ) ) . "M";
}
elsif ( $num >= 1000 ) { # Thousands
return int( ( $num / 1000 ) ) . "K";
}
else {
return $num;
}
}
# Calculate Percentage
sub percentage {
my $value = shift;
my $total = shift;
$total = 0 unless defined $total;
$total = 0 if $total eq "NULL";
return 100, 00 if $total == 0;
return sprintf( "%.2f", ( $value * 100 / $total ) );
}
# Calculates uptime to display in a more attractive form
sub pretty_uptime {
my $uptime = shift;
my $seconds = $uptime % 60;
my $minutes = int( ( $uptime % 3600 ) / 60 );
my $hours = int( ( $uptime % 86400 ) / (3600) );
my $days = int( $uptime / (86400) );
my $uptimestring;
if ( $days > 0 ) {
$uptimestring = "${days}d ${hours}h ${minutes}m ${seconds}s";
}
elsif ( $hours > 0 ) {
$uptimestring = "${hours}h ${minutes}m ${seconds}s";
}
elsif ( $minutes > 0 ) {
$uptimestring = "${minutes}m ${seconds}s";
}
else {
$uptimestring = "${seconds}s";
}
return $uptimestring;
}
# Retrieves the memory installed on this machine
my ( $physical_memory, $swap_memory, $duflags );
sub memerror {
badprint
"Unable to determine total memory/swap; use '--forcemem' and '--forceswap'";
exit 1;
}
sub os_setup {
my $os = `uname`;
$duflags = ( $os =~ /Linux/ ) ? '-b' : '';
if ( $opt{'forcemem'} > 0 ) {
$physical_memory = $opt{'forcemem'} * 1048576;
infoprint "Assuming $opt{'forcemem'} MB of physical memory";
if ( $opt{'forceswap'} > 0 ) {
$swap_memory = $opt{'forceswap'} * 1048576;
infoprint "Assuming $opt{'forceswap'} MB of swap space";
}
else {
$swap_memory = 0;
badprint "Assuming 0 MB of swap space (use --forceswap to specify)";
}
}
else {
if ( $os =~ /Linux|CYGWIN/ ) {
$physical_memory =
`grep -i memtotal: /proc/meminfo | awk '{print \$2}'`
or memerror;
$physical_memory *= 1024;
$swap_memory =
`grep -i swaptotal: /proc/meminfo | awk '{print \$2}'`
or memerror;
$swap_memory *= 1024;
}
elsif ( $os =~ /Darwin/ ) {
$physical_memory = `sysctl -n hw.memsize` or memerror;
$swap_memory =
`sysctl -n vm.swapusage | awk '{print \$3}' | sed 's/\..*\$//'`
or memerror;
}
elsif ( $os =~ /NetBSD|OpenBSD|FreeBSD/ ) {
$physical_memory = `sysctl -n hw.physmem` or memerror;
if ( $physical_memory < 0 ) {
$physical_memory = `sysctl -n hw.physmem64` or memerror;
}
$swap_memory =
`swapctl -l | grep '^/' | awk '{ s+= \$2 } END { print s }'`
or memerror;
}
elsif ( $os =~ /BSD/ ) {
$physical_memory = `sysctl -n hw.realmem` or memerror;
$swap_memory =
`swapinfo | grep '^/' | awk '{ s+= \$2 } END { print s }'`;
}
elsif ( $os =~ /SunOS/ ) {
$physical_memory =
`/usr/sbin/prtconf | grep Memory | cut -f 3 -d ' '`
or memerror;
chomp($physical_memory);
$physical_memory = $physical_memory * 1024 * 1024;
}
elsif ( $os =~ /AIX/ ) {
$physical_memory =
`lsattr -El sys0 | grep realmem | awk '{print \$2}'`
or memerror;
chomp($physical_memory);
$physical_memory = $physical_memory * 1024;
$swap_memory = `lsps -as | awk -F"(MB| +)" '/MB /{print \$2}'`
or memerror;
chomp($swap_memory);
$swap_memory = $swap_memory * 1024 * 1024;
}
elsif ( $os =~ /windows/i ) {
$physical_memory =
`wmic ComputerSystem get TotalPhysicalMemory | perl -ne "chomp; print if /[0-9]+/;"`
or memerror;
$swap_memory =
`wmic OS get FreeVirtualMemory | perl -ne "chomp; print if /[0-9]+/;"`
or memerror;
}
}
debugprint "Physical Memory: $physical_memory";
debugprint "Swap Memory: $swap_memory";
chomp($physical_memory);
chomp($swap_memory);
chomp($os);
$result{'OS'}{'OS Type'} = $os;
$result{'OS'}{'Physical Memory'}{'bytes'} = $physical_memory;
$result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);
$result{'OS'}{'Swap Memory'}{'bytes'} = $swap_memory;
$result{'OS'}{'Swap Memory'}{'pretty'} = hr_bytes($swap_memory);
$result{'OS'}{'Other Processes'}{'bytes'} = get_other_process_memory();
$result{'OS'}{'Other Processes'}{'pretty'} =
hr_bytes( get_other_process_memory() );
}
sub get_http_cli {
my $httpcli = which( "curl", $ENV{'PATH'} );
chomp($httpcli);
if ($httpcli) {
return $httpcli;
}
$httpcli = which( "wget", $ENV{'PATH'} );
chomp($httpcli);
if ($httpcli) {
return $httpcli;
}
return "";
}
# Checks for updates to MySQLTuner
sub validate_tuner_version {
if ( $opt{'checkversion'} eq 0 and $opt{'updateversion'} eq 0 ) {
print "\n" unless ( $opt{'silent'} or $opt{'json'} );
infoprint "Skipped version check for MySQLTuner script";
return;
}
my $update;
my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl";
my $httpcli = get_http_cli();
if ( $httpcli =~ /curl$/ ) {
debugprint "$httpcli is available.";
debugprint
"$httpcli -m 3 -silent '$url' 2>/dev/null | grep 'my \$tunerversion'| cut -d\\\" -f2";
$update =
`$httpcli -m 3 -silent '$url' 2>/dev/null | grep 'my \$tunerversion'| cut -d\\\" -f2`;
chomp($update);
debugprint "VERSION: $update";
compare_tuner_version($update);
return;
}
if ( $httpcli =~ /wget$/ ) {
debugprint "$httpcli is available.";
debugprint
"$httpcli -e timestamping=off -t 1 -T 3 -O - '$url' 2>$devnull| grep 'my \$tunerversion'| cut -d\\\" -f2";
$update =
`$httpcli -e timestamping=off -t 1 -T 3 -O - '$url' 2>$devnull| grep 'my \$tunerversion'| cut -d\\\" -f2`;
chomp($update);
compare_tuner_version($update);
return;
}
debugprint "curl and wget are not available.";
infoprint "Unable to check for the latest MySQLTuner version";
infoprint
"Using --pass and --password option is insecure during MySQLTuner execution(Password disclosure)"
if ( defined( $opt{'pass'} ) );
}
# Checks for updates to MySQLTuner
sub update_tuner_version {
if ( $opt{'updateversion'} eq 0 ) {
badprint "Skipped version update for MySQLTuner script";
print "\n" unless ( $opt{'silent'} or $opt{'json'} );
return;
}
my $update;
my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/";
my @scripts =
( "mysqltuner.pl", "basic_passwords.txt", "vulnerabilities.csv" );
my $totalScripts = scalar(@scripts);
my $receivedScripts = 0;
my $httpcli = get_http_cli();
foreach my $script (@scripts) {
if ( $httpcli =~ /curl$/ ) {
debugprint "$httpcli is available.";
debugprint
"$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $script";
$update =
`$httpcli --connect-timeout 3 '$url$script' 2>$devnull > $script`;
chomp($update);
debugprint "$script updated: $update";
if ( -s $script eq 0 ) {
badprint "Couldn't update $script";
}
else {
++$receivedScripts;
debugprint "$script updated: $update";
}
}
elsif ( $httpcli =~ /wget$/ ) {
debugprint "$httpcli is available.";
debugprint
"$httpcli -qe timestamping=off -t 1 -T 3 -O $script '$url$script'";
$update =
`$httpcli -qe timestamping=off -t 1 -T 3 -O $script '$url$script'`;
chomp($update);
if ( -s $script eq 0 ) {
badprint "Couldn't update $script";
}
else {
++$receivedScripts;
debugprint "$script updated: $update";
}
}
else {
debugprint "curl and wget are not available.";
infoprint "Unable to check for the latest MySQLTuner version";
}
}
if ( $receivedScripts eq $totalScripts ) {
goodprint "Successfully updated MySQLTuner script";
}
else {
badprint "Couldn't update MySQLTuner script";
}
exit 0;
}
sub compare_tuner_version {
my $remoteversion = shift;
debugprint "Remote data: $remoteversion";
#exit 0;
if ( $remoteversion ne $tunerversion ) {
badprint
"There is a new version of MySQLTuner available($remoteversion)";
update_tuner_version();
return;
}
goodprint "You have the latest version of MySQLTuner($tunerversion)";
return;
}
# Checks to see if a MySQL login is possible
my ( $mysqllogin, $doremote, $remotestring, $mysqlcmd, $mysqladmincmd );
my $osname = $^O;
if ( $osname eq 'MSWin32' ) {
eval { require Win32; } or last;
$osname = Win32::GetOSName();
infoprint "* Windows OS($osname) is not fully supported.\n";
#exit 1;
}
sub mysql_setup {
$doremote = 0;
$remotestring = '';
if ( $opt{mysqladmin} ) {
$mysqladmincmd = $opt{mysqladmin};
}
else {
$mysqladmincmd = which( "mysqladmin", $ENV{'PATH'} );
}
chomp($mysqladmincmd);
if ( !-e $mysqladmincmd && $opt{mysqladmin} ) {
badprint "Unable to find the mysqladmin command you specified: "
. $mysqladmincmd . "";
exit 1;
}
elsif ( !-e $mysqladmincmd ) {
badprint "Couldn't find mysqladmin in your \$PATH. Is MySQL installed?";
exit 1;
}
if ( $opt{mysqlcmd} ) {
$mysqlcmd = $opt{mysqlcmd};
}
else {
$mysqlcmd = which( "mysql", $ENV{'PATH'} );
}
chomp($mysqlcmd);
if ( !-e $mysqlcmd && $opt{mysqlcmd} ) {
badprint "Unable to find the mysql command you specified: "
. $mysqlcmd . "";
exit 1;
}
elsif ( !-e $mysqlcmd ) {
badprint "Couldn't find mysql in your \$PATH. Is MySQL installed?";
exit 1;
}
$mysqlcmd =~ s/\n$//g;
my $mysqlclidefaults = `$mysqlcmd --print-defaults`;
debugprint "MySQL Client: $mysqlclidefaults";
if ( $mysqlclidefaults =~ /auto-vertical-output/ ) {
badprint
"Avoid auto-vertical-output in configuration file(s) for MySQL like";
exit 1;
}
debugprint "MySQL Client: $mysqlcmd";
$opt{port} = ( $opt{port} eq 0 ) ? 3306 : $opt{port};
# Are we being asked to connect via a socket?
if ( $opt{socket} ne 0 ) {
$remotestring = " -S $opt{socket} -P $opt{port}";
}
# Are we being asked to connect to a remote server?
if ( $opt{host} ne 0 ) {
chomp( $opt{host} );
# If we're doing a remote connection, but forcemem wasn't specified, we need to exit
if ( $opt{'forcemem'} eq 0
&& ( $opt{host} ne "127.0.0.1" )
&& ( $opt{host} ne "localhost" ) )
{
badprint "The --forcemem option is required for remote connections";
exit 1;
}
infoprint "Performing tests on $opt{host}:$opt{port}";
$remotestring = " -h $opt{host} -P $opt{port}";
if ( ( $opt{host} ne "127.0.0.1" ) && ( $opt{host} ne "localhost" ) ) {
$doremote = 1;
}
} else {
$opt{host}='127.0.0.1';
}
# Did we already get a username without password on the command line?
if ( $opt{user} ne 0 and $opt{pass} eq 0 ) {
$mysqllogin = "-u $opt{user} " . $remotestring;
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials passed on the command line";
return 1;
}
else {
badprint
"Attempted to use login credentials, but they were invalid";
exit 1;
}
}
# Did we already get a username and password passed on the command line?
if ( $opt{user} ne 0 and $opt{pass} ne 0 ) {
$mysqllogin = "-u $opt{user} -p'$opt{pass}'" . $remotestring;
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials passed on the command line";
return 1;
}
else {
badprint
"Attempted to use login credentials, but they were invalid";
exit 1;
}
}
my $svcprop = which( "svcprop", $ENV{'PATH'} );
if ( substr( $svcprop, 0, 1 ) =~ "/" ) {
# We are on solaris
( my $mysql_login =
`svcprop -p quickbackup/username svc:/network/mysql-quickbackup:default`
) =~ s/\s+$//;
( my $mysql_pass =
`svcprop -p quickbackup/password svc:/network/mysql-quickbackup:default`
) =~ s/\s+$//;
if ( substr( $mysql_login, 0, 7 ) ne "svcprop" ) {
# mysql-quickbackup is installed
$mysqllogin = "-u $mysql_login -p$mysql_pass";
my $loginstatus = `mysqladmin $mysqllogin ping 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials from mysql-quickbackup.";
return 1;
}
else {
badprint
"Attempted to use login credentials from mysql-quickbackup, but they failed.";
exit 1;
}
}
}
elsif ( -r "/etc/psa/.psa.shadow" and $doremote == 0 ) {
# It's a Plesk box, use the available credentials
$mysqllogin = "-u admin -p`cat /etc/psa/.psa.shadow`";
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
unless ( $loginstatus =~ /mysqld is alive/ ) {
# Plesk 10+
$mysqllogin =
"-u admin -p`/usr/local/psa/bin/admin --show-password`";
$loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
unless ( $loginstatus =~ /mysqld is alive/ ) {
badprint
"Attempted to use login credentials from Plesk and Plesk 10+, but they failed.";
exit 1;
}
}
}
elsif ( -r "/usr/local/directadmin/conf/mysql.conf" and $doremote == 0 ) {
# It's a DirectAdmin box, use the available credentials
my $mysqluser =
`cat /usr/local/directadmin/conf/mysql.conf | egrep '^user=.*'`;
my $mysqlpass =
`cat /usr/local/directadmin/conf/mysql.conf | egrep '^passwd=.*'`;
$mysqluser =~ s/user=//;
$mysqluser =~ s/[\r\n]//;
$mysqlpass =~ s/passwd=//;
$mysqlpass =~ s/[\r\n]//;
$mysqllogin = "-u $mysqluser -p$mysqlpass";
my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`;
unless ( $loginstatus =~ /mysqld is alive/ ) {
badprint
"Attempted to use login credentials from DirectAdmin, but they failed.";
exit 1;
}
}
elsif ( -r "/etc/mysql/debian.cnf" and $doremote == 0 ) {
# We have a debian maintenance account, use it
$mysqllogin = "--defaults-file=/etc/mysql/debian.cnf";
my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint
"Logged in using credentials from debian maintenance account.";
return 1;
}
else {
badprint
"Attempted to use login credentials from debian maintenance account, but they failed.";
exit 1;
}
}
elsif ( $opt{'defaults-file'} ne 0 and -r "$opt{'defaults-file'}" ) {
# defaults-file
debugprint "defaults file detected: $opt{'defaults-file'}";
my $mysqlclidefaults = `$mysqlcmd --print-defaults`;
debugprint "MySQL Client Default File: $opt{'defaults-file'}";
$mysqllogin = "--defaults-file=" . $opt{'defaults-file'};
my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials from defaults file account.";
return 1;
}
}
else {
# It's not Plesk or debian, we should try a login
debugprint "$mysqladmincmd $remotestring ping 2>&1";
my $loginstatus = `$mysqladmincmd $remotestring ping 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
# Login went just fine
$mysqllogin = " $remotestring ";
# Did this go well because of a .my.cnf file or is there no password set?
my $userpath = `printenv HOME`;
if ( length($userpath) > 0 ) {
chomp($userpath);
}
unless ( -e "${userpath}/.my.cnf" or -e "${userpath}/.mylogin.cnf" )
{
badprint
"Successfully authenticated with no password - SECURITY RISK!";
}
return 1;
}
else {
if ( $opt{'noask'} == 1 ) {
badprint
"Attempted to use login credentials, but they were invalid";
exit 1;
}
my ( $name, $password );
# If --user is defined no need to ask for username
if ( $opt{user} ne 0 ) {
$name = $opt{user};
}
else {
print STDERR "Please enter your MySQL administrative login: ";
$name = ;
}
# If --pass is defined no need to ask for password
if ( $opt{pass} ne 0 ) {
$password = $opt{pass};
}
else {
print STDERR
"Please enter your MySQL administrative password: ";
system("stty -echo >$devnull 2>&1");
$password = ;
system("stty echo >$devnull 2>&1");
}
chomp($password);
chomp($name);
$mysqllogin = "-u $name";
if ( length($password) > 0 ) {
$mysqllogin .= " -p'$password'";
}
$mysqllogin .= $remotestring;
my $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
print STDERR "";
if ( !length($password) ) {
# Did this go well because of a .my.cnf file or is there no password set?
my $userpath = `printenv HOME`;
chomp($userpath);
unless ( -e "$userpath/.my.cnf" ) {
badprint
"Successfully authenticated with no password - SECURITY RISK!";
}
}
return 1;
}
else {
badprint
"Attempted to use login credentials, but they were invalid.";
exit 1;
}
exit 1;
}
}
}
# MySQL Request Array
sub select_array {
my $req = shift;
debugprint "PERFORM: $req ";
my @result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>/dev/null`;
if ( $? != 0 ) {
badprint "failed to execute: $req";
badprint "FAIL Execute SQL / return code: $?";
debugprint "CMD : $mysqlcmd";
debugprint "OPTIONS: $mysqllogin";
debugprint `$mysqlcmd $mysqllogin -Bse "$req" 2>&1`;
#exit $?;
}
debugprint "select_array: return code : $?";
chomp(@result);
return @result;
}
# MySQL Request one
sub select_one {
my $req = shift;
debugprint "PERFORM: $req ";
my $result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>/dev/null`;
if ( $? != 0 ) {
badprint "failed to execute: $req";
badprint "FAIL Execute SQL / return code: $?";
debugprint "CMD : $mysqlcmd";
debugprint "OPTIONS: $mysqllogin";
debugprint `$mysqlcmd $mysqllogin -Bse "$req" 2>&1`;
#exit $?;
}
debugprint "select_array: return code : $?";
chomp($result);
return $result;
}
sub get_tuning_info {
my @infoconn = select_array "\\s";
my ( $tkey, $tval );
@infoconn =
grep { !/Threads:/ and !/Connection id:/ and !/pager:/ and !/Using/ }
@infoconn;
foreach my $line (@infoconn) {
if ( $line =~ /\s*(.*):\s*(.*)/ ) {
debugprint "$1 => $2";
$tkey = $1;
$tval = $2;
chomp($tkey);
chomp($tval);
$result{'MySQL Client'}{$tkey} = $tval;
}
}
$result{'MySQL Client'}{'Client Path'} = $mysqlcmd;
$result{'MySQL Client'}{'Admin Path'} = $mysqladmincmd;
$result{'MySQL Client'}{'Authentication Info'} = $mysqllogin;
}
# Populates all of the variable and status hashes
my ( %mystat, %myvar, $dummyselect, %myrepl, %myslaves );
sub arr2hash {
my $href = shift;
my $harr = shift;
my $sep = shift;
$sep = '\s' unless defined($sep);
foreach my $line (@$harr) {
next if ( $line =~ m/^\*\*\*\*\*\*\*/ );
$line =~ /([a-zA-Z_]*)\s*$sep\s*(.*)/;
$$href{$1} = $2;
debugprint "V: $1 = $2";
}
}
sub get_all_vars {
# We need to initiate at least one query so that our data is useable
$dummyselect = select_one "SELECT VERSION()";
if ( not defined($dummyselect) or $dummyselect eq "" ) {
badprint
"You probably doesn't get enough privileges for running MySQLTuner ...";
exit(256);
}
$dummyselect =~ s/(.*?)\-.*/$1/;
debugprint "VERSION: " . $dummyselect . "";
$result{'MySQL Client'}{'Version'} = $dummyselect;
my @mysqlvarlist = select_array("SHOW VARIABLES");
push( @mysqlvarlist, select_array("SHOW GLOBAL VARIABLES") );
arr2hash( \%myvar, \@mysqlvarlist );
$result{'Variables'} = \%myvar;
my @mysqlstatlist = select_array("SHOW STATUS");
push( @mysqlstatlist, select_array("SHOW GLOBAL STATUS") );
arr2hash( \%mystat, \@mysqlstatlist );
$result{'Status'} = \%mystat;
$myvar{'have_galera'} = "NO";
if ( defined( $myvar{'wsrep_provider_options'} )
&& $myvar{'wsrep_provider_options'} ne "" )
{
$myvar{'have_galera'} = "YES";
debugprint "Galera options: " . $myvar{'wsrep_provider_options'};
}
# Workaround for MySQL bug #59393 wrt. ignore-builtin-innodb
if ( ( $myvar{'ignore_builtin_innodb'} || "" ) eq "ON" ) {
$myvar{'have_innodb'} = "NO";
}
# Support GTID MODE FOR MARIADB
# Issue MariaDB GTID mode #272
$myvar{'gtid_mode'} = $myvar{'gtid_strict_mode'}
if ( defined( $myvar{'gtid_strict_mode'} ) );
$myvar{'have_threadpool'} = "NO";
if ( defined( $myvar{'thread_pool_size'} )
and $myvar{'thread_pool_size'} > 0 )
{
$myvar{'have_threadpool'} = "YES";
}
# have_* for engines is deprecated and will be removed in MySQL 5.6;
# check SHOW ENGINES and set corresponding old style variables.
# Also works around MySQL bug #59393 wrt. skip-innodb
my @mysqlenginelist = select_array "SHOW ENGINES";
foreach my $line (@mysqlenginelist) {
if ( $line =~ /^([a-zA-Z_]+)\s+(\S+)/ ) {
my $engine = lc($1);
if ( $engine eq "federated" || $engine eq "blackhole" ) {
$engine .= "_engine";
}
elsif ( $engine eq "berkeleydb" ) {
$engine = "bdb";
}
my $val = ( $2 eq "DEFAULT" ) ? "YES" : $2;
$myvar{"have_$engine"} = $val;
$result{'Storage Engines'}{$engine} = $2;
}
}
debugprint Dumper(@mysqlenginelist);
my @mysqlslave = select_array("SHOW SLAVE STATUS\\G");
arr2hash( \%myrepl, \@mysqlslave, ':' );
$result{'Replication'}{'Status'} = \%myrepl;
my @mysqlslaves = select_array "SHOW SLAVE HOSTS";
my @lineitems = ();
foreach my $line (@mysqlslaves) {
debugprint "L: $line ";
@lineitems = split /\s+/, $line;
$myslaves{ $lineitems[0] } = $line;
$result{'Replication'}{'Slaves'}{ $lineitems[0] } = $lineitems[4];
}
}
sub remove_cr {
return map {
my $line = $_;
$line =~ s/\n$//g;
$line =~ s/^\s+$//g;
$line;
} @_;
}
sub remove_empty {
grep { $_ ne '' } @_;
}
sub grep_file_contents {
my $file = shift;
my $patt;
}
sub get_file_contents {
my $file = shift;
open( my $fh, "<", $file ) or die "Can't open $file for read: $!";
my @lines = <$fh>;
close $fh or die "Cannot close $file: $!";
@lines = remove_cr @lines;
return @lines;
}
sub get_basic_passwords {
return get_file_contents(shift);
}
sub log_file_recommandations {
subheaderprint "Log file Recommendations";
infoprint "Log file: "
. $myvar{'log_error'} . "("
. hr_bytes_rnd( ( stat $myvar{'log_error'} )[7] ) . ")";
if ( -f "$myvar{'log_error'}" ) {
goodprint "Log file $myvar{'log_error'} exists";
}
else {
badprint "Log file $myvar{'log_error'} doesn't exist";
}
if ( -r "$myvar{'log_error'}" ) {
goodprint "Log file $myvar{'log_error'} is readable.";
}
else {
badprint "Log file $myvar{'log_error'} isn't readable.";
return;
}
if ( ( stat $myvar{'log_error'} )[7] > 0 ) {
goodprint "Log file $myvar{'log_error'} is not empty";
}
else {
badprint "Log file $myvar{'log_error'} is empty";
}
if ( ( stat $myvar{'log_error'} )[7] < 32 * 1024 * 1024 ) {
goodprint "Log file $myvar{'log_error'} is smaller than 32 Mb";
}
else {
badprint "Log file $myvar{'log_error'} is bigger than 32 Mb";
push @generalrec,
$myvar{'log_error'}
. " is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!";
}
my @log_content = get_file_contents( $myvar{'log_error'} );
my $numLi = 0;
my $nbWarnLog = 0;
my $nbErrLog = 0;
my @lastShutdowns;
my @lastStarts;
foreach my $logLi (@log_content) {
$numLi++;
debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i;
$nbErrLog++ if $logLi =~ /error/i;
$nbWarnLog++ if $logLi =~ /warning/i;
push @lastShutdowns, $logLi
if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i;
push @lastStarts, $logLi if $logLi =~ /ready for connections/;
}
if ( $nbWarnLog > 0 ) {
badprint "$myvar{'log_error'} contains $nbWarnLog warning(s).";
push @generalrec,
"Control warning line(s) into $myvar{'log_error'} file";
}
else {
goodprint "$myvar{'log_error'} doesn't contain any warning.";
}
if ( $nbErrLog > 0 ) {
badprint "$myvar{'log_error'} contains $nbErrLog error(s).";
push @generalrec, "Control error line(s) into $myvar{'log_error'} file";
}
else {
goodprint "$myvar{'log_error'} doesn't contain any error.";
}
infoprint scalar @lastStarts . " start(s) detected in $myvar{'log_error'}";
my $nStart = 0;
my $nEnd = 10;
if ( scalar @lastStarts < $nEnd ) {
$nEnd = scalar @lastStarts;
}
for my $startd ( reverse @lastStarts[ -$nEnd .. -1 ] ) {
$nStart++;
infoprint "$nStart) $startd";
}
infoprint scalar @lastShutdowns
. " shutdown(s) detected in $myvar{'log_error'}";
$nStart = 0;
$nEnd = 10;
if ( scalar @lastShutdowns < $nEnd ) {
$nEnd = scalar @lastShutdowns;
}
for my $shutd ( reverse @lastShutdowns[ -$nEnd .. -1 ] ) {
$nStart++;
infoprint "$nStart) $shutd";
}
#exit 0;
}
sub cve_recommendations {
subheaderprint "CVE Security Recommendations";
unless ( defined( $opt{cvefile} ) && -f "$opt{cvefile}" ) {
infoprint "Skipped due to --cvefile option undefined";
return;
}
#$mysqlvermajor=10;
#$mysqlverminor=1;
#$mysqlvermicro=17;
#prettyprint "Look for related CVE for $myvar{'version'} or lower in $opt{cvefile}";
my $cvefound = 0;
open( my $fh, "<", $opt{cvefile} )
or die "Can't open $opt{cvefile} for read: $!";
while ( my $cveline = <$fh> ) {
my @cve = split( ';', $cveline );
debugprint
"Comparing $mysqlvermajor\.$mysqlverminor\.$mysqlvermicro with $cve[1]\.$cve[2]\.$cve[3] : "
. ( mysql_version_le( $cve[1], $cve[2], $cve[3] ) ? '<=' : '>' );
# Avoid not major/minor version corresponding CVEs
next
unless ( int( $cve[1] ) == $mysqlvermajor
&& int( $cve[2] ) == $mysqlverminor );
if ( int( $cve[3] ) >= $mysqlvermicro ) {
badprint "$cve[4](<= $cve[1]\.$cve[2]\.$cve[3]) : $cve[6]";
$result{'CVE'}{'List'}{$cvefound} =
"$cve[4](<= $cve[1]\.$cve[2]\.$cve[3]) : $cve[6]";
$cvefound++;
}
}
close $fh or die "Cannot close $opt{cvefile}: $!";
$result{'CVE'}{'nb'} = $cvefound;
my $cve_warning_notes = "";
if ( $cvefound == 0 ) {
goodprint "NO SECURITY CVE FOUND FOR YOUR VERSION";
return;
}
if ( $mysqlvermajor eq 5 and $mysqlverminor eq 5 ) {
infoprint
"False positive CVE(s) for MySQL and MariaDB 5.5.x can be found.";
infoprint "Check careful each CVE for those particular versions";
}
badprint $cvefound . " CVE(s) found for your MySQL release.";
push( @generalrec,
$cvefound
. " CVE(s) found for your MySQL release. Consider upgrading your version !"
);
}
sub get_opened_ports {
my @opened_ports = `netstat -ltn`;
@opened_ports = map {
my $v = $_;
$v =~ s/.*:(\d+)\s.*$/$1/;
$v =~ s/\D//g;
$v;
} @opened_ports;
@opened_ports = sort { $a <=> $b } grep { !/^$/ } @opened_ports;
debugprint Dumper \@opened_ports;
$result{'Network'}{'TCP Opened'} = \@opened_ports;
return @opened_ports;
}
sub is_open_port {
my $port = shift;
if ( grep { /^$port$/ } get_opened_ports ) {
return 1;
}
return 0;
}
sub get_process_memory {
my $pid = shift;
my @mem = `ps -p $pid -o rss`;
return 0 if scalar @mem != 2;
return $mem[1] * 1024;
}
sub get_other_process_memory {
my @procs = `ps eaxo pid,command`;
@procs = map {
my $v = $_;
$v =~ s/.*PID.*//;
$v =~ s/.*mysqld.*//;
$v =~ s/.*\[.*\].*//;
$v =~ s/^\s+$//g;
$v =~ s/.*PID.*CMD.*//;
$v =~ s/.*systemd.*//;
$v =~ s/\s*?(\d+)\s*.*/$1/g;
$v;
} @procs;
@procs = remove_cr @procs;
@procs = remove_empty @procs;
my $totalMemOther = 0;
map { $totalMemOther += get_process_memory($_); } @procs;
return $totalMemOther;
}
sub get_os_release {
if ( -f "/etc/lsb-release" ) {
my @info_release = get_file_contents "/etc/lsb-release";
my $os_relase = $info_release[3];
$os_relase =~ s/.*="//;
$os_relase =~ s/"$//;
return $os_relase;
}
if ( -f "/etc/system-release" ) {
my @info_release = get_file_contents "/etc/system-release";
return $info_release[0];
}
if ( -f "/etc/os-release" ) {
my @info_release = get_file_contents "/etc/os-release";
my $os_relase = $info_release[0];
$os_relase =~ s/.*="//;
$os_relase =~ s/"$//;
return $os_relase;
}
if ( -f "/etc/issue" ) {
my @info_release = get_file_contents "/etc/issue";
my $os_relase = $info_release[0];
$os_relase =~ s/\s+\\n.*//;
return $os_relase;
}
return "Unknown OS release";
}
sub get_fs_info {
my @sinfo = `df -P | grep '%'`;
my @iinfo = `df -Pi| grep '%'`;
shift @iinfo;
@sinfo = map {
my $v = $_;
$v =~ s/.*\s(\d+)%\s+(.*)/$1\t$2/g;
$v;
} @sinfo;
foreach my $info (@sinfo) {
next if $info =~ m{(\d+)\t/(run|dev|sys|proc)($|/)};
if ( $info =~ /(\d+)\t(.*)/ ) {
if ( $1 > 85 ) {
badprint "mount point $2 is using $1 % total space";
push( @generalrec, "Add some space to $2 mountpoint." );
}
else {
infoprint "mount point $2 is using $1 % of total space";
}
$result{'Filesystem'}{'Space Pct'}{$2} = $1;
}
}
@iinfo = map {
my $v = $_;
$v =~ s/.*\s(\d+)%\s+(.*)/$1\t$2/g;
$v;
} @iinfo;
foreach my $info (@iinfo) {
next if $info =~ m{(\d+)\t/(run|dev|sys|proc)($|/)};
if ( $info =~ /(\d+)\t(.*)/ ) {
if ( $1 > 85 ) {
badprint "mount point $2 is using $1 % of max allowed inodes";
push( @generalrec,
"Cleanup files from $2 mountpoint or reformat you filesystem."
);
}
else {
infoprint "mount point $2 is using $1 % of max allowed inodes";
}
$result{'Filesystem'}{'Inode Pct'}{$2} = $1;
}
}
}
sub merge_hash {
my $h1 = shift;
my $h2 = shift;
my %result = {};
foreach my $substanceref ( $h1, $h2 ) {
while ( my ( $k, $v ) = each %$substanceref ) {
next if ( exists $result{$k} );
$result{$k} = $v;
}
}
return \%result;
}
sub is_virtual_machine {
my $isVm = `grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo`;
return ( $isVm == 0 ? 0 : 1 );
}
sub infocmd {
my $cmd = "@_";
debugprint "CMD: $cmd";
my @result = `$cmd`;
@result = remove_cr @result;
for my $l (@result) {
infoprint "$l";
}
}
sub infocmd_tab {
my $cmd = "@_";
debugprint "CMD: $cmd";
my @result = `$cmd`;
@result = remove_cr @result;
for my $l (@result) {
infoprint "\t$l";
}
}
sub infocmd_one {
my $cmd = "@_";
my @result = `$cmd`;
@result = remove_cr @result;
return join ', ', @result;
}
sub get_kernel_info {
my @params = (
'fs.aio-max-nr', 'fs.aio-nr',
'fs.file-max', 'sunrpc.tcp_fin_timeout',
'sunrpc.tcp_max_slot_table_entries', 'sunrpc.tcp_slot_table_entries',
'vm.swappiness'
);
infoprint "Information about kernel tuning:";
foreach my $param (@params) {
infocmd_tab("sysctl $param 2>/dev/null");
$result{'OS'}{'Config'}{$param} = `sysctl -n $param 2>/dev/null`;
}
if ( `sysctl -n vm.swappiness` > 10 ) {
badprint
"Swappiness is > 10, please consider having a value lower than 10";
push @generalrec, "setup swappiness lower or equals to 10";
push @adjvars, 'vm.swappiness <= 10 (echo 10 > /proc/sys/vm/swappiness)';
}
else {
infoprint "Swappiness is < 10.";
}
# only if /proc/sys/sunrpc exists
my $tcp_slot_entries =
`sysctl -n sunrpc.tcp_slot_table_entries 2>/dev/null`;
if ( -f "/proc/sys/sunrpc"
and ( $tcp_slot_entries eq '' or $tcp_slot_entries < 100 ) )
{
badprint
"Initial TCP slot entries is < 1M, please consider having a value greater than 100";
push @generalrec, "setup Initial TCP slot entries greater than 100";
push @adjvars,
'sunrpc.tcp_slot_table_entries > 100 (echo 128 > /proc/sys/sunrpc/tcp_slot_table_entries)';
}
else {
infoprint "TCP slot entries is > 100.";
}
if ( `sysctl -n fs.aio-max-nr` < 1000000 ) {
badprint
"Max running total of the number of events is < 1M, please consider having a value greater than 1M";
push @generalrec, "setup Max running number events greater than 1M";
push @adjvars,
'fs.aio-max-nr > 1M (echo 1048576 > /proc/sys/fs/aio-max-nr)';
}
else {
infoprint "Max Number of AIO events is > 1M.";
}
}
sub get_system_info {
$result{'OS'}{'Release'} = get_os_release();
infoprint get_os_release;
if (is_virtual_machine) {
infoprint "Machine type : Virtual machine";
$result{'OS'}{'Virtual Machine'} = 'YES';
}
else {
infoprint "Machine type : Physical machine";
$result{'OS'}{'Virtual Machine'} = 'NO';
}
$result{'Network'}{'Connected'} = 'NO';
`ping -c 1 ipecho.net &>/dev/null`;
my $isConnected = $?;
if ( $? == 0 ) {
infoprint "Internet : Connected";
$result{'Network'}{'Connected'} = 'YES';
}
else {
badprint "Internet : Disconnected";
}
$result{'OS'}{'NbCore'} = cpu_cores;
infoprint "Number of Core CPU : " . cpu_cores;
$result{'OS'}{'Type'} = `uname -o`;
infoprint "Operating System Type : " . infocmd_one "uname -o";
$result{'OS'}{'Kernel'} = `uname -r`;
infoprint "Kernel Release : " . infocmd_one "uname -r";
$result{'OS'}{'Hostname'} = `hostname`;
$result{'Network'}{'Internal Ip'} = `hostname -I`;
infoprint "Hostname : " . infocmd_one "hostname";
infoprint "Network Cards : ";
infocmd_tab "ifconfig| grep -A1 mtu";
infoprint "Internal IP : " . infocmd_one "hostname -I";
my $httpcli = get_http_cli();
infoprint "HTTP client found: $httpcli" if defined $httpcli;
my $ext_ip = "";
if ( $httpcli =~ /curl$/ ) {
$ext_ip = infocmd_one "$httpcli -m 3 ipecho.net/plain";
}
elsif ( $httpcli =~ /wget$/ ) {
$ext_ip = infocmd_one "$httpcli -t 1 -T 3 -q -O - ipecho.net/plain";
}
infoprint "External IP : " . $ext_ip;
$result{'Network'}{'External Ip'} = $ext_ip;
badprint
"External IP : Can't check because of Internet connectivity"
unless defined($httpcli);
infoprint "Name Servers : "
. infocmd_one "grep 'nameserver' /etc/resolv.conf \| awk '{print \$2}'";
infoprint "Logged In users : ";
infocmd_tab "who";
$result{'OS'}{'Logged users'} = `who`;
infoprint "Ram Usages in Mb : ";
infocmd_tab "free -m | grep -v +";
$result{'OS'}{'Free Memory RAM'} = `free -m | grep -v +`;
infoprint "Load Average : ";
infocmd_tab "top -n 1 -b | grep 'load average:'";
$result{'OS'}{'Load Average'} = `top -n 1 -b | grep 'load average:'`;
#infoprint "System Uptime Days/(HH:MM) : `uptime | awk '{print $3,$4}' | cut -f1 -d,`";
}
sub system_recommendations {
return if ( $opt{sysstat} == 0 );
subheaderprint "System Linux Recommendations";
my $os = `uname`;
unless ( $os =~ /Linux/i ) {
infoprint "Skipped due to non Linux server";
return;
}
prettyprint "Look for related Linux system recommendations";
#prettyprint '-'x78;
get_system_info();
my $omem = get_other_process_memory;
infoprint "User process except mysqld used "
. hr_bytes_rnd($omem) . " RAM.";
if ( ( 0.15 * $physical_memory ) < $omem ) {
badprint
"Other user process except mysqld used more than 15% of total physical memory "
. percentage( $omem, $physical_memory ) . "% ("
. hr_bytes_rnd($omem) . " / "
. hr_bytes_rnd($physical_memory) . ")";
push( @generalrec,
"Consider stopping or dedicate server for additional process other than mysqld."
);
push( @adjvars,
"DON'T APPLY SETTINGS BECAUSE THERE ARE TOO MANY PROCESSES RUNNING ON THIS SERVER. OOM KILL CAN OCCUR!"
);
}
else {
infoprint
"Other user process except mysqld used less than 15% of total physical memory "
. percentage( $omem, $physical_memory ) . "% ("
. hr_bytes_rnd($omem) . " / "
. hr_bytes_rnd($physical_memory) . ")";
}
if ( $opt{'maxportallowed'} > 0 ) {
my @opened_ports = get_opened_ports;
infoprint "There is "
. scalar @opened_ports
. " listening port(s) on this server.";
if ( scalar(@opened_ports) > $opt{'maxportallowed'} ) {
badprint "There is too many listening ports: "
. scalar(@opened_ports)
. " opened > "
. $opt{'maxportallowed'}
. "allowed.";
push( @generalrec,
"Consider dedicating a server for your database installation with less services running on !"
);
}
else {
goodprint "There is less than "
. $opt{'maxportallowed'}
. " opened ports on this server.";
}
}
foreach my $banport (@banned_ports) {
if ( is_open_port($banport) ) {
badprint "Banned port: $banport is opened..";
push( @generalrec,
"Port $banport is opened. Consider stopping program handling this port."
);
}
else {
goodprint "$banport is not opened.";
}
}
get_fs_info;
get_kernel_info;
}
sub security_recommendations {
subheaderprint "Security Recommendations";
if ( $opt{skippassword} eq 1 ) {
infoprint "Skipped due to --skippassword option";
return;
}
my $PASS_COLUMN_NAME = 'password';
if ( $myvar{'version'} =~ /5.7/ ) {
$PASS_COLUMN_NAME = 'authentication_string';
}
debugprint "Password column = $PASS_COLUMN_NAME";
# Looking for Anonymous users
my @mysqlstatlist = select_array
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE TRIM(USER) = '' OR USER IS NULL";
debugprint Dumper \@mysqlstatlist;
#exit 0;
if (@mysqlstatlist) {
foreach my $line ( sort @mysqlstatlist ) {
chomp($line);
badprint "User '" . $line . "' is an anonymous account.";
}
push( @generalrec,
"Remove Anonymous User accounts - there are "
. scalar(@mysqlstatlist)
. " anonymous accounts." );
}
else {
goodprint "There are no anonymous accounts for any database users";
}
if ( mysql_version_le( 5, 1 ) ) {
badprint "No more password checks for MySQL version <=5.1";
badprint "MySQL version <=5.1 are deprecated and end of support.";
return;
}
# Looking for Empty Password
if ( mysql_version_ge( 5, 5 ) ) {
@mysqlstatlist = select_array
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE ($PASS_COLUMN_NAME = '' OR $PASS_COLUMN_NAME IS NULL) AND plugin NOT IN ('unix_socket', 'win_socket')";
}
else {
@mysqlstatlist = select_array
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE ($PASS_COLUMN_NAME = '' OR $PASS_COLUMN_NAME IS NULL)";
}
if (@mysqlstatlist) {
foreach my $line ( sort @mysqlstatlist ) {
chomp($line);
badprint "User '" . $line . "' has no password set.";
}
push( @generalrec,
"Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'\@'SpecificDNSorIp' = PASSWORD('secure_password'); )"
);
}
else {
goodprint "All database users have passwords assigned";
}
if ( mysql_version_ge( 5, 7 ) ) {
my $valPlugin = select_one(
"select count(*) from information_schema.plugins where PLUGIN_NAME='validate_password' AND PLUGIN_STATUS='ACTIVE'"
);
if ( $valPlugin >= 1 ) {
infoprint
"Bug #80860 MySQL 5.7: Avoid testing password when validate_password is activated";
return;
}
}
# Looking for User with user/ uppercase /capitalise user as password
@mysqlstatlist = select_array
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(user) OR CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(UPPER(user)) OR CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(CONCAT(UPPER(LEFT(User, 1)), SUBSTRING(User, 2, LENGTH(User))))";
if (@mysqlstatlist) {
foreach my $line ( sort @mysqlstatlist ) {
chomp($line);
badprint "User '" . $line . "' has user name as password.";
}
push( @generalrec,
"Set up a Secure Password for user\@host ( SET PASSWORD FOR 'user'\@'SpecificDNSorIp' = PASSWORD('secure_password'); )"
);
}
@mysqlstatlist = select_array
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE HOST='%'";
if (@mysqlstatlist) {
foreach my $line ( sort @mysqlstatlist ) {
chomp($line);
badprint "User '" . $line . "' hasn't specific host restriction.";
}
push( @generalrec,
"Restrict Host for user\@% to user\@SpecificDNSorIp" );
}
unless ( -f $basic_password_files ) {
badprint "There is no basic password file list!";
return;
}
my @passwords = get_basic_passwords $basic_password_files;
infoprint "There are "
. scalar(@passwords)
. " basic passwords in the list.";
my $nbins = 0;
my $passreq;
if (@passwords) {
my $nbInterPass = 0;
foreach my $pass (@passwords) {
$nbInterPass++;
$pass =~ s/\s//g;
$pass =~ s/\'/\\\'/g;
chomp($pass);
# Looking for User with user/ uppercase /capitalise weak password
@mysqlstatlist =
select_array
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE $PASS_COLUMN_NAME = PASSWORD('"
. $pass
. "') OR $PASS_COLUMN_NAME = PASSWORD(UPPER('"
. $pass
. "')) OR $PASS_COLUMN_NAME = PASSWORD(CONCAT(UPPER(LEFT('"
. $pass
. "', 1)), SUBSTRING('"
. $pass
. "', 2, LENGTH('"
. $pass . "'))))";
debugprint "There is " . scalar(@mysqlstatlist) . " items.";
if (@mysqlstatlist) {
foreach my $line (@mysqlstatlist) {
chomp($line);
badprint "User '" . $line
. "' is using weak password: $pass in a lower, upper or capitalize derivative version.";
$nbins++;
}
}
debugprint "$nbInterPass / " . scalar(@passwords)
if ( $nbInterPass % 1000 == 0 );
}
}
if ( $nbins > 0 ) {
push( @generalrec, $nbins . " user(s) used basic or weak password." );
}
}
sub get_replication_status {
subheaderprint "Replication Metrics";
infoprint "Galera Synchronous replication: " . $myvar{'have_galera'};
if ( scalar( keys %myslaves ) == 0 ) {
infoprint "No replication slave(s) for this server.";
}
else {
infoprint "This server is acting as master for "
. scalar( keys %myslaves )
. " server(s).";
}
if ( scalar( keys %myrepl ) == 0 and scalar( keys %myslaves ) == 0 ) {
infoprint "This is a standalone server.";
return;
}
if ( scalar( keys %myrepl ) == 0 ) {
infoprint "No replication setup for this server.";
return;
}
$result{'Replication'}{'status'} = \%myrepl;
my ($io_running) = $myrepl{'Slave_IO_Running'};
debugprint "IO RUNNING: $io_running ";
my ($sql_running) = $myrepl{'Slave_SQL_Running'};
debugprint "SQL RUNNING: $sql_running ";
my ($seconds_behind_master) = $myrepl{'Seconds_Behind_Master'};
debugprint "SECONDS : $seconds_behind_master ";
if ( defined($io_running)
and ( $io_running !~ /yes/i or $sql_running !~ /yes/i ) )
{
badprint
"This replication slave is not running but seems to be configured.";
}
if ( defined($io_running)
&& $io_running =~ /yes/i
&& $sql_running =~ /yes/i )
{
if ( $myvar{'read_only'} eq 'OFF' ) {
badprint
"This replication slave is running with the read_only option disabled.";
}
else {
goodprint
"This replication slave is running with the read_only option enabled.";
}
if ( $seconds_behind_master > 0 ) {
badprint
"This replication slave is lagging and slave has $seconds_behind_master second(s) behind master host.";
}
else {
goodprint "This replication slave is up to date with master.";
}
}
}
sub validate_mysql_version {
( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) =
$myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/;
$mysqlverminor ||= 0;
$mysqlvermicro ||= 0;
if ( !mysql_version_ge( 5, 1 ) ) {
badprint "Your MySQL version "
. $myvar{'version'}
. " is EOL software! Upgrade soon!";
}
elsif ( ( mysql_version_ge(6) and mysql_version_le(9) )
or mysql_version_ge(12) )
{
badprint "Currently running unsupported MySQL version "
. $myvar{'version'} . "";
}
else {
goodprint "Currently running supported MySQL version "
. $myvar{'version'} . "";
}
}
# Checks if MySQL version is greater than equal to (major, minor, micro)
sub mysql_version_ge {
my ( $maj, $min, $mic ) = @_;
$min ||= 0;
$mic ||= 0;
return
int($mysqlvermajor) > int($maj)
|| ( int($mysqlvermajor) == int($maj) && int($mysqlverminor) > int($min) )
|| ( int($mysqlverminor) == int($min)
&& int($mysqlvermicro) >= int($mic) );
}
# Checks if MySQL version is lower than equal to (major, minor, micro)
sub mysql_version_le {
my ( $maj, $min, $mic ) = @_;
$min ||= 0;
$mic ||= 0;
return
int($mysqlvermajor) < int($maj)
|| ( int($mysqlvermajor) == int($maj) && int($mysqlverminor) < int($min) )
|| ( int($mysqlverminor) == int($min)
&& int($mysqlvermicro) <= int($mic) );
}
# Checks if MySQL micro version is lower than equal to (major, minor, micro)
sub mysql_micro_version_le {
my ( $maj, $min, $mic ) = @_;
return $mysqlvermajor == $maj
&& ( $mysqlverminor == $min
&& $mysqlvermicro <= $mic );
}
# Checks for 32-bit boxes with more than 2GB of RAM
my ($arch);
sub check_architecture {
if ( $doremote eq 1 ) { return; }
if ( `uname` =~ /SunOS/ && `isainfo -b` =~ /64/ ) {
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
elsif ( `uname` !~ /SunOS/ && `uname -m` =~ /64/ ) {
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
elsif ( `uname` =~ /AIX/ && `bootinfo -K` =~ /64/ ) {
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
elsif ( `uname` =~ /NetBSD|OpenBSD/ && `sysctl -b hw.machine` =~ /64/ ) {
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
elsif ( `uname` =~ /FreeBSD/ && `sysctl -b hw.machine_arch` =~ /64/ ) {
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /Power Macintosh/ ) {
# Darwin box.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu1228.15.4~1/RELEASE_PPC Power Macintosh
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) {
# Darwin gibas.local 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
$arch = 64;
goodprint "Operating on 64-bit architecture";
}
else {
$arch = 32;
if ( $physical_memory > 2147483648 ) {
badprint
"Switch to 64-bit OS - MySQL cannot currently use all of your RAM";
}
else {
goodprint "Operating on 32-bit architecture with less than 2GB RAM";
}
}
$result{'OS'}{'Architecture'} = "$arch bits";
}
# Start up a ton of storage engine counts/statistics
my ( %enginestats, %enginecount, $fragtables );
sub check_storage_engines {
if ( $opt{skipsize} eq 1 ) {
subheaderprint "Storage Engine Statistics";
infoprint "Skipped due to --skipsize option";
return;
}
subheaderprint "Storage Engine Statistics";
my $engines;
if ( mysql_version_ge( 5, 5 ) ) {
my @engineresults = select_array
"SELECT ENGINE,SUPPORT FROM information_schema.ENGINES ORDER BY ENGINE ASC";
foreach my $line (@engineresults) {
my ( $engine, $engineenabled );
( $engine, $engineenabled ) = $line =~ /([a-zA-Z_]*)\s+([a-zA-Z]+)/;
$result{'Engine'}{$engine}{'Enabled'} = $engineenabled;
$engines .=
( $engineenabled eq "YES" || $engineenabled eq "DEFAULT" )
? greenwrap "+" . $engine . " "
: redwrap "-" . $engine . " ";
}
}
elsif ( mysql_version_ge( 5, 1, 5 ) ) {
my @engineresults = select_array
"SELECT ENGINE,SUPPORT FROM information_schema.ENGINES WHERE ENGINE NOT IN ('performance_schema','MyISAM','MERGE','MEMORY') ORDER BY ENGINE ASC";
foreach my $line (@engineresults) {
my ( $engine, $engineenabled );
( $engine, $engineenabled ) = $line =~ /([a-zA-Z_]*)\s+([a-zA-Z]+)/;
$result{'Engine'}{$engine}{'Enabled'} = $engineenabled;
$engines .=
( $engineenabled eq "YES" || $engineenabled eq "DEFAULT" )
? greenwrap "+" . $engine . " "
: redwrap "-" . $engine . " ";
}
}
else {
$engines .=
( defined $myvar{'have_archive'} && $myvar{'have_archive'} eq "YES" )
? greenwrap "+Archive "
: redwrap "-Archive ";
$engines .=
( defined $myvar{'have_bdb'} && $myvar{'have_bdb'} eq "YES" )
? greenwrap "+BDB "
: redwrap "-BDB ";
$engines .=
( defined $myvar{'have_federated_engine'}
&& $myvar{'have_federated_engine'} eq "YES" )
? greenwrap "+Federated "
: redwrap "-Federated ";
$engines .=
( defined $myvar{'have_innodb'} && $myvar{'have_innodb'} eq "YES" )
? greenwrap "+InnoDB "
: redwrap "-InnoDB ";
$engines .=
( defined $myvar{'have_isam'} && $myvar{'have_isam'} eq "YES" )
? greenwrap "+ISAM "
: redwrap "-ISAM ";
$engines .=
( defined $myvar{'have_ndbcluster'}
&& $myvar{'have_ndbcluster'} eq "YES" )
? greenwrap "+NDBCluster "
: redwrap "-NDBCluster ";
}
my @dblist = grep { $_ ne 'lost+found' } select_array "SHOW DATABASES";
$result{'Databases'}{'List'} = [@dblist];
infoprint "Status: $engines";
if ( mysql_version_ge( 5, 1, 5 ) ) {
# MySQL 5 servers can have table sizes calculated quickly from information schema
my @templist = select_array
"SELECT ENGINE,SUM(DATA_LENGTH+INDEX_LENGTH),COUNT(ENGINE),SUM(DATA_LENGTH),SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;";
my ( $engine, $size, $count, $dsize, $isize );
foreach my $line (@templist) {
( $engine, $size, $count, $dsize, $isize ) =
$line =~ /([a-zA-Z_]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
debugprint "Engine Found: $engine";
next unless ( defined($engine) );
$size = 0 unless defined($size);
$isize = 0 unless defined($isize);
$dsize = 0 unless defined($dsize);
$count = 0 unless defined($count);
$enginestats{$engine} = $size;
$enginecount{$engine} = $count;
$result{'Engine'}{$engine}{'Table Number'} = $count;
$result{'Engine'}{$engine}{'Total Size'} = $size;
$result{'Engine'}{$engine}{'Data Size'} = $dsize;
$result{'Engine'}{$engine}{'Index Size'} = $isize;
}
my $not_innodb = '';
if ( not defined $result{'Variables'}{'innodb_file_per_table'} ) {
$not_innodb = "AND NOT ENGINE='InnoDB'";
}
elsif ( $result{'Variables'}{'innodb_file_per_table'} eq 'OFF' ) {
$not_innodb = "AND NOT ENGINE='InnoDB'";
}
$result{'Tables'}{'Fragmented tables'} =
[ select_array
"SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),DATA_FREE FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND DATA_FREE*100/(DATA_LENGTH+INDEX_LENGTH+DATA_FREE) > 10 AND NOT ENGINE='MEMORY' $not_innodb"
];
$fragtables = scalar @{ $result{'Tables'}{'Fragmented tables'} };
}
else {
# MySQL < 5 servers take a lot of work to get table sizes
my @tblist;
# Now we build a database list, and loop through it to get storage engine stats for tables
foreach my $db (@dblist) {
chomp($db);
if ( $db eq "information_schema"
or $db eq "performance_schema"
or $db eq "mysql"
or $db eq "lost+found" )
{
next;
}
my @ixs = ( 1, 6, 9 );
if ( !mysql_version_ge( 4, 1 ) ) {
# MySQL 3.23/4.0 keeps Data_Length in the 5th (0-based) column
@ixs = ( 1, 5, 8 );
}
push( @tblist,
map { [ (split)[@ixs] ] }
select_array "SHOW TABLE STATUS FROM \\\`$db\\\`" );
}
# Parse through the table list to generate storage engine counts/statistics
$fragtables = 0;
foreach my $tbl (@tblist) {
debugprint "Data dump " . Dumper(@$tbl);
my ( $engine, $size, $datafree ) = @$tbl;
next if $engine eq 'NULL';
$size = 0 if $size eq 'NULL';
$datafree = 0 if $datafree eq 'NULL';
if ( defined $enginestats{$engine} ) {
$enginestats{$engine} += $size;
$enginecount{$engine} += 1;
}
else {
$enginestats{$engine} = $size;
$enginecount{$engine} = 1;
}
if ( $datafree > 0 ) {
$fragtables++;
}
}
}
while ( my ( $engine, $size ) = each(%enginestats) ) {
infoprint "Data in $engine tables: "
. hr_bytes_rnd($size)
. " (Tables: "
. $enginecount{$engine} . ")" . "";
}
# If the storage engine isn't being used, recommend it to be disabled
if ( !defined $enginestats{'InnoDB'}
&& defined $myvar{'have_innodb'}
&& $myvar{'have_innodb'} eq "YES" )
{
badprint "InnoDB is enabled but isn't being used";
push( @generalrec,
"Add skip-innodb to MySQL configuration to disable InnoDB" );
}
if ( !defined $enginestats{'BerkeleyDB'}
&& defined $myvar{'have_bdb'}
&& $myvar{'have_bdb'} eq "YES" )
{
badprint "BDB is enabled but isn't being used";
push( @generalrec,
"Add skip-bdb to MySQL configuration to disable BDB" );
}
if ( !defined $enginestats{'ISAM'}
&& defined $myvar{'have_isam'}
&& $myvar{'have_isam'} eq "YES" )
{
badprint "MYISAM is enabled but isn't being used";
push( @generalrec,
"Add skip-isam to MySQL configuration to disable ISAM (MySQL > 4.1.0)"
);
}
# Fragmented tables
if ( $fragtables > 0 ) {
badprint "Total fragmented tables: $fragtables";
push( @generalrec,
"Run OPTIMIZE TABLE to defragment tables for better performance" );
my $total_free = 0;
foreach my $table_line ( @{ $result{'Tables'}{'Fragmented tables'} } ) {
my ( $table_name, $data_free ) = split( /\s+/, $table_line );
$data_free = 0 if ( !defined($data_free) or $data_free eq '' );
$data_free = $data_free / 1024 / 1024;
$total_free += $data_free;
push( @generalrec,
" OPTIMIZE TABLE `$table_name`; -- can free $data_free MB" );
}
push( @generalrec,
"Total freed space after theses OPTIMIZE TABLE : $total_free Mb" );
}
else {
goodprint "Total fragmented tables: $fragtables";
}
# Auto increments
my %tblist;
# Find the maximum integer
my $maxint = select_one "SELECT ~0";
$result{'MaxInt'} = $maxint;
# Now we use a database list, and loop through it to get storage engine stats for tables
foreach my $db (@dblist) {
chomp($db);
if ( !$tblist{$db} ) {
$tblist{$db} = ();
}
if ( $db eq "information_schema" ) { next; }
my @ia = ( 0, 10 );
if ( !mysql_version_ge( 4, 1 ) ) {
# MySQL 3.23/4.0 keeps Data_Length in the 5th (0-based) column
@ia = ( 0, 9 );
}
push(
@{ $tblist{$db} },
map { [ (split)[@ia] ] }
select_array "SHOW TABLE STATUS FROM \\\`$db\\\`"
);
}
my @dbnames = keys %tblist;
foreach my $db (@dbnames) {
foreach my $tbl ( @{ $tblist{$db} } ) {
my ( $name, $autoincrement ) = @$tbl;
if ( $autoincrement =~ /^\d+?$/ ) {
my $percent = percentage( $autoincrement, $maxint );
$result{'PctAutoIncrement'}{"$db.$name"} = $percent;
if ( $percent >= 75 ) {
badprint
"Table '$db.$name' has an autoincrement value near max capacity ($percent%)";
}
}
}
}
}
my %mycalc;
sub calculations {
if ( $mystat{'Questions'} < 1 ) {
badprint
"Your server has not answered any queries - cannot continue...";
exit 2;
}
# Per-thread memory
if ( mysql_version_ge(4) ) {
$mycalc{'per_thread_buffers'} =
$myvar{'read_buffer_size'} +
$myvar{'read_rnd_buffer_size'} +
$myvar{'sort_buffer_size'} +
$myvar{'thread_stack'} +
$myvar{'join_buffer_size'};
}
else {
$mycalc{'per_thread_buffers'} =
$myvar{'record_buffer'} +
$myvar{'record_rnd_buffer'} +
$myvar{'sort_buffer'} +
$myvar{'thread_stack'} +
$myvar{'join_buffer_size'};
}
$mycalc{'total_per_thread_buffers'} =
$mycalc{'per_thread_buffers'} * $myvar{'max_connections'};
$mycalc{'max_total_per_thread_buffers'} =
$mycalc{'per_thread_buffers'} * $mystat{'Max_used_connections'};
# Server-wide memory
$mycalc{'max_tmp_table_size'} =
( $myvar{'tmp_table_size'} > $myvar{'max_heap_table_size'} )
? $myvar{'max_heap_table_size'}
: $myvar{'tmp_table_size'};
$mycalc{'server_buffers'} =
$myvar{'key_buffer_size'} + $mycalc{'max_tmp_table_size'};
$mycalc{'server_buffers'} +=
( defined $myvar{'innodb_buffer_pool_size'} )
? $myvar{'innodb_buffer_pool_size'}
: 0;
$mycalc{'server_buffers'} +=
( defined $myvar{'innodb_additional_mem_pool_size'} )
? $myvar{'innodb_additional_mem_pool_size'}
: 0;
$mycalc{'server_buffers'} +=
( defined $myvar{'innodb_log_buffer_size'} )
? $myvar{'innodb_log_buffer_size'}
: 0;
$mycalc{'server_buffers'} +=
( defined $myvar{'query_cache_size'} ) ? $myvar{'query_cache_size'} : 0;
$mycalc{'server_buffers'} +=
( defined $myvar{'aria_pagecache_buffer_size'} )
? $myvar{'aria_pagecache_buffer_size'}
: 0;
# Global memory
# Max used memory is memory used by MySQL based on Max_used_connections
# This is the max memory used theorically calculated with the max concurrent connection number reached by mysql
$mycalc{'max_used_memory'} =
$mycalc{'server_buffers'} +
$mycalc{"max_total_per_thread_buffers"} +
get_pf_memory() +
get_gcache_memory();
$mycalc{'pct_max_used_memory'} =
percentage( $mycalc{'max_used_memory'}, $physical_memory );
# Total possible memory is memory needed by MySQL based on max_connections
# This is the max memory MySQL can theorically used if all connections allowed has opened by mysql
$mycalc{'max_peak_memory'} =
$mycalc{'server_buffers'} +
$mycalc{'total_per_thread_buffers'} +
get_pf_memory() +
get_gcache_memory();
$mycalc{'pct_max_physical_memory'} =
percentage( $mycalc{'max_peak_memory'}, $physical_memory );
debugprint "Max Used Memory: "
. hr_bytes( $mycalc{'max_used_memory'} ) . "";
debugprint "Max Used Percentage RAM: "
. $mycalc{'pct_max_used_memory'} . "%";
debugprint "Max Peak Memory: "
. hr_bytes( $mycalc{'max_peak_memory'} ) . "";
debugprint "Max Peak Percentage RAM: "
. $mycalc{'pct_max_physical_memory'} . "%";
# Slow queries
$mycalc{'pct_slow_queries'} =
int( ( $mystat{'Slow_queries'} / $mystat{'Questions'} ) * 100 );
# Connections
$mycalc{'pct_connections_used'} = int(
( $mystat{'Max_used_connections'} / $myvar{'max_connections'} ) * 100 );
$mycalc{'pct_connections_used'} =
( $mycalc{'pct_connections_used'} > 100 )
? 100
: $mycalc{'pct_connections_used'};
# Aborted Connections
$mycalc{'pct_connections_aborted'} =
percentage( $mystat{'Aborted_connects'}, $mystat{'Connections'} );
debugprint "Aborted_connects: " . $mystat{'Aborted_connects'} . "";
debugprint "Connections: " . $mystat{'Connections'} . "";
debugprint "pct_connections_aborted: "
. $mycalc{'pct_connections_aborted'} . "";
# Key buffers
if ( mysql_version_ge( 4, 1 ) && $myvar{'key_buffer_size'} > 0 ) {
$mycalc{'pct_key_buffer_used'} = sprintf(
"%.1f",
(
1 - (
(
$mystat{'Key_blocks_unused'} *
$myvar{'key_cache_block_size'}
) / $myvar{'key_buffer_size'}
)
) * 100
);
}
else {
$mycalc{'pct_key_buffer_used'} = 0;
}
if ( $mystat{'Key_read_requests'} > 0 ) {
$mycalc{'pct_keys_from_mem'} = sprintf(
"%.1f",
(
100 - (
( $mystat{'Key_reads'} / $mystat{'Key_read_requests'} ) *
100
)
)
);
}
else {
$mycalc{'pct_keys_from_mem'} = 0;
}
if ( defined $mystat{'Aria_pagecache_read_requests'}
&& $mystat{'Aria_pagecache_read_requests'} > 0 )
{
$mycalc{'pct_aria_keys_from_mem'} = sprintf(
"%.1f",
(
100 - (
(
$mystat{'Aria_pagecache_reads'} /
$mystat{'Aria_pagecache_read_requests'}
) * 100
)
)
);
}
else {
$mycalc{'pct_aria_keys_from_mem'} = 0;
}
if ( $mystat{'Key_write_requests'} > 0 ) {
$mycalc{'pct_wkeys_from_mem'} = sprintf(
"%.1f",( ($mystat{'Key_writes'} / $mystat{'Key_write_requests'} ) * 100 ) );
}
else {
$mycalc{'pct_wkeys_from_mem'} = 0;
}
if ( $doremote eq 0 and !mysql_version_ge(5) ) {
my $size = 0;
$size += (split)[0]
for
`find $myvar{'datadir'} -name "*.MYI" 2>&1 | xargs du -L $duflags 2>&1`;
$mycalc{'total_myisam_indexes'} = $size;
$mycalc{'total_aria_indexes'} = 0;
}
elsif ( mysql_version_ge(5) ) {
$mycalc{'total_myisam_indexes'} = select_one
"SELECT IFNULL(SUM(INDEX_LENGTH),0) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema') AND ENGINE = 'MyISAM';";
$mycalc{'total_aria_indexes'} = select_one
"SELECT IFNULL(SUM(INDEX_LENGTH),0) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema') AND ENGINE = 'Aria';";
}
if ( defined $mycalc{'total_myisam_indexes'}
and $mycalc{'total_myisam_indexes'} == 0 )
{
$mycalc{'total_myisam_indexes'} = "fail";
}
elsif ( defined $mycalc{'total_myisam_indexes'} ) {
chomp( $mycalc{'total_myisam_indexes'} );
}
if ( defined $mycalc{'total_aria_indexes'}
and $mycalc{'total_aria_indexes'} == 0 )
{
$mycalc{'total_aria_indexes'} = 1;
}
elsif ( defined $mycalc{'total_aria_indexes'} ) {
chomp( $mycalc{'total_aria_indexes'} );
}
# Query cache
if ( mysql_version_ge(4) ) {
$mycalc{'query_cache_efficiency'} = sprintf(
"%.1f",
(
$mystat{'Qcache_hits'} /
( $mystat{'Com_select'} + $mystat{'Qcache_hits'} )
) * 100
);
if ( $myvar{'query_cache_size'} ) {
$mycalc{'pct_query_cache_used'} = sprintf(
"%.1f",
100 - (
$mystat{'Qcache_free_memory'} / $myvar{'query_cache_size'}
) * 100
);
}
if ( $mystat{'Qcache_lowmem_prunes'} == 0 ) {
$mycalc{'query_cache_prunes_per_day'} = 0;
}
else {
$mycalc{'query_cache_prunes_per_day'} = int(
$mystat{'Qcache_lowmem_prunes'} / ( $mystat{'Uptime'} / 86400 )
);
}
}
# Sorting
$mycalc{'total_sorts'} = $mystat{'Sort_scan'} + $mystat{'Sort_range'};
if ( $mycalc{'total_sorts'} > 0 ) {
$mycalc{'pct_temp_sort_table'} = int(
( $mystat{'Sort_merge_passes'} / $mycalc{'total_sorts'} ) * 100 );
}
# Joins
$mycalc{'joins_without_indexes'} =
$mystat{'Select_range_check'} + $mystat{'Select_full_join'};
$mycalc{'joins_without_indexes_per_day'} =
int( $mycalc{'joins_without_indexes'} / ( $mystat{'Uptime'} / 86400 ) );
# Temporary tables
if ( $mystat{'Created_tmp_tables'} > 0 ) {
if ( $mystat{'Created_tmp_disk_tables'} > 0 ) {
$mycalc{'pct_temp_disk'} = int(
(
$mystat{'Created_tmp_disk_tables'} /
$mystat{'Created_tmp_tables'}
) * 100
);
}
else {
$mycalc{'pct_temp_disk'} = 0;
}
}
# Table cache
if ( $mystat{'Opened_tables'} > 0 ) {
$mycalc{'table_cache_hit_rate'} =
int( $mystat{'Open_tables'} * 100 / $mystat{'Opened_tables'} );
}
else {
$mycalc{'table_cache_hit_rate'} = 100;
}
# Open files
if ( $myvar{'open_files_limit'} > 0 ) {
$mycalc{'pct_files_open'} =
int( $mystat{'Open_files'} * 100 / $myvar{'open_files_limit'} );
}
# Table locks
if ( $mystat{'Table_locks_immediate'} > 0 ) {
if ( $mystat{'Table_locks_waited'} == 0 ) {
$mycalc{'pct_table_locks_immediate'} = 100;
}
else {
$mycalc{'pct_table_locks_immediate'} = int(
$mystat{'Table_locks_immediate'} * 100 / (
$mystat{'Table_locks_waited'} +
$mystat{'Table_locks_immediate'}
)
);
}
}
# Thread cache
$mycalc{'thread_cache_hit_rate'} =
int( 100 -
( ( $mystat{'Threads_created'} / $mystat{'Connections'} ) * 100 ) );
# Other
if ( $mystat{'Connections'} > 0 ) {
$mycalc{'pct_aborted_connections'} =
int( ( $mystat{'Aborted_connects'} / $mystat{'Connections'} ) * 100 );
}
if ( $mystat{'Questions'} > 0 ) {
$mycalc{'total_reads'} = $mystat{'Com_select'};
$mycalc{'total_writes'} =
$mystat{'Com_delete'} +
$mystat{'Com_insert'} +
$mystat{'Com_update'} +
$mystat{'Com_replace'};
if ( $mycalc{'total_reads'} == 0 ) {
$mycalc{'pct_reads'} = 0;
$mycalc{'pct_writes'} = 100;
}
else {
$mycalc{'pct_reads'} = int(
(
$mycalc{'total_reads'} /
( $mycalc{'total_reads'} + $mycalc{'total_writes'} )
) * 100
);
$mycalc{'pct_writes'} = 100 - $mycalc{'pct_reads'};
}
}
# InnoDB
if ( $myvar{'have_innodb'} eq "YES" ) {
$mycalc{'innodb_log_size_pct'} =
( $myvar{'innodb_log_file_size'} *
$myvar{'innodb_log_files_in_group'} * 100 /
$myvar{'innodb_buffer_pool_size'} );
}
# InnoDB Buffer pool read cache effiency
(
$mystat{'Innodb_buffer_pool_read_requests'},
$mystat{'Innodb_buffer_pool_reads'}
)
= ( 1, 1 )
unless defined $mystat{'Innodb_buffer_pool_reads'};
$mycalc{'pct_read_efficiency'} = percentage(
(
$mystat{'Innodb_buffer_pool_read_requests'} -
$mystat{'Innodb_buffer_pool_reads'}
),
$mystat{'Innodb_buffer_pool_read_requests'}
) if defined $mystat{'Innodb_buffer_pool_read_requests'};
debugprint "pct_read_efficiency: " . $mycalc{'pct_read_efficiency'} . "";
debugprint "Innodb_buffer_pool_reads: "
. $mystat{'Innodb_buffer_pool_reads'} . "";
debugprint "Innodb_buffer_pool_read_requests: "
. $mystat{'Innodb_buffer_pool_read_requests'} . "";
# InnoDB log write cache effiency
( $mystat{'Innodb_log_write_requests'}, $mystat{'Innodb_log_writes'} ) =
( 1, 1 )
unless defined $mystat{'Innodb_log_writes'};
$mycalc{'pct_write_efficiency'} = percentage(
( $mystat{'Innodb_log_write_requests'} - $mystat{'Innodb_log_writes'} ),
$mystat{'Innodb_log_write_requests'}
) if defined $mystat{'Innodb_log_write_requests'};
debugprint "pct_write_efficiency: " . $mycalc{'pct_write_efficiency'} . "";
debugprint "Innodb_log_writes: " . $mystat{'Innodb_log_writes'} . "";
debugprint "Innodb_log_write_requests: "
. $mystat{'Innodb_log_write_requests'} . "";
$mycalc{'pct_innodb_buffer_used'} = percentage(
(
$mystat{'Innodb_buffer_pool_pages_total'} -
$mystat{'Innodb_buffer_pool_pages_free'}
),
$mystat{'Innodb_buffer_pool_pages_total'}
) if defined $mystat{'Innodb_buffer_pool_pages_total'};
# Binlog Cache
if ( $myvar{'log_bin'} ne 'OFF' ) {
$mycalc{'pct_binlog_cache'} = percentage(
$mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'},
$mystat{'Binlog_cache_use'} );
}
}
sub mysql_stats {
subheaderprint "Performance Metrics";
# Show uptime, queries per second, connections, traffic stats
my $qps;
if ( $mystat{'Uptime'} > 0 ) {
$qps = sprintf( "%.3f", $mystat{'Questions'} / $mystat{'Uptime'} );
}
push( @generalrec,
"MySQL started within last 24 hours - recommendations may be inaccurate"
) if ( $mystat{'Uptime'} < 86400 );
infoprint "Up for: "
. pretty_uptime( $mystat{'Uptime'} ) . " ("
. hr_num( $mystat{'Questions'} ) . " q ["
. hr_num($qps)
. " qps], "
. hr_num( $mystat{'Connections'} )
. " conn," . " TX: "
. hr_bytes_rnd( $mystat{'Bytes_sent'} )
. ", RX: "
. hr_bytes_rnd( $mystat{'Bytes_received'} ) . ")";
infoprint "Reads / Writes: "
. $mycalc{'pct_reads'} . "% / "
. $mycalc{'pct_writes'} . "%";
# Binlog Cache
if ( $myvar{'log_bin'} eq 'OFF' ) {
infoprint "Binary logging is disabled";
}
else {
infoprint "Binary logging is enabled (GTID MODE: "
. ( defined( $myvar{'gtid_mode'} ) ? $myvar{'gtid_mode'} : "OFF" )
. ")";
}
# Memory usage
infoprint "Physical Memory : " . hr_bytes($physical_memory);
infoprint "Max MySQL memory : " . hr_bytes( $mycalc{'max_peak_memory'} );
infoprint "Other process memory: " . hr_bytes( get_other_process_memory() );
#print hr_bytes( $mycalc{'server_buffers'} );
infoprint "Total buffers: "
. hr_bytes( $mycalc{'server_buffers'} )
. " global + "
. hr_bytes( $mycalc{'per_thread_buffers'} )
. " per thread ($myvar{'max_connections'} max threads)";
infoprint "P_S Max memory usage: " . hr_bytes_rnd( get_pf_memory() );
$result{'P_S'}{'memory'} = get_other_process_memory();
$result{'P_S'}{'pretty_memory'} =
hr_bytes_rnd( get_other_process_memory() );
infoprint "Galera GCache Max memory usage: "
. hr_bytes_rnd( get_gcache_memory() );
$result{'Galera'}{'GCache'}{'memory'} = get_gcache_memory();
$result{'Galera'}{'GCache'}{'pretty_memory'} =
hr_bytes_rnd( get_gcache_memory() );
if ( $opt{buffers} ne 0 ) {
infoprint "Global Buffers";
infoprint " +-- Key Buffer: "
. hr_bytes( $myvar{'key_buffer_size'} ) . "";
infoprint " +-- Max Tmp Table: "
. hr_bytes( $mycalc{'max_tmp_table_size'} ) . "";
if ( defined $myvar{'query_cache_type'} ) {
infoprint "Query Cache Buffers";
infoprint " +-- Query Cache: "
. $myvar{'query_cache_type'} . " - "
. (
$myvar{'query_cache_type'} eq 0 |
$myvar{'query_cache_type'} eq 'OFF' ? "DISABLED"
: (
$myvar{'query_cache_type'} eq 1 ? "ALL REQUESTS"
: "ON DEMAND"
)
) . "";
infoprint " +-- Query Cache Size: "
. hr_bytes( $myvar{'query_cache_size'} ) . "";
}
infoprint "Per Thread Buffers";
infoprint " +-- Read Buffer: "
. hr_bytes( $myvar{'read_buffer_size'} ) . "";
infoprint " +-- Read RND Buffer: "
. hr_bytes( $myvar{'read_rnd_buffer_size'} ) . "";
infoprint " +-- Sort Buffer: "
. hr_bytes( $myvar{'sort_buffer_size'} ) . "";
infoprint " +-- Thread stack: "
. hr_bytes( $myvar{'thread_stack'} ) . "";
infoprint " +-- Join Buffer: "
. hr_bytes( $myvar{'join_buffer_size'} ) . "";
if ( $myvar{'log_bin'} ne 'OFF' ) {
infoprint "Binlog Cache Buffers";
infoprint " +-- Binlog Cache: "
. hr_bytes( $myvar{'binlog_cache_size'} ) . "";
}
}
if ( $arch
&& $arch == 32
&& $mycalc{'max_used_memory'} > 2 * 1024 * 1024 * 1024 )
{
badprint
"Allocating > 2GB RAM on 32-bit systems can cause system instability";
badprint "Maximum reached memory usage: "
. hr_bytes( $mycalc{'max_used_memory'} )
. " ($mycalc{'pct_max_used_memory'}% of installed RAM)";
}
elsif ( $mycalc{'pct_max_used_memory'} > 85 ) {
badprint "Maximum reached memory usage: "
. hr_bytes( $mycalc{'max_used_memory'} )
. " ($mycalc{'pct_max_used_memory'}% of installed RAM)";
}
else {
goodprint "Maximum reached memory usage: "
. hr_bytes( $mycalc{'max_used_memory'} )
. " ($mycalc{'pct_max_used_memory'}% of installed RAM)";
}
if ( $mycalc{'pct_max_physical_memory'} > 85 ) {
badprint "Maximum possible memory usage: "
. hr_bytes( $mycalc{'max_peak_memory'} )
. " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
push( @generalrec,
"Reduce your overall MySQL memory footprint for system stability" );
}
else {
goodprint "Maximum possible memory usage: "
. hr_bytes( $mycalc{'max_peak_memory'} )
. " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
}
if ( $physical_memory <
( $mycalc{'max_peak_memory'} + get_other_process_memory() ) )
{
badprint
"Overall possible memory usage with other process exceeded memory";
push( @generalrec,
"Dedicate this server to your database for highest performance." );
}
else {
goodprint
"Overall possible memory usage with other process is compatible with memory available";
}
# Slow queries
if ( $mycalc{'pct_slow_queries'} > 5 ) {
badprint "Slow queries: $mycalc{'pct_slow_queries'}% ("
. hr_num( $mystat{'Slow_queries'} ) . "/"
. hr_num( $mystat{'Questions'} ) . ")";
}
else {
goodprint "Slow queries: $mycalc{'pct_slow_queries'}% ("
. hr_num( $mystat{'Slow_queries'} ) . "/"
. hr_num( $mystat{'Questions'} ) . ")";
}
if ( $myvar{'long_query_time'} > 10 ) {
push( @adjvars, "long_query_time (<= 10)" );
}
if ( defined( $myvar{'log_slow_queries'} ) ) {
if ( $myvar{'log_slow_queries'} eq "OFF" ) {
push( @generalrec,
"Enable the slow query log to troubleshoot bad queries" );
}
}
# Connections
if ( $mycalc{'pct_connections_used'} > 85 ) {
badprint
"Highest connection usage: $mycalc{'pct_connections_used'}% ($mystat{'Max_used_connections'}/$myvar{'max_connections'})";
push( @adjvars,
"max_connections (> " . $myvar{'max_connections'} . ")" );
push( @adjvars,
"wait_timeout (< " . $myvar{'wait_timeout'} . ")",
"interactive_timeout (< " . $myvar{'interactive_timeout'} . ")" );
push( @generalrec,
"Reduce or eliminate persistent connections to reduce connection usage"
);
}
else {
goodprint
"Highest usage of available connections: $mycalc{'pct_connections_used'}% ($mystat{'Max_used_connections'}/$myvar{'max_connections'})";
}
# Aborted Connections
if ( $mycalc{'pct_connections_aborted'} > 3 ) {
badprint
"Aborted connections: $mycalc{'pct_connections_aborted'}% ($mystat{'Aborted_connects'}/$mystat{'Connections'})";
push( @generalrec,
"Reduce or eliminate unclosed connections and network issues" );
}
else {
goodprint
"Aborted connections: $mycalc{'pct_connections_aborted'}% ($mystat{'Aborted_connects'}/$mystat{'Connections'})";
}
# name resolution
if ( defined( $result{'Variables'}{'skip_networking'} )
&& $result{'Variables'}{'skip_networking'} eq 'ON' )
{
infoprint
"Skipped name resolution test due to skip_networking=ON in system variables.";
}
elsif ( not defined( $result{'Variables'}{'skip_name_resolve'} ) ) {
infoprint
"Skipped name resolution test due to missing skip_name_resolve in system variables.";
}
elsif ( $result{'Variables'}{'skip_name_resolve'} eq 'OFF' ) {
badprint
"name resolution is active : a reverse name resolution is made for each new connection and can reduce performance";
push( @generalrec,
"Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1"
);
}
# Query cache
if ( !mysql_version_ge(4) ) {
# MySQL versions < 4.01 don't support query caching
push( @generalrec,
"Upgrade MySQL to version 4+ to utilize query caching" );
}
elsif ( $myvar{'query_cache_size'} < 1
and $myvar{'query_cache_type'} eq "OFF" )
{
goodprint
"Query cache is disabled by default due to mutex contention on multiprocessor machines.";
}
elsif ( $mystat{'Com_select'} == 0 ) {
badprint
"Query cache cannot be analyzed - no SELECT statements executed";
}
else {
badprint
"Query cache may be disabled by default due to mutex contention.";
push( @adjvars, "query_cache_size (=0)" );
push( @adjvars, "query_cache_type (=0)" );
if ( $mycalc{'query_cache_efficiency'} < 20 ) {
badprint
"Query cache efficiency: $mycalc{'query_cache_efficiency'}% ("
. hr_num( $mystat{'Qcache_hits'} )
. " cached / "
. hr_num( $mystat{'Qcache_hits'} + $mystat{'Com_select'} )
. " selects)";
push( @adjvars,
"query_cache_limit (> "
. hr_bytes_rnd( $myvar{'query_cache_limit'} )
. ", or use smaller result sets)" );
}
else {
goodprint
"Query cache efficiency: $mycalc{'query_cache_efficiency'}% ("
. hr_num( $mystat{'Qcache_hits'} )
. " cached / "
. hr_num( $mystat{'Qcache_hits'} + $mystat{'Com_select'} )
. " selects)";
}
if ( $mycalc{'query_cache_prunes_per_day'} > 98 ) {
badprint
"Query cache prunes per day: $mycalc{'query_cache_prunes_per_day'}";
if ( $myvar{'query_cache_size'} >= 128 * 1024 * 1024 ) {
push( @generalrec,
"Increasing the query_cache size over 128M may reduce performance"
);
push( @adjvars,
"query_cache_size (> "
. hr_bytes_rnd( $myvar{'query_cache_size'} )
. ") [see warning above]" );
}
else {
push( @adjvars,
"query_cache_size (> "
. hr_bytes_rnd( $myvar{'query_cache_size'} )
. ")" );
}
}
else {
goodprint
"Query cache prunes per day: $mycalc{'query_cache_prunes_per_day'}";
}
}
# Sorting
if ( $mycalc{'total_sorts'} == 0 ) {
goodprint "No Sort requiring temporary tables";
}
elsif ( $mycalc{'pct_temp_sort_table'} > 10 ) {
badprint
"Sorts requiring temporary tables: $mycalc{'pct_temp_sort_table'}% ("
. hr_num( $mystat{'Sort_merge_passes'} )
. " temp sorts / "
. hr_num( $mycalc{'total_sorts'} )
. " sorts)";
push( @adjvars,
"sort_buffer_size (> "
. hr_bytes_rnd( $myvar{'sort_buffer_size'} )
. ")" );
push( @adjvars,
"read_rnd_buffer_size (> "
. hr_bytes_rnd( $myvar{'read_rnd_buffer_size'} )
. ")" );
}
else {
goodprint
"Sorts requiring temporary tables: $mycalc{'pct_temp_sort_table'}% ("
. hr_num( $mystat{'Sort_merge_passes'} )
. " temp sorts / "
. hr_num( $mycalc{'total_sorts'} )
. " sorts)";
}
# Joins
if ( $mycalc{'joins_without_indexes_per_day'} > 250 ) {
badprint
"Joins performed without indexes: $mycalc{'joins_without_indexes'}";
push( @adjvars,
"join_buffer_size (> "
. hr_bytes( $myvar{'join_buffer_size'} )
. ", or always use indexes with joins)" );
push( @generalrec,
"Adjust your join queries to always utilize indexes" );
}
else {
goodprint "No joins without indexes";
# No joins have run without indexes
}
# Temporary tables
if ( $mystat{'Created_tmp_tables'} > 0 ) {
if ( $mycalc{'pct_temp_disk'} > 25
&& $mycalc{'max_tmp_table_size'} < 256 * 1024 * 1024 )
{
badprint
"Temporary tables created on disk: $mycalc{'pct_temp_disk'}% ("
. hr_num( $mystat{'Created_tmp_disk_tables'} )
. " on disk / "
. hr_num( $mystat{'Created_tmp_tables'} )
. " total)";
push( @adjvars,
"tmp_table_size (> "
. hr_bytes_rnd( $myvar{'tmp_table_size'} )
. ")" );
push( @adjvars,
"max_heap_table_size (> "
. hr_bytes_rnd( $myvar{'max_heap_table_size'} )
. ")" );
push( @generalrec,
"When making adjustments, make tmp_table_size/max_heap_table_size equal"
);
push( @generalrec,
"Reduce your SELECT DISTINCT queries which have no LIMIT clause"
);
}
elsif ($mycalc{'pct_temp_disk'} > 25
&& $mycalc{'max_tmp_table_size'} >= 256 * 1024 * 1024 )
{
badprint
"Temporary tables created on disk: $mycalc{'pct_temp_disk'}% ("
. hr_num( $mystat{'Created_tmp_disk_tables'} )
. " on disk / "
. hr_num( $mystat{'Created_tmp_tables'} )
. " total)";
push( @generalrec,
"Temporary table size is already large - reduce result set size"
);
push( @generalrec,
"Reduce your SELECT DISTINCT queries without LIMIT clauses" );
}
else {
goodprint
"Temporary tables created on disk: $mycalc{'pct_temp_disk'}% ("
. hr_num( $mystat{'Created_tmp_disk_tables'} )
. " on disk / "
. hr_num( $mystat{'Created_tmp_tables'} )
. " total)";
}
}
else {
goodprint "No tmp tables created on disk";
}
# Thread cache
if ( $myvar{'thread_cache_size'} eq 0 ) {
badprint "Thread cache is disabled";
push( @generalrec, "Set thread_cache_size to 4 as a starting value" );
push( @adjvars, "thread_cache_size (start at 4)" );
}
else {
if ( defined( $myvar{'thread_handling'} )
and $myvar{'thread_handling'} eq 'pools-of-threads' )
{
infoprint "Thread cache hit rate: not used with pool-of-threads";
}
else {
if ( $mycalc{'thread_cache_hit_rate'} <= 50 ) {
badprint
"Thread cache hit rate: $mycalc{'thread_cache_hit_rate'}% ("
. hr_num( $mystat{'Threads_created'} )
. " created / "
. hr_num( $mystat{'Connections'} )
. " connections)";
push( @adjvars,
"thread_cache_size (> $myvar{'thread_cache_size'})" );
}
else {
goodprint
"Thread cache hit rate: $mycalc{'thread_cache_hit_rate'}% ("
. hr_num( $mystat{'Threads_created'} )
. " created / "
. hr_num( $mystat{'Connections'} )
. " connections)";
}
}
}
# Table cache
my $table_cache_var = "";
if ( $mystat{'Open_tables'} > 0 ) {
if ( $mycalc{'table_cache_hit_rate'} < 20 ) {
badprint "Table cache hit rate: $mycalc{'table_cache_hit_rate'}% ("
. hr_num( $mystat{'Open_tables'} )
. " open / "
. hr_num( $mystat{'Opened_tables'} )
. " opened)";
if ( mysql_version_ge( 5, 1 ) ) {
$table_cache_var = "table_open_cache";
}
else {
$table_cache_var = "table_cache";
}
push( @adjvars,
$table_cache_var . " (> " . $myvar{$table_cache_var} . ")" );
push( @generalrec,
"Increase "
. $table_cache_var
. " gradually to avoid file descriptor limits" );
push( @generalrec,
"Read this before increasing "
. $table_cache_var
. " over 64: http://bit.ly/1mi7c4C" );
push( @generalrec,
"Beware that open_files_limit ("
. $myvar{'open_files_limit'}
. ") variable " );
push( @generalrec,
"should be greater than $table_cache_var ("
. $myvar{$table_cache_var}
. ")" );
}
else {
goodprint "Table cache hit rate: $mycalc{'table_cache_hit_rate'}% ("
. hr_num( $mystat{'Open_tables'} )
. " open / "
. hr_num( $mystat{'Opened_tables'} )
. " opened)";
}
}
# Open files
if ( defined $mycalc{'pct_files_open'} ) {
if ( $mycalc{'pct_files_open'} > 85 ) {
badprint "Open file limit used: $mycalc{'pct_files_open'}% ("
. hr_num( $mystat{'Open_files'} ) . "/"
. hr_num( $myvar{'open_files_limit'} ) . ")";
push( @adjvars,
"open_files_limit (> " . $myvar{'open_files_limit'} . ")" );
}
else {
goodprint "Open file limit used: $mycalc{'pct_files_open'}% ("
. hr_num( $mystat{'Open_files'} ) . "/"
. hr_num( $myvar{'open_files_limit'} ) . ")";
}
}
# Table locks
if ( defined $mycalc{'pct_table_locks_immediate'} ) {
if ( $mycalc{'pct_table_locks_immediate'} < 95 ) {
badprint
"Table locks acquired immediately: $mycalc{'pct_table_locks_immediate'}%";
push( @generalrec,
"Optimize queries and/or use InnoDB to reduce lock wait" );
}
else {
goodprint
"Table locks acquired immediately: $mycalc{'pct_table_locks_immediate'}% ("
. hr_num( $mystat{'Table_locks_immediate'} )
. " immediate / "
. hr_num( $mystat{'Table_locks_waited'} +
$mystat{'Table_locks_immediate'} )
. " locks)";
}
}
# Binlog cache
if ( defined $mycalc{'pct_binlog_cache'} ) {
if ( $mycalc{'pct_binlog_cache'} < 90
&& $mystat{'Binlog_cache_use'} > 0 )
{
badprint "Binlog cache memory access: "
. $mycalc{'pct_binlog_cache'} . "% ("
. (
$mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'} )
. " Memory / "
. $mystat{'Binlog_cache_use'}
. " Total)";
push( @generalrec,
"Increase binlog_cache_size (Actual value: "
. $myvar{'binlog_cache_size'}
. ")" );
push( @adjvars,
"binlog_cache_size ("
. hr_bytes( $myvar{'binlog_cache_size'} + 16 * 1024 * 1024 )
. ")" );
}
else {
goodprint "Binlog cache memory access: "
. $mycalc{'pct_binlog_cache'} . "% ("
. (
$mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'} )
. " Memory / "
. $mystat{'Binlog_cache_use'}
. " Total)";
debugprint "Not enough data to validate binlog cache size\n"
if $mystat{'Binlog_cache_use'} < 10;
}
}
# Performance options
if ( !mysql_version_ge( 5, 1 ) ) {
push( @generalrec, "Upgrade to MySQL 5.5+ to use asynchronous write" );
}
elsif ( $myvar{'concurrent_insert'} eq "OFF" ) {
push( @generalrec, "Enable concurrent_insert by setting it to 'ON'" );
}
elsif ( $myvar{'concurrent_insert'} eq 0 ) {
push( @generalrec, "Enable concurrent_insert by setting it to 1" );
}
}
# Recommendations for MyISAM
sub mysql_myisam {
subheaderprint "MyISAM Metrics";
# Key buffer usage
if ( defined( $mycalc{'pct_key_buffer_used'} ) ) {
if ( $mycalc{'pct_key_buffer_used'} < 90 ) {
badprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_num( $myvar{'key_buffer_size'} *
$mycalc{'pct_key_buffer_used'} /
100 )
. " used / "
. hr_num( $myvar{'key_buffer_size'} )
. " cache)";
#push(@adjvars,"key_buffer_size (\~ ".hr_num( $myvar{'key_buffer_size'} * $mycalc{'pct_key_buffer_used'} / 100).")");
}
else {
goodprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_num( $myvar{'key_buffer_size'} *
$mycalc{'pct_key_buffer_used'} /
100 )
. " used / "
. hr_num( $myvar{'key_buffer_size'} )
. " cache)";
}
}
else {
# No queries have run that would use keys
debugprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_num(
$myvar{'key_buffer_size'} * $mycalc{'pct_key_buffer_used'} / 100 )
. " used / "
. hr_num( $myvar{'key_buffer_size'} )
. " cache)";
}
# Key buffer
if ( !defined( $mycalc{'total_myisam_indexes'} ) and $doremote == 1 ) {
push( @generalrec,
"Unable to calculate MyISAM indexes on remote MySQL server < 5.0.0"
);
}
elsif ( $mycalc{'total_myisam_indexes'} =~ /^fail$/ ) {
badprint
"Cannot calculate MyISAM index size - re-run script as root user";
}
elsif ( $mycalc{'total_myisam_indexes'} == "0" ) {
badprint
"None of your MyISAM tables are indexed - add indexes immediately";
}
else {
if ( $myvar{'key_buffer_size'} < $mycalc{'total_myisam_indexes'}
&& $mycalc{'pct_keys_from_mem'} < 95 )
{
badprint "Key buffer size / total MyISAM indexes: "
. hr_bytes( $myvar{'key_buffer_size'} ) . "/"
. hr_bytes( $mycalc{'total_myisam_indexes'} ) . "";
push( @adjvars,
"key_buffer_size (> "
. hr_bytes( $mycalc{'total_myisam_indexes'} )
. ")" );
}
else {
goodprint "Key buffer size / total MyISAM indexes: "
. hr_bytes( $myvar{'key_buffer_size'} ) . "/"
. hr_bytes( $mycalc{'total_myisam_indexes'} ) . "";
}
if ( $mystat{'Key_read_requests'} > 0 ) {
if ( $mycalc{'pct_keys_from_mem'} < 95 ) {
badprint
"Read Key buffer hit rate: $mycalc{'pct_keys_from_mem'}% ("
. hr_num( $mystat{'Key_read_requests'} )
. " cached / "
. hr_num( $mystat{'Key_reads'} )
. " reads)";
}
else {
goodprint
"Read Key buffer hit rate: $mycalc{'pct_keys_from_mem'}% ("
. hr_num( $mystat{'Key_read_requests'} )
. " cached / "
. hr_num( $mystat{'Key_reads'} )
. " reads)";
}
}
else {
# No queries have run that would use keys
debugprint "Key buffer size / total MyISAM indexes: "
. hr_bytes( $myvar{'key_buffer_size'} ) . "/"
. hr_bytes( $mycalc{'total_myisam_indexes'} ) . "";
}
if ( $mystat{'Key_write_requests'} > 0 ) {
if ( $mycalc{'pct_wkeys_from_mem'} < 95 ) {
badprint
"Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% ("
. hr_num( $mystat{'Key_write_requests'} )
. " cached / "
. hr_num( $mystat{'Key_writes'} )
. " writes)";
}
else {
goodprint
"Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% ("
. hr_num( $mystat{'Key_write_requests'} )
. " cached / "
. hr_num( $mystat{'Key_writes'} )
. " writes)";
}
}
else {
# No queries have run that would use keys
debugprint
"Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% ("
. hr_num( $mystat{'Key_write_requests'} )
. " cached / "
. hr_num( $mystat{'Key_writes'} )
. " writes)";
}
}
}
# Recommendations for ThreadPool
sub mariadb_threadpool {
subheaderprint "ThreadPool Metrics";
# AriaDB
unless ( defined $myvar{'have_threadpool'}
&& $myvar{'have_threadpool'} eq "YES" )
{
infoprint "ThreadPool stat is disabled.";
return;
}
infoprint "ThreadPool stat is enabled.";
infoprint "Thread Pool Size: " . $myvar{'thread_pool_size'} . " thread(s).";
if ( $myvar{'version'} =~ /mariadb|percona/i ) {
infoprint "Using default value is good enough for your version ("
. $myvar{'version'} . ")";
return;
}
if ( $myvar{'have_innodb'} eq 'YES' ) {
if ( $myvar{'thread_pool_size'} < 16
or $myvar{'thread_pool_size'} > 36 )
{
badprint
"thread_pool_size between 16 and 36 when using InnoDB storage engine.";
push( @generalrec,
"Thread pool size for InnoDB usage ("
. $myvar{'thread_pool_size'}
. ")" );
push( @adjvars,
"thread_pool_size between 16 and 36 for InnoDB usage" );
}
else {
goodprint
"thread_pool_size between 16 and 36 when using InnoDB storage engine.";
}
return;
}
if ( $myvar{'have_isam'} eq 'YES' ) {
if ( $myvar{'thread_pool_size'} < 4 or $myvar{'thread_pool_size'} > 8 )
{
badprint
"thread_pool_size between 4 and 8 when using MyIsam storage engine.";
push( @generalrec,
"Thread pool size for MyIsam usage ("
. $myvar{'thread_pool_size'}
. ")" );
push( @adjvars,
"thread_pool_size between 4 and 8 for MyIsam usage" );
}
else {
goodprint
"thread_pool_size between 4 and 8 when using MyISAM storage engine.";
}
}
}
sub get_pf_memory {
# Performance Schema
return 0 unless defined $myvar{'performance_schema'};
return 0 if $myvar{'performance_schema'} eq 'OFF';
my @infoPFSMemory = grep /performance_schema.memory/,
select_array("SHOW ENGINE PERFORMANCE_SCHEMA STATUS");
return 0 if scalar(@infoPFSMemory) == 0;
$infoPFSMemory[0] =~ s/.*\s+(\d+)$/$1/g;
return $infoPFSMemory[0];
}
# Recommendations for Performance Schema
sub mysqsl_pfs {
subheaderprint "Performance schema";
# Performance Schema
$myvar{'performance_schema'} = 'OFF'
unless defined( $myvar{'performance_schema'} );
unless ( $myvar{'performance_schema'} eq 'ON' ) {
infoprint "Performance schema is disabled.";
if ( mysql_version_ge( 5, 6 ) ) {
push( @generalrec,
"Performance should be activated for better diagnostics" );
push( @adjvars, "performance_schema = ON enable PFS" );
}
else {
push( @generalrec,
"Performance shouldn't be activated for MySQL and MariaDB 5.5 and lower version"
);
push( @adjvars, "performance_schema = OFF disable PFS" );
}
}
debugprint "Performance schema is " . $myvar{'performance_schema'};
infoprint "Memory used by P_S: " . hr_bytes( get_pf_memory() );
unless ( grep /^sys$/, select_array("SHOW DATABASES") ) {
infoprint "Sys schema isn't installed.";
push( @generalrec,
"Consider installing Sys schema from https://github.com/mysql/mysql-sys"
);
return;
}
else {
infoprint "Sys schema is installed.";
}
return if ( $opt{pfstat} == 0 or $myvar{'performance_schema'} ne 'ON' );
infoprint "Sys schema Version: "
. select_one("select sys_version from sys.version");
# Top user per connection
subheaderprint "Performance schema: Top 5 user per connection";
my $nbL = 1;
for my $lQuery (
select_array(
'select user, total_connections from sys.user_summary order by total_connections desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery conn(s)";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per statement
subheaderprint "Performance schema: Top 5 user per statement";
$nbL = 1;
for my $lQuery (
select_array(
'select user, statements from sys.user_summary order by statements desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery stmt(s)";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per statement latency
subheaderprint "Performance schema: Top 5 user per statement latency";
$nbL = 1;
for my $lQuery (
select_array(
'select user, statement_avg_latency from sys.user_summary order by statement_avg_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per lock latency
subheaderprint "Performance schema: Top 5 user per lock latency";
$nbL = 1;
for my $lQuery (
select_array(
'select user, lock_latency from sys.user_summary_by_statement_latency order by lock_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per full scans
subheaderprint "Performance schema: Top 5 user per nb full scans";
$nbL = 1;
for my $lQuery (
select_array(
'select user, full_scans from sys.user_summary_by_statement_latency order by full_scans desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per row_sent
subheaderprint "Performance schema: Top 5 user per rows sent";
$nbL = 1;
for my $lQuery (
select_array(
'select user, rows_sent from sys.user_summary_by_statement_latency order by rows_sent desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per row modified
subheaderprint "Performance schema: Top 5 user per rows modified";
$nbL = 1;
for my $lQuery (
select_array(
'select user, rows_affected from sys.user_summary_by_statement_latency order by rows_affected desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per io
subheaderprint "Performance schema: Top 5 user per io";
$nbL = 1;
for my $lQuery (
select_array(
'select user, file_ios from sys.user_summary order by file_ios desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top user per io latency
subheaderprint "Performance schema: Top 5 user per io latency";
$nbL = 1;
for my $lQuery (
select_array(
'select user, file_io_latency from sys.user_summary order by file_io_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per connection
subheaderprint "Performance schema: Top 5 host per connection";
$nbL = 1;
for my $lQuery (
select_array(
'select host, total_connections from sys.host_summary order by total_connections desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery conn(s)";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per statement
subheaderprint "Performance schema: Top 5 host per statement";
$nbL = 1;
for my $lQuery (
select_array(
'select host, statements from sys.host_summary order by statements desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery stmt(s)";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per statement latency
subheaderprint "Performance schema: Top 5 host per statement latency";
$nbL = 1;
for my $lQuery (
select_array(
'select host, statement_avg_latency from sys.host_summary order by statement_avg_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per lock latency
subheaderprint "Performance schema: Top 5 host per lock latency";
$nbL = 1;
for my $lQuery (
select_array(
'select host, lock_latency from sys.host_summary_by_statement_latency order by lock_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per full scans
subheaderprint "Performance schema: Top 5 host per nb full scans";
$nbL = 1;
for my $lQuery (
select_array(
'select host, full_scans from sys.host_summary_by_statement_latency order by full_scans desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per rows sent
subheaderprint "Performance schema: Top 5 host per rows sent";
$nbL = 1;
for my $lQuery (
select_array(
'select host, rows_sent from sys.host_summary_by_statement_latency order by rows_sent desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per rows modified
subheaderprint "Performance schema: Top 5 host per rows modified";
$nbL = 1;
for my $lQuery (
select_array(
'select host, rows_affected from sys.host_summary_by_statement_latency order by rows_affected desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per io
subheaderprint "Performance schema: Top 5 host per io";
$nbL = 1;
for my $lQuery (
select_array(
'select host, file_ios from sys.host_summary order by file_ios desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top 5 host per io latency
subheaderprint "Performance schema: Top 5 host per io latency";
$nbL = 1;
for my $lQuery (
select_array(
'select host, file_io_latency from sys.host_summary order by file_io_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top IO type order by total io
subheaderprint "Performance schema: Top IO type order by total io";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select substring(event_name,14), SUM(total)AS total from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY total DESC;'
)
)
{
infoprint " +-- $nbL: $lQuery i/o";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top IO type order by total latency
subheaderprint "Performance schema: Top IO type order by total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select substring(event_name,14), format_time(ROUND(SUM(total_latency),1)) AS total_latency from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY total_latency DESC;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top IO type order by max latency
subheaderprint "Performance schema: Top IO type order by max latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select substring(event_name,14), MAX(max_latency) as max_latency from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY max_latency DESC;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top Stages order by total io
subheaderprint "Performance schema: Top Stages order by total io";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select substring(event_name,7), SUM(total)AS total from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY total DESC;'
)
)
{
infoprint " +-- $nbL: $lQuery i/o";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top Stages order by total latency
subheaderprint "Performance schema: Top Stages order by total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select substring(event_name,7), format_time(ROUND(SUM(total_latency),1)) AS total_latency from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY total_latency DESC;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top Stages order by avg latency
subheaderprint "Performance schema: Top Stages order by avg latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select substring(event_name,7), MAX(avg_latency) as avg_latency from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY avg_latency DESC;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top host per table scans
subheaderprint "Performance schema: Top 5 host per table scans";
$nbL = 1;
for my $lQuery (
select_array(
'select host, table_scans from sys.host_summary order by table_scans desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# InnoDB Buffer Pool by schema
subheaderprint "Performance schema: InnoDB Buffer Pool by schema";
$nbL = 1;
for my $lQuery (
select_array(
'select object_schema, allocated, data, pages from sys.innodb_buffer_stats_by_schema ORDER BY pages DESC'
)
)
{
infoprint " +-- $nbL: $lQuery page(s)";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# InnoDB Buffer Pool by table
subheaderprint "Performance schema: InnoDB Buffer Pool by table";
$nbL = 1;
for my $lQuery (
select_array(
"select CONCAT(object_schema,CONCAT('.', object_name)), allocated,data, pages from sys.innodb_buffer_stats_by_table ORDER BY pages DESC"
)
)
{
infoprint " +-- $nbL: $lQuery page(s)";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Process per allocated memory
subheaderprint "Performance schema: Process per allocated memory";
$nbL = 1;
for my $lQuery (
select_array(
"select concat(user,concat('/', IFNULL(Command,'NONE'))) AS PROC, current_memory from sys.processlist ORDER BY current_memory DESC;"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# InnoDB Lock Waits
subheaderprint "Performance schema: InnoDB Lock Waits";
$nbL = 1;
for my $lQuery (
select_array(
"use sys;select wait_age_secs, locked_table, locked_type, waiting_query from innodb_lock_waits order by wait_age_secs DESC;"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Threads IO Latency
subheaderprint "Performance schema: Thread IO Latency";
$nbL = 1;
for my $lQuery (
select_array(
"use sys;select user, total_latency, max_latency from io_by_thread_by_latency order by total_latency;"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# High Cost SQL statements
subheaderprint "Performance schema: Top 5 Most latency statements";
$nbL = 1;
for my $lQuery (
select_array(
'select query, avg_latency from sys.statement_analysis order by avg_latency desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top 5% slower queries
subheaderprint "Performance schema: Top 5 slower queries";
$nbL = 1;
for my $lQuery (
select_array(
'select query, exec_count from sys.statements_with_runtimes_in_95th_percentile order by exec_count desc LIMIT 5'
)
)
{
infoprint " +-- $nbL: $lQuery s";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top 10 nb statement type
subheaderprint "Performance schema: Top 10 nb statement type";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select statement, sum(total) as total from host_summary_by_statement_type group by statement order by total desc LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top statement by total latency
subheaderprint "Performance schema: Top statement by total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select statement, sum(total_latency) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top statement by lock latency
subheaderprint "Performance schema: Top statement by lock latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select statement, sum(lock_latency) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top statement by full scans
subheaderprint "Performance schema: Top statement by full scans";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select statement, sum(full_scans) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top statement by rows sent
subheaderprint "Performance schema: Top statement by rows sent";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select statement, sum(rows_sent) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Top statement by rows modified
subheaderprint "Performance schema: Top statement by rows modified";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select statement, sum(rows_affected) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Use temporary tables
subheaderprint "Performance schema: Some queries using temp table";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select query from sys.statements_with_temp_tables LIMIT 20'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Unused Indexes
subheaderprint "Performance schema: Unused indexes";
$nbL = 1;
for my $lQuery ( select_array('select * from sys.schema_unused_indexes') ) {
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Full table scans
subheaderprint "Performance schema: Tables with full table scans";
$nbL = 1;
for my $lQuery (
select_array(
'select * from sys.schema_tables_with_full_table_scans order by rows_full_scanned DESC'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Latest file IO by latency
subheaderprint "Performance schema: Latest FILE IO by latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select thread, file, latency, operation from latest_file_io ORDER BY latency LIMIT 10;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# FILE by IO read bytes
subheaderprint "Performance schema: FILE by IO read bytes";
$nbL = 1;
for my $lQuery (
select_array(
"use sys;(select file, total_read from io_global_by_file_by_bytes where total_read like '%MiB' order by total_read DESC) UNION (select file, total_read from io_global_by_file_by_bytes where total_read like '%KiB' order by total_read DESC LIMIT 15);"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# FILE by IO written bytes
subheaderprint "Performance schema: FILE by IO written bytes";
$nbL = 1;
for my $lQuery (
select_array(
"use sys;(select file, total_written from io_global_by_file_by_bytes where total_written like '%MiB' order by total_written DESC) UNION (select file, total_written from io_global_by_file_by_bytes where total_written like '%KiB' order by total_written DESC LIMIT 15);"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# file per IO total latency
subheaderprint "Performance schema: file per IO total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select file, total_latency from io_global_by_file_by_latency ORDER BY total_latency DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# file per IO read latency
subheaderprint "Performance schema: file per IO read latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select file, read_latency from io_global_by_file_by_latency ORDER BY read_latency DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# file per IO write latency
subheaderprint "Performance schema: file per IO write latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select file, write_latency from io_global_by_file_by_latency ORDER BY write_latency DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Event Wait by read bytes
subheaderprint "Performance schema: Event Wait by read bytes";
$nbL = 1;
for my $lQuery (
select_array(
"use sys;(select event_name, total_read from io_global_by_wait_by_bytes where total_read like '%MiB' order by total_read DESC) UNION (select event_name, total_read from io_global_by_wait_by_bytes where total_read like '%KiB' order by total_read DESC LIMIT 15);"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Event Wait by write bytes
subheaderprint "Performance schema: Event Wait written bytes";
$nbL = 1;
for my $lQuery (
select_array(
"use sys;(select event_name, total_written from io_global_by_wait_by_bytes where total_written like '%MiB' order by total_written DESC) UNION (select event_name, total_written from io_global_by_wait_by_bytes where total_written like '%KiB' order by total_written DESC LIMIT 15);"
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# event per wait total latency
subheaderprint "Performance schema: event per wait total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select event_name, total_latency from io_global_by_wait_by_latency ORDER BY total_latency DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# event per wait read latency
subheaderprint "Performance schema: event per wait read latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select event_name, read_latency from io_global_by_wait_by_latency ORDER BY read_latency DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# event per wait write latency
subheaderprint "Performance schema: event per wait write latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select event_name, write_latency from io_global_by_wait_by_latency ORDER BY write_latency DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
#schema_index_statistics
# TOP 15 most read index
subheaderprint "Performance schema: TOP 15 most read indexes";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name,index_name, rows_selected from schema_index_statistics ORDER BY ROWs_selected DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 most used index
subheaderprint "Performance schema: TOP 15 most modified indexes";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name,index_name, rows_inserted+rows_updated+rows_deleted AS changes from schema_index_statistics ORDER BY rows_inserted+rows_updated+rows_deleted DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high read latency index
subheaderprint "Performance schema: TOP 15 high read latency index";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name,index_name, select_latency from schema_index_statistics ORDER BY select_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high insert latency index
subheaderprint "Performance schema: TOP 15 most modified indexes";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name,index_name, insert_latency from schema_index_statistics ORDER BY insert_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high update latency index
subheaderprint "Performance schema: TOP 15 high update latency index";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name,index_name, update_latency from schema_index_statistics ORDER BY update_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high delete latency index
subheaderprint "Performance schema: TOP 15 high delete latency index";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name,index_name, delete_latency from schema_index_statistics ORDER BY delete_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 most read tables
subheaderprint "Performance schema: TOP 15 most read tables";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name, rows_fetched from schema_table_statistics ORDER BY ROWs_fetched DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 most used tables
subheaderprint "Performance schema: TOP 15 most modified tables";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name, rows_inserted+rows_updated+rows_deleted AS changes from schema_table_statistics ORDER BY rows_inserted+rows_updated+rows_deleted DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high read latency tables
subheaderprint "Performance schema: TOP 15 high read latency tables";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name, fetch_latency from schema_table_statistics ORDER BY fetch_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high insert latency tables
subheaderprint "Performance schema: TOP 15 high insert latency tables";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name, insert_latency from schema_table_statistics ORDER BY insert_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high update latency tables
subheaderprint "Performance schema: TOP 15 high update latency tables";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name, update_latency from schema_table_statistics ORDER BY update_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# TOP 15 high delete latency tables
subheaderprint "Performance schema: TOP 15 high delete latency tables";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select table_schema, table_name, delete_latency from schema_table_statistics ORDER BY delete_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
# Redundant indexes
subheaderprint "Performance schema: Redundant indexes";
$nbL = 1;
for my $lQuery (
select_array('use sys;select * from schema_redundant_indexes;') )
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Tables not using InnoDB buffer";
$nbL = 1;
for my $lQuery (
select_array(
' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Table not using InnoDB buffer";
$nbL = 1;
for my $lQuery (
select_array(
' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Table not using InnoDB buffer";
$nbL = 1;
for my $lQuery (
select_array(
' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Top 15 Tables using InnoDB buffer";
$nbL = 1;
for my $lQuery (
select_array(
'select table_schema,table_name,innodb_buffer_allocated from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NOT NULL ORDER BY innodb_buffer_allocated DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Top 15 Tables with InnoDB buffer free";
$nbL = 1;
for my $lQuery (
select_array(
'select table_schema,table_name,innodb_buffer_free from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NOT NULL ORDER BY innodb_buffer_free DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Top 15 Most executed queries";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, exec_count from sys.statement_analysis order by exec_count DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: Latest SQL queries in errors or warnings";
$nbL = 1;
for my $lQuery (
select_array(
'select query, last_seen from sys.statements_with_errors_or_warnings ORDER BY last_seen LIMIT 100;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Top 20 queries with full table scans";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, exec_count from sys.statements_with_full_table_scans order BY exec_count DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Last 50 queries with full table scans";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, last_seen from sys.statements_with_full_table_scans order BY last_seen DESC LIMIT 50;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 reader queries (95% percentile)";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query , rows_sent from statements_with_runtimes_in_95th_percentile ORDER BY ROWs_sent DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: TOP 15 most row look queries (95% percentile)";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, rows_examined AS search from statements_with_runtimes_in_95th_percentile ORDER BY rows_examined DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: TOP 15 total latency queries (95% percentile)";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, total_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY total_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: TOP 15 max latency queries (95% percentile)";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, max_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY max_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: TOP 15 average latency queries (95% percentile)";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, avg_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY avg_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Top 20 queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, exec_count from sys.statements_with_sorting order BY exec_count DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Last 50 queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, last_seen from sys.statements_with_sorting order BY last_seen DESC LIMIT 50;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 row sorting queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query , rows_sorted from statements_with_sorting ORDER BY ROWs_sorted DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 total latency queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, total_latency AS search from statements_with_sorting ORDER BY total_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 merge queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, sort_merge_passes AS search from statements_with_sorting ORDER BY sort_merge_passes DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: TOP 15 average sort merges queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, avg_sort_merges AS search from statements_with_sorting ORDER BY avg_sort_merges DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 scans queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, sorts_using_scans AS search from statements_with_sorting ORDER BY sorts_using_scans DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 range queries with sort";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, sort_using_range AS search from statements_with_sorting ORDER BY sort_using_range DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
##################################################################################
#statements_with_temp_tables
#mysql> desc statements_with_temp_tables;
#+--------------------------+---------------------+------+-----+---------------------+-------+
#| Field | Type | Null | Key | Default | Extra |
#+--------------------------+---------------------+------+-----+---------------------+-------+
#| query | longtext | YES | | NULL | |
#| db | varchar(64) | YES | | NULL | |
#| exec_count | bigint(20) unsigned | NO | | NULL | |
#| total_latency | text | YES | | NULL | |
#| memory_tmp_tables | bigint(20) unsigned | NO | | NULL | |
#| disk_tmp_tables | bigint(20) unsigned | NO | | NULL | |
#| avg_tmp_tables_per_query | decimal(21,0) | NO | | 0 | |
#| tmp_tables_to_disk_pct | decimal(24,0) | NO | | 0 | |
#| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
#| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
#| digest | varchar(32) | YES | | NULL | |
#+--------------------------+---------------------+------+-----+---------------------+-------+
#11 rows in set (0,01 sec)#
#
subheaderprint "Performance schema: Top 20 queries with temp table";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, exec_count from sys.statements_with_temp_tables order BY exec_count DESC LIMIT 20;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: Last 50 queries with temp table";
$nbL = 1;
for my $lQuery (
select_array(
'select db, query, last_seen from sys.statements_with_temp_tables order BY last_seen DESC LIMIT 50;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint
"Performance schema: TOP 15 total latency queries with temp table";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, total_latency AS search from statements_with_temp_tables ORDER BY total_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 queries with temp table to disk";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select db, query, disk_tmp_tables from statements_with_temp_tables ORDER BY disk_tmp_tables DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
##################################################################################
#wait_classes_global_by_latency
#ysql> select * from wait_classes_global_by_latency;
#-----------------+-------+---------------+-------------+-------------+-------------+
# event_class | total | total_latency | min_latency | avg_latency | max_latency |
#-----------------+-------+---------------+-------------+-------------+-------------+
# wait/io/file | 15381 | 1.23 s | 0 ps | 80.12 us | 230.64 ms |
# wait/io/table | 59 | 7.57 ms | 5.45 us | 128.24 us | 3.95 ms |
# wait/lock/table | 69 | 3.22 ms | 658.84 ns | 46.64 us | 1.10 ms |
#-----------------+-------+---------------+-------------+-------------+-------------+
# rows in set (0,00 sec)
subheaderprint "Performance schema: TOP 15 class events by number";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select event_class, total from wait_classes_global_by_latency ORDER BY total DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 30 events by number";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select events, total from waits_global_by_latency ORDER BY total DESC LIMIT 30;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 class events by total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select event_class, total_latency from wait_classes_global_by_latency ORDER BY total_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 30 events by total latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select events, total_latency from waits_global_by_latency ORDER BY total_latency DESC LIMIT 30;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 15 class events by max latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select event_class, max_latency from wait_classes_global_by_latency ORDER BY max_latency DESC LIMIT 15;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
subheaderprint "Performance schema: TOP 30 events by max latency";
$nbL = 1;
for my $lQuery (
select_array(
'use sys;select events, max_latency from waits_global_by_latency ORDER BY max_latency DESC LIMIT 30;'
)
)
{
infoprint " +-- $nbL: $lQuery";
$nbL++;
}
infoprint "No information found or indicators desactivated."
if ( $nbL == 1 );
}
# Recommendations for Ariadb
sub mariadb_ariadb {
subheaderprint "AriaDB Metrics";
# AriaDB
unless ( defined $myvar{'have_aria'}
and $myvar{'have_aria'} eq "YES" )
{
infoprint "AriaDB is disabled.";
return;
}
infoprint "AriaDB is enabled.";
# Aria pagecache
if ( !defined( $mycalc{'total_aria_indexes'} ) and $doremote == 1 ) {
push( @generalrec,
"Unable to calculate Aria indexes on remote MySQL server < 5.0.0" );
}
elsif ( $mycalc{'total_aria_indexes'} =~ /^fail$/ ) {
badprint
"Cannot calculate Aria index size - re-run script as root user";
}
elsif ( $mycalc{'total_aria_indexes'} == "0" ) {
badprint
"None of your Aria tables are indexed - add indexes immediately";
}
else {
if (
$myvar{'aria_pagecache_buffer_size'} < $mycalc{'total_aria_indexes'}
&& $mycalc{'pct_aria_keys_from_mem'} < 95 )
{
badprint "Aria pagecache size / total Aria indexes: "
. hr_bytes( $myvar{'aria_pagecache_buffer_size'} ) . "/"
. hr_bytes( $mycalc{'total_aria_indexes'} ) . "";
push( @adjvars,
"aria_pagecache_buffer_size (> "
. hr_bytes( $mycalc{'total_aria_indexes'} )
. ")" );
}
else {
goodprint "Aria pagecache size / total Aria indexes: "
. hr_bytes( $myvar{'aria_pagecache_buffer_size'} ) . "/"
. hr_bytes( $mycalc{'total_aria_indexes'} ) . "";
}
if ( $mystat{'Aria_pagecache_read_requests'} > 0 ) {
if ( $mycalc{'pct_aria_keys_from_mem'} < 95 ) {
badprint
"Aria pagecache hit rate: $mycalc{'pct_aria_keys_from_mem'}% ("
. hr_num( $mystat{'Aria_pagecache_read_requests'} )
. " cached / "
. hr_num( $mystat{'Aria_pagecache_reads'} )
. " reads)";
}
else {
goodprint
"Aria pagecache hit rate: $mycalc{'pct_aria_keys_from_mem'}% ("
. hr_num( $mystat{'Aria_pagecache_read_requests'} )
. " cached / "
. hr_num( $mystat{'Aria_pagecache_reads'} )
. " reads)";
}
}
else {
# No queries have run that would use keys
}
}
}
# Recommendations for TokuDB
sub mariadb_tokudb {
subheaderprint "TokuDB Metrics";
# AriaDB
unless ( defined $myvar{'have_tokudb'}
&& $myvar{'have_tokudb'} eq "YES" )
{
infoprint "TokuDB is disabled.";
return;
}
infoprint "TokuDB is enabled.";
# All is to done here
}
# Recommendations for XtraDB
sub mariadb_xtradb {
subheaderprint "XtraDB Metrics";
# XtraDB
unless ( defined $myvar{'have_xtradb'}
&& $myvar{'have_xtradb'} eq "YES" )
{
infoprint "XtraDB is disabled.";
return;
}
infoprint "XtraDB is enabled.";
# All is to done here
}
# Recommendations for RocksDB
sub mariadb_rockdb {
subheaderprint "RocksDB Metrics";
# RocksDB
unless ( defined $myvar{'have_rocksdb'}
&& $myvar{'have_rocksdb'} eq "YES" )
{
infoprint "RocksDB is disabled.";
return;
}
infoprint "RocksDB is enabled.";
# All is to done here
}
# Recommendations for Spider
sub mariadb_spider {
subheaderprint "Spider Metrics";
# Spider
unless ( defined $myvar{'have_spider'}
&& $myvar{'have_spider'} eq "YES" )
{
infoprint "Spider is disabled.";
return;
}
infoprint "Spider is enabled.";
# All is to done here
}
# Recommendations for Connect
sub mariadb_connect {
subheaderprint "Connect Metrics";
# Connect
unless ( defined $myvar{'have_connect'}
&& $myvar{'have_connect'} eq "YES" )
{
infoprint "Connect is disabled.";
return;
}
infoprint "TokuDB is enabled.";
# All is to done here
}
# Perl trim function to remove whitespace from the start and end of the string
sub trim {
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
sub get_wsrep_options {
return () unless defined $myvar{'wsrep_provider_options'};
my @galera_options = split /;/, $myvar{'wsrep_provider_options'};
@galera_options = remove_cr @galera_options;
@galera_options = remove_empty @galera_options;
debugprint Dumper( \@galera_options );
return @galera_options;
}
sub get_gcache_memory {
my $gCacheMem = hr_raw( get_wsrep_option('gcache.size') );
return 0 unless defined $gCacheMem and $gCacheMem ne '';
return $gCacheMem;
}
sub get_wsrep_option {
my $key = shift;
return '' unless defined $myvar{'wsrep_provider_options'};
my @galera_options = get_wsrep_options;
return '' unless scalar(@galera_options) > 0;
my @memValues = grep /\s*$key =/, @galera_options;
my $memValue = $memValues[0];
return 0 unless defined $memValue;
$memValue =~ s/.*=\s*(.+)$/$1/g;
return $memValue;
}
# Recommendations for Galera
sub mariadb_galera {
subheaderprint "Galera Metrics";
# Galera Cluster
unless ( defined $myvar{'have_galera'}
&& $myvar{'have_galera'} eq "YES" )
{
infoprint "Galera is disabled.";
return;
}
infoprint "Galera is enabled.";
debugprint "Galera variables:";
foreach my $gvar ( keys %myvar ) {
next unless $gvar =~ /^wsrep.*/;
next if $gvar eq 'wsrep_provider_options';
debugprint "\t" . trim($gvar) . " = " . $myvar{$gvar};
$result{'Galera'}{'variables'}{$gvar} = $myvar{$gvar};
}
debugprint "Galera wsrep provider Options:";
my @galera_options = get_wsrep_options;
$result{'Galera'}{'wsrep options'} = get_wsrep_options();
foreach my $gparam (@galera_options) {
debugprint "\t" . trim($gparam);
}
debugprint "Galera status:";
foreach my $gstatus ( keys %mystat ) {
next unless $gstatus =~ /^wsrep.*/;
debugprint "\t" . trim($gstatus) . " = " . $mystat{$gstatus};
$result{'Galera'}{'status'}{$gstatus} = $myvar{$gstatus};
}
infoprint "GCache is using "
. hr_bytes_rnd( get_wsrep_option('gcache.mem_size') );
my @primaryKeysNbTables = select_array(
"Select CONCAT(c.table_schema,CONCAT('.', c.table_name))
from information_schema.columns c
join information_schema.tables t using (TABLE_SCHEMA, TABLE_NAME)
where c.table_schema not in ('mysql', 'information_schema', 'performance_schema')
and t.table_type != 'VIEW'
group by c.table_schema,c.table_name
having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
);
if ( get_wsrep_option('wsrep_slave_threads') > cpu_cores * 4
or get_wsrep_option('wsrep_slave_threads') < cpu_cores * 3 )
{
badprint
"wsrep_slave_threads is not equal to 2, 3 or 4 times number of CPU(s)";
push @adjvars, "wsrep_slave_threads= Nb of Core CPU * 4";
}
else {
goodprint
"wsrep_slave_threads is equal to 2, 3 or 4 times number of CPU(s)";
}
if ( get_wsrep_option('gcs.limit') !=
get_wsrep_option('wsrep_slave_threads') * 5 )
{
badprint "gcs.limit should be equal to 5 * wsrep_slave_threads";
push @adjvars, "gcs.limit= wsrep_slave_threads * 5";
} else {
goodprint "gcs.limit should be equal to 5 * wsrep_slave_threads";
}
if (get_wsrep_option('wsrep_slave_threads') > 1) {
infoprint "wsrep parallel slave can cause frequent inconsistency crash.";
push @adjvars, "Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
# check options for parallel slave
if (get_wsrep_option('wsrep_slave_FK_checks') eq "OFF") {
badprint "wsrep_slave_FK_checks is off with parallel slave";
push @adjvars, "wsrep_slave_FK_checks should be ON when using parallel slave";
}
# wsrep_slave_UK_checks seems useless in MySQL source code
if ($myvar{'innodb_autoinc_lock_mode'} != 2) {
badprint "innodb_autoinc_lock_mode is incorrect with parallel slave";
push @adjvars, "innodb_autoinc_lock_mode should be 2 when using parallel slave";
}
}
if (get_wsrep_option('gcs.fc_limit') != $myvar{'wsrep_slave_threads'} * 5 ) {
badprint "gcs.fc_limit should be equal to 5 * wsrep_slave_threads";
push @adjvars, "gcs.fc_limit= wsrep_slave_threads * 5";
} else {
goodprint "gcs.fc_limit is equal to 5 * wsrep_slave_threads";
}
if (get_wsrep_option('gcs.fc_factor') != 0.8 ) {
badprint "gcs.fc_factor should be equal to 0.8";
push @adjvars, "gcs.fc_factor=0.8";
}
else {
goodprint "gcs.fc_factor is equal to 0.8";
}
if ( get_wsrep_option('wsrep_flow_control_paused') > 0.02 ) {
badprint "Fraction of time node pause flow control > 0.02";
} else {
goodprint "Flow control fraction seems to be OK (wsrep_flow_control_paused<=0.02)";
}
if ( scalar(@primaryKeysNbTables) > 0 ) {
badprint "Following table(s) don't have primary key:";
foreach my $badtable (@primaryKeysNbTables) {
badprint "\t$badtable";
push @{ $result{'Tables without PK'} }, $badtable;
}
} else {
goodprint "All tables get a primary key";
}
my @nonInnoDBTables = select_array(
"select CONCAT(table_schema,CONCAT('.', table_name)) from information_schema.tables where ENGINE <> 'InnoDB' and table_schema not in ('mysql', 'performance_schema', 'information_schema')"
);
if ( scalar(@nonInnoDBTables) > 0 ) {
badprint "Following table(s) are not InnoDB table:";
push @generalrec,
"Ensure that all table(s) are InnoDB tables for Galera replication";
foreach my $badtable (@nonInnoDBTables) {
badprint "\t$badtable";
}
} else {
goodprint "All tables are InnoDB tables";
}
if ( $myvar{'binlog_format'} ne 'ROW' ) {
badprint "Binlog format should be in ROW mode.";
push @adjvars, "binlog_format = ROW";
} else {
goodprint "Binlog format is in ROW mode.";
}
if ( $myvar{'innodb_flush_log_at_trx_commit'} != 0 ) {
badprint "InnoDB flush log at each commit should be disabled.";
push @adjvars, "innodb_flush_log_at_trx_commit = 0";
} else {
goodprint "InnoDB flush log at each commit is disabled for Galera.";
}
infoprint "Read consistency mode :" . $myvar{'wsrep_causal_reads'};
if ( defined( $myvar{'wsrep_cluster_name'} )
and $myvar{'wsrep_on'} eq "ON" )
{
goodprint "Galera WsREP is enabled.";
if ( defined( $myvar{'wsrep_cluster_address'} )
and trim("$myvar{'wsrep_cluster_address'}") ne "" )
{
goodprint "Galera Cluster address is defined: "
. $myvar{'wsrep_cluster_address'};
my @NodesTmp = split /,/, $myvar{'wsrep_cluster_address'};
my $nbNodes = @NodesTmp;
infoprint "There are $nbNodes nodes in wsrep_cluster_address";
my $nbNodesSize = trim( $mystat{'wsrep_cluster_size'} );
if ( $nbNodesSize == 3 or $nbNodesSize == 5 ) {
goodprint "There are $nbNodesSize nodes in wsrep_cluster_size.";
}
else {
badprint
"There are $nbNodesSize nodes in wsrep_cluster_size. Prefer 3 or 5 nodes architecture.";
push @generalrec, "Prefer 3 or 5 nodes architecture.";
}
# wsrep_cluster_address doesn't include garbd nodes
if ( $nbNodes > $nbNodesSize ) {
badprint
"All cluster nodes are not detected. wsrep_cluster_size less then node count in wsrep_cluster_address";
}
else {
goodprint "All cluster nodes detected.";
}
}
else {
badprint "Galera Cluster address is undefined";
push @adjvars,
"set up wsrep_cluster_address variable for Galera replication";
}
if ( defined( $myvar{'wsrep_cluster_name'} )
and trim( $myvar{'wsrep_cluster_name'} ) ne "" )
{
goodprint "Galera Cluster name is defined: "
. $myvar{'wsrep_cluster_name'};
}
else {
badprint "Galera Cluster name is undefined";
push @adjvars,
"set up wsrep_cluster_name variable for Galera replication";
}
if ( defined( $myvar{'wsrep_node_name'} )
and trim( $myvar{'wsrep_node_name'} ) ne "" )
{
goodprint "Galera Node name is defined: "
. $myvar{'wsrep_node_name'};
}
else {
badprint "Galera node name is undefined";
push @adjvars,
"set up wsrep_node_name variable for Galera replication";
}
if ( trim( $myvar{'wsrep_notify_cmd'} ) ne "" ) {
goodprint "Galera Notify command is defined.";
}
else {
badprint "Galera Notify command is not defined.";
push( @adjvars, "set up parameter wsrep_notify_cmd to be notify" );
}
if ( trim( $myvar{'wsrep_sst_method'} ) !~ "^xtrabackup.*" ) {
badprint "Galera SST method is not xtrabackup based.";
push( @adjvars,
"set up parameter wsrep_sst_method to xtrabackup based parameter"
);
}
else {
goodprint "SST Method is based on xtrabackup.";
}
if (
(
defined( $myvar{'wsrep_OSU_method'} )
&& trim( $myvar{'wsrep_OSU_method'} ) eq "TOI"
)
|| ( defined( $myvar{'wsrep_osu_method'} )
&& trim( $myvar{'wsrep_osu_method'} ) eq "TOI" )
)
{
goodprint "TOI is default mode for upgrade.";
}
else {
badprint "Schema upgrade are not replicated automatically";
push( @adjvars, "set up parameter wsrep_OSU_method to TOI" );
}
infoprint "Max WsRep message : "
. hr_bytes( $myvar{'wsrep_max_ws_size'} );
}
else {
badprint "Galera WsREP is disabled";
}
if ( defined( $mystat{'wsrep_connected'} )
and $mystat{'wsrep_connected'} eq "ON" )
{
goodprint "Node is connected";
}
else {
badprint "Node is disconnected";
}
if ( defined( $mystat{'wsrep_ready'} ) and $mystat{'wsrep_ready'} eq "ON" )
{
goodprint "Node is ready";
}
else {
badprint "Node is not ready";
}
infoprint "Cluster status :" . $mystat{'wsrep_cluster_status'};
if ( defined( $mystat{'wsrep_cluster_status'} )
and $mystat{'wsrep_cluster_status'} eq "Primary" )
{
goodprint "Galera cluster is consistent and ready for operations";
}
else {
badprint "Cluster is not consistent and ready";
}
if ( $mystat{'wsrep_local_state_uuid'} eq
$mystat{'wsrep_cluster_state_uuid'} )
{
goodprint "Node and whole cluster at the same level: "
. $mystat{'wsrep_cluster_state_uuid'};
}
else {
badprint "Node and whole cluster not the same level";
infoprint "Node state uuid: " . $mystat{'wsrep_local_state_uuid'};
infoprint "Cluster state uuid: " . $mystat{'wsrep_cluster_state_uuid'};
}
if ( $mystat{'wsrep_local_state_comment'} eq 'Synced' ) {
goodprint "Node is synced with whole cluster.";
}
else {
badprint "Node is not synced";
infoprint "Node State : " . $mystat{'wsrep_local_state_comment'};
}
if ( $mystat{'wsrep_local_cert_failures'} == 0 ) {
goodprint "There is no certification failures detected.";
}
else {
badprint "There is "
. $mystat{'wsrep_local_cert_failures'}
. " certification failure(s)detected.";
}
for my $key ( keys %mystat ) {
if ( $key =~ /wsrep_|galera/i ) {
debugprint "WSREP: $key = $mystat{$key}";
}
}
debugprint Dumper get_wsrep_options();
}
# Recommendations for InnoDB
sub mysql_innodb {
subheaderprint "InnoDB Metrics";
# InnoDB
unless ( defined $myvar{'have_innodb'}
&& $myvar{'have_innodb'} eq "YES"
&& defined $enginestats{'InnoDB'} )
{
infoprint "InnoDB is disabled.";
if ( mysql_version_ge( 5, 5 ) ) {
badprint
"InnoDB Storage engine is disabled. InnoDB is the default storage engine";
}
return;
}
infoprint "InnoDB is enabled.";
if ( $opt{buffers} ne 0 ) {
infoprint "InnoDB Buffers";
if ( defined $myvar{'innodb_buffer_pool_size'} ) {
infoprint " +-- InnoDB Buffer Pool: "
. hr_bytes( $myvar{'innodb_buffer_pool_size'} ) . "";
}
if ( defined $myvar{'innodb_buffer_pool_instances'} ) {
infoprint " +-- InnoDB Buffer Pool Instances: "
. $myvar{'innodb_buffer_pool_instances'} . "";
}
if ( defined $myvar{'innodb_buffer_pool_chunk_size'} ) {
infoprint " +-- InnoDB Buffer Pool Chunk Size: "
. hr_bytes( $myvar{'innodb_buffer_pool_chunk_size'} ) . "";
}
if ( defined $myvar{'innodb_additional_mem_pool_size'} ) {
infoprint " +-- InnoDB Additional Mem Pool: "
. hr_bytes( $myvar{'innodb_additional_mem_pool_size'} ) . "";
}
if ( defined $myvar{'innodb_log_file_size'} ) {
infoprint " +-- InnoDB Log File Size: "
. hr_bytes( $myvar{'innodb_log_file_size'} ) . "("
. $mycalc{'innodb_log_size_pct'}
. " % of buffer pool)";
}
if ( defined $myvar{'innodb_log_files_in_group'} ) {
infoprint " +-- InnoDB Log File In Group: "
. $myvar{'innodb_log_files_in_group'};
}
if ( defined $myvar{'innodb_log_files_in_group'} ) {
infoprint " +-- InnoDB Total Log File Size: "
. hr_bytes( $myvar{'innodb_log_files_in_group'} *
$myvar{'innodb_log_file_size'} );
}
if ( defined $myvar{'innodb_log_buffer_size'} ) {
infoprint " +-- InnoDB Log Buffer: "
. hr_bytes( $myvar{'innodb_log_buffer_size'} );
}
if ( defined $mystat{'Innodb_buffer_pool_pages_free'} ) {
infoprint " +-- InnoDB Log Buffer Free: "
. hr_bytes( $mystat{'Innodb_buffer_pool_pages_free'} ) . "";
}
if ( defined $mystat{'Innodb_buffer_pool_pages_total'} ) {
infoprint " +-- InnoDB Log Buffer Used: "
. hr_bytes( $mystat{'Innodb_buffer_pool_pages_total'} ) . "";
}
}
if ( defined $myvar{'innodb_thread_concurrency'} ) {
infoprint "InnoDB Thread Concurrency: "
. $myvar{'innodb_thread_concurrency'};
}
# InnoDB Buffer Pull Size
if ( $myvar{'innodb_file_per_table'} eq "ON" ) {
goodprint "InnoDB File per table is activated";
}
else {
badprint "InnoDB File per table is not activated";
push( @adjvars, "innodb_file_per_table=ON" );
}
# InnoDB Buffer Pull Size
if ( $myvar{'innodb_buffer_pool_size'} > $enginestats{'InnoDB'} ) {
goodprint "InnoDB buffer pool / data size: "
. hr_bytes( $myvar{'innodb_buffer_pool_size'} ) . "/"
. hr_bytes( $enginestats{'InnoDB'} ) . "";
}
else {
badprint "InnoDB buffer pool / data size: "
. hr_bytes( $myvar{'innodb_buffer_pool_size'} ) . "/"
. hr_bytes( $enginestats{'InnoDB'} ) . "";
push( @adjvars,
"innodb_buffer_pool_size (>= "
. hr_bytes_rnd( $enginestats{'InnoDB'} )
. ") if possible." );
}
if ( $mycalc{'innodb_log_size_pct'} < 20
or $mycalc{'innodb_log_size_pct'} > 30 )
{
badprint "Ratio InnoDB log file size / InnoDB Buffer pool size ("
. $mycalc{'innodb_log_size_pct'} . " %): "
. hr_bytes( $myvar{'innodb_log_file_size'} ) . " * "
. $myvar{'innodb_log_files_in_group'} . "/"
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
. " should be equal 25%";
push(
@adjvars,
"innodb_log_file_size * innodb_log_files_in_group should be equal to 1/4 of buffer pool size (="
. hr_bytes_rnd(
$myvar{'innodb_buffer_pool_size'} *
$myvar{'innodb_log_files_in_group'} / 4
)
. ") if possible."
);
}
else {
goodprint "InnoDB log file size / InnoDB Buffer pool size: "
. hr_bytes( $myvar{'innodb_log_file_size'} ) . " * "
. $myvar{'innodb_log_files_in_group'} . "/"
. hr_bytes( $myvar{'innodb_buffer_pool_size'} )
. " should be equal 25%";
}
# InnoDB Buffer Pull Instances (MySQL 5.6.6+)
if ( defined( $myvar{'innodb_buffer_pool_instances'} ) ) {
# Bad Value if > 64
if ( $myvar{'innodb_buffer_pool_instances'} > 64 ) {
badprint "InnoDB buffer pool instances: "
. $myvar{'innodb_buffer_pool_instances'} . "";
push( @adjvars, "innodb_buffer_pool_instances (<= 64)" );
}
# InnoDB Buffer Pull Size > 1Go
if ( $myvar{'innodb_buffer_pool_size'} > 1024 * 1024 * 1024 ) {
# InnoDB Buffer Pull Size / 1Go = InnoDB Buffer Pull Instances limited to 64 max.
# InnoDB Buffer Pull Size > 64Go
my $max_innodb_buffer_pool_instances =
int( $myvar{'innodb_buffer_pool_size'} / ( 1024 * 1024 * 1024 ) );
$max_innodb_buffer_pool_instances = 64
if ( $max_innodb_buffer_pool_instances > 64 );
if ( $myvar{'innodb_buffer_pool_instances'} !=
$max_innodb_buffer_pool_instances )
{
badprint "InnoDB buffer pool instances: "
. $myvar{'innodb_buffer_pool_instances'} . "";
push( @adjvars,
"innodb_buffer_pool_instances(="
. $max_innodb_buffer_pool_instances
. ")" );
}
else {
goodprint "InnoDB buffer pool instances: "
. $myvar{'innodb_buffer_pool_instances'} . "";
}
# InnoDB Buffer Pull Size < 1Go
}
else {
if ( $myvar{'innodb_buffer_pool_instances'} != 1 ) {
badprint
"InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1).";
push( @adjvars, "innodb_buffer_pool_instances (=1)" );
}
else {
goodprint "InnoDB buffer pool instances: "
. $myvar{'innodb_buffer_pool_instances'} . "";
}
}
}
# InnoDB Used Buffer Pool Size vs CHUNK size
if ( !defined( $myvar{'innodb_buffer_pool_chunk_size'} ) ) {
infoprint
"InnoDB Buffer Pool Chunk Size not used or defined in your version";
}
else {
infoprint "Number of InnoDB Buffer Pool Chunk : "
. int( $myvar{'innodb_buffer_pool_size'} ) /
int( $myvar{'innodb_buffer_pool_chunk_size'} ) . " for "
. $myvar{'innodb_buffer_pool_instances'}
. " Buffer Pool Instance(s)";
if (
int( $myvar{'innodb_buffer_pool_size'} ) % (
int( $myvar{'innodb_buffer_pool_chunk_size'} ) *
int( $myvar{'innodb_buffer_pool_instances'} )
) eq 0
)
{
goodprint
"Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances";
}
else {
badprint
"Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances";
#push( @adjvars, "Adjust innodb_buffer_pool_instances, innodb_buffer_pool_chunk_size with innodb_buffer_pool_size" );
push( @adjvars,
"innodb_buffer_pool_size must always be equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances"
);
}
}
# InnoDB Read efficency
if ( defined $mycalc{'pct_read_efficiency'}
&& $mycalc{'pct_read_efficiency'} < 90 )
{
badprint "InnoDB Read buffer efficiency: "
. $mycalc{'pct_read_efficiency'} . "% ("
. ( $mystat{'Innodb_buffer_pool_read_requests'} -
$mystat{'Innodb_buffer_pool_reads'} )
. " hits/ "
. $mystat{'Innodb_buffer_pool_read_requests'}
. " total)";
}
else {
goodprint "InnoDB Read buffer efficiency: "
. $mycalc{'pct_read_efficiency'} . "% ("
. ( $mystat{'Innodb_buffer_pool_read_requests'} -
$mystat{'Innodb_buffer_pool_reads'} )
. " hits/ "
. $mystat{'Innodb_buffer_pool_read_requests'}
. " total)";
}
# InnoDB Write efficiency
if ( defined $mycalc{'pct_write_efficiency'}
&& $mycalc{'pct_write_efficiency'} < 90 )
{
badprint "InnoDB Write Log efficiency: "
. abs( $mycalc{'pct_write_efficiency'} ) . "% ("
. abs( $mystat{'Innodb_log_write_requests'} -
$mystat{'Innodb_log_writes'} )
. " hits/ "
. $mystat{'Innodb_log_write_requests'}
. " total)";
}
else {
goodprint "InnoDB Write log efficiency: "
. $mycalc{'pct_write_efficiency'} . "% ("
. ( $mystat{'Innodb_log_write_requests'} -
$mystat{'Innodb_log_writes'} )
. " hits/ "
. $mystat{'Innodb_log_write_requests'}
. " total)";
}
# InnoDB Log Waits
if ( defined $mystat{'Innodb_log_waits'}
&& $mystat{'Innodb_log_waits'} > 0 )
{
badprint "InnoDB log waits: "
. percentage( $mystat{'Innodb_log_waits'},
$mystat{'Innodb_log_writes'} )
. "% ("
. $mystat{'Innodb_log_waits'}
. " waits / "
. $mystat{'Innodb_log_writes'}
. " writes)";
push( @adjvars,
"innodb_log_buffer_size (>= "
. hr_bytes_rnd( $myvar{'innodb_log_buffer_size'} )
. ")" );
}
else {
goodprint "InnoDB log waits: "
. percentage( $mystat{'Innodb_log_waits'},
$mystat{'Innodb_log_writes'} )
. "% ("
. $mystat{'Innodb_log_waits'}
. " waits / "
. $mystat{'Innodb_log_writes'}
. " writes)";
}
$result{'Calculations'} = {%mycalc};
}
# Recommendations for Database metrics
sub mysql_databases {
return if ( $opt{dbstat} == 0 );
subheaderprint "Database Metrics";
unless ( mysql_version_ge( 5, 5 ) ) {
infoprint
"Skip Database metrics from information schema missing in this version";
return;
}
my @dblist = select_array("SHOW DATABASES;");
infoprint "There is " . scalar(@dblist) . " Database(s).";
my @totaldbinfo = split /\s/,
select_one(
"SELECT SUM(TABLE_ROWS), SUM(DATA_LENGTH), SUM(INDEX_LENGTH) , SUM(DATA_LENGTH+INDEX_LENGTH), COUNT(TABLE_NAME),COUNT(DISTINCT(TABLE_COLLATION)),COUNT(DISTINCT(ENGINE)) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ( 'mysql' );"
);
infoprint "All Databases:";
infoprint " +-- TABLE : "
. ( $totaldbinfo[4] eq 'NULL' ? 0 : $totaldbinfo[4] ) . "";
infoprint " +-- ROWS : "
. ( $totaldbinfo[0] eq 'NULL' ? 0 : $totaldbinfo[0] ) . "";
infoprint " +-- DATA : "
. hr_bytes( $totaldbinfo[1] ) . "("
. percentage( $totaldbinfo[1], $totaldbinfo[3] ) . "%)";
infoprint " +-- INDEX : "
. hr_bytes( $totaldbinfo[2] ) . "("
. percentage( $totaldbinfo[2], $totaldbinfo[3] ) . "%)";
infoprint " +-- SIZE : " . hr_bytes( $totaldbinfo[3] ) . "";
infoprint " +-- COLLA : "
. ( $totaldbinfo[5] eq 'NULL' ? 0 : $totaldbinfo[5] ) . " ("
. (
join ", ",
select_array(
"SELECT DISTINCT(TABLE_COLLATION) FROM information_schema.TABLES;")
) . ")";
infoprint " +-- ENGIN : "
. ( $totaldbinfo[6] eq 'NULL' ? 0 : $totaldbinfo[6] ) . " ("
. (
join ", ",
select_array("SELECT DISTINCT(ENGINE) FROM information_schema.TABLES;")
) . ")";
$result{'Databases'}{'All databases'}{'Rows'} =
( $totaldbinfo[0] eq 'NULL' ? 0 : $totaldbinfo[0] );
$result{'Databases'}{'All databases'}{'Data Size'} = $totaldbinfo[1];
$result{'Databases'}{'All databases'}{'Data Pct'} =
percentage( $totaldbinfo[1], $totaldbinfo[3] ) . "%";
$result{'Databases'}{'All databases'}{'Index Size'} = $totaldbinfo[2];
$result{'Databases'}{'All databases'}{'Index Pct'} =
percentage( $totaldbinfo[2], $totaldbinfo[3] ) . "%";
$result{'Databases'}{'All databases'}{'Total Size'} = $totaldbinfo[3];
print "\n" unless ( $opt{'silent'} or $opt{'json'} );
foreach (@dblist) {
chomp($_);
if ( $_ eq "information_schema"
or $_ eq "performance_schema"
or $_ eq "mysql"
or $_ eq "" )
{
next;
}
my @dbinfo = split /\s/,
select_one(
"SELECT TABLE_SCHEMA, SUM(TABLE_ROWS), SUM(DATA_LENGTH), SUM(INDEX_LENGTH) , SUM(DATA_LENGTH+INDEX_LENGTH), COUNT(DISTINCT ENGINE),COUNT(TABLE_NAME),COUNT(DISTINCT(TABLE_COLLATION)),COUNT(DISTINCT(ENGINE)) FROM information_schema.TABLES WHERE TABLE_SCHEMA='$_' GROUP BY TABLE_SCHEMA ORDER BY TABLE_SCHEMA"
);
next unless defined $dbinfo[0];
infoprint "Database: " . $dbinfo[0] . "";
infoprint " +-- TABLE: "
. ( !defined( $dbinfo[6] ) or $dbinfo[6] eq 'NULL' ? 0 : $dbinfo[6] )
. "";
infoprint " +-- COLL : "
. ( $dbinfo[7] eq 'NULL' ? 0 : $dbinfo[7] ) . " ("
. (
join ", ",
select_array(
"SELECT DISTINCT(TABLE_COLLATION) FROM information_schema.TABLES WHERE TABLE_SCHEMA='$_';"
)
) . ")";
infoprint " +-- ROWS : "
. ( !defined( $dbinfo[1] ) or $dbinfo[1] eq 'NULL' ? 0 : $dbinfo[1] )
. "";
infoprint " +-- DATA : "
. hr_bytes( $dbinfo[2] ) . "("
. percentage( $dbinfo[2], $dbinfo[4] ) . "%)";
infoprint " +-- INDEX: "
. hr_bytes( $dbinfo[3] ) . "("
. percentage( $dbinfo[3], $dbinfo[4] ) . "%)";
infoprint " +-- TOTAL: " . hr_bytes( $dbinfo[4] ) . "";
infoprint " +-- ENGIN : "
. ( $dbinfo[8] eq 'NULL' ? 0 : $dbinfo[8] ) . " ("
. (
join ", ",
select_array(
"SELECT DISTINCT(ENGINE) FROM information_schema.TABLES WHERE TABLE_SCHEMA='$_'"
)
) . ")";
badprint "Index size is larger than data size for $dbinfo[0] \n"
if ( $dbinfo[2] ne 'NULL' )
and ( $dbinfo[3] ne 'NULL' )
and ( $dbinfo[2] < $dbinfo[3] );
badprint "There are " . $dbinfo[5] . " storage engines. Be careful. \n"
if $dbinfo[5] > 1;
$result{'Databases'}{ $dbinfo[0] }{'Rows'} = $dbinfo[1];
$result{'Databases'}{ $dbinfo[0] }{'Tables'} = $dbinfo[6];
$result{'Databases'}{ $dbinfo[0] }{'Collations'} = $dbinfo[7];
$result{'Databases'}{ $dbinfo[0] }{'Data Size'} = $dbinfo[2];
$result{'Databases'}{ $dbinfo[0] }{'Data Pct'} =
percentage( $dbinfo[2], $dbinfo[4] ) . "%";
$result{'Databases'}{ $dbinfo[0] }{'Index Size'} = $dbinfo[3];
$result{'Databases'}{ $dbinfo[0] }{'Index Pct'} =
percentage( $dbinfo[3], $dbinfo[4] ) . "%";
$result{'Databases'}{ $dbinfo[0] }{'Total Size'} = $dbinfo[4];
if ( $dbinfo[7] > 1 ) {
badprint $dbinfo[7]
. " different collations for database "
. $dbinfo[0];
push( @generalrec,
"Check all table collations are identical for all tables in "
. $dbinfo[0]
. " database." );
}
else {
goodprint $dbinfo[7]
. " collation for "
. $dbinfo[0]
. " database.";
}
if ( $dbinfo[8] > 1 ) {
badprint $dbinfo[8]
. " different engines for database "
. $dbinfo[0];
push( @generalrec,
"Check all table engines are identical for all tables in "
. $dbinfo[0]
. " database." );
}
else {
goodprint $dbinfo[8] . " engine for " . $dbinfo[0] . " database.";
}
my @distinct_column_charset = select_array(
"select DISTINCT(CHARACTER_SET_NAME) from information_schema.COLUMNS where CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA ='$_'"
);
infoprint "Charsets for $dbinfo[0] database table column: "
. join( ', ', @distinct_column_charset );
if ( scalar(@distinct_column_charset) > 1 ) {
badprint $dbinfo[0]
. " table column(s) has several charsets defined for all text like column(s).";
push( @generalrec,
"Limit charset for column to one charset if possible for "
. $dbinfo[0]
. " database." );
}
else {
goodprint $dbinfo[0]
. " table column(s) has same charset defined for all text like column(s).";
}
my @distinct_column_collation = select_array(
"select DISTINCT(COLLATION_NAME) from information_schema.COLUMNS where COLLATION_NAME IS NOT NULL AND TABLE_SCHEMA ='$_'"
);
infoprint "Collations for $dbinfo[0] database table column: "
. join( ', ', @distinct_column_collation );
if ( scalar(@distinct_column_collation) > 1 ) {
badprint $dbinfo[0]
. " table column(s) has several collations defined for all text like column(s).";
push( @generalrec,
"Limit collations for column to one collation if possible for "
. $dbinfo[0]
. " database." );
}
else {
goodprint $dbinfo[0]
. " table column(s) has same collation defined for all text like column(s).";
}
}
}
# Recommendations for Indexes metrics
sub mysql_indexes {
return if ( $opt{idxstat} == 0 );
subheaderprint "Indexes Metrics";
unless ( mysql_version_ge( 5, 5 ) ) {
infoprint
"Skip Index metrics from information schema missing in this version";
return;
}
# unless ( mysql_version_ge( 5, 6 ) ) {
# infoprint
#"Skip Index metrics from information schema due to erroneous information provided in this version";
# return;
# }
my $selIdxReq = <<'ENDSQL';
SELECT
CONCAT(CONCAT(t.TABLE_SCHEMA, '.'),t.TABLE_NAME) AS 'table'
, CONCAT(CONCAT(CONCAT(s.INDEX_NAME, '('),s.COLUMN_NAME), ')') AS 'index'
, s.SEQ_IN_INDEX AS 'seq'
, s2.max_columns AS 'maxcol'
, s.CARDINALITY AS 'card'
, t.TABLE_ROWS AS 'est_rows'
, INDEX_TYPE as type
, ROUND(((s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) * 100), 2) AS 'sel'
FROM INFORMATION_SCHEMA.STATISTICS s
INNER JOIN INFORMATION_SCHEMA.TABLES t
ON s.TABLE_SCHEMA = t.TABLE_SCHEMA
AND s.TABLE_NAME = t.TABLE_NAME
INNER JOIN (
SELECT
TABLE_SCHEMA
, TABLE_NAME
, INDEX_NAME
, MAX(SEQ_IN_INDEX) AS max_columns
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA NOT IN ('mysql', 'information_schema', 'performance_schema')
AND INDEX_TYPE <> 'FULLTEXT'
GROUP BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME
) AS s2
ON s.TABLE_SCHEMA = s2.TABLE_SCHEMA
AND s.TABLE_NAME = s2.TABLE_NAME
AND s.INDEX_NAME = s2.INDEX_NAME
WHERE t.TABLE_SCHEMA NOT IN ('mysql', 'information_schema', 'performance_schema')
AND t.TABLE_ROWS > 10
AND s.CARDINALITY IS NOT NULL
AND (s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) < 8.00
ORDER BY sel
LIMIT 10;
ENDSQL
my @idxinfo = select_array($selIdxReq);
infoprint "Worst selectivity indexes:";
foreach (@idxinfo) {
debugprint "$_";
my @info = split /\s/;
infoprint "Index: " . $info[1] . "";
infoprint " +-- COLUMN : " . $info[0] . "";
infoprint " +-- NB SEQS : " . $info[2] . " sequence(s)";
infoprint " +-- NB COLS : " . $info[3] . " column(s)";
infoprint " +-- CARDINALITY : " . $info[4] . " distinct values";
infoprint " +-- NB ROWS : " . $info[5] . " rows";
infoprint " +-- TYPE : " . $info[6];
infoprint " +-- SELECTIVITY : " . $info[7] . "%";
$result{'Indexes'}{ $info[1] }{'Column'} = $info[0];
$result{'Indexes'}{ $info[1] }{'Sequence number'} = $info[2];
$result{'Indexes'}{ $info[1] }{'Number of column'} = $info[3];
$result{'Indexes'}{ $info[1] }{'Cardinality'} = $info[4];
$result{'Indexes'}{ $info[1] }{'Row number'} = $info[5];
$result{'Indexes'}{ $info[1] }{'Index Type'} = $info[6];
$result{'Indexes'}{ $info[1] }{'Selectivity'} = $info[7];
if ( $info[7] < 25 ) {
badprint "$info[1] has a low selectivity";
}
}
return
unless ( defined( $myvar{'performance_schema'} )
and $myvar{'performance_schema'} eq 'ON' );
$selIdxReq = <<'ENDSQL';
SELECT CONCAT(CONCAT(object_schema,'.'),object_name) AS 'table', index_name
FROM performance_schema.table_io_waits_summary_by_index_usage
WHERE index_name IS NOT NULL
AND count_star =0
AND index_name <> 'PRIMARY'
AND object_schema != 'mysql'
ORDER BY count_star, object_schema, object_name;
ENDSQL
@idxinfo = select_array($selIdxReq);
infoprint "Unused indexes:";
push( @generalrec, "Remove unused indexes." ) if ( scalar(@idxinfo) > 0 );
foreach (@idxinfo) {
debugprint "$_";
my @info = split /\s/;
badprint "Index: $info[1] on $info[0] is not used.";
push @{ $result{'Indexes'}{'Unused Indexes'} },
$info[0] . "." . $info[1];
}
}
# Take the two recommendation arrays and display them at the end of the output
sub make_recommendations {
$result{'Recommendations'} = \@generalrec;
$result{'Adjust variables'} = \@adjvars;
subheaderprint "Recommendations";
if ( @generalrec > 0 ) {
prettyprint "General recommendations:";
foreach (@generalrec) { prettyprint " " . $_ . ""; }
}
if ( @adjvars > 0 ) {
prettyprint "Variables to adjust:";
if ( $mycalc{'pct_max_physical_memory'} > 90 ) {
prettyprint
" *** MySQL's maximum memory usage is dangerously high ***\n"
. " *** Add RAM before increasing MySQL buffer variables ***";
}
foreach (@adjvars) { prettyprint " " . $_ . ""; }
}
if ( @generalrec == 0 && @adjvars == 0 ) {
prettyprint "No additional performance recommendations are available.";
}
}
sub close_outputfile {
close($fh) if defined($fh);
}
sub headerprint {
prettyprint
" >> MySQLTuner $tunerversion - Major Hayden \n"
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.com/\n"
. " >> Run with '--help' for additional options and output filtering";
}
sub string2file {
my $filename = shift;
my $content = shift;
open my $fh, q(>), $filename
or die
"Unable to open $filename in write mode. Please check permissions for this file or directory";
print $fh $content if defined($content);
close $fh;
debugprint $content if ( $opt{'debug'} );
}
sub file2array {
my $filename = shift;
debugprint "* reading $filename" if ( $opt{'debug'} );
my $fh;
open( $fh, q(<), "$filename" )
or die "Couldn't open $filename for reading: $!\n";
my @lines = <$fh>;
close($fh);
return @lines;
}
sub file2string {
return join( '', file2array(@_) );
}
my $templateModel;
if ( $opt{'template'} ne 0 ) {
$templateModel = file2string( $opt{'template'} );
}
else {
# DEFAULT REPORT TEMPLATE
$templateModel = <<'END_TEMPLATE';
MySQLTuner Report
Result output
{$data}
END_TEMPLATE
}
sub dump_result {
if ( $opt{'debug'} ) {
debugprint Dumper( \%result );
}
debugprint "HTML REPORT: $opt{'reportfile'}";
if ( $opt{'reportfile'} ne 0 ) {
eval { require Text::Template };
if ($@) {
badprint "Text::Template Module is needed.";
exit 1;
}
my $vars = { 'data' => Dumper( \%result ) };
my $template;
{
no warnings 'once';
$template = Text::Template->new(
TYPE => 'STRING',
PREPEND => q{;},
SOURCE => $templateModel
) or die "Couldn't construct template: $Text::Template::ERROR";
}
open my $fh, q(>), $opt{'reportfile'}
or die
"Unable to open $opt{'reportfile'} in write mode. please check permissions for this file or directory";
$template->fill_in( HASH => $vars, OUTPUT => $fh );
close $fh;
}
if ( $opt{'json'} ne 0 ) {
eval { require JSON };
if ($@) {
print "$bad JSON Module is needed.\n";
exit 1;
}
my $json = JSON->new->allow_nonref;
print $json->utf8(1)->pretty( ( $opt{'prettyjson'} ? 1 : 0 ) )
->encode( \%result );
}
}
sub which {
my $prog_name = shift;
my $path_string = shift;
my @path_array = split /:/, $ENV{'PATH'};
for my $path (@path_array) {
if ( -x "$path/$prog_name" ) {
return "$path/$prog_name";
}
}
return 0;
}
# ---------------------------------------------------------------------------
# BEGIN 'MAIN'
# ---------------------------------------------------------------------------
headerprint; # Header Print
validate_tuner_version; # Check last version
mysql_setup; # Gotta login first
os_setup; # Set up some OS variables
get_all_vars; # Toss variables/status into hashes
get_tuning_info; # Get information about the tuning connexion
validate_mysql_version; # Check current MySQL version
check_architecture; # Suggest 64-bit upgrade
system_recommendations; # avoid to many service on the same host
log_file_recommandations; # check log file content
check_storage_engines; # Show enabled storage engines
mysql_databases; # Show informations about databases
mysql_indexes; # Show informations about indexes
security_recommendations; # Display some security recommendations
cve_recommendations; # Display related CVE
calculations; # Calculate everything we need
mysql_stats; # Print the server stats
mysqsl_pfs; # Print Performance schema info
mariadb_threadpool; # Print MaraiDB ThreadPool stats
mysql_myisam; # Print MyISAM stats
mysql_innodb; # Print InnoDB stats
mariadb_ariadb; # Print MaraiDB AriaDB stats
mariadb_tokudb; # Print MariaDB Tokudb stats
mariadb_xtradb; # Print MariaDB XtraDB stats
mariadb_rockdb; # Print MariaDB RockDB stats
mariadb_spider; # Print MariaDB Spider stats
mariadb_connect; # Print MariaDB Connect stats
mariadb_galera; # Print MariaDB Galera Cluster stats
get_replication_status; # Print replication info
make_recommendations; # Make recommendations based on stats
dump_result; # Dump result if debug is on
close_outputfile; # Close reportfile if needed
# ---------------------------------------------------------------------------
# END 'MAIN'
# ---------------------------------------------------------------------------
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
MySQLTuner 1.7.2 - MySQL High Performance Tuning Script
=head1 IMPORTANT USAGE GUIDELINES
To run the script with the default options, run the script without arguments
Allow MySQL server to run for at least 24-48 hours before trusting suggestions
Some routines may require root level privileges (script will provide warnings)
You must provide the remote server's total memory when connecting to other servers
=head1 CONNECTION AND AUTHENTIFICATION
--host Connect to a remote host to perform tests (default: localhost)
--socket Use a different socket for a local connection
--port Port to use for connection (default: 3306)
--user Username to use for authentication
--userenv Name of env variable which contains username to use for authentication
--pass Password to use for authentication
--passenv Name of env variable which contains password to use for authentication
--mysqladmin Path to a custom mysqladmin executable
--mysqlcmd Path to a custom mysql executable
--defaults-file Path to a custom .my.cnf
=head1 PERFORMANCE AND REPORTING OPTIONS
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
--skippassword Don't perform checks on user passwords(default: off)
--checkversion Check for updates to MySQLTuner (default: don't check)
--updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check)
--forcemem Amount of RAM installed in megabytes
--forceswap Amount of swap memory configured in megabytes
--passwordfile Path to a password file list(one password by line)
=head1 OUTPUT OPTIONS
--silent Don't output anything on screen
--nogood Remove OK responses
--nobad Remove negative/suggestion responses
--noinfo Remove informational responses
--debug Print debug information
--dbstat Print database information
--idxstat Print index information
--sysstat Print system information
--pfstat Print Performance schema
--bannedports Ports banned separated by comma(,)
--maxportallowed Number of ports opened allowed on this hosts
--cvefile CVE File for vulnerability checks
--nocolor Don't print output in color
--json Print result as JSON string
--buffers Print global and per-thread buffer values
--outputfile Path to a output txt file
--reportfile Path to a report txt file
--template Path to a template file
--verbose Prints out all options (default: no verbose)
=head1 PERLDOC
You can find documentation for this module with the perldoc command.
perldoc mysqltuner
=head2 INTERNALS
L
Internal documentation
=head1 AUTHORS
Major Hayden - major@mhtx.net
=head1 CONTRIBUTORS
=over 4
=item *
Matthew Montgomery
=item *
Paul Kehrer
=item *
Dave Burgess
=item *
Jonathan Hinds
=item *
Mike Jackson
=item *
Nils Breunese
=item *
Shawn Ashlee
=item *
Luuk Vosslamber
=item *
Ville Skytta
=item *
Trent Hornibrook
=item *
Jason Gill
=item *
Mark Imbriaco
=item *
Greg Eden
=item *
Aubin Galinotti
=item *
Giovanni Bechis
=item *
Bill Bradford
=item *
Ryan Novosielski
=item *
Michael Scheidell
=item *
Blair Christensen
=item *
Hans du Plooy
=item *
Victor Trac
=item *
Everett Barnes
=item *
Tom Krouper
=item *
Gary Barrueto
=item *
Simon Greenaway
=item *
Adam Stein
=item *
Isart Montane
=item *
Baptiste M.
=item *
Cole Turner
=item *
Major Hayden
=item *
Joe Ashcraft
=item *
Jean-Marie Renouard
=item *
Stephan GroBberndt
=item *
Christian Loos
=back
=head1 SUPPORT
Bug reports, feature requests, and downloads at http://mysqltuner.com/
Bug tracker can be found at https://github.com/major/MySQLTuner-perl/issues
Maintained by Major Hayden (major\@mhtx.net) - Licensed under GPL
=head1 SOURCE CODE
L
git clone https://github.com/major/MySQLTuner-perl.git
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2006-2017 Major Hayden - major@mhtx.net
For the latest updates, please visit http://mysqltuner.com/
Git repository available at http://github.com/major/MySQLTuner-perl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will 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 have received a copy of the GNU General Public License
along with this program. If not, see .
=cut
# Local variables:
# indent-tabs-mode: t
# cperl-indent-level: 8
# perl-indent-level: 8
# End:
MySQLTuner-perl-1.7.2/mysqltuner.png 0000664 0000000 0000000 00000232035 13107067151 0017403 0 ustar 00root root 0000000 0000000 PNG
IHDR
+ sRGB gAMA a pHYs od IDATx^>q ~7{oG!H<
<