Misc. small changes.
- Update 3rd party dependencies
This commit is contained in:
parent
8b426931e7
commit
0332732401
13
README.md
13
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.
|
- 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.
|
- 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
|
## Components
|
||||||
|
|
||||||
|
@ -15,17 +15,18 @@ Runs on your hosts and collects metrics, which are sent to the central *server*.
|
||||||
|
|
||||||
[More information](client/README.md).
|
[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
|
### Server
|
||||||
|
|
||||||
Receives aggregated metrics from *clients* and saves these into InfluxDB.
|
Receives aggregated metrics from *clients* and saves these into InfluxDB.
|
||||||
|
|
||||||
[More information](server/README.md).
|
[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
|
## Known problems
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
# Client
|
# 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
|
## Development
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,4 @@ rpm -i --ignoreos sysmon-client.rpm sysmon-plugins.rpm
|
||||||
|
|
||||||
## Run automatically at boot
|
## Run automatically at boot
|
||||||
|
|
||||||
Change the *sysmon-server* URL for your environment.
|
See the [sysv-init.md](sysv-init.md) file for instructions.
|
||||||
|
|
||||||
```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
|
|
||||||
```
|
|
|
@ -2,6 +2,8 @@
|
||||||
Description=Sysmon Client Service
|
Description=Sysmon Client Service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
#User=nobody
|
||||||
|
#Group=nobody
|
||||||
TimeoutSec=20
|
TimeoutSec=20
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
ExecStart=/opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics
|
ExecStart=/opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics
|
||||||
|
|
100
client/doc/sysmon-client.sh
Normal file
100
client/doc/sysmon-client.sh
Normal file
|
@ -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
|
6
client/doc/sysv-init.md
Normal file
6
client/doc/sysv-init.md
Normal file
|
@ -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.
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
# Example Ansible Playbooks
|
|
||||||
|
|
||||||
For installing on AIX and RPM-based Linux.
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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 }}"
|
|
BIN
doc/monitoring-eye-320x320.png
Normal file
BIN
doc/monitoring-eye-320x320.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
@ -1,6 +1,6 @@
|
||||||
version=0.1.7
|
version=0.1.7
|
||||||
pf4jVersion=3.6.0
|
pf4jVersion=3.6.0
|
||||||
slf4jVersion=1.7.32
|
slf4jVersion=1.7.32
|
||||||
camelVersion=3.11.4
|
camelVersion=3.14.0
|
||||||
picocliVersion=4.6.2
|
picocliVersion=4.6.2
|
||||||
oshiVersion=5.8.5
|
oshiVersion=5.8.6
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
Collection of standard sysmon plugins.
|
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
|
- [aix](os-aix/) - AIX (and Power) specific metrics
|
||||||
- [linux](os-linux/) - Linux specific metrics
|
- [linux](os-linux/) - Linux specific metrics
|
|
@ -40,7 +40,7 @@ Metrics reported are:
|
||||||
## Filesystem Extension
|
## Filesystem Extension
|
||||||
|
|
||||||
### Metrics
|
### Metrics
|
||||||
-
|
|
||||||
- **free_bytes** - Free bytes for filesystem.
|
- **free_bytes** - Free bytes for filesystem.
|
||||||
- **total_bytes** - Total bytes for filesystem.
|
- **total_bytes** - Total bytes for filesystem.
|
||||||
- **free_inoed** - Free inodes for filesystem.
|
- **free_inoed** - Free inodes for filesystem.
|
||||||
|
|
|
@ -4,15 +4,11 @@ import org.pf4j.Extension;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import oshi.SystemInfo;
|
import oshi.SystemInfo;
|
||||||
import oshi.hardware.HWDiskStore;
|
|
||||||
import oshi.hardware.HardwareAbstractionLayer;
|
|
||||||
import sysmon.shared.Measurement;
|
import sysmon.shared.Measurement;
|
||||||
import sysmon.shared.MetricExtension;
|
import sysmon.shared.MetricExtension;
|
||||||
import sysmon.shared.MetricResult;
|
import sysmon.shared.MetricResult;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
|
|
|
@ -4,15 +4,11 @@ import org.pf4j.Extension;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import oshi.SystemInfo;
|
import oshi.SystemInfo;
|
||||||
import oshi.hardware.HWDiskStore;
|
|
||||||
import oshi.hardware.HardwareAbstractionLayer;
|
|
||||||
import sysmon.shared.Measurement;
|
import sysmon.shared.Measurement;
|
||||||
import sysmon.shared.MetricExtension;
|
import sysmon.shared.MetricExtension;
|
||||||
import sysmon.shared.MetricResult;
|
import sysmon.shared.MetricResult;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
# Server
|
# Server
|
||||||
|
|
||||||
Server component.
|
This is the server component of SysMon.
|
||||||
|
|
||||||
## Installation
|
## 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
|
### Influx Database
|
||||||
|
|
||||||
|
|
18
server/doc/AIX.md
Normal file
18
server/doc/AIX.md
Normal file
|
@ -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.
|
100
server/doc/sysmon-server.sh
Normal file
100
server/doc/sysmon-server.sh
Normal file
|
@ -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
|
6
server/doc/sysv-init.md
Normal file
6
server/doc/sysv-init.md
Normal file
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue