Updated clarified module for new recorder init scripts

This commit is contained in:
Ossi Salmi 2011-05-03 14:09:49 +03:00 committed by Timo Mkinen
parent f1fc87b750
commit 6f828786eb
3 changed files with 30 additions and 135 deletions

View file

@ -56,7 +56,7 @@ class clarified::recorder {
mode => 0644, mode => 0644,
owner => root, owner => root,
group => root, group => root,
before => Exec["/usr/local/src/probe-linux-i686.sh"], before => Exec["/usr/local/src/clarified-recorder-linux-i686.sh"],
} }
File["/etc/clarified/probe.d", "/etc/clarified/remote.d"] { File["/etc/clarified/probe.d", "/etc/clarified/remote.d"] {
@ -66,17 +66,17 @@ class clarified::recorder {
source => "puppet:///modules/custom/empty", source => "puppet:///modules/custom/empty",
} }
file { "/usr/local/src/probe-linux-i686.sh": file { "/usr/local/src/clarified-recorder-linux-i686.sh":
ensure => present, ensure => present,
mode => 0755, mode => 0755,
owner => root, owner => root,
group => root, group => root,
source => "puppet:///files/packages/probe-linux-i686.sh", source => "puppet:///files/packages/clarified-recorder-linux-i686.sh",
links => follow, links => follow,
before => Exec["/usr/local/src/probe-linux-i686.sh"], before => Exec["/usr/local/src/clarified-recorder-linux-i686.sh"],
} }
exec { "/usr/local/src/probe-linux-i686.sh": exec { "/usr/local/src/clarified-recorder-linux-i686.sh":
creates => "/usr/local/probe", creates => "/usr/local/probe",
} }
@ -85,7 +85,7 @@ class clarified::recorder {
cwd => "/usr/local/probe", cwd => "/usr/local/probe",
command => "sed s:@PREFIX@:/usr/local/probe: clarified-functions.in > /etc/clarified/clarified-functions", command => "sed s:@PREFIX@:/usr/local/probe: clarified-functions.in > /etc/clarified/clarified-functions",
creates => "/etc/clarified/clarified-functions", creates => "/etc/clarified/clarified-functions",
require => Exec["/usr/local/src/probe-linux-i686.sh"], require => Exec["/usr/local/src/clarified-recorder-linux-i686.sh"],
before => Service["clarified-probe"], before => Service["clarified-probe"],
} }
@ -95,13 +95,14 @@ class clarified::recorder {
owner => root, owner => root,
group => root, group => root,
source => "/usr/local/probe/probe-init.sh", source => "/usr/local/probe/probe-init.sh",
require => Exec["/usr/local/src/probe-linux-i686.sh"], require => Exec["/usr/local/src/clarified-recorder-linux-i686.sh"],
before => Service["clarified-probe"], before => Service["clarified-probe"],
} }
service { "clarified-probe": service { "clarified-probe":
ensure => running, ensure => running,
enable => true, enable => true,
hasrestart => true,
status => "pgrep -f /usr/local/probe", status => "pgrep -f /usr/local/probe",
} }
@ -139,12 +140,13 @@ class clarified::recorder {
# keeptime => "500GB", # keeptime => "500GB",
# blocksize => "10GB", # blocksize => "10GB",
# filter => "host 192.168.1.1", # filter => "host 192.168.1.1",
# collab => [ "collabname:PageName", ], # collab => [ "collabname:PageName" ],
# } # }
# #
define clarified::probe($interface="", $snaplen="65535", $keeptime="100GB", define clarified::probe($interface="", $snaplen="65535", $keeptime="100GB",
$blocksize="1GB", $filter="", $remoteport="10000", $blocksize="1GB", $filter="", $remoteport="10000",
$collab="", $probe=true, $remote=true) { $collab=[], $probeopt="", $remoteopt="",
$probe=true, $remote=true) {
if $interface { if $interface {
$interface_real = $interface $interface_real = $interface
@ -152,12 +154,6 @@ define clarified::probe($interface="", $snaplen="65535", $keeptime="100GB",
$interface_real = $name $interface_real = $name
} }
if $filter {
$miscopts = "-b ${blocksize} -f \"${filter}\""
} else {
$miscopts = "-b ${blocksize}"
}
file { "/etc/clarified/probe.d/${name}": file { "/etc/clarified/probe.d/${name}":
ensure => $probe ? { ensure => $probe ? {
true => present, true => present,

View file

@ -1,63 +1,11 @@
#!/bin/sh #!/bin/bash
# Copyright (c) 2007 Clarified Networks Oy. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
CAPTURE_DIR=/var/lib/recorder/<%= name %> NETWORK_IFC="<%= interface_real %>"
NETWORK_IFC=<%= interface_real %> CAPTURE_DIR="/var/lib/recorder/<%= name %>"
PROBE_IDENT=<%= name %> SNAPLEN="<%= snaplen %>"
SNAPLEN=<%= snaplen %> KEEPTIME="<%= keeptime %>"
KEEPTIME=<%= keeptime %> BLOCKSIZE="<%= blocksize %>"
MISC_OPTS='<%= miscopts %>' FILTER="<%= filter %>"
OPTIONS="<%= probeopt %>"
. /etc/clarified/clarified-functions . /etc/clarified/clarified-functions
start() {
if [ ! -z $SNAPLEN ]; then
PROBE_OPTIONS="-s $SNAPLEN"
fi
if [ ! -z $KEEPTIME ]; then
PROBE_OPTIONS="$PROBE_OPTIONS -k $KEEPTIME"
fi
eval start_probe ${PROBE_OPTIONS} ${MISC_OPTS} ${CAPTURE_DIR} ${NETWORK_IFC}
#LOG_SUCCESS "Probe" $PROBE_IDENT "up"
}
stop() {
stop_probe $PROBE_IDENT
#LOG_SUCCESS "Probe" $PROBE_IDENT "down"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

View file

@ -1,59 +1,10 @@
#!/bin/sh #!/bin/bash
# Copyright (c) 2007 Clarified Networks Oy. All rights reserved.
# CAPTURE_DIR="/var/lib/recorder/<%= name %>"
# Permission is hereby granted, free of charge, to any person obtaining a copy PRIVATE_CERT="<%= puppet_ssldir %>/private_keys/<%= homename %>.pem"
# of this software and associated documentation files (the "Software"), to deal PUBLIC_CERT="<%= puppet_ssldir %>/certs/<%= homename %>.pem"
# in the Software without restriction, including without limitation the rights PORT="<%= remoteport %>"
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell COLLAB="<%= collab.join(" ") %>"
# copies of the Software, and to permit persons to whom the Software is OPTIONS="<%= remoteopt %>"
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
REMOTE_IDENT=<%= name %>
WORK_DIR=/var/lib/recorder/<%= name %>
PRIVATE_CERT=<%= puppet_ssldir %>/private_keys/<%= homename %>.pem
PUBLIC_CERT=<%= puppet_ssldir %>/certs/<%= homename %>.pem
PORT=<%= remoteport %>
. /etc/clarified/clarified-functions . /etc/clarified/clarified-functions
start() {
start_remote \
<% collab.each do |c| -%>
-c '<%= c %>' \
<% end -%>
-p $PORT "$WORK_DIR" "$PRIVATE_CERT" "$PUBLIC_CERT"
#LOG_SUCCESS "Remote" $REMOTE_IDENT "up"
}
stop() {
stop_remote $REMOTE_IDENT
#LOG_SUCCESS "Remote" $REMOTE_IDENT "down"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac