From 79f3b3a81dce0e101968d445362c65e9d3ffdd92 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Sun, 25 Dec 2022 11:29:45 +0100 Subject: [PATCH] Initial work on script support --- client/doc/scripts/ExampleScript.groovy | 19 +++++++++ client/doc/scripts/example.groovy | 20 ---------- .../linux/src/test/resources/sensors-1.json | 39 +++++++++++++++++++ .../linux/src/test/resources/sensors-2.json | 39 +++++++++++++++++++ plugins/power/README.md | 4 +- shared/build.gradle | 19 +++++++++ 6 files changed, 118 insertions(+), 22 deletions(-) create mode 100755 client/doc/scripts/ExampleScript.groovy delete mode 100644 client/doc/scripts/example.groovy create mode 100644 plugins/linux/src/test/resources/sensors-1.json create mode 100644 plugins/linux/src/test/resources/sensors-2.json diff --git a/client/doc/scripts/ExampleScript.groovy b/client/doc/scripts/ExampleScript.groovy new file mode 100755 index 0000000..6864705 --- /dev/null +++ b/client/doc/scripts/ExampleScript.groovy @@ -0,0 +1,19 @@ + +class ExampleScript implements MetricScript { + + MetricResult getMetrics() { + Map tags = new TreeMap<>(); + Map fields = new TreeMap<>(); + + tags.put("type", "temp"); + fields.put("sensor1", 23.2); + fields.put("sensor2", 25.8); + + Measurement measurement = new Measurement(tags, fields); + return new MetricResult("script_sensors", measurement); + } + +} + + + diff --git a/client/doc/scripts/example.groovy b/client/doc/scripts/example.groovy deleted file mode 100644 index cdcbd01..0000000 --- a/client/doc/scripts/example.groovy +++ /dev/null @@ -1,20 +0,0 @@ -import sysmon.shared.MetricResult -import sysmon.shared.MetricScript -import sysmon.shared.Measurement - -class ExampleScript implements MetricScript { - - @Override - MetricResult getMetrics() { - Map tags = new TreeMap<>(); - Map fields = new TreeMap<>(); - - tags.put("location", "blabla"); - fields.put("temp1", 23); - fields.put("temp2", 25); - - Measurement measurement = new Measurement(tags, fields); - return new MetricResult("script_example", measurement); - } - -} diff --git a/plugins/linux/src/test/resources/sensors-1.json b/plugins/linux/src/test/resources/sensors-1.json new file mode 100644 index 0000000..d07babe --- /dev/null +++ b/plugins/linux/src/test/resources/sensors-1.json @@ -0,0 +1,39 @@ +{ + "k10temp-pci-00c3":{ + "Adapter": "PCI adapter", + "Tctl":{ + "temp1_input": 56.250 + } + }, + "nvme-pci-0400":{ + "Adapter": "PCI adapter", + "Composite":{ + "temp1_input": 35.850, + "temp1_max": 74.850, + "temp1_min": -20.150, + "temp1_crit": 79.850, + "temp1_alarm": 0.000 + } + }, + "iwlwifi_1-virtual-0":{ + "Adapter": "Virtual device", + "temp1":{ + "temp1_input": 37.000 + } + }, + "amdgpu-pci-0500":{ + "Adapter": "PCI adapter", + "vddgfx":{ + "in0_input": 0.681 + }, + "vddnb":{ + "in1_input": 0.712 + }, + "edge":{ + "temp1_input": 37.000 + }, + "PPT":{ + "power1_average": 0.000 + } + } +} diff --git a/plugins/linux/src/test/resources/sensors-2.json b/plugins/linux/src/test/resources/sensors-2.json new file mode 100644 index 0000000..7b21ed3 --- /dev/null +++ b/plugins/linux/src/test/resources/sensors-2.json @@ -0,0 +1,39 @@ +{ + "k10temp-pci-00c3":{ + "Adapter": "PCI adapter", + "Tctl":{ + "temp1_input": 53.875 + } + }, + "nvme-pci-0400":{ + "Adapter": "PCI adapter", + "Composite":{ + "temp1_input": 36.850, + "temp1_max": 74.850, + "temp1_min": -20.150, + "temp1_crit": 79.850, + "temp1_alarm": 0.000 + } + }, + "iwlwifi_1-virtual-0":{ + "Adapter": "Virtual device", + "temp1":{ + "temp1_input": 41.000 + } + }, + "amdgpu-pci-0500":{ + "Adapter": "PCI adapter", + "vddgfx":{ + "in0_input": 1.281 + }, + "vddnb":{ + "in1_input": 0.712 + }, + "edge":{ + "temp1_input": 42.000 + }, + "PPT":{ + "power1_average": 0.000 + } + } +} diff --git a/plugins/power/README.md b/plugins/power/README.md index 2170b88..0ff997c 100644 --- a/plugins/power/README.md +++ b/plugins/power/README.md @@ -1,6 +1,6 @@ -# AIX Plugin +# IBM Power Plugin -## LPAR Processor Extension +## Power LPAR Processor Extension The processor extension works for both AIX and Linux on the Power ppc64/ppc64le architecture. diff --git a/shared/build.gradle b/shared/build.gradle index b115439..2a8e4e7 100644 --- a/shared/build.gradle +++ b/shared/build.gradle @@ -9,6 +9,7 @@ plugins { id 'groovy' id 'java-library' + id 'maven-publish' } repositories { @@ -33,3 +34,21 @@ tasks.named('test') { // Use junit platform for unit tests. useJUnitPlatform() } + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/Danish-Sensor-Engineering/libsensor") + credentials { + username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") + password = project.findProperty("gpr.key") ?: System.getenv("TOKEN") + } + } + } + publications { + gpr(MavenPublication) { + from(components.java) + } + } +}