More work on example Ansible playbooks.
This commit is contained in:
parent
e2b478a1c2
commit
84f36163b6
3
doc/ansible/README.md
Normal file
3
doc/ansible/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Example Ansible Playbooks
|
||||
|
||||
For installing on AIX and RPM-based Linux.
|
|
@ -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 }}"
|
||||
- name: Sysmon Client | Ensure hostname resolves
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/hosts
|
||||
state: present
|
||||
line: "127.0.1.1 {{ ansible_hostname }}"
|
||||
|
||||
- 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: Download sysmon-plugins
|
||||
get_url:
|
||||
url: "{{ plugins_download_url }}"
|
||||
- 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: Install sysmon-client (if /opt/sysmon/client does not exist)
|
||||
- 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: Install sysmon-plugins (if /opt/sysmon/plugins does not exist)
|
||||
- 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: Create inittab entry for sysmon-client
|
||||
- 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 }} -n {{ client_hostname }} >/tmp/sysmon.log 2>&1
|
||||
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
|
||||
|
|
61
doc/ansible/sysmon-client-linux.yml
Normal file
61
doc/ansible/sysmon-client-linux.yml
Normal file
|
@ -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
|
10
doc/ansible/templates/sysmon-client.service.j2
Normal file
10
doc/ansible/templates/sysmon-client.service.j2
Normal file
|
@ -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
|
|
@ -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:
|
||||
|
|
|
@ -56,7 +56,7 @@ public class AixProcessorExtension implements MetricExtension {
|
|||
Map<String, String> tagsMap = null;
|
||||
Map<String, Object> 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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue