summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-11-02 15:15:09 -0500
committerDave Brolley <brolley@redhat.com>2009-11-02 15:15:09 -0500
commit41b0a0c67e5848de4c621a53f6b2d0acb92b901f (patch)
treed251063c4da28517e0030bd8de62bc8dcbded630
parentd210cb1c6405a7560c98961af286a6aee36df7ef (diff)
downloadsystemtap-steved-41b0a0c67e5848de4c621a53f6b2d0acb92b901f.tar.gz
systemtap-steved-41b0a0c67e5848de4c621a53f6b2d0acb92b901f.tar.xz
systemtap-steved-41b0a0c67e5848de4c621a53f6b2d0acb92b901f.zip
Final cleanup of stap-server initscript and packaging.
-rw-r--r--initscript/README.stap-server511
-rw-r--r--initscript/config.stap-server3
-rw-r--r--initscript/stap-server.in1
-rwxr-xr-xstap-gen-cert3
-rw-r--r--stap-server-connect.c9
5 files changed, 230 insertions, 297 deletions
diff --git a/initscript/README.stap-server b/initscript/README.stap-server
index c7bb4888..a09859b0 100644
--- a/initscript/README.stap-server
+++ b/initscript/README.stap-server
@@ -1,6 +1,5 @@
-Systemtap initscript
-Version 0.2.1
-Author: Masami Hiramatsu <mhiramat@redhat.com>
+stap-server initscript
+Version 0.1.0
INDEX
=====
@@ -8,348 +7,278 @@ INDEX
2. Usage
3. Files
4. Configuration Format
-5. How to use
+5. Usage Examples
1. Introduction
===============
-Systemtap initscript aims to provide
-- running systemtap script as a service with dependency.
-- easy way to control(start/stop) those scripts individually.
-The dependency means that which user-defined systemtap script is required by
-other script (Here the scripts don't include tapsets). This dependency
-will be useful for users who use -DRELAY_HOST and -DRELAY_GUEST.
+The stap-server init script aims to provide
+- management of systemtap compile servers as a service.
+- convenient control over configured servers and individual (ad-hoc) servers.
2. Usage
========
2.1 Synopsis
+------------
+ /sbin/service stap-server {start|stop|restart|condrestart|try-restart|force-reload|status} [options]
-/sbin/service systemtap {start|stop|restart|status|compile|cleanup} \
- [-r kernelrelease] [-c config] [-R] [-y] [script(s)]
-
-2.2 Commands
- You have to specify one of the below commands.
+2.2 Actions
+-----------
+One of the actions below must be specified.
2.2.1 start
- Run script(s). If the script(s) is already started, the command will be
- ignored. If it fails to start, return FAIL. If AUTOCOMPILE option is 'yes'
- (see 4.1.9), this will try to compile or update the specified script when
- one of the below condition is true.
- - compiled cache file does not exist.
- - mtime (modified time stamp) of original script file is newer than compiled
- script cache.
- - script options which is used when compiling(see 4.2.1) has been changed.
- - result of `uname -a` has been changed.
- If no scripts specified from command line, it starts all scripts in the script
- directory or the scripts specified by DEFAULT_START in config (see 4.1.10).
+ Start server(s). If a specified server is already started, this action will
+ be ignored for that server. If any server fails to start this action fails.
+ If no server is specified, the configured servers are started. If no servers
+ are configured, a server for the kernel release and architecture of the host
+ is started.
2.2.2 stop
- Stop script(s). If the script(s) is already stopped, this will be ignored.
- If it fails to stop, return FAIL.
- If no scripts specified from command line, it stops all running scripts.
+ Stop server(s). If a specified server is already stopped, this action
+ will be ignored for that server. If a server fails to stop, this action fails.
+ If no server is specified, all currently running servers are stopped.
2.2.3 restart
- Stop and start script(s) again.
+ Stop and start servers again. The specified servers are stopped and restarted.
+ If no server is specified, all currently running servers are stopped and
+ restarted. If no servers are running this action behaves like 'start'.
+
+2.2.4 condrestart
+ Stop and start servers again. The specified servers are stopped and restarted.
+ If a specified server is not running, it is not started. If no server is
+ specified, all currently running servers are stopped and restarted. If no
+ servers are running, none will be started.
-2.2.4 status
- Show running script(s) status and dependency.
+2.2.5 try-restart
+ This action is identical to condrestart.
-2.2.5 compile
- Compile script(s) on the specified kernel. This command takes '-r' option
- which specifies the release of the kernel(see 2.3.4) on which you would
- like to compile script(s). This command asks user whether it can overwrite
-existing caches.
+2.2.6 force-reload
+ Stop all running servers, reload config files and restart the service as if
+ 'start' was specified.
-2.2.6 cleanup
- Cleanup compiled script(s) from cache directory(see 3.4). This command also
- takes '-r' option. If '-r' option is omitted, cleanup all caches for running
- kernel. This command asks user whether it can remove caches.
+2.2.7 status
+ Print information about running servers. Information about the specified
+ server(s) will be printed. If no server is specified, information about all
+ running servers will be printed.
2.3 Options
- Systemtap initscript can have some options. However, since user can't pass
- these options on boot, these options are only for testing or managing scripts
- after booting.
+-----------
+The following options may be used to provide additional configuration and
+to specify servers to be managed.
+
+2.3.1 -c configfile
+ This option specifies a configuration file in addition to those described
+ in section 4 below. This file will be processed after the default
+ configuration file. If the -c option is specified more than once, the last
+ configuration file specified will be used.
+
+2.3.2 -a architecture
+ Each stap-server instance targets a specific kernel release and target
+ architecture. This option specifies the target architecture to be associated
+ with subsequent -r options. The default architecture is the architecture of
+ the host.
+
+2.3.3 -r kernel-release
+ This option specifies a server for the given kernel release and the current
+ target architecture (specified by a previous -a option, or the default). The
+ arguments accepted by this option are the same as for stap itself. See stap(1)
+ for more details.
+
+2.3.4 -i
+ This option is a shortcut which specifies one server for each kernel
+ release installed in /lib/modules/. The default architecture is associated
+ with these servers (i.e. previous -a has no effect).
-2.3.1 -c config_path
- You can specify configuration path of this initscript.
+3. Files
+========
+3.1 stap-server
+---------------
+/etc/init.d/stap-server
-2.3.2 script(s)
- You can specify individual scripts to the commands. If you omit to specify
- any script, systemtap initscript will execute the command with all scripts
- in the script directory(except 'start' and 'stop' command, see 2.2.1 and
- 2.2.2).
+This is the stap-server initscript.
-2.3.3 -R
- If this option is specified, systemtap initscript will try to solve
- dependency of specified script(s). This option is always set if you don't
- specify any script(s) from command line.
+3.2 Configuration files
+-----------------------
+Configuration files are written in bash script.
-2.3.4 -r kernelrelease
- You can specify release version of the kernel(e.g. 2.6.26.1). This option
- is valid only with compile and cleanup commands.
+3.2.1 Global config file
+ /etc/sysconfig/stap-server
-2.3.5 -y
- Answer yes for all questions.
+ This config file is for global configuration (see section 4.1).
-2.4 Misc
-2.4.1 Service Priority
- Each initscript has execution priority. Since user would like to trace
- other services by using systemtap, systemtap initscript should have the
- highest priority.
+3.2.2 Server config files
+ /etc/stap-server/conf.d/*.conf
-3. Files
-========
-3.1 initscript
- /etc/init.d/systemtap
+ The config files under this directory are for each server to be started by
+ default (see section see 4.2).
- This file is an executable bash script.
+3.3 Message Log
+---------------
+/var/log/stap-server.log
-3.2 Configurations
- Configuration files are written in bash script.
+All messages including server errors and detailed messages are sent
+to this file.
+Some error and warning messages are also sent to console and syslogd (syslog
+output is optional, because this service may start before syslog).
-3.2.1 Global config file
- /etc/systemtap/config
+3.4 Status files
+----------------
+/var/run/stap-server/<server_spec>
- This config file is for global parameters(see 4.1).
+4. Configuration Format
+=======================
+Configuration files allows us to
+ - specify global configuration of logging, server configuration files, status
+ files and other global parameters.
+ - specify which servers are to be started by default.
+
+4.1 Global Configuration file (/etc/sysconfig/stap-server)
+----------------------------------------------------------
+The global configuration file may contain settings for the following
+variables.
+
+4.1.1 CONFIG_PATH
+ Specify the absolute path of the directory containing the default server
+ configurations.
+ (default: /etc/stap-server/conf.d)
+
+4.1.2 STAT_PATH
+ Specify the absolute path of the running server status directory.
+ (default: /var/run/stap-server)
+
+4.1.3 LOG_FILE
+ Specify the absolute path of the log file
+ (default: /var/log/stap-server.log)
-3.2.2 Script config files
- /etc/systemtap/conf.d/*.conf
+4.1.4 STAP_USER
+ Specify the userid which will be used to run the server(s).
+ (default: stap-server)
- The config files under this directory are for each scripts or script groups
- (see 4.2).
+4.2 Individual server configuration (/etc/stap-server/conf.d/*.conf)
+--------------------------------------------------------------------
+Each server configuration file configures a server to be started when no
+server is specified for the 'start' action.
-3.3 Script directory
- /etc/systemtap/script.d/
+4.2.1 ARCH
+ Specify the target architecture for this server. If ARCH is not set, the
+ architecture of the host will be used.
- Systemtap initscript finds systemtap scripts from this directory.
+4.2.2 RELEASE
+ Specify the kernel release for this server. If RELEASE is not set, the release
+ of the kernel running on the host will be used.
+
+4.3 Configuration Example
+-------------------------
+
+4.3.1 Global Config Example (/etc/sysconfig/stap-server)
+ ---
+ CONFIG_PATH=~<user>/my-stap-server-configs
+ LOG_FILE=/tmp/stap-server.log
+ ---
+
+4.3.2 Server Config Examples (/etc/stap-server/conf.d/*.conf)
+ --- file1.conf
+ ARCH=i386
+ RELEASE=2.6.18-128.el5
+ --- file2.conf
+ ARCH=powerpc
+ RELEASE=/kernels/2.6.18-92.1.18.el5/build
+ ---
+
+5. Usage Eamples
+================
-3.3.1 Scripts in the directory
- /etc/systemtap/script.d/<script-name>.stp
+5.1 Package Installation
+------------------------
+After installing the systemtap package, install the systemtap-server package.
+# yum install systemtap-server
+This package will include the initscript, default configuration files and
+other files.
- Systemtap scripts stored in the script directory must have ".stp" suffix.
+5.2 Testing
+-----------
+See if the default service operates correctly.
+ # service stap-server start
+ # service stap-server status
+ # service stap-server restart
+ # service stap-server status
+ # service stap-server condrestart
+ # service stap-server status
+ # service stap-server force-relooad
+ # service stap-server status
+ # service stap-server stop
+ # service stap-server status
+ # service stap-server condrestart
+ # service stap-server status # <---no server should be running
-3.4 Cache directory
- /var/cache/systemtap/<kernel-version>/
+If there are no errors, the service is correctly installed.
- Systemtap initscript stores compiled scripts in this directory.
+5.3 Service Enabling
+--------------------
+After all test have passed, enable the stap-server initscript.
+# chkconfig stap-server on
-3.4.1 Compiled scripts (or script caches)
- /var/cache/systemtap/<kernel-version>/<script-name>.ko
- /var/cache/systemtap/<kernel-version>/<script-name>.opts
+5.4 Starting Specific Servers
+-----------------------------
+5.4.1 Starting a server for an installed kernel release
- *.ko file is the compiled script, and *.opts is the file which stores
- stap options and uname -a.
+ # service stap-server start -r <release>
+
+ where <release> refers to a kernel installed in /lib/modules
-3.5 Message Log
- /var/log/systemtap.log
+5.4.2 Starting servers for all installed kernel releases
- All messages including compilation errors and detailed messages are sent
- to this file.
- Some error and warning messages are also sent to console and syslogd (syslog
- output is optional, because this service will start before syslog).
+ # service stap-server start -i
-3.7 Status files
- /var/run/systemtap/<script-name>
+5.4.3 Starting a server for a kernel release not installed (cross compiling)
+ # service stap-server start -a <arch> -r /<builddir>
+
+ where <arch> is the target architecture and
+ <buildder> is the absolute path to the kernel's build tree.
-4. Configuration Format
-=======================
-Configuration file allows us
-- specifying options for each script
-- supporting flight recorder mode (on file or memory)
+5.5 Managing Specific Servers
+-----------------------------
+Specifying an architecture and/or release for all other actions will act on
+that server alone (if it is running). For example
-4.1 Global Parameters
+ # service stap-server status -r 2.6.18-128.el5
+ # service stap-server restart -a i386 -r 2.6.18-92.1.18.el5
+ # service stap-server stop -a powerpc -r /kernels/2.6.18-92.1.18.el5/build
-4.1.1 SCRIPT_PATH
- Specify the absolute path of the script directory.
- (default: /etc/systemtap/script.d)
+5.6 Configuring Default Servers
+-------------------------------
+5.6.1 Create Server Config Files
+ Each file in /etc/stap-server/conf.d/*.conf represents a server to be started
+ by default if no servers are specifued on the 'start' action. Each such
+ config file may set the ARCH and/or RELEASE variables which correspond to the
+ -a and -r command line options respectively.
-4.1.2 CONFIG_PATH
- Specify the absolute path of the script config directory.
- (default: /etc/systemtap/conf.d)
+ # vi /etc/stap-server/conf.d/2.6.18-128.el5.conf
+ ARCH= # default arch
+ RELEASE=2.6.18-128.el5
-4.1.3 CACHE_PATH
- Specify the absolute path of the parent directory of the cache directory.
- (default: /var/cache/systemtap)
+ # vi /etc/stap-server/conf.d/powerpc.conf
+ ARCH=powerpc
+ RELEASE= #default release
-4.1.4 TEMP_PATH
- Specify the absolute path of the temporary directory on which systemtap
- initscript make temporary directories to compile scripts.
- (default: /tmp)
+ # vi /etc/stap-server/conf.d/native.conf
+ ARCH= #default arch
+ RELEASE= #default release
-4.1.5 STAT_PATH
- Specify the absolute path of the running status directory.
- (default: /var/run/systemtap)
+5.6.2 Starting Default Servers
-4.1.6 LOG_FILE
- Specify the absolute path of the log file
- (default: /var/log/systemtap.log)
-
-4.1.7 PASSALL
- If this is set 'yes', systemtap initscript will fail when it fails
- to run one of the scripts. If not, systemtap initscript will not
- fail(just warn).
- (default: yes)
-
-4.1.8 RECURSIVE
- If this is set 'yes', systemtap initscript will always follow script
- dependencies. This means, you don't need to specify '-R' option. This flag is
- effective only if you specify script(s) from command line.
- (default: no)
-
-4.1.9 AUTOCOMPILE
- If this is set 'yes', systemtap initscript automatically tries to compile
- specified script if there is no valid cache. Otherwides, it just fails to
- run script(s).
- (default: yes)
-
-4.1.10 DEFAULT_START
- Specify scripts which will be started by default. If omitted (or empty),
- all scripts in the script directory will be started.
- (default: "")
-
-4.1.11 ALLOW_CACHEONLY
- If this is set 'yes', systemtap initscript list up cache-only scripts too.
- *NOTE*: systemtap initscript will load unexpected obsolate caches with this
- option. You should check cache directory before enabling this option.
- (default: no)
-
-4.2 Script Parameters
-
-4.2.1 <script-name>_OPT
- Specify options passed to stap command for each script. "script-name" is the
- name of the script file without the suffix extension(.stp).
- Some options are just ignored. And even if you don't specify -F option,
- systemtap initscript always add it for flight recorder mode.
- - Below options are ignored when compiling script.
- -p,-m,-r,-c,-x,-e,-s,-o,-h,-V,-k
- - Below options are ignored when starting script.
- -h,-V,-v,-t,-p,-I,-e,-R,-r,-m,-k,-g,-P,-D,-b,-u,-q,-w,-l,-d,-L,-F, and
- other long options.
-
-4.2.2 <script-name>_REQ
- Specify script dependency(which script this script requires).
- For example, "foo.stp" script requires(or run after) "bar.stp" script, set
-
- foo_REQ="bar"
-
- If the script requires many scripts, set all scripts separated by spaces.
-
- foo_REQ="bar baz"
+ # service stap-server start
-4.3 Configuration Example
+5.6.2 Restarting After Changing the Configuration
-4.3.1 Global Config Example
----
-SCRIPT_PATH=/var/systemtap/script.d/
-PASSALL=yes
-RECURSIVE=no
----
+ To restart the service after global configuration changes and/or when default
+ servcers have been added to removed:
-4.3.2 Script Config Example
----
-script1_OPT="-o /var/log/script1.out -DRELAYHOST=group1"
-script2_OPT="-DRELAYGUEST=group1"
-script2_REQ=script1
----
+ # service stap-server force-reload
-5. How to use
-=============
+5.7 Stopping the stap-server Service
+------------------------------------
-5.1 Package Installation
- After installing systemtap package, install systemtap-initscript package.
- # yum install systemtap-initscript
- This package will include initscript and default configuration file and
- other files.
-
-5.2 Script installation
-5.2.1 Installing script files
- Copy a systemtap script ("script1.stp") into script directory.
- # cp script1.stp /etc/systemtap/script.d/
-
-5.2.2 Configuration script options
- Add configuration file to specify options.
- # vi /etc/systemtap/conf.d/group1
- script1_OPT="-o /var/log/group1.log -DRELAYHOST=group1"
-
-5.2.3 Installing script file with dependency
- For example, a script("script2.stp") which shares buffer with another
- script("script1.stp"), there is a dependency. In this case, you just do
- as following.
-
- # cp script2.stp /etc/systemtap/script.d/
- # vi /etc/systemtap/conf.d/group1
- script2_OPT="-DRELAYGUEST=group1"
- script2_REQ=script1
-
- In this case, if stap fails to run script1.stp, systemtap initscript will
- not run script2.stp.
-
-5.3 Testing
- After installing all scripts, please make sure to run service successfully.
- # service systemtap start
- # service systemtap stop
- If there is no error, we are ready to use it.
-
-5.4 Service Enabling
- After all test passed, enable systemtap initscript.
- # chkconfig systemtap on
-
-5.5 Adding script
-5.5.1 Installing and configuring new scripts
- Copy new systemtap script("script3.stp") into script directory.
- # cp script3.stp /etc/systemtap/script.d/
- and configure it.
- # vi /etc/systemtap/conf.d/group1
- script3_OPT="-DRELAYGUEST=group1"
- script3_REQ="script1"
-
-5.5.2 Start new script
- If you've already started systemtap initscript, just start new script.
- # service systemtap start script3
-
-5.6 Deleting script
-5.6.1 Deleting old script
- Remove old script ("script2.stp") and remove configure lines
- # rm /etc/systemtap/script.d/script2.stp
- # vi /etc/systemtap/conf.d/group1
- (delete script2_OPT and script2_REQ)
-
-5.6.2 Stopping old script and cleanup
- Stop old script.
- # service systemtap stop script2
- And cleanup the script caches.
- # service systemtap cleanup script2
-
-5.7 Updating kernel
- Usually, you don't need to do anything. Systemtap initscript checks the
- kernel version when starting the service, and compile scripts.
- (If you would like to use compiled scripts due to lack of compiler or
- debuginfo on the system, see 5.8)
- However, if you want to avoid compiling when booting system, you can prepare
- script caches for new kernel.
- # service systemtap compile -r <new kernel version>
-
-5.8 Using with compiled scripts
- Sometimes, production systems don't have any compilation environment. Even
- though, you can use systemtap initscript with compiled scripts as script
- caches, which are compiled on other machine (but same software environment).
-
-5.8.1 Preparing compiled scripts
- As described in 5.2, installing scripts and configure it on the compiling
- machine (which has compilation environment).
- After that, compile those scripts.
- # service systemtap compile -r <kernel-version>
- And package the compiled scripts and configuration file.
- # tar czf stap-scripts-<kernel-version>.tar.gz \
- /var/cache/systemtap/<kernel-version> /etc/systemtap/conf.d/<config>
- And copy this package to the target machine.
-
-5.8.2 Installing pre-compiled scripts
- On the target machine, unpackage the compiled scripts into cache
- directory.
- # tar xzf stap-scripts-<kernel-version>.tar.gz -C /var/cache/systemtap/
- # mv /var/cache/systemtap/<config> /etc/systemtap/conf.d/
- At last, set AUTOCOMPILE=no and ALLOW_CACHEONLY=yes in config file.
- # vi /etc/systemtap/config
- AUTOCOMPILE=no
- ALLOW_CACHEONLY=yes
+ To stop all running servers:
+
+ # service stap-server stop
diff --git a/initscript/config.stap-server b/initscript/config.stap-server
index baadbf28..ad0c9c4d 100644
--- a/initscript/config.stap-server
+++ b/initscript/config.stap-server
@@ -1,6 +1,5 @@
# Path setup
# CONFIG_PATH=/etc/stap-server/conf.d
# STAT_PATH=/var/run/stap-server
-# TEMP_PATH=/tmp
# LOG_FILE=/var/log/stap-server.log
-# STAP_USER=stap-server \ No newline at end of file
+# STAP_USER=stap-server
diff --git a/initscript/stap-server.in b/initscript/stap-server.in
index 4c666c83..f00110b0 100644
--- a/initscript/stap-server.in
+++ b/initscript/stap-server.in
@@ -27,7 +27,6 @@ UNAME=/bin/uname
CONFIG_FILE=/etc/sysconfig/stap-server
CONFIG_PATH=/etc/stap-server/conf.d
STAT_PATH=/var/run/stap-server
-TEMP_PATH=/tmp
LOG_FILE=/var/log/stap-server.log
# Default Settings
diff --git a/stap-gen-cert b/stap-gen-cert
index 574df351..54195187 100755
--- a/stap-gen-cert
+++ b/stap-gen-cert
@@ -93,3 +93,6 @@ rm -fr $serverdb/stap.req
# Add the certificate to the server's certificate/key database as a trusted peer, ssl server and object signer
certutil -A -n stap-server -t "PCu,,PCu" -i $serverdb/$stap_certfile -d $serverdb -f $serverdb/pw
+
+echo "Certificate $serverdb/$stap_certfile created and added to database $serverdb"
+exit 0
diff --git a/stap-server-connect.c b/stap-server-connect.c
index cbbc97d1..c4d8da88 100644
--- a/stap-server-connect.c
+++ b/stap-server-connect.c
@@ -410,6 +410,9 @@ handle_connection(PRFileDesc *tcpSocket)
goto cleanup;
}
+ /* Log the accepted connection. */
+ printf ("Accepted connection!\n");
+
/* Create a temporary files and directories. */
memcpy (requestFileName + sizeof (requestFileName) - 1 - 6, "XXXXXX", 6);
rc = mkstemp(requestFileName);
@@ -609,8 +612,8 @@ server_main(unsigned short port, SECKEYPrivateKey *privKey, CERTCertificate *cer
/* Configure the network connection. */
addr.inet.family = PR_AF_INET;
- addr.inet.ip = PR_INADDR_ANY;
- addr.inet.port = PR_htons(port);
+ addr.inet.ip = PR_INADDR_ANY;
+ addr.inet.port = PR_htons(port);
/* Bind the address to the listener socket. */
prStatus = PR_Bind(listenSocket, &addr);
@@ -744,7 +747,7 @@ main(int argc, char **argv)
/* Set the cert database password callback. */
PK11_SetPasswordFunc(myPasswd);
- /* Initialize NSS. */
+ /* Initialize NSS. */
secStatus = NSS_Init(dbdir);
if (secStatus != SECSuccess)
exitErr("NSS_Init");