-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,538 additions
and
1,620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
install plugin DISKS soname 'disks'; | ||
show create table information_schema.disks; | ||
Table Create Table | ||
DISKS CREATE TEMPORARY TABLE `DISKS` ( | ||
`Disk` varchar(4096) NOT NULL DEFAULT '', | ||
`Path` varchar(4096) NOT NULL DEFAULT '', | ||
`Total` int(32) NOT NULL DEFAULT 0, | ||
`Used` int(32) NOT NULL DEFAULT 0, | ||
`Available` int(32) NOT NULL DEFAULT 0 | ||
) ENGINE=MEMORY DEFAULT CHARSET=utf8 | ||
select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; | ||
sum(Total) > sum(Available) sum(Total)>sum(Used) | ||
1 1 | ||
uninstall plugin DISKS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--source include/not_windows.inc | ||
|
||
if (!$DISKS_SO) { | ||
skip No DISKS plugin; | ||
} | ||
|
||
install plugin DISKS soname 'disks'; | ||
show create table information_schema.disks; | ||
select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; | ||
|
||
uninstall plugin DISKS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
IF(NOT WIN32) | ||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql) | ||
MYSQL_ADD_PLUGIN(DISKS information_schema_disks.cc MODULE_ONLY RECOMPILE_FOR_EMBEDDED) | ||
ENDIF() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
Information Schema Disks | ||
------------------------ | ||
This is a proof-of-concept information schema plugin that allows the | ||
disk space situation to be monitored. When installed, it can be used | ||
as follows: | ||
|
||
> select * from information_schema.disks; | ||
+-----------+-----------------------+-----------+----------+-----------+ | ||
| Disk | Path | Total | Used | Available | | ||
+-----------+-----------------------+-----------+----------+-----------+ | ||
| /dev/sda3 | / | 47929956 | 30666304 | 14805864 | | ||
| /dev/sda1 | /boot/efi | 191551 | 3461 | 188090 | | ||
| /dev/sda4 | /home | 174679768 | 80335392 | 85448120 | | ||
| /dev/sdb1 | /mnt/hdd | 961301832 | 83764 | 912363644 | | ||
| /dev/sdb1 | /home/wikman/Music | 961301832 | 83764 | 912363644 | | ||
| /dev/sdb1 | /home/wikman/Videos | 961301832 | 83764 | 912363644 | | ||
| /dev/sdb1 | /home/wikman/hdd | 961301832 | 83764 | 912363644 | | ||
| /dev/sdb1 | /home/wikman/Pictures | 961301832 | 83764 | 912363644 | | ||
| /dev/sda3 | /var/lib/docker/aufs | 47929956 | 30666304 | 14805864 | | ||
+-----------+-----------------------+-----------+----------+-----------+ | ||
9 rows in set (0.00 sec) | ||
|
||
- 'Disk' is the name of the disk itself. | ||
- 'Path' is the mount point of the disk. | ||
- 'Total' is the total space in KiB. | ||
- 'Used' is the used amount of space in KiB, and | ||
- 'Available' is the amount of space in KiB available to non-root users. | ||
|
||
Note that as the amount of space available to root may be more that what | ||
is available to non-root users, 'available' + 'used' may be less than 'total'. | ||
|
||
All paths to which a particular disk has been mounted are reported. The | ||
rationale is that someone might want to take different action e.g. depending | ||
on which disk is relevant for a particular path. This leads to the same disk | ||
being reported multiple times. An alternative to this would be to have two | ||
tables; disks and mounts. | ||
|
||
> select * from information_schema.disks; | ||
+-----------+-----------+----------+-----------+ | ||
| Disk | Total | Used | Available | | ||
+-----------+-----------+----------+-----------+ | ||
| /dev/sda3 | 47929956 | 30666304 | 14805864 | | ||
| /dev/sda1 | 191551 | 3461 | 188090 | | ||
| /dev/sda4 | 174679768 | 80335392 | 85448120 | | ||
| /dev/sdb1 | 961301832 | 83764 | 912363644 | | ||
+-----------+-----------+----------+-----------+ | ||
|
||
> select * from information_schema.mounts; | ||
+-----------------------+-----------+ | ||
| Path | Disk | | ||
+-----------------------+-----------+ | ||
| / | /dev/sda3 | | ||
| /boot/efi | /dev/sda1 | | ||
| /home | /dev/sda4 | | ||
| /mnt/hdd | /dev/sdb1 | | ||
| /home/wikman/Music | /dev/sdb1 | | ||
... | ||
|
||
|
||
Building | ||
-------- | ||
- Ensure that the directory information_schema_disks is in the top-level | ||
directory of the server. | ||
- Add | ||
|
||
ADD_SUBDIRECTORY(information_schema_disks) | ||
|
||
to the top-level CMakeLists.txt | ||
|
||
> Invoke make | ||
|
||
$ make | ||
|
||
Installation | ||
------------ | ||
- Copy information_schema_disks/libinformation_schema_disks.so to the plugin | ||
directory of the server: | ||
|
||
$ cd information_schema_disks | ||
$ sudo cp libinformation_schema_disks.so plugin-directory-of-server | ||
|
||
- Using mysql, install the plugin: | ||
|
||
MariaDB [(none)]> install plugin disks soname 'libinformation_schema_disks.so'; | ||
|
||
Usage | ||
----- | ||
The plugin appears as the table 'disks' in 'information_schema'. | ||
|
||
MariaDB [(none)]> select * from information_schema.disks; | ||
+-----------+-----------------------+-----------+----------+-----------+ | ||
| Disk | Path | Total | Used | Available | | ||
+-----------+-----------------------+-----------+----------+-----------+ | ||
| /dev/sda3 | / | 47929956 | 30666308 | 14805860 | | ||
| /dev/sda1 | /boot/efi | 191551 | 3461 | 188090 | | ||
| /dev/sda4 | /home | 174679768 | 80348148 | 85435364 | | ||
| /dev/sdb1 | /mnt/hdd | 961301832 | 83764 | 912363644 | | ||
| /dev/sdb1 | /home/wikman/Music | 961301832 | 83764 | 912363644 | | ||
| /dev/sdb1 | /home/wikman/Videos | 961301832 | 83764 | 912363644 | | ||
... | ||
|
Oops, something went wrong.