diff --git a/README.md b/README.md index 81bcb88..69f6021 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This software is free to use and is licensed under the [Apache 2.0 License](LICE - Example dashboards are provided in the [doc/](doc) folder, which can be imported into your Grafana installation. - Screenshots are available in the [downloads](https://bitbucket.org/mnellemann/sysmon/downloads/) section. -![Sysmon Icon](doc/monitoring-eye-svgrepo-com.png) +![Sysmon Icon](doc/monitoring-eye-320x320.png) ## Components @@ -15,17 +15,18 @@ Runs on your hosts and collects metrics, which are sent to the central *server*. [More information](client/README.md). +### Plugins + +Loaded by the *client* and provides extensions for doing the actual collecting of metrics. + +[More information](plugins/README.md). + ### Server Receives aggregated metrics from *clients* and saves these into InfluxDB. [More information](server/README.md). -### Plugins - -Loaded by the *client* and provides extensions for doing the actual collecting of metrics. - -[More information](plugins/README.md). ## Known problems diff --git a/client/README.md b/client/README.md index d5d165a..2d23ac9 100644 --- a/client/README.md +++ b/client/README.md @@ -1,6 +1,12 @@ # Client -Client component. +This is the client component of SysMon. Install on the hosts for which you want to collect metrics. + +## Installation + +Download *.deb* or *.rpm* packages for sysmon-client *and* sysmon-plugins, and install. + +See the [doc/systemd.md](doc/systemd.md) or [doc/sysv-init.md](doc/sysv-init.md) files for further instructions. ## Development diff --git a/client/doc/AIX.md b/client/doc/AIX.md index cea5076..db4374e 100644 --- a/client/doc/AIX.md +++ b/client/doc/AIX.md @@ -13,9 +13,4 @@ rpm -i --ignoreos sysmon-client.rpm sysmon-plugins.rpm ## Run automatically at boot -Change the *sysmon-server* URL for your environment. - -```shell -mkitab 'sysmon:2:respawn:env JAVA_HOME=/usr/java8_64 /opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics >/tmp/sysmon.log 2>&1' -init q -``` +See the [sysv-init.md](sysv-init.md) file for instructions. \ No newline at end of file diff --git a/client/doc/sysmon-client.service b/client/doc/sysmon-client.service index cee5c52..e6e25d9 100644 --- a/client/doc/sysmon-client.service +++ b/client/doc/sysmon-client.service @@ -2,6 +2,8 @@ Description=Sysmon Client Service [Service] +#User=nobody +#Group=nobody TimeoutSec=20 Restart=on-failure ExecStart=/opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics diff --git a/client/doc/sysmon-client.sh b/client/doc/sysmon-client.sh new file mode 100644 index 0000000..e958d1f --- /dev/null +++ b/client/doc/sysmon-client.sh @@ -0,0 +1,100 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by daemon. +### END INIT INFO + +dir="/opt/sysmon/client" +cmd="/opt/sysmon/client/bin/client" +args="-s http://10.20.30.40:9925/metrics" +user="" + +name=`basename $0` +pid_file="/var/run/$name.pid" +stdout_log="/var/log/$name.log" +stderr_log="/var/log/$name.err" + +get_pid() { + cat "$pid_file" +} + +is_running() { + [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1 +} + +case "$1" in + start) + if is_running; then + echo "Already started" + else + echo "Starting $name" + cd "$dir" + if [ -z "$user" ]; then + $cmd $args >> "$stdout_log" 2>> "$stderr_log" & + else + sudo -u "$user" $cmd $args >> "$stdout_log" 2>> "$stderr_log" & + fi + echo $! > "$pid_file" + if ! is_running; then + echo "Unable to start, see $stdout_log and $stderr_log" + exit 1 + fi + fi + ;; + stop) + if is_running; then + echo -n "Stopping $name.." + kill `get_pid` + for i in 1 2 3 4 5 6 7 8 9 10 + # for i in `seq 10` + do + if ! is_running; then + break + fi + + echo -n "." + sleep 1 + done + echo + + if is_running; then + echo "Not stopped; may still be shutting down or shutdown may have failed" + exit 1 + else + echo "Stopped" + if [ -f "$pid_file" ]; then + rm "$pid_file" + fi + fi + else + echo "Not running" + fi + ;; + restart) + $0 stop + if is_running; then + echo "Unable to stop, will not attempt to start" + exit 1 + fi + $0 start + ;; + status) + if is_running; then + echo "Running" + else + echo "Stopped" + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/client/doc/sysv-init.md b/client/doc/sysv-init.md new file mode 100644 index 0000000..909ddb7 --- /dev/null +++ b/client/doc/sysv-init.md @@ -0,0 +1,6 @@ +# SysV init Notes + +- Copy the *sysmon-client.sh* into *sysmon-client* in the correct location for init scripts on your operating system. +- Edit the file to specify sysmon-server URL in the *args* variable. +- SymLink to the required run-levels. + diff --git a/doc/ansible/README.md b/doc/ansible/README.md deleted file mode 100644 index a89fbd8..0000000 --- a/doc/ansible/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# 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 deleted file mode 100644 index 785177f..0000000 --- a/doc/ansible/sysmon-client-aix.yml +++ /dev/null @@ -1,63 +0,0 @@ ---- -# -# 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, -u root sysmon-client-aix.yml -# -# NOTE: Ensure correct timezone and time - -- name: "Install Sysmon Client and Plugins on AIX" - hosts: all - gather_facts: yes - vars: - server_url: http://sysmon-server:9925/metrics - - tasks: - - - 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: 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 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 deleted file mode 100644 index 4bfcb0d..0000000 --- a/doc/ansible/sysmon-client-linux.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -# -# 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 deleted file mode 100644 index 25ea9a2..0000000 --- a/doc/ansible/templates/sysmon-client.service.j2 +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index 97c426a..0000000 --- a/doc/ansible/timezone-aix.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -# -# Example ansible playbook for timezone and NTP setup on AIX. -# -# ansible-playbook -i aixhost, -u root timezone-aix.yml -# - -- name: "Timezone and NTP on AIX" - hosts: all - gather_facts: no - 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: "env TZ={{ timezone }} /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/doc/monitoring-eye-320x320.png b/doc/monitoring-eye-320x320.png new file mode 100644 index 0000000..b76724a Binary files /dev/null and b/doc/monitoring-eye-320x320.png differ diff --git a/doc/monitoring-eye-svgrepo-com.png b/doc/monitoring-eye-512x512.png similarity index 100% rename from doc/monitoring-eye-svgrepo-com.png rename to doc/monitoring-eye-512x512.png diff --git a/gradle.properties b/gradle.properties index 2c76e0e..6f8fccf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ version=0.1.7 pf4jVersion=3.6.0 slf4jVersion=1.7.32 -camelVersion=3.11.4 +camelVersion=3.14.0 picocliVersion=4.6.2 -oshiVersion=5.8.5 \ No newline at end of file +oshiVersion=5.8.6 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 84d1f85..d2880ba 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/plugins/README.md b/plugins/README.md index 6e6b5b9..38ebedf 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -2,6 +2,6 @@ Collection of standard sysmon plugins. -- [base](os-base/) - base OS metrics +- [base](os-base/) - Base OS metrics (through [oshi](https://github.com/oshi/oshi)) - [aix](os-aix/) - AIX (and Power) specific metrics - [linux](os-linux/) - Linux specific metrics \ No newline at end of file diff --git a/plugins/os-base/README.md b/plugins/os-base/README.md index e0790fe..8470b4e 100644 --- a/plugins/os-base/README.md +++ b/plugins/os-base/README.md @@ -40,7 +40,7 @@ Metrics reported are: ## Filesystem Extension ### Metrics -- + - **free_bytes** - Free bytes for filesystem. - **total_bytes** - Total bytes for filesystem. - **free_inoed** - Free inodes for filesystem. diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDetailsExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDetailsExtension.java index e03640f..912e6bf 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDetailsExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDetailsExtension.java @@ -4,15 +4,11 @@ import org.pf4j.Extension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import oshi.SystemInfo; -import oshi.hardware.HWDiskStore; -import oshi.hardware.HardwareAbstractionLayer; import sysmon.shared.Measurement; import sysmon.shared.MetricExtension; import sysmon.shared.MetricResult; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; @Extension diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetstatExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetstatExtension.java index 3f57f33..bf1a383 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetstatExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetstatExtension.java @@ -4,15 +4,11 @@ import org.pf4j.Extension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import oshi.SystemInfo; -import oshi.hardware.HWDiskStore; -import oshi.hardware.HardwareAbstractionLayer; import sysmon.shared.Measurement; import sysmon.shared.MetricExtension; import sysmon.shared.MetricResult; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; @Extension diff --git a/server/README.md b/server/README.md index 4546314..0947758 100644 --- a/server/README.md +++ b/server/README.md @@ -1,10 +1,12 @@ # Server -Server component. +This is the server component of SysMon. ## Installation -TODO. +Download *.deb* or *.rpm* package and install. + +See the [doc/systemd.md](doc/systemd.md) or [doc/sysv-init.md](doc/sysv-init.md) files for further instructions. ### Influx Database diff --git a/server/doc/AIX.md b/server/doc/AIX.md new file mode 100644 index 0000000..1c0bbcd --- /dev/null +++ b/server/doc/AIX.md @@ -0,0 +1,18 @@ +# AIX Notes + +Works on IBM Power AIX installations. + +## Installation + +We require Java 8, which should already be installed on AIX, or is available to install. +The RPM packages are *"noarch"* Java bytecode, so we can use the **--ignoreos** option to install: + +```shell +rpm -i --ignoreos sysmon-server.rpm +``` + +You can find InfluxDB and Grafana packaged for AIX on the [https://www.power-devops.com/](https://www.power-devops.com/) website. + +## Run automatically at boot + +See the [sysv-init.md](sysv-init.md) file for instructions. \ No newline at end of file diff --git a/server/doc/sysmon-server.sh b/server/doc/sysmon-server.sh new file mode 100644 index 0000000..60f4b38 --- /dev/null +++ b/server/doc/sysmon-server.sh @@ -0,0 +1,100 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by daemon. +### END INIT INFO + +dir="/opt/sysmon/server" +cmd="/opt/sysmon/server/bin/server" +args="-d" +user="" + +name=`basename $0` +pid_file="/var/run/$name.pid" +stdout_log="/var/log/$name.log" +stderr_log="/var/log/$name.err" + +get_pid() { + cat "$pid_file" +} + +is_running() { + [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1 +} + +case "$1" in + start) + if is_running; then + echo "Already started" + else + echo "Starting $name" + cd "$dir" + if [ -z "$user" ]; then + $cmd $args >> "$stdout_log" 2>> "$stderr_log" & + else + sudo -u "$user" $cmd $args >> "$stdout_log" 2>> "$stderr_log" & + fi + echo $! > "$pid_file" + if ! is_running; then + echo "Unable to start, see $stdout_log and $stderr_log" + exit 1 + fi + fi + ;; + stop) + if is_running; then + echo -n "Stopping $name.." + kill `get_pid` + for i in 1 2 3 4 5 6 7 8 9 10 + # for i in `seq 10` + do + if ! is_running; then + break + fi + + echo -n "." + sleep 1 + done + echo + + if is_running; then + echo "Not stopped; may still be shutting down or shutdown may have failed" + exit 1 + else + echo "Stopped" + if [ -f "$pid_file" ]; then + rm "$pid_file" + fi + fi + else + echo "Not running" + fi + ;; + restart) + $0 stop + if is_running; then + echo "Unable to stop, will not attempt to start" + exit 1 + fi + $0 start + ;; + status) + if is_running; then + echo "Running" + else + echo "Stopped" + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/server/doc/sysv-init.md b/server/doc/sysv-init.md new file mode 100644 index 0000000..9bd78aa --- /dev/null +++ b/server/doc/sysv-init.md @@ -0,0 +1,6 @@ +# SysV init Notes + +- Copy the *sysmon-server.sh* into *sysmon-server* in the correct location for init scripts on your operating system. +- Edit the file if you need to specify any options in the *args* variable. +- SymLink to the required run-levels. +