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; } }