MySQL information shell scripts (Linux)

Monitors of this template are compatible with all license types and are provided as an example of using "one-liners" to get MySQL-related information.

Prerequisites:
- utility bc (general purpose calculator) present on target host
- mysql' defaults file (such as ~/.my.cnf) should be set up, allowing connecting to MySQL server as DB superuser, without requiring to enter password
- the target (credentials) user ID used to connect should be allowed, in /etc/sudoers, to run '/usr/bin/du -ms *' without password; also, its defaults should allow running sudo without terminal allocated

The typical lines for /etc/sudoers file, to meet the above requirement:
Defaults:monitor.user !requiretty
monitor.user ALL=NOPASSWD: /usr/bin/du -ms *
(assuming the user ID used to connect is monitor.user; please set corresponding Unix-like credentials in Settings > User Credentials section of IPHost GUI client)

The typical ~/.my.cnf file for the above user:
[mysql]
user=root
password="rootpassword"
(use actual user name and password; set the mentioned file permissions to 0400)

Monitors description:
MySQL storage disk usage, MiBs (Linux): shows how much space, in megabytes (1024 * 1024 bytes) do MySQL data directory occupy
MySQL user records number (Linux): shows the number of users credentials defined; if this value ever changes, it might be reasonable to raise alert
MySQL version string (Linux): retrieves current MySQL version string (in format "5.1.23") and transforms it into integer, with every version part multiplied by 1000 (the example version above will return performance value of 5001023) - useful to watch automated MySQL updates

You are encouraged to use these monitors as starting point to write your own short on-liners, to get database engine-related state variables.
MySQL-shell-scripts-Linux.zip 1.3K Downloaded: 21043 times
Sign In or Register to comment.