New subclass: xymon::client::config : Manage the init script for Xymon
client.
This commit is contained in:
parent
c09b1ece7e
commit
8f2174bc06
|
@ -28,12 +28,18 @@ class xymon::client (
|
|||
$package_name = $xymon::params::cli_package_name,
|
||||
$pkg_ensure = $xymon::params::cli_pkg_ensure,
|
||||
$pkg_provider = $xymon::params::cli_pkg_provider,
|
||||
$service_name = $xymon::params::cli_service_name,
|
||||
$service_default_path = $xymon::params::cli_service_default_path,
|
||||
$service_path = $xymon::params::cli_service_path,
|
||||
$service_tpl = $xymon::params::cli_service_tpl,
|
||||
) inherits xymon::params {
|
||||
|
||||
include '::xymon::client::preconfig'
|
||||
include '::xymon::client::install'
|
||||
include '::xymon::client::config'
|
||||
|
||||
Class['::xymon::client::preconfig'] ->
|
||||
Class['::xymon::client::install']
|
||||
Class['::xymon::client::install'] ->
|
||||
Class['::xymon::client::config']
|
||||
|
||||
} # Public class: xymon::client
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# == Class: xymon::client::install
|
||||
#
|
||||
# Install Xymon client
|
||||
#
|
||||
class xymon::client::config {
|
||||
|
||||
File {
|
||||
owner => root,
|
||||
group => root,
|
||||
mode => 0644,
|
||||
}
|
||||
|
||||
file { "${xymon::client::service_path}":
|
||||
ensure => present,
|
||||
mode => 0754,
|
||||
content => template($xymon::client::service_tpl),
|
||||
}
|
||||
|
||||
|
||||
} # Private class: xymon::client::config
|
|
@ -4,15 +4,21 @@ class xymon::params {
|
|||
case $::osfamily {
|
||||
'Debian': {
|
||||
|
||||
# Client
|
||||
## Client
|
||||
# Package
|
||||
$cli_download_dir = '/opt/xymon/packages'
|
||||
$cli_download_url = undef
|
||||
$cli_new_version = '4.3.17'
|
||||
|
||||
$cli_package_name = undef
|
||||
$cli_pkg_ensure = 'present'
|
||||
$cli_pkg_provider = 'dpkg'
|
||||
|
||||
# Service
|
||||
$cli_service_name = 'xymon-client'
|
||||
$cli_service_default_path = '/etc/default/xymon-client'
|
||||
$cli_service_path = '/etc/init.d/xymon-client'
|
||||
$cli_service_tpl = 'xymon/client/xymon-client.deb_service.erb'
|
||||
|
||||
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# <%= scope.lookupvar('xymon::client::service_name') %> This shell script takes care of starting and stopping
|
||||
# the xymon client.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: <%= scope.lookupvar('xymon::client::service_name') %> hobbit-client
|
||||
# Required-Start: $remote_fs $network
|
||||
# Should-Start: $all
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Xymon system monitor client
|
||||
# Description: Client to feed system data to a remote Xymon server.
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DAEMON="/usr/lib/xymon/client/bin/xymonlaunch"
|
||||
NAME=<%= scope.lookupvar('xymon::client::service_name') %>
|
||||
DESC="Xymon Client"
|
||||
PIDFILE="/var/run/xymon/clientlaunch.pid"
|
||||
XYMONCLIENTHOME="/usr/lib/xymon/client"
|
||||
|
||||
test -x $DAEMON || exit 0
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
. /usr/share/xymon/init-common.sh
|
||||
|
||||
# Include <%= scope.lookupvar('xymon::client::service_name') %> defaults if available
|
||||
if [ -f <%= scope.lookupvar('xymon::client::service_default_path') %> ] ; then
|
||||
. <%= scope.lookupvar('xymon::client::service_default_path') %>
|
||||
fi
|
||||
[ -z "$MACHINE" ] && MACHINE="$CLIENTHOSTNAME"
|
||||
[ -z "$MACHINEDOTS" ] && MACHINEDOTS="`hostname -f`"
|
||||
export XYMONSERVERS XYMONCLIENTHOME CLIENTHOSTNAME MACHINE MACHINEDOTS
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
# do not run the client script on the server
|
||||
[ -x /usr/lib/xymon/server/bin/xymond ] && exit 0
|
||||
|
||||
create_includefiles
|
||||
|
||||
if test "$TMPFSSIZE" && test -e /proc/mounts && ! grep -q /var/lib/xymon/tmp /proc/mounts; then
|
||||
echo "Mounting tmpfs on /var/lib/xymon/tmp"
|
||||
rm -f /var/lib/xymon/tmp/*
|
||||
mount -t tmpfs -o"size=$TMPFSSIZE,mode=755,uid=$(id -u xymon)" tmpfs /var/lib/xymon/tmp
|
||||
fi
|
||||
|
||||
log_daemon_msg "Starting $DESC" "$NAME"
|
||||
start-stop-daemon --exec $DAEMON --chuid xymon --umask 022 --start \
|
||||
-- \
|
||||
--config=/etc/xymon/clientlaunch.cfg \
|
||||
--log=/var/log/xymon/clientlaunch.log \
|
||||
--pidfile=$PIDFILE
|
||||
log_end_msg $?
|
||||
;;
|
||||
stop)
|
||||
log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
start-stop-daemon --exec $DAEMON --pidfile $PIDFILE --stop --retry 5
|
||||
log_end_msg $?
|
||||
;;
|
||||
status)
|
||||
if test -s $PIDFILE
|
||||
then
|
||||
kill -0 `cat $PIDFILE`
|
||||
if test $? -eq 0
|
||||
then
|
||||
echo "Xymon client running with PID `cat $PIDFILE`"
|
||||
exit 0
|
||||
else
|
||||
echo "Xymon client not running, removing stale PID file"
|
||||
rm -f $PIDFILE
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Xymon client does not appear to be running"
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
if [ -x /usr/lib/xymon/server/bin/xymond ] ; then
|
||||
log_action_msg "Xymon server installed. Please restart 'xymon' instead"
|
||||
exit 0
|
||||
fi
|
||||
$0 stop
|
||||
sleep 1
|
||||
$0 start
|
||||
;;
|
||||
reload|force-reload)
|
||||
[ -x /usr/lib/xymon/server/bin/xymond ] && exit 0
|
||||
create_includefiles
|
||||
kill -HUP `cat /var/run/xymon/clientlaunch.pid`
|
||||
;;
|
||||
rotate)
|
||||
for PIDFILE in /var/run/xymon/*.pid
|
||||
do
|
||||
test -e $PIDFILE && kill -HUP `cat $PIDFILE`
|
||||
done
|
||||
;;
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
echo "Usage: $N {start|stop|restart|force-reload|status|rotate}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue