diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 39ca093..8bc8479 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -11,8 +11,6 @@ builds: - arm64 goos: - linux - - windows - - darwin ldflags: - >- -s -w -X main.version={{.Version}} diff --git a/README.md b/README.md index 42a2806..a9b70de 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,61 @@ -![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/NETWAYS/check_vspheredb_data) -![GitHub](https://img.shields.io/github/license/NETWAYS/check_vspheredb_data) +# check_vspheredb_data -# README +An Icinga check plugin to check the performance data gathered by the [Icingaweb2 vSphereDB module](https://github.com/icinga/icingaweb2-module-vspheredb). -`check_vspheredb_data` is a check plugin for checking performance data gathered by the [Icingaweb2 vSphereDB module](https://github.com/icinga/icingaweb2-module-vspheredb) -against given thresholds written in Go. It is a rewrite of [an older version](https://github.com/NETWAYS/vspheredb-data-check) written in Rust, utilizing the [go-check](https://github.com/NETWAYS/go-check) SDK for monitoring plugins for better maintainability. - -It allows for finegrained monitoring of ESXI hosts on Icinga2's side without the need to configure alerting on -the vCenters' side as vSphereDB's inbuilt mechanisms do. - -![screenshot of plugin output](docs/thumbnail.png) +It allows for monitoring of ESXI hosts on Icinga2's side without the need to configure alerting on the vCenters' side as vSphereDB's inbuilt mechanisms do. ## Installation Download a Release binary for your system's architecture from the [Releases](https://github.com/NETWAYS/check_vspheredb_data/releases) page. -## Building the project +## Usage + +``` +Available Commands: + completion Generate the autocompletion script for the specified shell + cpu Checks the current CPU usage + datastore Checks all datastores or a single specified datastore + hba Checks attached HBAs. Uses negative thresholds as parameters, e.g. 10: + help Help about any command + memory Checks the current memory usage + nic Checks the number of attached NICs. Uses negative thresholds as parameters, e.g. 10: + temperature Checks the temperature of sensors + +Flags: + -f, --credentials-file string Path to the credentials file + -d, --database string Database name (default "vspheredb") + -h, --help help for check_vspheredb_data + -H, --host string Database host to connect to + -m, --machine string Machine to be queried for + -P, --password string Database password (default "vspheredb") + -p, --port int16 Database port to connect to (default 3306) + -u, --username string Database username (default "vspheredb") + + datastore: + -s, --datastore string Name of the datastore to check + temperature: + -s, --sensor string Sensor name filter (supports SQL LIKE pattern) +``` + +## Development -Alternatively, you can build the binary yourself using the Golang toolchain. +To build the tool yourself using the Golang toolchain: ```shell -git clone https://github.com/NETWAYS/check_vspheredb_data --branch=v1.0.0 +git clone https://github.com/NETWAYS/check_vspheredb_data cd check_vspheredb_data go build ``` -The resulting binary `check_vspheredb_data` can be found in the root directory of the repository. - -## Usage - -The check plugin provides detailed information about available check modes (see thumbnail above). More information can be accessed by -entering `check_vspheredb_data --help`. +The repository contains example SQL data to test the plugin against: +``` +podman run -ti --rm -p 3306:3306 \ + -e MYSQL_DATABASE=example -e MYSQL_USER=example -e MYSQL_PASSWORD=example -e MYSQL_ROOT_PASSWORD=example \ + -v $(pwd)/testdata/:/docker-entrypoint-initdb.d docker.io/mariadb:latest +``` ## License Copyright© 2024 [NETWAYS GmbH](mailto:info@netways.de) -This check plugin is distributed under the GPL-2.0 or newer license shipped with this repository in the [LICENSE](LICENSE) file. +This check plugin is distributed under the GPL-3.0 license shipped with this repository in the [LICENSE](LICENSE) file. diff --git a/cmd/cpu.go b/cmd/cpu.go index d7e1f95..5b317f3 100644 --- a/cmd/cpu.go +++ b/cmd/cpu.go @@ -14,10 +14,9 @@ var cpuCritical string var cpuWarnThreshold *check.Threshold var cpuCritThreshold *check.Threshold -// cpuCmd represents the cpu command. var cpuCmd = &cobra.Command{ Use: "cpu", - Short: "Checks CPU usage", + Short: "Checks the current CPU usage", Run: func(_ *cobra.Command, _ []string) { queryCPU() }, @@ -25,8 +24,8 @@ var cpuCmd = &cobra.Command{ func init() { rootCmd.AddCommand(cpuCmd) - cpuCmd.Flags().StringVarP(&cpuWarning, "warning", "w", "80", "Warning threshold in percent as Integer") - cpuCmd.Flags().StringVarP(&cpuCritical, "critical", "c", "90", "Critical threshold in percent as Integer") + cpuCmd.Flags().StringVarP(&cpuWarning, "warning", "w", "80", "Warning threshold in percent") + cpuCmd.Flags().StringVarP(&cpuCritical, "critical", "c", "90", "Critical threshold in percent") } // Query for CPU usage of the given machine, exit with UNKNOWN on query errors. @@ -52,27 +51,25 @@ func queryCPU() { dbConnection := internal.DBConnection(host, port, username, password, database) err = dbConnection.QueryRow( - `SELECT hqs.overall_cpu_usage, - hs.hardware_cpu_mhz, - hs.hardware_cpu_cores - FROM host_quick_stats hqs - INNER JOIN host_system hs - ON hqs.uuid = hs.uuid + `SELECT hqs.overall_cpu_usage, + hs.hardware_cpu_mhz, + hs.hardware_cpu_cores + FROM host_quick_stats hqs + INNER JOIN host_system hs + ON hqs.uuid = hs.uuid WHERE hs.host_name LIKE ?`, machine).Scan(&overallCPUUsage, &hardwareCPUMHz, &hardwareCPUCores) if err != nil { check.ExitError(err) } - // calculate percentage usage for check result decision. + // Calculate percentage usage for check result decision. cpuUsagePercent := overallCPUUsage * 100 / (hardwareCPUCores * hardwareCPUMHz) - // Add Perfdata. - // total usage. + // Add performance data pl.Add(&check.Perfdata{ Label: "usage", Value: overallCPUUsage, }) - // usage in percent, including thresholds. pl.Add(&check.Perfdata{ Label: "usage_percent", Value: cpuUsagePercent, @@ -80,12 +77,10 @@ func queryCPU() { Warn: cpuWarnThreshold, Crit: cpuCritThreshold, }) - // mhz. pl.Add(&check.Perfdata{ Label: "mhz", Value: hardwareCPUMHz, }) - // cores. pl.Add(&check.Perfdata{ Label: "cores", Value: hardwareCPUCores, diff --git a/cmd/datastore.go b/cmd/datastore.go index 9065ec7..ee818b5 100644 --- a/cmd/datastore.go +++ b/cmd/datastore.go @@ -16,10 +16,9 @@ var datastoreWarnThreshold *check.Threshold var datastoreCritThreshold *check.Threshold var datastore string -// datastoreCmd represents the datastore command. var datastoreCmd = &cobra.Command{ Use: "datastore", - Short: "Checks all datastores or a singular, specified datastore", + Short: "Checks all datastores or a single specified datastore", Run: func(_ *cobra.Command, _ []string) { queryDatastore() }, @@ -35,9 +34,9 @@ var datastoreCmd = &cobra.Command{ func init() { rootCmd.AddCommand(datastoreCmd) - datastoreCmd.Flags().StringVarP(&datastoreWarning, "warning", "w", "80", "Warning threshold in percent as Integer") - datastoreCmd.Flags().StringVarP(&datastoreCritical, "critical", "c", "90", "Critical threshold in percent as Integer") - datastoreCmd.Flags().StringVarP(&datastore, "datastore", "s", "", "Datastore to check") + datastoreCmd.Flags().StringVarP(&datastoreWarning, "warning", "w", "80", "Warning threshold in percent") + datastoreCmd.Flags().StringVarP(&datastoreCritical, "critical", "c", "90", "Critical threshold in percent") + datastoreCmd.Flags().StringVarP(&datastore, "datastore", "s", "", "Name of the datastore to check") } func queryDatastore() { @@ -60,11 +59,11 @@ func queryDatastore() { dbConnection := internal.DBConnection(host, port, username, password, database) - err = dbConnection.QueryRow(`SELECT ds.capacity, ds.free_space - FROM datastore ds - INNER JOIN vcenter vc - ON ds.vcenter_uuid = vc.instance_uuid - INNER JOIN object o + err = dbConnection.QueryRow(`SELECT ds.capacity, ds.free_space + FROM datastore ds + INNER JOIN vcenter vc + ON ds.vcenter_uuid = vc.instance_uuid + INNER JOIN object o ON ds.uuid = o.uuid WHERE o.object_name LIKE ? AND vc.name LIKE ?`, @@ -105,11 +104,11 @@ func queryDatastores() { // Collect query results. dbConnection := internal.DBConnection(host, port, username, password, database) - rows, err := dbConnection.Query(`SELECT o.object_name, ds.capacity, ds.free_space - FROM datastore ds - INNER JOIN vcenter vc - ON ds.vcenter_uuid = vc.instance_uuid - INNER JOIN object o + rows, err := dbConnection.Query(`SELECT o.object_name, ds.capacity, ds.free_space + FROM datastore ds + INNER JOIN vcenter vc + ON ds.vcenter_uuid = vc.instance_uuid + INNER JOIN object o ON ds.uuid = o.uuid WHERE vc.name LIKE ?`, machine) @@ -147,13 +146,13 @@ func queryDatastores() { // Computes Perfdata, check result based on the queried data. func processQueryResults(datastore string, capacity, freeSpace int64) (check.Perfdata, check.Status) { // calculate percentage usage for check result decision. - datastoreUsagePercent := int64(0) + var datastoreUsagePercent int64 + if capacity != 0 { datastoreUsagePercent = (capacity - freeSpace) * 100 / capacity } - // Add Perfdata. - // percentage usage. + // Add performance data perfData := check.Perfdata{ Label: datastore + "_used", Value: datastoreUsagePercent, diff --git a/cmd/hba.go b/cmd/hba.go index 5bb9d8a..20c3c78 100644 --- a/cmd/hba.go +++ b/cmd/hba.go @@ -14,10 +14,9 @@ var hbaCritical string var hbaWarnThreshold *check.Threshold var hbaCritThreshold *check.Threshold -// hbaCmd represents the hba command. var hbaCmd = &cobra.Command{ Use: "hba", - Short: "Checks attached HBAs", + Short: "Checks attached HBAs. Uses negative thresholds as parameters, e.g. 10:", Run: func(_ *cobra.Command, _ []string) { queryHba() }, @@ -26,8 +25,8 @@ var hbaCmd = &cobra.Command{ func init() { rootCmd.AddCommand(hbaCmd) - hbaCmd.Flags().StringVarP(&hbaWarning, "warning", "w", "2", "Warning threshold as Integer (\"less than X available\")") - hbaCmd.Flags().StringVarP(&hbaCritical, "critical", "c", "1", "Critical threshold as Integer (\"less than X available\")") + hbaCmd.Flags().StringVarP(&hbaWarning, "warning", "w", "2:", "Warning threshold (\"less than X available\")") + hbaCmd.Flags().StringVarP(&hbaCritical, "critical", "c", "1:", "Critical threshold (\"less than X available\")") } func queryHba() { @@ -37,20 +36,20 @@ func queryHba() { ) // Parse thresholds from given flags. - hbaWarnThreshold, err = check.ParseThreshold(hbaWarning + ":") // `:` is needed because warning/critical are reversed. + hbaWarnThreshold, err = check.ParseThreshold(hbaWarning) if err != nil { check.ExitError(err) } - hbaCritThreshold, err = check.ParseThreshold(hbaCritical + ":") // `:` is needed because warning/critical are reversed. + hbaCritThreshold, err = check.ParseThreshold(hbaCritical) if err != nil { check.ExitError(err) } dbConnection := internal.DBConnection(host, port, username, password, database) - err = dbConnection.QueryRow(`SELECT hardware_num_hba - FROM host_system + err = dbConnection.QueryRow(`SELECT hardware_num_hba + FROM host_system WHERE host_system.host_name LIKE ?`, machine).Scan(&hardwareNumHBAs) if err != nil { diff --git a/cmd/memory.go b/cmd/memory.go index fdff10f..a7d8307 100644 --- a/cmd/memory.go +++ b/cmd/memory.go @@ -14,10 +14,9 @@ var memoryCritical string var memoryWarnThreshold *check.Threshold var memoryCritThreshold *check.Threshold -// memoryCmd represents the memory command. var memoryCmd = &cobra.Command{ Use: "memory", - Short: "Checks memory usage", + Short: "Checks the current memory usage", Run: func(_ *cobra.Command, _ []string) { queryMemory() }, @@ -26,8 +25,8 @@ var memoryCmd = &cobra.Command{ func init() { rootCmd.AddCommand(memoryCmd) - memoryCmd.Flags().StringVarP(&memoryWarning, "warning", "w", "80", "Warning threshold in percent as Integer") - memoryCmd.Flags().StringVarP(&memoryCritical, "critical", "c", "90", "Critical threshold in percent as Integer") + memoryCmd.Flags().StringVarP(&memoryWarning, "warning", "w", "80", "Warning threshold in percent") + memoryCmd.Flags().StringVarP(&memoryCritical, "critical", "c", "90", "Critical threshold in percent") } // Query for memory usage of the given machine, exit with UNKNOWN on query errors. @@ -52,11 +51,11 @@ func queryMemory() { dbConnection := internal.DBConnection(host, port, username, password, database) err = dbConnection.QueryRow( - `SELECT hqs.overall_memory_usage_mb, - hs.hardware_memory_size_mb - FROM host_quick_stats hqs - INNER JOIN host_system hs - ON hqs.uuid = hs.uuid + `SELECT hqs.overall_memory_usage_mb, + hs.hardware_memory_size_mb + FROM host_quick_stats hqs + INNER JOIN host_system hs + ON hqs.uuid = hs.uuid WHERE hs.host_name LIKE ?`, machine).Scan(&overallMemoryUsageMB, &hardwareMemorySizeMB) if err != nil { check.ExitError(err) @@ -65,14 +64,11 @@ func queryMemory() { // calculate percentage usage for check result decision. memoryUsagePercent := overallMemoryUsageMB * 100 / hardwareMemorySizeMB - // Add Perfdata. - // total usage. pl.Add(&check.Perfdata{ Label: "usage", Value: overallMemoryUsageMB * 1024 * 1024, // Report in Bytes. Uom: "B", }) - // percentage usage. pl.Add(&check.Perfdata{ Label: "usage_percent", Value: memoryUsagePercent, diff --git a/cmd/nic.go b/cmd/nic.go index e8834fc..f1d37ef 100644 --- a/cmd/nic.go +++ b/cmd/nic.go @@ -14,10 +14,9 @@ var nicCritical string var nicWarnThreshold *check.Threshold var nicCritThreshold *check.Threshold -// nicCmd represents the nic command. var nicCmd = &cobra.Command{ Use: "nic", - Short: "Checks attached NICs", + Short: "Checks the number of attached NICs. Uses negative thresholds as parameters, e.g. 10:", Run: func(_ *cobra.Command, _ []string) { queryNic() }, @@ -26,8 +25,8 @@ var nicCmd = &cobra.Command{ func init() { rootCmd.AddCommand(nicCmd) - nicCmd.Flags().StringVarP(&nicWarning, "warning", "w", "2", "Warning threshold as Integer (\"less than X available\")") - nicCmd.Flags().StringVarP(&nicCritical, "critical", "c", "1", "Critical threshold as Integer (\"less than X available\")") + nicCmd.Flags().StringVarP(&nicWarning, "warning", "w", "2:", "Warning threshold (\"less than X available\")") + nicCmd.Flags().StringVarP(&nicCritical, "critical", "c", "1:", "Critical threshold (\"less than X available\")") } func queryNic() { @@ -37,20 +36,20 @@ func queryNic() { ) // Parse thresholds from given flags. - nicWarnThreshold, err = check.ParseThreshold(nicWarning + ":") // `:` is needed because warning/critical are reversed. + nicWarnThreshold, err = check.ParseThreshold(nicWarning) if err != nil { check.ExitError(err) } - nicCritThreshold, err = check.ParseThreshold(nicCritical + ":") // `:` is needed because warning/critical are reversed. + nicCritThreshold, err = check.ParseThreshold(nicCritical) if err != nil { check.ExitError(err) } dbConnection := internal.DBConnection(host, port, username, password, database) - err = dbConnection.QueryRow(`SELECT hardware_num_nic - FROM host_system + err = dbConnection.QueryRow(`SELECT hardware_num_nic + FROM host_system WHERE host_system.host_name LIKE ?`, machine).Scan(&hardwareNumNICs) if err != nil { diff --git a/cmd/root.go b/cmd/root.go index b08da30..f183135 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -16,19 +16,13 @@ var username string var password string var credentialsFile string -// Helper vars. var pl check.PerfdataList -// rootCmd represents the base command when called without any subcommands. var rootCmd = &cobra.Command{ Use: "check_vspheredb_data", - Short: "A check plugin for retrieving performance data of vSphere hosts collected by Icingaweb2's vSphereDB modul.", - Long: `The vSphereDB module collects lots of useful information and performance data from the vCenters -it queries, but without proper alert management on the vCenters' side, this information is -rendered merily cosmetical and not useful for alerting. - -This plugin allows to query the collected data via vSphereDB's database tables and enables -Icinga2 admins to trigger alerts on their side of the monitoring.`, + Short: "A check plugin for retrieving performance data of vSphere hosts collected by Icingaweb2's vSphereDB module.", + Long: `The vSphereDB module collects performance data from the vCenters it queries, but without proper alert management. +This plugin allows to query the collected data via vSphereDB's database tables and enables.`, // Check global flags - `machine` and `host` need to be set, // and `credentialsFile` needs to be valid if present. diff --git a/cmd/temperature.go b/cmd/temperature.go index aa53967..fe141e6 100644 --- a/cmd/temperature.go +++ b/cmd/temperature.go @@ -6,18 +6,20 @@ import ( "github.com/NETWAYS/check_vspheredb_data/internal" "github.com/NETWAYS/go-check" + "github.com/NETWAYS/go-check/result" "github.com/spf13/cobra" ) var temperatureWarning string var temperatureCritical string +var temperatureSensor string var temperatureWarnThreshold *check.Threshold var temperatureCritThreshold *check.Threshold // temperatureCmd represents the temperature command. var temperatureCmd = &cobra.Command{ Use: "temperature", - Short: "Checks temperature", + Short: "Checks the temperature of sensors", Run: func(_ *cobra.Command, _ []string) { queryTemperature() }, @@ -26,17 +28,16 @@ var temperatureCmd = &cobra.Command{ func init() { rootCmd.AddCommand(temperatureCmd) - temperatureCmd.Flags().StringVarP(&temperatureWarning, "warning", "w", "50", "Warning threshold as Integer") - temperatureCmd.Flags().StringVarP(&temperatureCritical, "critical", "c", "60", "Critical threshold as Integer") + temperatureCmd.Flags().StringVarP(&temperatureWarning, "warning", "w", "50", "Warning threshold") + temperatureCmd.Flags().StringVarP(&temperatureCritical, "critical", "c", "60", "Critical threshold") + temperatureCmd.Flags().StringVarP(&temperatureSensor, "sensor", "s", "%", "Sensor name filter (supports SQL LIKE pattern)") } func queryTemperature() { var ( - err error - currentReading int64 + err error ) - // Parse thresholds from given flags. temperatureWarnThreshold, err = check.ParseThreshold(temperatureWarning) if err != nil { check.ExitError(err) @@ -48,37 +49,68 @@ func queryTemperature() { } dbConnection := internal.DBConnection(host, port, username, password, database) + defer dbConnection.Close() - err = dbConnection.QueryRow(`SELECT se.current_reading - FROM host_sensor se - INNER JOIN host_system hs - ON se.host_uuid = hs.uuid + rows, err := dbConnection.Query(`SELECT se.name, se.current_reading + FROM host_sensor se + INNER JOIN host_system hs + ON se.host_uuid = hs.uuid WHERE hs.host_name LIKE ? - AND se.name LIKE "System Board 1 Inlet Temp"`, - machine).Scan(¤tReading) + AND se.sensor_type = "temperature" + AND se.name LIKE ?`, + machine, temperatureSensor) if err != nil { check.ExitError(err) } + defer rows.Close() - pl.Add(&check.Perfdata{ - Label: "temp", - Value: currentReading, - Uom: "C", - Warn: temperatureWarnThreshold, - Crit: temperatureCritThreshold, - }) + o := result.Overall{} - // Decide on check result state. - statusCode := check.OK + var sensorCount int - if temperatureWarnThreshold.DoesViolate(float64(currentReading)) { - statusCode = check.Warning - } + var maxTemp int64 + + for rows.Next() { + var sensorName string + + var currentReading int64 + + err := rows.Scan(&sensorName, ¤tReading) + if err != nil { + check.ExitError(err) + } + + // The division by 100 is necessary here, to do the temperature calculation and output correctly - otherwise we would have wrong temperature results, because vsphereDB saves the temperatures to its database without any separators. + currentReading /= 100 + sensorCount++ + + if currentReading > maxTemp { + maxTemp = currentReading + } + + pr := result.NewPartialResult() + pr.SetState(check.OK) + + if temperatureWarnThreshold.DoesViolate(float64(currentReading)) { + pr.SetState(check.Warning) + } + + if temperatureCritThreshold.DoesViolate(float64(currentReading)) { + pr.SetState(check.Critical) + } + + pr.AddPerfdata(&check.Perfdata{ + Label: "temp", + Value: currentReading, + Uom: "C", + Warn: temperatureWarnThreshold, + Crit: temperatureCritThreshold, + }) + + pr.SetOutput(fmt.Sprintf("%s is %d Celsius", sensorName, currentReading)) - if temperatureCritThreshold.DoesViolate(float64(currentReading)) { - statusCode = check.Critical + o.AddSubcheck(pr) } - dbConnection.Close() - check.ExitWithPerfdata(statusCode, pl, fmt.Sprintf("Temperature is %d°C", currentReading)) + check.Exit(o.GetStatus(), o.GetOutput()) } diff --git a/contrib/icinga2-basket.json b/contrib/icinga2-basket.json new file mode 100644 index 0000000..5f1ad88 --- /dev/null +++ b/contrib/icinga2-basket.json @@ -0,0 +1,212 @@ +{ + "Command": { + "vspheredb_data": { + "arguments": { + "-H": { + "description": "Database host to connect to", + "value": "$vspheredb_data_dbhost$" + }, + "-P": { + "description": "Database password (defaults to vspheredb)", + "value": "$vspheredb_data_dbpass$" + }, + "-d": { + "description": "Database name (defaults to vspheredb)", + "value": "$vspheredb_data_dbname$" + }, + "-f": { + "description": "Path to the credentials file", + "value": "$vspheredb_data_credfile$" + }, + "-m": { + "description": "Machine to be queried for", + "value": "$host.name$" + }, + "-p": { + "description": "Database port to connecto to (defaults to 3306)", + "value": "$vspheredb_data_dbport$" + }, + "-u": { + "description": "Database username (defaults to vspheredb)", + "value": "$vspheredb_data_username$" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data", + "object_type": "object", + "timeout": 60 + }, + "vspheredb_data_cpu": { + "arguments": { + "-c": { + "description": "Critical threshold in percent as Integer (defaults to 90)", + "value": "$vspheredb_data_cpucrit$" + }, + "-w": { + "description": "Warning threshold in percent as Integer (defaults to 80)", + "value": "$vspheredb_data_cpuwarn$" + }, + "mode": { + "description": "Checks CPU usage", + "skip_key": true, + "value": "cpu", + "order": "-1" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "imports": [ + "vspheredb_data" + ], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data_cpu", + "object_type": "object", + "timeout": 60 + }, + "vspheredb_data_datastore": { + "arguments": { + "-c": { + "description": "Critical threshold in percent as Integer (defaults to 90)", + "value": "$vspheredb_data_datastorecrit$" + }, + "-s": { + "description": "Datastore to check", + "value": "$vspheredb_data_datastore$" + }, + "-w": { + "description": "Warning threshold in percent as Integer (defaults to 80)", + "value": "$vspheredb_data_datastorewarn$" + }, + "mode": { + "description": "Checks all datastores or a singular, specified datastore", + "skip_key": true, + "value": "datastore", + "order": "-1" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "imports": [ + "vspheredb_data" + ], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data_datastore", + "object_type": "object", + "timeout": 60 + }, + "vspheredb_data_hba": { + "arguments": { + "-c": { + "description": "Critical threshold as Integer (less than X available) (defaults to 1)", + "value": "$vspheredb_data_hbacrit$" + }, + "-w": { + "description": "Warning threshold as Integer (less than X available) (defaults to 2)", + "value": "$vspheredb_data_hbawarn$" + }, + "mode": { + "description": "Checks attached HBAs", + "skip_key": true, + "value": "hba", + "order": "-1" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "imports": [ + "vspheredb_data" + ], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data_hba", + "object_type": "object", + "timeout": 60 + }, + "vspheredb_data_memory": { + "arguments": { + "-c": { + "description": "Critical threshold in percent as Integer (defaults to 90)", + "value": "$vspheredb_data_memorycrit$" + }, + "-w": { + "description": "Warning threshold in percent as Integer (defaults to 80)", + "value": "$vspheredb_data_memorywarn$" + }, + "mode": { + "description": "Checks memory usage", + "skip_key": true, + "value": "memory", + "order": "-1" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "imports": [ + "vspheredb_data" + ], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data_memory", + "object_type": "object", + "timeout": 60 + }, + "vspheredb_data_nic": { + "arguments": { + "-c": { + "description": "Critical threshold as Integer (less than X available) (defaults to 1)", + "value": "$vspheredb_data_niccrit$" + }, + "-w": { + "description": "Warning threshold as Integer (less than X available) (defaults to 2)", + "value": "$vspheredb_data_nicwarn$" + }, + "mode": { + "description": "Checks attached NICs", + "skip_key": true, + "value": "nic", + "order": "-1" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "imports": [ + "vspheredb_data" + ], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data_nic", + "object_type": "object", + "timeout": 60 + }, + "vspheredb_data_temperature": { + "arguments": { + "-c": { + "description": "Critical threshold (defaults to 60)", + "value": "$vspheredb_data_tempcrit$" + }, + "-s": { + "description": "Sensor name filter (supports SQL LIKE pattern)", + "value": "$vspheredb_data_tempsensor$" + }, + "-w": { + "description": "Warning threshold (defaults to 50)", + "value": "$vspheredb_data_tempwarn$" + }, + "mode": { + "description": "Checks temperature", + "skip_key": true, + "value": "temperature", + "order": "-1" + } + }, + "command": "check_vspheredb_data", + "fields": [], + "imports": [ + "vspheredb_data" + ], + "methods_execute": "PluginCheck", + "object_name": "vspheredb_data_temperature", + "object_type": "object", + "timeout": 60 + } + } +} \ No newline at end of file diff --git a/contrib/icinga2-commands.conf b/contrib/icinga2-commands.conf new file mode 100644 index 0000000..a703738 --- /dev/null +++ b/contrib/icinga2-commands.conf @@ -0,0 +1,162 @@ +object CheckCommand "vspheredb_data" { + command = [ PluginContribDir + "/check_vspheredb_data" ] + + arguments = { + "-f" = { + description = "Path to the credentials file" + value = "$vspheredb_data_credfile$" + } + "-d" = { + description = "Database name (defaults to vspheredb)" + value = "$vspheredb_data_dbname$" + } + "-H" = { + description = "Database host to connect to" + value = "$vspheredb_data_dbhost$" + } + "-m" = { + description = "Machine to be queried for" + value = "$host.name$" + } + "-P" = { + description = "Database password (defaults to vspheredb)" + value = "$vspheredb_data_dbpass$" + } + "-p" = { + description = "Database port to connecto to (defaults to 3306)" + value = "$vspheredb_data_dbport$" + } + "-u" = { + description = "Database username (defaults to vspheredb)" + value = "$vspheredb_data_username$" + } + } +} + +object CheckCommand "vspheredb_data_cpu" { + import "vspheredb_data" + arguments += { + "mode" = { + description = "Checks CPU usage" + value = "cpu" + skip_key = true + order = -1 + } + "-c" = { + description = "Critical threshold in percent as Integer (defaults to 90)" + value = "$vspheredb_data_cpucrit$" + } + "-w" = { + description = "Warning threshold in percent as Integer (defaults to 80)" + value = "$vspheredb_data_cpuwarn$" + } + } +} + +object CheckCommand "vspheredb_data_datastore" { + import "vspheredb_data" + arguments += { + "mode" = { + description = "Checks all datastores or a singular, specified datastore" + value = "datastore" + skip_key = true + order = -1 + } + "-c" = { + description = "Critical threshold in percent as Integer (defaults to 90)" + value = "$vspheredb_data_datastorecrit$" + } + "-w" = { + description = "Warning threshold in percent as Integer (defaults to 80)" + value = "$vspheredb_data_datastorewarn$" + } + "-s" = { + description = "Datastore to check" + value = "$vspheredb_data_datastore$" + } + } +} + +object CheckCommand "vspheredb_data_hba" { + import "vspheredb_data" + arguments += { + "mode" = { + description = "Checks attached HBAs" + value = "hba" + skip_key = true + order = -1 + } + "-c" = { + description = "Critical threshold as Integer (less than X available) (defaults to 1)" + value = "$vspheredb_data_hbacrit$" + } + "-w" = { + description = "Warning threshold as Integer (less than X available) (defaults to 2)" + value = "$vspheredb_data_hbawarn$" + } + } +} + +object CheckCommand "vspheredb_data_memory" { + import "vspheredb_data" + arguments += { + "mode" = { + description = "Checks memory usage" + value = "memory" + skip_key = true + order = -1 + } + "-c" = { + description = "Critical threshold in percent as Integer (defaults to 90)" + value = "$vspheredb_data_memorycrit$" + } + "-w" = { + description = "Warning threshold in percent as Integer (defaults to 80)" + value = "$vspheredb_data_memorywarn$" + } + } +} + +object CheckCommand "vspheredb_data_nic" { + import "vspheredb_data" + arguments += { + "mode" = { + description = "Checks attached NICs" + value = "nic" + skip_key = true + order = -1 + } + "-c" = { + description = "Critical threshold as Integer (less than X available) (defaults to 1)" + value = "$vspheredb_data_niccrit$" + } + "-w" = { + description = "Warning threshold as Integer (less than X available) (defaults to 2)" + value = "$vspheredb_data_nicwarn$" + } + } +} + +object CheckCommand "vspheredb_data_temperature" { + import "vspheredb_data" + arguments += { + "mode" = { + description = "Checks temperature" + value = "temperature" + skip_key = true + order = -1 + } + "-c" = { + description = "Critical threshold as Integer (defaults to 60)" + value = "$vspheredb_data_niccrit$" + } + "-w" = { + description = "Warning threshold as Integer (less than X available) (defaults to 50)" + value = "$vspheredb_data_nicwarn$" + } + "-s" ) { + description = "Sensor name filter (supports SQL LIKE pattern)" + value = "$vspheredb_data_sensor$" + } + } +} \ No newline at end of file diff --git a/docs/thumbnail.png b/docs/thumbnail.png deleted file mode 100644 index efe7a7d..0000000 Binary files a/docs/thumbnail.png and /dev/null differ diff --git a/main.go b/main.go index 57b1f12..f584837 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,8 @@ package main -import "github.com/NETWAYS/check_vspheredb_data/cmd" +import ( + "github.com/NETWAYS/check_vspheredb_data/cmd" +) func main() { cmd.Execute() diff --git a/testdata/example.sql b/testdata/example.sql new file mode 100644 index 0000000..ac36f53 --- /dev/null +++ b/testdata/example.sql @@ -0,0 +1,285 @@ +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vspheredb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; + +USE `vspheredb`; + +-- +-- Table structure for table `datastore` +-- + +DROP TABLE IF EXISTS `datastore`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `datastore` ( + `uuid` varbinary(20) NOT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + `maintenance_mode` enum('normal','enteringMaintenance','inMaintenance') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `is_accessible` enum('y','n') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `capacity` bigint unsigned DEFAULT NULL, + `free_space` bigint unsigned DEFAULT NULL, + `uncommitted` bigint unsigned DEFAULT NULL, + `multiple_host_access` enum('y','n') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `ts_last_forced_refresh` bigint DEFAULT NULL, + PRIMARY KEY (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `datastore` +-- + +LOCK TABLES `datastore` WRITE; +/*!40000 ALTER TABLE `datastore` DISABLE KEYS */; +INSERT INTO `datastore` VALUES (_binary '��]���\',_binary 'LLED\0CJ�5�\',NULL,'y',3590055788544,1965910130688,956095986075,NULL,NULL); +/*!40000 ALTER TABLE `datastore` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_physical_nic` +-- + +DROP TABLE IF EXISTS `host_physical_nic`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `host_physical_nic` ( + `host_uuid` varbinary(20) NOT NULL, + `nic_key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `auto_negotiate_supported` enum('y','n') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `device` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `driver` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `link_speed_mb` int unsigned DEFAULT NULL, + `link_duplex` enum('y','n') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `mac_address` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `pci` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + PRIMARY KEY (`host_uuid`,`nic_key`), + KEY `vcenter_uuid` (`vcenter_uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_physical_nic` +-- + +LOCK TABLES `host_physical_nic` WRITE; +/*!40000 ALTER TABLE `host_physical_nic` DISABLE KEYS */; +INSERT INTO `host_physical_nic` VALUES (_binary '9�4��϶Pj@l\','key-vim.host.PhysicalNic-vmnic0','y','vmnic0','bnx2',1000,'y','00:22:19:68:9a:d9','0000:01:00.0',_binary 'LLED\0CJ�5�\'),(_binary '9�4��϶Pj@l\','key-vim.host.PhysicalNic-vmnic1','y','vmnic1','bnx2',1000,'y','00:22:19:68:9a:db','0000:01:00.1',_binary 'LLED\0CJ�5�\'),(_binary '9�4��϶Pj@l\','key-vim.host.PhysicalNic-vmnic2','y','vmnic2','bnx2',NULL,NULL,'00:22:19:68:9a:dd','0000:02:00.0',_binary 'LLED\0CJ�5�\'),(_binary '9�4��϶Pj@l\','key-vim.host.PhysicalNic-vmnic3','y','vmnic3','bnx2',NULL,NULL,'00:22:19:68:9a:df','0000:02:00.1',_binary 'LLED\0CJ�5�\'); +/*!40000 ALTER TABLE `host_physical_nic` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_quick_stats` +-- + +DROP TABLE IF EXISTS `host_quick_stats`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `host_quick_stats` ( + `uuid` varbinary(20) NOT NULL, + `distributed_cpu_fairness` int DEFAULT NULL, + `distributed_memory_fairness` int DEFAULT NULL, + `overall_cpu_usage` int unsigned DEFAULT NULL, + `overall_memory_usage_mb` int unsigned DEFAULT NULL, + `uptime` int unsigned DEFAULT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + PRIMARY KEY (`uuid`), + KEY `vcenter_uuid` (`vcenter_uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_quick_stats` +-- + +LOCK TABLES `host_quick_stats` WRITE; +/*!40000 ALTER TABLE `host_quick_stats` DISABLE KEYS */; +INSERT INTO `host_quick_stats` VALUES (_binary '9�4��϶Pj@l\',NULL,NULL,1625,19182,4760028,_binary 'LLED\0CJ�5�\'); +/*!40000 ALTER TABLE `host_quick_stats` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_sensor` +-- + +DROP TABLE IF EXISTS `host_sensor`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `host_sensor` ( + `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `host_uuid` varbinary(20) NOT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + `health_state` enum('green','yellow','unknown','red') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `current_reading` int NOT NULL, + `unit_modifier` smallint NOT NULL, + `base_units` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `rate_units` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `sensor_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + PRIMARY KEY (`host_uuid`,`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_sensor` +-- + +LOCK TABLES `host_sensor` WRITE; +/*!40000 ALTER TABLE `host_sensor` DISABLE KEYS */; +INSERT INTO `host_sensor` VALUES ('Disk Drive Bay 1 Cable SAS A 0 --- 0.26.1.144',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Cable SAS B 0 --- 0.26.1.145',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Drive 0 --- 0.26.1.128',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Drive 1 --- 0.26.1.129',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Drive 2 --- 0.26.1.130',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Drive 3 --- 0.26.1.131',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Drive 4 --- 0.26.1.132',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Drive 5 --- 0.26.1.133',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 1 Presence 0 --- 0.26.1.86',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','storage'),('Disk Drive Bay 3 ROMB Battery 0 --- 0.26.3.17',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',0,0,'sensor-discrete','none','battery'),('Power Supply 1 Current --- 0.10.1.148',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',47,-2,'Amps','none','power'),('Power Supply 1 Presence 0 --- 0.10.1.84',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','power'),('Power Supply 1 Status 0 --- 0.10.1.100',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','power'),('Power Supply 1 Voltage --- 0.10.1.150',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',23000,-2,'Volts','none','voltage'),('Power Supply 2 Current --- 0.10.2.149',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',40,-2,'Amps','none','power'),('Power Supply 2 Presence 0 --- 0.10.2.85',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','power'),('Power Supply 2 Status 0 --- 0.10.2.101',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','power'),('Power Supply 2 Voltage --- 0.10.2.151',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',23000,-2,'Volts','none','voltage'),('Processor 1 0.75 VTT PG 0 --- 0.3.1.21',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 1 1.8 PLL PG 0 --- 0.3.1.36',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 1 MEM PG 0 --- 0.3.1.30',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 1 Presence 0 --- 0.3.1.80',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','processor'),('Processor 1 Status 0 --- 0.3.1.96',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',128,0,'sensor-discrete','none','processor'),('Processor 1 VCORE PG 0 --- 0.3.1.18',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 1 VTT PG 0 --- 0.3.1.32',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 2 0.75VTT PG 0 --- 0.3.2.20',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 2 1.8 PLL PG 0 --- 0.3.2.34',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 2 MEM PG 0 --- 0.3.2.27',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 2 Presence 0 --- 0.3.2.81',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','processor'),('Processor 2 Status 0 --- 0.3.2.97',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',128,0,'sensor-discrete','none','processor'),('Processor 2 VCORE PG 0 --- 0.3.2.19',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('Processor 2 VTT PG 0 --- 0.3.2.31',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 0.9V PG 0 --- 0.7.1.33',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 1.05V PG 0 --- 0.7.1.43',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 1.0V AUX PG 0 --- 0.7.1.42',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 1.0V LOM PG 0 --- 0.7.1.41',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 1.1V PG 0 --- 0.7.1.40',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 1.5V PG 0 --- 0.7.1.23',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 1.8V PG 0 --- 0.7.1.24',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 3.3V PG 0 --- 0.7.1.25',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 5V PG 0 --- 0.7.1.26',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 8.0V PG 0 --- 0.7.1.37',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'assert-discrete','none','voltage'),('System Board 1 Ambient Temp --- 0.7.1.14',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',2000,-2,'degrees C','none','temperature'),('System Board 1 CMOS Battery 0 --- 0.7.1.16',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',0,0,'sensor-discrete','none','battery'),('System Board 1 FAN MOD 1A RPM --- 0.7.1.48',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',432000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 1B RPM --- 0.7.1.54',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',300000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 2A RPM --- 0.7.1.49',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',432000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 2B RPM --- 0.7.1.55',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',300000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 3A RPM --- 0.7.1.50',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',432000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 3B RPM --- 0.7.1.56',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',300000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 4A RPM --- 0.7.1.51',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',432000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 4B RPM --- 0.7.1.57',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',300000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 5A RPM --- 0.7.1.52',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',432000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 5B RPM --- 0.7.1.58',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',300000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 6A RPM --- 0.7.1.53',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',432000,-2,'RPM','none','fan'),('System Board 1 FAN MOD 6B RPM --- 0.7.1.59',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',300000,-2,'RPM','none','fan'),('System Board 1 Fan Redundancy 0 --- 0.7.1.117',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'redundancy-discrete','none','fan'),('System Board 1 HEATSINK PRES 0 --- 0.7.1.82',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','systemBoard'),('System Board 1 Intrusion 0 --- 0.7.1.115',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',0,0,'sensor-discrete','none','systemBoard'),('System Board 1 OS Watchdog 0 --- 0.7.1.113',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',0,0,'sensor-discrete','none','watchdog'),('System Board 1 PS Redundancy 0 --- 0.7.1.116',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'redundancy-discrete','none','power'),('System Board 1 Power Optimized 0 --- 0.7.1.153',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','unknown',1,0,'sensor-discrete','none','systemBoard'),('System Board 1 RISER1 PRES 0 --- 0.7.1.92',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','systemBoard'),('System Board 1 RISER2 PRES 0 --- 0.7.1.91',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','systemBoard'),('System Board 1 Riser Config 0 --- 0.7.1.102',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','cable'),('System Board 1 STOR ADAPT PRES 0 --- 0.7.1.90',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','systemBoard'),('System Board 1 System Level --- 0.7.1.152',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',20300,-2,'Watts','none','systemBoard'),('System Board 1 Test Temp',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',25000,-2,'degrees C','none','temperature'),('System Board 1 USB CABLE PRES 0 --- 0.7.1.89',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','systemBoard'),('System Board 1 iDRAC6 Ent PRES 0 --- 0.7.1.112',_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','green',1,0,'sensor-discrete','none','systemBoard'); +/*!40000 ALTER TABLE `host_sensor` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_system` +-- + +DROP TABLE IF EXISTS `host_system`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `host_system` ( + `uuid` varbinary(20) NOT NULL, + `host_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + `product_api_version` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `product_full_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `bios_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `bios_release_date` datetime DEFAULT NULL, + `sysinfo_vendor` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `sysinfo_model` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `sysinfo_uuid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `service_tag` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `hardware_cpu_model` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `hardware_cpu_mhz` int unsigned NOT NULL, + `hardware_cpu_packages` smallint unsigned NOT NULL, + `hardware_cpu_cores` smallint unsigned NOT NULL, + `hardware_cpu_threads` smallint unsigned NOT NULL, + `hardware_memory_size_mb` int unsigned NOT NULL, + `hardware_num_hba` smallint unsigned NOT NULL, + `hardware_num_nic` smallint unsigned NOT NULL, + `runtime_power_state` enum('poweredOff','poweredOn','standBy','unknown') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `das_host_state` enum('connectedToMaster','election','fdmUnreachable','hostDown','initializationError','master','networkIsolated','networkPartitionedFromMaster','uninitializationError','uninitialized') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `custom_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin, + PRIMARY KEY (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_system` +-- + +LOCK TABLES `host_system` WRITE; +/*!40000 ALTER TABLE `host_system` DISABLE KEYS */; +INSERT INTO `host_system` VALUES (_binary '9�4��϶Pj@l\','net-example-demo.',_binary 'LLED\0CJ�5�\','6.5','VMware ESXi 6.5.0 build-18678235','1.2.3','2013-07-23 00:00:00','Dell Inc.','PowerEdge R610','badfood1-0012-1a23-4444-bacc4d47312a','1DC5G4J','Intel(R) Xeon(R) CPU E5540 @ 2.50GHz',2527,2,8,16,49132,7,4,'poweredOn',NULL,NULL); +/*!40000 ALTER TABLE `host_system` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_virtual_nic` +-- + +DROP TABLE IF EXISTS `host_virtual_nic`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `host_virtual_nic` ( + `host_uuid` varbinary(20) NOT NULL, + `nic_key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `net_stack_instance_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `port` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `portgroup` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `mac_address` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `mtu` int DEFAULT NULL, + `ipv4_address` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `ipv4_subnet_mask` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `ipv6_address` varchar(47) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `ipv6_prefic_length` int DEFAULT NULL, + `ipv6_dad_state` enum('deprecated','duplicate','inaccessible','invalid','preferred','tentative','unknown') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `ipv6_origin` enum('dhcp','linklayer','manual','other','random') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `dv_connection_cookie` int DEFAULT NULL, + `dv_portgroup_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `dv_port_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `dv_switch_uuid` varchar(47) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `device` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `tso_enabled` enum('y','n') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + PRIMARY KEY (`host_uuid`,`nic_key`), + KEY `vcenter_uuid` (`vcenter_uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_virtual_nic` +-- + +LOCK TABLES `host_virtual_nic` WRITE; +/*!40000 ALTER TABLE `host_virtual_nic` DISABLE KEYS */; +INSERT INTO `host_virtual_nic` VALUES (_binary '9�4��϶Pj@l\','key-vim.host.VirtualNic-vmk0',NULL,'key-vim.host.PortGroup.Port-33554436','Management Network','00:22:19:68:9a:d9',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vmk0',NULL,_binary 'LLED\0CJ�5�\'),(_binary '9�4��϶Pj@l\','key-vim.host.VirtualNic-vmk1',NULL,'key-vim.host.PortGroup.Port-50331652','net-monitor','00:50:56:64:69:cc',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vmk1',NULL,_binary 'LLED\0CJ�5�\'),(_binary '9�4��϶Pj@l\','key-vim.host.VirtualNic-vmk2',NULL,'key-vim.host.PortGroup.Port-67108866','Testing MS','00:50:56:62:d5:37',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vmk2',NULL,_binary 'LLED\0CJ�5�\'),(_binary '9�4��϶Pj@l\','key-vim.host.VirtualNic-vmk3',NULL,'key-vim.host.PortGroup.Port-100663300','Sales-Demo-LAN','00:50:56:6e:e9:07',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vmk3',NULL,_binary 'LLED\0CJ�5�\'); +/*!40000 ALTER TABLE `host_virtual_nic` ENABLE KEYS */; +UNLOCK TABLES; + +DROP TABLE IF EXISTS `vcenter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `vcenter` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `instance_uuid` varbinary(16) NOT NULL, + `trust_store_id` int unsigned DEFAULT NULL, + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `version` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `os_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `api_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `api_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `api_version` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `build` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `vendor` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `product_line` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `license_product_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `license_product_version` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `locale_build` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `locale_version` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `instance_uuid` (`instance_uuid`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `vcenter` +-- + +LOCK TABLES `vcenter` WRITE; +/*!40000 ALTER TABLE `vcenter` DISABLE KEYS */; +INSERT INTO `vcenter` VALUES (1,_binary 'LLED\0CJ�5�\',NULL,'192.168.58.123','6.5.0','vmnix-x86','VMware ESXi','HostAgent','6.5','5969303','VMware, Inc.','embeddedEsx','VMware ESX Server','6.0','000','INTL'); +/*!40000 ALTER TABLE `vcenter` ENABLE KEYS */; +UNLOCK TABLES; +-- +-- Table structure for table `object` +-- + +DROP TABLE IF EXISTS `object`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `object` ( + `uuid` varbinary(20) NOT NULL, + `vcenter_uuid` varbinary(16) NOT NULL, + `moref` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `object_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `object_type` enum('ComputeResource','ClusterComputeResource','Datacenter','Datastore','DatastoreHostMount','DistributedVirtualPortgroup','DistributedVirtualSwitch','Folder','HostMountInfo','HostSystem','Network','OpaqueNetwork','ResourcePool','StoragePod','VirtualApp','VirtualMachine','VmwareDistributedVirtualSwitch') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `overall_status` enum('gray','green','yellow','red') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, + `level` tinyint unsigned NOT NULL, + `parent_uuid` varbinary(20) DEFAULT NULL, + PRIMARY KEY (`uuid`), + UNIQUE KEY `vcenter_moref` (`vcenter_uuid`,`moref`), + KEY `object_type` (`object_type`), + KEY `object_name` (`object_name`(64)), + KEY `object_parent` (`parent_uuid`), + -- CONSTRAINT `object_parent` FOREIGN KEY (`parent_uuid`) REFERENCES `object` (`uuid`), + CONSTRAINT `object_vcenter` FOREIGN KEY (`vcenter_uuid`) REFERENCES `vcenter` (`instance_uuid`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `object` +-- + +LOCK TABLES `object` WRITE; +/*!40000 ALTER TABLE `object` DISABLE KEYS */; +INSERT INTO `object` VALUES (_binary '\0\"�K>�4~�}�3',_binary 'LLED\0CJ�5�\','HaNetwork-Foreman Intern','Foreman Intern','Network','green',3,_binary '�xo�W�n�\'),(_binary '���v��\',_binary 'LLED\0CJ�5�\','20','example-env','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '\rrɾU npR�a\'�\',_binary 'LLED\0CJ�5�\','ha-folder-root','root','Folder','green',0,NULL),(_binary '��d~��@:�',_binary 'LLED\0CJ�5�\','HaNetwork-VM Network','VM Network','Network','green',3,_binary '�xo�W�n�\'),(_binary '1+J+��o�X�\',_binary 'LLED\0CJ�5�\','ha-folder-host','host','Folder','green',2,_binary '{웓�l$�8y�cw'),(_binary '1��7�]Ĵ�\',_binary 'LLED\0CJ�5�\','ha-compute-res','net-example-demo.','ComputeResource','green',3,_binary '1+J+��o�X�\'),(_binary '7�F��\'D�H\',_binary 'LLED\0CJ�5�\','27','example-net-share','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '9�4��϶Pj@l\',_binary 'LLED\0CJ�5�\','ha-host','net-example-demo.','HostSystem','green',4,_binary '1��7�]Ĵ�\'),(_binary 'Gu/�.t!��z',_binary 'LLED\0CJ�5�\','5','example-demo-icinga2b','VirtualMachine','green',3,_binary '� -���5j�'),(_binary 'M�C�_i�>,1Dn3',_binary 'LLED\0CJ�5�\','28','example-net-icinga2a','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '\\jj��D�u�\',_binary 'LLED\0CJ�5�\','18','example-demo-rt','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '{웓�l$�8y�cw',_binary 'LLED\0CJ�5�\','ha-datacenter','ha-datacenter','Datacenter','green',1,_binary '\rrɾU npR�a\'�\'),(_binary '~�ҹ��d4/`\',_binary 'LLED\0CJ�5�\','7','example-demo-windows','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '˨�d瀆���\',_binary 'LLED\0CJ�5�\','2','example-demo-elastic','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '͒����\'�',_binary 'LLED\0CJ�5�\','8','example-net-mysql','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '�J�G��aSn\',_binary 'LLED\0CJ�5�\','26','test1-foreman','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '� @��$�%0\',_binary 'LLED\0CJ�5�\','33','example-net-graphing','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '� -���5j�',_binary 'LLED\0CJ�5�\','ha-folder-vm','vm','Folder','green',2,_binary '{웓�l$�8y�cw'),(_binary '�\ZS�\\�uB�',_binary 'LLED\0CJ�5�\','HaNetwork-Example Demo LAN','Example Demo LAN','Network','green',3,_binary '�xo�W�n�\'),(_binary '�\"rzODT\r+@��',_binary 'LLED\0CJ�5�\','32','example-net-collabora','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '�E^gG4��P6� ',_binary 'LLED\0CJ�5�\','3','example-demo-icinga2a','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '�S�*��^z\',_binary 'LLED\0CJ�5�\','6','example-demo-ansible','VirtualMachine','green',3,_binary '� -���5j�'),(_binary '�Z�