From 3dd568a95ed5d32f3c55f75bb01da2353d80f496 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Tue, 29 Jun 2021 14:02:01 +0200 Subject: [PATCH 1/3] Make influx database name configurable. --- gradle.properties | 6 ++--- .../main/java/sysmon/server/Application.java | 23 +++++++++++-------- .../sysmon/server/ServerRouteBuilder.java | 9 +++++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9ad9b18..d015b8f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ -version=0.0.5 +version=0.0.6 pf4jVersion=3.6.0 -slf4jVersion=1.7.30 -camelVersion=3.10.0 +slf4jVersion=1.7.31 +camelVersion=3.11.0 picocliVersion=4.6.1 oshiVersion=5.7.5 \ No newline at end of file diff --git a/server/src/main/java/sysmon/server/Application.java b/server/src/main/java/sysmon/server/Application.java index dd22e72..2328896 100644 --- a/server/src/main/java/sysmon/server/Application.java +++ b/server/src/main/java/sysmon/server/Application.java @@ -2,7 +2,9 @@ package sysmon.server; import org.apache.camel.main.Main; import org.influxdb.InfluxDB; +import org.influxdb.InfluxDBException; import org.influxdb.InfluxDBFactory; +import org.influxdb.dto.Query; import picocli.CommandLine; import java.io.IOException; @@ -21,8 +23,8 @@ public class Application implements Callable { @CommandLine.Option(names = { "-p", "--influxdb-pass" }, description = "InfluxDB Password (default: ${DEFAULT-VALUE}).", defaultValue = "", paramLabel = "") private String influxPass; - //@CommandLine.Option(names = { "-d", "--influxdb-db" }, description = "InfluxDB Database (default: ${DEFAULT-VALUE}).", defaultValue = "", paramLabel = "") - //private String influxName = "sysmon"; + @CommandLine.Option(names = { "-d", "--influxdb-db" }, description = "InfluxDB Database (default: ${DEFAULT-VALUE}).", defaultValue = "sysmon", paramLabel = "") + private String influxName; @CommandLine.Option(names = { "-H", "--server-host" }, description = "Server listening address (default: ${DEFAULT-VALUE}).", paramLabel = "") private String listenHost = "0.0.0.0"; @@ -42,20 +44,21 @@ public class Application implements Callable { @Override public Integer call() throws IOException { + InfluxDB influxDB = InfluxDBFactory.connect(influxUrl.toString(), influxUser, influxPass); /* - Properties properties = new Properties(); - properties.put("http.host", listenHost); - properties.put("http.port", listenPort); -*/ - InfluxDB influxConnectionBean = InfluxDBFactory.connect(influxUrl.toString(), influxUser, influxPass); + try { + influxDB.query(new Query("CREATE DATABASE " + influxName)); + } catch (InfluxDBException e) { + System.err.println(e.getMessage()); + return -1; + }*/ Main main = new Main(); - main.bind("myInfluxConnection", influxConnectionBean); + main.bind("myInfluxConnection", influxDB); main.bind("http.host", listenHost); main.bind("http.port", listenPort); - //main.bind("properties", properties); main.bind("threads", threads); - //main.bind("influxdb_name", influxName); + main.bind("dbname", influxName); main.configure().addRoutesBuilder(ServerRouteBuilder.class); // now keep the application running until the JVM is terminated (ctrl + c or sigterm) diff --git a/server/src/main/java/sysmon/server/ServerRouteBuilder.java b/server/src/main/java/sysmon/server/ServerRouteBuilder.java index 5bfc315..0cc0f39 100644 --- a/server/src/main/java/sysmon/server/ServerRouteBuilder.java +++ b/server/src/main/java/sysmon/server/ServerRouteBuilder.java @@ -2,6 +2,7 @@ package sysmon.server; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.influxdb.InfluxDbConstants; import org.apache.camel.model.rest.RestBindingMode; import org.apache.camel.spi.Registry; import sysmon.shared.MetricResult; @@ -11,7 +12,9 @@ public class ServerRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { - Registry registry = getContext().getRegistry(); + final Registry registry = getContext().getRegistry(); + final String dbname = registry.lookupByNameAndType("dbname", String.class); + final Integer threads = registry.lookupByNameAndType("threads", Integer.class); restConfiguration().component("netty-http") .bindingMode(RestBindingMode.auto) @@ -38,11 +41,11 @@ public class ServerRouteBuilder extends RouteBuilder { .to("seda:inbound") .endRest(); - fromF("seda:inbound?concurrentConsumers=%s", registry.lookupByNameAndType("threads", Integer.class)) + fromF("seda:inbound?concurrentConsumers=%s", threads) .log(">>> metric: ${header.hostname} - ${body}") .doTry() .process(new MetricResultToPointProcessor()) - .toF("influxdb://ref.myInfluxConnection?databaseName=%s&retentionPolicy=autogen", "sysmon") + .toF("influxdb://ref.myInfluxConnection?databaseName=%s&retentionPolicy=autogen", dbname) .doCatch(Exception.class) .log("Error storing metric to InfluxDB: ${exception}") .end(); From e2b478a1c273a788ea477b0f713c2b20e60d131d Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Mon, 23 Aug 2021 11:07:07 +0200 Subject: [PATCH 2/3] Ansible playbook for easy install on AIX, and dependency updates. --- build.gradle | 2 +- client/build.gradle | 2 +- .../sysmon/client/ClientRouteBuilder.java | 1 + doc/ansible/sysmon-client-aix.yml | 48 +++++++++++++++++++ doc/ansible/timezone-aix.yml | 35 ++++++++++++++ gradle.properties | 4 +- plugins/build.gradle | 2 +- plugins/os-base/gradle.properties | 2 - plugins/os-ibmi/gradle.properties | 2 - server/build.gradle | 2 +- shared/build.gradle | 6 +-- 11 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 doc/ansible/sysmon-client-aix.yml create mode 100644 doc/ansible/timezone-aix.yml diff --git a/build.gradle b/build.gradle index 77fdee7..00ac202 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ subprojects { maven { url("https://plugins.gradle.org/m2/") } } dependencies { - classpath 'org.redline-rpm:redline:1.2.9' + classpath 'org.redline-rpm:redline:1.2.10' } } diff --git a/client/build.gradle b/client/build.gradle index 5b6a03e..2f4edf6 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -5,7 +5,7 @@ plugins { id "com.github.johnrengelman.shadow" version "7.0.0" id "net.nemerosa.versioning" version "2.14.0" - id "nebula.ospackage" version "8.5.6" + id "nebula.ospackage" version "8.6.1" } dependencies { diff --git a/client/src/main/java/sysmon/client/ClientRouteBuilder.java b/client/src/main/java/sysmon/client/ClientRouteBuilder.java index 1d1df3e..ec3d62e 100644 --- a/client/src/main/java/sysmon/client/ClientRouteBuilder.java +++ b/client/src/main/java/sysmon/client/ClientRouteBuilder.java @@ -82,4 +82,5 @@ public class ClientRouteBuilder extends RouteBuilder { } + } diff --git a/doc/ansible/sysmon-client-aix.yml b/doc/ansible/sysmon-client-aix.yml new file mode 100644 index 0000000..db784e0 --- /dev/null +++ b/doc/ansible/sysmon-client-aix.yml @@ -0,0 +1,48 @@ +--- +# +# Example ansible playbook for installation of sysmon client on AIX. +# +# ansible-galaxy collection install community.general +# ansible-playbook -i aixhost, -k -u root sysmon-client.yml +# +# NOTE: Ensure correct timezone and time + +- name: "Install / Configure sysmon client and plugins" + hosts: all + gather_facts: yes + vars: + client_download_url: https://bitbucket.org/mnellemann/sysmon/downloads/sysmon-client-0.0.5-1.noarch.rpm + plugins_download_url: https://bitbucket.org/mnellemann/sysmon/downloads/sysmon-plugins-0.0.5-1.noarch.rpm + server_url: http://sysmon-server:9925/metrics + client_hostname: myaix + + tasks: + + - name: Download sysmon-client + get_url: + url: "{{ client_download_url }}" + dest: /opt/sysmon-client.rpm + + - name: Download sysmon-plugins + get_url: + url: "{{ plugins_download_url }}" + dest: /opt/sysmon-plugins.rpm + + - name: Install sysmon-client (if /opt/sysmon/client does not exist) + ansible.builtin.command: /usr/bin/rpm -i --ignoreos /opt/sysmon-client.rpm + args: + creates: /opt/sysmon/client + + - name: Install sysmon-plugins (if /opt/sysmon/plugins does not exist) + ansible.builtin.command: /usr/bin/rpm -i --ignoreos /opt/sysmon-plugins.rpm + args: + creates: /opt/sysmon/plugins + + - name: Create inittab entry for sysmon-client + community.general.aix_inittab: + name: sysmon + runlevel: '2' + action: respawn + command: env JAVA_HOME=/usr/java8_64 /opt/sysmon/client/bin/client -s {{ server_url }} -n {{ client_hostname }} >/tmp/sysmon.log 2>&1 + state: present + become: yes \ No newline at end of file diff --git a/doc/ansible/timezone-aix.yml b/doc/ansible/timezone-aix.yml new file mode 100644 index 0000000..4dfde67 --- /dev/null +++ b/doc/ansible/timezone-aix.yml @@ -0,0 +1,35 @@ +--- +# +# Example ansible playbook for timezone and NTP setup on AIX. +# A reboot is required for the timezone change. +# +# ansible-galaxy collection install community.general +# ansible-playbook -i aixhost, -k -u root timezone-aix.yml +# + +- name: "Install / Configure sysmon client and plugins" + hosts: all + gather_facts: yes + vars: + timezone: Europe/Copenhagen + ntp_server: dk.pool.ntp.org + + tasks: + + - name: Configure timezone + ansible.builtin.replace: + path: /etc/environment + regexp: '^TZ=(.*)$' + replace: "TZ={{ timezone }}" + + - name: Update time from NTP server + ansible.builtin.command: /usr/sbin/ntpdate {{ ntp_server }} + + - name: Create cron entry for updating time periodically + ansible.builtin.cron: + name: ntpdate + weekday: "*" + minute: "1" + hour: "*" + user: root + job: "/usr/sbin/ntpdate {{ ntp_server }}" diff --git a/gradle.properties b/gradle.properties index d015b8f..da8f1bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ version=0.0.6 pf4jVersion=3.6.0 -slf4jVersion=1.7.31 +slf4jVersion=1.7.32 camelVersion=3.11.0 picocliVersion=4.6.1 -oshiVersion=5.7.5 \ No newline at end of file +oshiVersion=5.8.1 \ No newline at end of file diff --git a/plugins/build.gradle b/plugins/build.gradle index c2ed79c..c5919ca 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -1,7 +1,7 @@ import org.redline_rpm.header.Os plugins { - id "nebula.ospackage" version "8.5.6" + id "nebula.ospackage" version "8.6.1" } diff --git a/plugins/os-base/gradle.properties b/plugins/os-base/gradle.properties index 3aaf9bc..db66d99 100644 --- a/plugins/os-base/gradle.properties +++ b/plugins/os-base/gradle.properties @@ -1,7 +1,5 @@ pluginId=sysmon-base pluginClass=sysmon.plugins.os_base.BasePlugin -pluginVersion=0.0.1 -pluginProvider=System Monitor pluginDependencies= pluginDescription=Base OS metrics where supported. diff --git a/plugins/os-ibmi/gradle.properties b/plugins/os-ibmi/gradle.properties index cf7297d..18a185f 100644 --- a/plugins/os-ibmi/gradle.properties +++ b/plugins/os-ibmi/gradle.properties @@ -1,6 +1,4 @@ pluginId=sysmon-ibmi pluginClass=sysmon.plugins.os_ibmi.IbmIPlugin -pluginVersion=0.0.1 -pluginProvider=System Monitor pluginDependencies= pluginDescription=Collects IBM-i OS metrics. \ No newline at end of file diff --git a/server/build.gradle b/server/build.gradle index 4513ec5..ffa0468 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -5,7 +5,7 @@ plugins { id "com.github.johnrengelman.shadow" version "7.0.0" id "net.nemerosa.versioning" version "2.14.0" - id "nebula.ospackage" version "8.5.6" + id "nebula.ospackage" version "8.6.1" } dependencies { diff --git a/shared/build.gradle b/shared/build.gradle index 936de1d..3178e62 100644 --- a/shared/build.gradle +++ b/shared/build.gradle @@ -17,9 +17,9 @@ repositories { } dependencies { - testImplementation 'org.codehaus.groovy:groovy:3.0.7' - testImplementation 'org.spockframework:spock-core:2.0-M4-groovy-3.0' - testImplementation 'junit:junit:4.13.1' + testImplementation 'org.codehaus.groovy:groovy:3.0.8' + testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0' + testImplementation 'junit:junit:4.13.2' testImplementation "org.slf4j:slf4j-api:${slf4jVersion}" implementation "org.slf4j:slf4j-api:${slf4jVersion}" From 84f36163b61650e0db2a88639f5c1b4965fb086f Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Tue, 24 Aug 2021 14:21:56 +0200 Subject: [PATCH 3/3] More work on example Ansible playbooks. --- doc/ansible/README.md | 3 + doc/ansible/sysmon-client-aix.yml | 77 +++++++++++-------- doc/ansible/sysmon-client-linux.yml | 61 +++++++++++++++ .../templates/sysmon-client.service.j2 | 10 +++ doc/ansible/timezone-aix.yml | 10 +-- .../plugins/os_aix/AixProcessorExtension.java | 2 +- .../sysmon/plugins/os_ibmi/TestExtension.java | 50 ++++++++++++ 7 files changed, 175 insertions(+), 38 deletions(-) create mode 100644 doc/ansible/README.md create mode 100644 doc/ansible/sysmon-client-linux.yml create mode 100644 doc/ansible/templates/sysmon-client.service.j2 diff --git a/doc/ansible/README.md b/doc/ansible/README.md new file mode 100644 index 0000000..a89fbd8 --- /dev/null +++ b/doc/ansible/README.md @@ -0,0 +1,3 @@ +# Example Ansible Playbooks + +For installing on AIX and RPM-based Linux. \ No newline at end of file diff --git a/doc/ansible/sysmon-client-aix.yml b/doc/ansible/sysmon-client-aix.yml index db784e0..785177f 100644 --- a/doc/ansible/sysmon-client-aix.yml +++ b/doc/ansible/sysmon-client-aix.yml @@ -1,48 +1,63 @@ --- # # Example ansible playbook for installation of sysmon client on AIX. +# More information at: https://bitbucket.org/mnellemann/sysmon # # ansible-galaxy collection install community.general -# ansible-playbook -i aixhost, -k -u root sysmon-client.yml +# ansible-playbook -i aixhost, -u root sysmon-client-aix.yml # # NOTE: Ensure correct timezone and time -- name: "Install / Configure sysmon client and plugins" +- name: "Install Sysmon Client and Plugins on AIX" hosts: all gather_facts: yes vars: - client_download_url: https://bitbucket.org/mnellemann/sysmon/downloads/sysmon-client-0.0.5-1.noarch.rpm - plugins_download_url: https://bitbucket.org/mnellemann/sysmon/downloads/sysmon-plugins-0.0.5-1.noarch.rpm server_url: http://sysmon-server:9925/metrics - client_hostname: myaix - + tasks: - - - name: Download sysmon-client - get_url: - url: "{{ client_download_url }}" - dest: /opt/sysmon-client.rpm - - name: Download sysmon-plugins - get_url: - url: "{{ plugins_download_url }}" - dest: /opt/sysmon-plugins.rpm + - name: Sysmon Client | Ensure hostname resolves + ansible.builtin.lineinfile: + path: /etc/hosts + state: present + line: "127.0.1.1 {{ ansible_hostname }}" - - name: Install sysmon-client (if /opt/sysmon/client does not exist) - ansible.builtin.command: /usr/bin/rpm -i --ignoreos /opt/sysmon-client.rpm - args: - creates: /opt/sysmon/client + - name: Sysmon Client | Copy sysmon-client.rpm + ansible.builtin.copy: + src: "{{ item }}" + dest: /opt/sysmon-client.rpm + with_fileglob: + - ../../client/build/distributions/sysmon-client-*.noarch.rpm - - name: Install sysmon-plugins (if /opt/sysmon/plugins does not exist) - ansible.builtin.command: /usr/bin/rpm -i --ignoreos /opt/sysmon-plugins.rpm - args: - creates: /opt/sysmon/plugins + - name: Sysmon Client | Copy sysmon-plugins.rpm + ansible.builtin.copy: + src: "{{ item }}" + dest: /opt/sysmon-plugins.rpm + with_fileglob: + - ../../plugins/build/distributions/sysmon-plugins-*.noarch.rpm - - name: Create inittab entry for sysmon-client - community.general.aix_inittab: - name: sysmon - runlevel: '2' - action: respawn - command: env JAVA_HOME=/usr/java8_64 /opt/sysmon/client/bin/client -s {{ server_url }} -n {{ client_hostname }} >/tmp/sysmon.log 2>&1 - state: present - become: yes \ No newline at end of file + - name: Sysmon Client | Install sysmon-client.rpm + ansible.builtin.command: /usr/bin/rpm -i --ignoreos /opt/sysmon-client.rpm + args: + creates: /opt/sysmon/client + + - name: Sysmon Client | Install sysmon-plugins.rpm + ansible.builtin.command: /usr/bin/rpm -i --ignoreos /opt/sysmon-plugins.rpm + args: + creates: /opt/sysmon/plugins + + - name: Sysmon Client | Create inittab entry for sysmon-client + community.general.aix_inittab: + name: sysmon + runlevel: '2' + action: respawn + command: env JAVA_HOME=/usr/java8_64 /opt/sysmon/client/bin/client -s {{ server_url }} >/tmp/sysmon.log 2>&1 + state: present + become: yes + notify: + - reload inittab + + handlers: + + - name: reload inittab + command: init q diff --git a/doc/ansible/sysmon-client-linux.yml b/doc/ansible/sysmon-client-linux.yml new file mode 100644 index 0000000..4bfcb0d --- /dev/null +++ b/doc/ansible/sysmon-client-linux.yml @@ -0,0 +1,61 @@ +--- +# +# Example ansible playbook for installation of sysmon client on Linux (RPM based). +# More information at: https://bitbucket.org/mnellemann/sysmon +# +# ansible-playbook -i linuxhost, -u root sysmon-client-linux.yml +# +# NOTE: Ensure correct timezone and time + +- name: "Install Sysmon Client and Plugins on Linux (RPM based)" + hosts: all + gather_facts: no + vars: + server_url: http://sysmon-server:9925/metrics + + tasks: + + - name: Sysmon Client | Copy sysmon-client.rpm + ansible.builtin.copy: + src: "{{ item }}" + dest: /opt/sysmon-client.rpm + with_fileglob: + - ../../client/build/distributions/sysmon-client-*.noarch.rpm + + - name: Sysmon Client | Copy sysmon-plugins.rpm + ansible.builtin.copy: + src: "{{ item }}" + dest: /opt/sysmon-plugins.rpm + with_fileglob: + - ../../plugins/build/distributions/sysmon-plugins-*.noarch.rpm + + - name: Sysmon Client | Install OpenJDK (headless) + yum: + name: "java-11-openjdk-headless" + state: present + + - name: Sysmon Client | Install sysmon-client.rpm + yum: + name: /opt/sysmon-client.rpm + state: present + disable_gpg_check: true + + - name: Sysmon Plugins | Install sysmon-plugins.rpm + yum: + name: /opt/sysmon-plugins.rpm + state: present + disable_gpg_check: true + + - name: Sysmon Client | Create service file + template: src=sysmon-client.service.j2 dest=/lib/systemd/system/sysmon-client.service mode=644 + notify: + - reload systemctl + + - name: Sysmon Client | Start service + service: name=sysmon-client.service state=started enabled=yes + + + handlers: + + - name: reload systemctl + command: systemctl daemon-reload diff --git a/doc/ansible/templates/sysmon-client.service.j2 b/doc/ansible/templates/sysmon-client.service.j2 new file mode 100644 index 0000000..25ea9a2 --- /dev/null +++ b/doc/ansible/templates/sysmon-client.service.j2 @@ -0,0 +1,10 @@ +[Unit] +Description=Sysmon Client Service + +[Service] +TimeoutStartSec=3 +Restart=always +ExecStart=/opt/sysmon/client/bin/client -s {{server_url}} + +[Install] +WantedBy=default.target diff --git a/doc/ansible/timezone-aix.yml b/doc/ansible/timezone-aix.yml index 4dfde67..97c426a 100644 --- a/doc/ansible/timezone-aix.yml +++ b/doc/ansible/timezone-aix.yml @@ -1,15 +1,13 @@ --- # # Example ansible playbook for timezone and NTP setup on AIX. -# A reboot is required for the timezone change. # -# ansible-galaxy collection install community.general -# ansible-playbook -i aixhost, -k -u root timezone-aix.yml +# ansible-playbook -i aixhost, -u root timezone-aix.yml # -- name: "Install / Configure sysmon client and plugins" +- name: "Timezone and NTP on AIX" hosts: all - gather_facts: yes + gather_facts: no vars: timezone: Europe/Copenhagen ntp_server: dk.pool.ntp.org @@ -23,7 +21,7 @@ replace: "TZ={{ timezone }}" - name: Update time from NTP server - ansible.builtin.command: /usr/sbin/ntpdate {{ ntp_server }} + ansible.builtin.command: "env TZ={{ timezone }} /usr/sbin/ntpdate {{ ntp_server }}" - name: Create cron entry for updating time periodically ansible.builtin.cron: diff --git a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java index b41f301..a9f12ca 100644 --- a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java +++ b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java @@ -56,7 +56,7 @@ public class AixProcessorExtension implements MetricExtension { Map tagsMap = null; Map fieldsMap = null; - try (InputStream buf = PluginHelper.executeCommand("lparstat 1 1")) { + try (InputStream buf = PluginHelper.executeCommand("lparstat 5 1")) { AixProcessorStat processorStat = processCommandOutput(buf); tagsMap = processorStat.getTags(); fieldsMap = processorStat.getFields(); diff --git a/plugins/os-ibmi/src/main/java/sysmon/plugins/os_ibmi/TestExtension.java b/plugins/os-ibmi/src/main/java/sysmon/plugins/os_ibmi/TestExtension.java index 52e0d94..1a0c39c 100644 --- a/plugins/os-ibmi/src/main/java/sysmon/plugins/os_ibmi/TestExtension.java +++ b/plugins/os-ibmi/src/main/java/sysmon/plugins/os_ibmi/TestExtension.java @@ -1,14 +1,22 @@ package sysmon.plugins.os_ibmi; +import com.ibm.as400.access.*; +import org.pf4j.Extension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import sysmon.shared.MetricExtension; import sysmon.shared.MetricResult; +import java.io.IOException; + +// Disable for now... +//@Extension public class TestExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(TestExtension.class); + private AS400 as400; + private SystemStatus systemStatus; @Override public boolean isSupported() { @@ -19,6 +27,21 @@ public class TestExtension implements MetricExtension { System.err.println("OS Arch: " + osArch); System.err.println("OS Name: " + osName); + try { + //as400 = new AS400("localhost", "CURRENT"); + as400 = new AS400("10.32.64.142"); + systemStatus = new SystemStatus(as400); + } catch (Exception exception) { + log.error(exception.getMessage()); + } + + if(as400.isLocal()) { + log.info("as400 isLocal() true"); + } else { + log.info("as400 isLocal() FALSE"); + } + + return true; } @@ -39,6 +62,33 @@ public class TestExtension implements MetricExtension { @Override public MetricResult getMetrics() { + + if(systemStatus == null) { + log.warn("getMetrics() - no system or status"); + return null; + } + + try { + int jobsInSystem = systemStatus.getJobsInSystem(); + log.info("Jobs In System: " + jobsInSystem); + + int batchJobsRunning = systemStatus.getBatchJobsRunning(); + log.info("Batch Jobs Running: " + batchJobsRunning); + + int activeThreads = systemStatus.getActiveThreadsInSystem(); + log.info("Active Threads: " + activeThreads); + + int activeJobs = systemStatus.getActiveJobsInSystem(); + log.info("Active Jobs: " + activeJobs); + + int onlineUsers = systemStatus.getUsersCurrentSignedOn(); + log.info("Online Users: " + onlineUsers); + + } catch (AS400SecurityException | ErrorCompletingRequestException | InterruptedException | IOException | ObjectDoesNotExistException e) { + log.error(e.getMessage()); + e.printStackTrace(); + } + return null; } }