From d698dc8058d3d66ee11c22adf411080486d3d04b Mon Sep 17 00:00:00 2001 From: tbauriedel Date: Mon, 15 Aug 2022 14:34:48 +0200 Subject: [PATCH] mysql: add version --- README.md | 1 + modules/mysql/collector.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index ef8820e..daf535d 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ Module: `mysql` Is looking for standard MySQL or MariaDB installations. +* Mysql version * Package versions * Service status * Configuration files from `/etc/my*` (depending on the known paths) diff --git a/modules/mysql/collector.go b/modules/mysql/collector.go index f10c29e..09bc9e1 100644 --- a/modules/mysql/collector.go +++ b/modules/mysql/collector.go @@ -22,6 +22,10 @@ var possibleConfigPaths = []string{ "/etc/mariadb*", } +var commands = map[string][]string{ + "mysql-version.txt": {"mysql", "-V"}, +} + // Detect if a MySQL or MariaDB daemon appears to be running. func Detect() string { for _, name := range possibleServices { @@ -47,4 +51,8 @@ func Collect(c *collection.Collection) { c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*mysql*", "*mariadb*") c.AddServiceStatusRaw(ModuleName+"/service.txt", service) c.AddFilesIfFound(ModuleName, possibleConfigPaths...) + + for name, cmd := range commands { + c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...) + } }