initial import (Boeing r1752, NRL r878)
This commit is contained in:
commit
f8f46d28be
394 changed files with 99738 additions and 0 deletions
61
scripts/Makefile.am
Executable file
61
scripts/Makefile.am
Executable file
|
@ -0,0 +1,61 @@
|
|||
# CORE
|
||||
# (c)2011-2013 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
# Makefile for installing scripts.
|
||||
#
|
||||
|
||||
DISTCLEANFILES = Makefile.in xen/Makefile xen/Makefile.in
|
||||
|
||||
EXTRA_DIST = core-daemon-init.d \
|
||||
core-daemon.service \
|
||||
core-daemon-rc.d \
|
||||
core-daemon-init.d-SUSE \
|
||||
xen
|
||||
|
||||
SUBDIRS = perf
|
||||
|
||||
# clean up dirs included by EXTRA_DIST
|
||||
dist-hook:
|
||||
rm -rf $(distdir)/xen/.svn
|
||||
|
||||
|
||||
# install startup scripts based on --with-startup=option configure option
|
||||
# FreeBSD, init.d (default), systemd, SUSE
|
||||
if WANT_BSD
|
||||
install-exec-hook:
|
||||
test -d "$(DESTDIR)/usr/local/etc/rc.d" || \
|
||||
mkdir -p $(DESTDIR)/usr/local/etc/rc.d
|
||||
test -d "$(DESTDIR)/usr/local/etc/rc.d" && \
|
||||
cp -f core-daemon-rc.d $(DESTDIR)/usr/local/etc/rc.d/core-daemon
|
||||
else
|
||||
|
||||
if WANT_INITD
|
||||
install-exec-hook:
|
||||
test -d "$(DESTDIR)/etc/init.d" || \
|
||||
mkdir -p $(DESTDIR)/etc/init.d
|
||||
test -d "$(DESTDIR)/etc/init.d" && \
|
||||
cp -f core-daemon-init.d $(DESTDIR)/etc/init.d/core-daemon
|
||||
endif
|
||||
if WANT_SYSTEMD
|
||||
install-exec-hook:
|
||||
test -d "$(DESTDIR)/etc/systemd/system" || \
|
||||
mkdir -p $(DESTDIR)/etc/systemd/system
|
||||
test -d "$(DESTDIR)/etc/systemd/system" && \
|
||||
cp -f core-daemon.service $(DESTDIR)/etc/systemd/system/
|
||||
endif
|
||||
if WANT_SUSE
|
||||
install-exec-hook:
|
||||
test -d "$(DESTDIR)/etc/init.d" || \
|
||||
mkdir -p $(DESTDIR)/etc/init.d
|
||||
test -d "$(DESTDIR)/etc/init.d" && \
|
||||
cp -f core-daemon-init.d-SUSE $(DESTDIR)/etc/init.d/core-daemon
|
||||
endif
|
||||
# endif FreeBSD
|
||||
endif
|
||||
|
||||
# remove extra scripts and their directories if they are empty
|
||||
uninstall-hook:
|
||||
rm -f /etc/init.d/core-daemon /usr/local/etc/rc.d/core-daemon
|
142
scripts/core-daemon-init.d
Executable file
142
scripts/core-daemon-init.d
Executable file
|
@ -0,0 +1,142 @@
|
|||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: core-daemon
|
||||
# Required-Start: $network $remote_fs
|
||||
# Required-Stop: $network $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start the core-daemon CORE daemon at boot time
|
||||
# Description: Starts and stops the core-daemon CORE daemon used to
|
||||
# provide network emulation services for the CORE GUI
|
||||
# or scripts.
|
||||
### END INIT INFO
|
||||
#
|
||||
# chkconfig: 35 90 03
|
||||
# description: Starts and stops the CORE daemon \
|
||||
# used to provide network emulation services.
|
||||
#
|
||||
# pidfile: /var/run/core-daemon.pid
|
||||
# config: /usr/local/etc/core/
|
||||
|
||||
DEB=no
|
||||
# Source function library.
|
||||
if [ -f /etc/init.d/functions ] ; then
|
||||
. /etc/init.d/functions
|
||||
elif [ -f /etc/rc.d/init.d/functions ] ; then
|
||||
. /etc/rc.d/init.d/functions
|
||||
elif [ -f /lib/lsb/init-functions ] ; then
|
||||
. /lib/lsb/init-functions
|
||||
DEB=yes
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# search for core-daemon which may or may not be installed
|
||||
cored=
|
||||
for p in /usr/local/sbin \
|
||||
/usr/sbin \
|
||||
/sbin \
|
||||
/usr/local/bin \
|
||||
/usr/bin \
|
||||
/bin
|
||||
do
|
||||
if [ -e $p/core-daemon ] ; then
|
||||
cored=$p/core-daemon
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# this function comes from /etc/profile
|
||||
pathmunge () {
|
||||
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
|
||||
if [ "$2" = "after" ] ; then
|
||||
PATH=$PATH:$1
|
||||
else
|
||||
PATH=$1:$PATH
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# these lines add to the PATH variable used by CORE and its containers
|
||||
# you can add your own pathmunge statements to change the container's PATH
|
||||
pathmunge "/usr/local/sbin"
|
||||
pathmunge "/usr/local/bin"
|
||||
|
||||
RETVAL=0
|
||||
PIDFILE=/var/run/core-daemon.pid
|
||||
|
||||
# the /etc/init.d/functions (RedHat) differs from
|
||||
# /usr/lib/init-functions (Debian)
|
||||
if [ $DEB = yes ]; then
|
||||
daemon="start-stop-daemon --start -p ${PIDFILE} --exec /usr/bin/python --"
|
||||
#daemon=start_daemon
|
||||
status=status_of_proc
|
||||
msg () {
|
||||
log_daemon_msg "$@"
|
||||
}
|
||||
endmsg () {
|
||||
echo -n ""
|
||||
}
|
||||
else
|
||||
daemon="daemon /usr/bin/python"
|
||||
status=status
|
||||
msg () {
|
||||
echo -n $"$@"
|
||||
}
|
||||
endmsg () {
|
||||
echo ""
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
start() {
|
||||
msg "Starting core-daemon"
|
||||
$daemon $cored -d
|
||||
RETVAL=$?
|
||||
endmsg
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
msg "Shutting down core-daemon"
|
||||
killproc -p ${PIDFILE} $cored
|
||||
RETVAL=$?
|
||||
rm -f ${PIDFILE}
|
||||
endmsg
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
corestatus() {
|
||||
$status -p ${PIDFILE} core-daemon core-daemon
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
force-reload)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
corestatus
|
||||
;;
|
||||
*)
|
||||
msg "Usage: $0 {start|stop|restart|status}"
|
||||
endmsg
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit $?
|
264
scripts/core-daemon-init.d-SUSE
Executable file
264
scripts/core-daemon-init.d-SUSE
Executable file
|
@ -0,0 +1,264 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Template SUSE system startup script for example service/daemon core
|
||||
# Copyright (C) 1995--2005 Kurt Garloff, SUSE / Novell Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
|
||||
# USA.
|
||||
#
|
||||
# /etc/init.d/FOO
|
||||
# and its symbolic link
|
||||
# /(usr/)sbin/rcFOO
|
||||
#
|
||||
# Template system startup script for some example service/daemon FOO
|
||||
#
|
||||
# LSB compatible service control script; see http://www.linuxbase.org/spec/
|
||||
#
|
||||
# Note: This template uses functions rc_XXX defined in /etc/rc.status on
|
||||
# UnitedLinux/SUSE/Novell based Linux distributions. If you want to base your
|
||||
# script on this template and ensure that it works on non UL based LSB
|
||||
# compliant Linux distributions, you either have to provide the rc.status
|
||||
# functions from UL or change the script to work without them.
|
||||
# See skeleton.compat for a template that works with other distros as well.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: core-daemon
|
||||
# Required-Start: $network $remote_fs xend
|
||||
# Required-Stop: $network $remote_fs xend
|
||||
# Default-Start: 3 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: core-daemon
|
||||
# Description: Start core-daemon
|
||||
# continued on second line by '#<TAB>'
|
||||
# should contain enough info for the runlevel editor
|
||||
# to give admin some idea what this service does and
|
||||
# what it's needed for ...
|
||||
# (The Short-Description should already be a good hint.)
|
||||
### END INIT INFO
|
||||
#
|
||||
# Any extensions to the keywords given above should be preceeded by
|
||||
# X-VendorTag- (X-UnitedLinux- X-SuSE- for us) according to LSB.
|
||||
#
|
||||
# Notes on Required-Start/Should-Start:
|
||||
# * There are two different issues that are solved by Required-Start
|
||||
# and Should-Start
|
||||
# (a) Hard dependencies: This is used by the runlevel editor to determine
|
||||
# which services absolutely need to be started to make the start of
|
||||
# this service make sense. Example: nfsserver should have
|
||||
# Required-Start: $portmap
|
||||
# Also, required services are started before the dependent ones.
|
||||
# The runlevel editor will warn about such missing hard dependencies
|
||||
# and suggest enabling. During system startup, you may expect an error,
|
||||
# if the dependency is not fulfilled.
|
||||
# (b) Specifying the init script ordering, not real (hard) dependencies.
|
||||
# This is needed by insserv to determine which service should be
|
||||
# started first (and at a later stage what services can be started
|
||||
# in parallel). The tag Should-Start: is used for this.
|
||||
# It tells, that if a service is available, it should be started
|
||||
# before. If not, never mind.
|
||||
# * When specifying hard dependencies or ordering requirements, you can
|
||||
# use names of services (contents of their Provides: section)
|
||||
# or pseudo names starting with a $. The following ones are available
|
||||
# according to LSB (1.1):
|
||||
# $local_fs all local file systems are mounted
|
||||
# (most services should need this!)
|
||||
# $remote_fs all remote file systems are mounted
|
||||
# (note that /usr may be remote, so
|
||||
# many services should Require this!)
|
||||
# $syslog system logging facility up
|
||||
# $network low level networking (eth card, ...)
|
||||
# $named hostname resolution available
|
||||
# $netdaemons all network daemons are running
|
||||
# The $netdaemons pseudo service has been removed in LSB 1.2.
|
||||
# For now, we still offer it for backward compatibility.
|
||||
# These are new (LSB 1.2):
|
||||
# $time the system time has been set correctly
|
||||
# $portmap SunRPC portmapping service available
|
||||
# UnitedLinux extensions:
|
||||
# $ALL indicates that a script should be inserted
|
||||
# at the end
|
||||
# * The services specified in the stop tags
|
||||
# (Required-Stop/Should-Stop)
|
||||
# specify which services need to be still running when this service
|
||||
# is shut down. Often the entries there are just copies or a subset
|
||||
# from the respective start tag.
|
||||
# * Should-Start/Stop are now part of LSB as of 2.0,
|
||||
# formerly SUSE/Unitedlinux used X-UnitedLinux-Should-Start/-Stop.
|
||||
# insserv does support both variants.
|
||||
# * X-UnitedLinux-Default-Enabled: yes/no is used at installation time
|
||||
# (%fillup_and_insserv macro in %post of many RPMs) to specify whether
|
||||
# a startup script should default to be enabled after installation.
|
||||
# It's not used by insserv.
|
||||
#
|
||||
# Note on runlevels:
|
||||
# 0 - halt/poweroff 6 - reboot
|
||||
# 1 - single user 2 - multiuser without network exported
|
||||
# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
|
||||
#
|
||||
# Note on script names:
|
||||
# http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/scrptnames.html
|
||||
# A registry has been set up to manage the init script namespace.
|
||||
# http://www.lanana.org/
|
||||
# Please use the names already registered or register one or use a
|
||||
# vendor prefix.
|
||||
|
||||
|
||||
# Check for missing binaries (stale symlinks should not happen)
|
||||
# Note: Special treatment of stop for LSB conformance
|
||||
CORE_BIN=/usr/local/sbin/core-daemon
|
||||
test -x $CORE_BIN || { echo "$CORE_BIN not installed";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 5; fi; }
|
||||
|
||||
# Check for existence of needed config file and read it
|
||||
CORE_CONFIG=/etc/core
|
||||
test -r $CORE_CONFIG || { echo "$CORE_CONFIG not existing";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 6; fi; }
|
||||
|
||||
# Source LSB init functions
|
||||
# providing start_daemon, killproc, pidofproc,
|
||||
# log_success_msg, log_failure_msg and log_warning_msg.
|
||||
# This is currently not used by UnitedLinux based distributions and
|
||||
# not needed for init scripts for UnitedLinux only. If it is used,
|
||||
# the functions from rc.status should not be sourced or used.
|
||||
#. /lib/lsb/init-functions
|
||||
|
||||
# Shell functions sourced from /etc/rc.status:
|
||||
# rc_check check and set local and overall rc status
|
||||
# rc_status check and set local and overall rc status
|
||||
# rc_status -v be verbose in local rc status and clear it afterwards
|
||||
# rc_status -v -r ditto and clear both the local and overall rc status
|
||||
# rc_status -s display "skipped" and exit with status 3
|
||||
# rc_status -u display "unused" and exit with status 3
|
||||
# rc_failed set local and overall rc status to failed
|
||||
# rc_failed <num> set local and overall rc status to <num>
|
||||
# rc_reset clear both the local and overall rc status
|
||||
# rc_exit exit appropriate to overall rc status
|
||||
# rc_active checks whether a service is activated by symlinks
|
||||
. /etc/rc.status
|
||||
|
||||
# Reset status of this service
|
||||
rc_reset
|
||||
|
||||
# Return values acc. to LSB for all commands but status:
|
||||
# 0 - success
|
||||
# 1 - generic or unspecified error
|
||||
# 2 - invalid or excess argument(s)
|
||||
# 3 - unimplemented feature (e.g. "reload")
|
||||
# 4 - user had insufficient privileges
|
||||
# 5 - program is not installed
|
||||
# 6 - program is not configured
|
||||
# 7 - program is not running
|
||||
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
|
||||
#
|
||||
# Note that starting an already running service, stopping
|
||||
# or restarting a not-running service as well as the restart
|
||||
# with force-reload (in case signaling is not supported) are
|
||||
# considered a success.
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting CORE "
|
||||
## Start daemon with startproc(8). If this fails
|
||||
## the return value is set appropriately by startproc.
|
||||
/sbin/startproc $CORE_BIN -d
|
||||
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down CORE "
|
||||
## Stop daemon with killproc(8) and if this fails
|
||||
## killproc sets the return value according to LSB.
|
||||
|
||||
if [ -r /var/run/core-daemon.pid ] ; then
|
||||
/bin/kill -TERM `cat /var/run/core-daemon.pid`
|
||||
/bin/rm -f /var/run/core-daemon.pid
|
||||
fi
|
||||
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
## Do a restart only if the service was active before.
|
||||
## Note: try-restart is now part of LSB (as of 1.9).
|
||||
## RH has a similar command named condrestart.
|
||||
if test "$1" = "condrestart"; then
|
||||
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
|
||||
fi
|
||||
$0 status
|
||||
if test $? = 0; then
|
||||
$0 restart
|
||||
else
|
||||
rc_reset # Not running is not a failure.
|
||||
fi
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
restart)
|
||||
## Stop the service and regardless of whether it was
|
||||
## running or not, start it again.
|
||||
$0 stop
|
||||
$0 start
|
||||
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
force-reload)
|
||||
## Signal the daemon to reload its config. Most daemons
|
||||
## do this on signal 1 (SIGHUP).
|
||||
## If it does not support it, restart the service if it
|
||||
## is running.
|
||||
|
||||
echo -n "Reload service CORE "
|
||||
$0 try-restart
|
||||
rc_status
|
||||
;;
|
||||
|
||||
reload)
|
||||
## Like force-reload, but if daemon does not support
|
||||
## signaling, do nothing (!)
|
||||
|
||||
## It does not support reload:
|
||||
rc_failed 3
|
||||
rc_status -v
|
||||
;;
|
||||
|
||||
status)
|
||||
echo -n "Checking for service CORE "
|
||||
## Check status with checkproc(8), if process is running
|
||||
## checkproc will return with exit status 0.
|
||||
|
||||
# Return value is slightly different for the status command:
|
||||
# 0 - service up and running
|
||||
# 1 - service dead, but /var/run/ pid file exists
|
||||
# 2 - service dead, but /var/lock/ lock file exists
|
||||
# 3 - service not running (unused)
|
||||
# 4 - service status unknown :-(
|
||||
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
|
||||
|
||||
# NOTE: checkproc returns LSB compliant status values.
|
||||
/sbin/checkproc -p /var/run/core-daemon.pid python
|
||||
# NOTE: rc_status knows that we called this init script with
|
||||
# "status" option and adapts its messages accordingly.
|
||||
rc_status -v
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
rc_exit
|
50
scripts/core-daemon-rc.d
Executable file
50
scripts/core-daemon-rc.d
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
|
||||
# PROVIDE: core
|
||||
# REQUIRE: NETWORKING
|
||||
|
||||
# To enable CORE services on startup, add the following line to /etc/rc.conf:
|
||||
# core_enable="YES"
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="core"
|
||||
rcvar=`set_rcvar`
|
||||
|
||||
stop_postcmd=stop_postcmd
|
||||
|
||||
stop_postcmd()
|
||||
{
|
||||
rm -f $pidfile
|
||||
}
|
||||
|
||||
# defaults
|
||||
load_rc_config $name
|
||||
: ${core_enable="NO"}
|
||||
: ${core_flags="-d"}
|
||||
: ${core_daemons="core-daemon"}
|
||||
|
||||
core_cmd=$1
|
||||
|
||||
case "${core_cmd}" in
|
||||
start)
|
||||
;;
|
||||
stop|restart)
|
||||
core_daemons=$(reverse_list ${core_daemons})
|
||||
;;
|
||||
esac
|
||||
|
||||
for daemon in ${core_daemons}; do
|
||||
command=/usr/local/sbin/${daemon}
|
||||
pidname=`echo ${daemon} | sed 's/\.//g'`
|
||||
pidfile=/var/run/${pidname}.pid
|
||||
command_interpreter=python
|
||||
if [ "${daemon}" = "core-daemon" ]; then
|
||||
command_interpreter=python
|
||||
fi
|
||||
run_rc_command "$1"
|
||||
_rc_restart_done=false
|
||||
done
|
||||
|
11
scripts/core-daemon.service
Normal file
11
scripts/core-daemon.service
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Common Open Research Emulator Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/var/run/core-daemon.pid
|
||||
ExecStart=/usr/bin/python /usr/sbin/core-daemon -d
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
22
scripts/perf/Makefile.am
Executable file
22
scripts/perf/Makefile.am
Executable file
|
@ -0,0 +1,22 @@
|
|||
# CORE
|
||||
# (c)2011-2012 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
# Makefile for installing performance monitoring scripts.
|
||||
#
|
||||
|
||||
DISTCLEANFILES = Makefile.in
|
||||
|
||||
|
||||
# Hook scripts installed to /usr[/local]/share/core/examples/hooks
|
||||
hooksdir=$(pkgdatadir)/examples/hooks
|
||||
dist_hooks_SCRIPTS = perflogstart.sh perflogstop.sh sessiondatacollect.sh \
|
||||
timesyncstop.sh timesyncstart.sh perflogserver.py \
|
||||
configuration_hook.sh datacollect_hook.sh
|
||||
|
||||
# Files installed to /etc/core/
|
||||
perfconfdir=$(sysconfdir)/core
|
||||
dist_perfconf_DATA = perflogserver.conf
|
||||
|
6
scripts/perf/configuration_hook.sh
Normal file
6
scripts/perf/configuration_hook.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
# experiment hook script; write commands here to execute on the host at the
|
||||
# specified state
|
||||
|
||||
sh /usr/local/share/core/examples/hooks/timesyncstop.sh
|
||||
sh /usr/local/share/core/examples/hooks/perflogstart.sh
|
7
scripts/perf/datacollect_hook.sh
Normal file
7
scripts/perf/datacollect_hook.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
# experiment hook script; write commands here to execute on the host at the
|
||||
# specified state
|
||||
|
||||
sh /usr/local/share/core/examples/hooks/perflogstop.sh
|
||||
sh /usr/local/share/core/examples/hooks/sessiondatacollect.sh
|
||||
sh /usr/local/share/core/examples/hooks/timesyncstart.sh
|
37
scripts/perf/perflogserver.conf
Normal file
37
scripts/perf/perflogserver.conf
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Configuration file for CORE performance logging to generate alarms
|
||||
#
|
||||
# The string lef of "=" is the key of the performance metric - do not change it
|
||||
|
||||
# raise alarm if 1-minute, 5-minute, 16-minute load average
|
||||
# rises above those values
|
||||
serverloadavg1 = 3.6
|
||||
serverloadavg5 = 3.7
|
||||
serverloadavg15 = 3.8
|
||||
|
||||
# raise alarm if the server used memory rises above this value
|
||||
serverusedmemory = 81.0
|
||||
|
||||
# raise alarm if the server used cpu time rises above this value
|
||||
serverusedcputime = 91.0
|
||||
|
||||
# raise alarm if any server processor used cpu time rises above this value
|
||||
processorusedcputime = 92.0
|
||||
|
||||
# raise alarm if any node throughput rises above this value
|
||||
nodethroughput = 21.0
|
||||
|
||||
# raise alarm if any node used memory rises above this value
|
||||
nodeusedmemory = 11.0
|
||||
|
||||
# raise alarm if any node total cpu time rises above this value
|
||||
nodetotalcpu = 91.0
|
||||
|
||||
# raise alarm if any node used cpu time rises above this value
|
||||
nodeusercpu = 41.0
|
||||
|
||||
# raise alarm if any node system cpu time rises above this value
|
||||
nodesystemcpu = 21.0
|
||||
|
||||
# raise alarm if any node wait cpu time rises above this value
|
||||
nodewaitcpu = 51.0
|
||||
|
588
scripts/perf/perflogserver.py
Executable file
588
scripts/perf/perflogserver.py
Executable file
|
@ -0,0 +1,588 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# (c)2011-2012 the Boeing Company
|
||||
#
|
||||
# perfmon.py - CORE server and node performace metrics logger and alarmer
|
||||
# server metrics: loadave1, 5, 15, mem, used cpu% of total, cpu1, cpu2, ..., cpun
|
||||
# node metrics: throughput, mem, cpu total, usr, sys, wait
|
||||
#
|
||||
import os, sys, time, re, optparse, signal, commands, pdb
|
||||
|
||||
def readfile(fname):
|
||||
lines=[]
|
||||
try:
|
||||
f = open(fname, "r")
|
||||
except:
|
||||
if options.timestamp == True:
|
||||
print str(time.time()),
|
||||
print "ERROR: failed to open file %s\n" % fname
|
||||
else :
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
return lines
|
||||
|
||||
def numcpus():
|
||||
lines = readfile("/proc/stat")
|
||||
n = 0
|
||||
for l in lines[1:]:
|
||||
if l[:3] != "cpu":
|
||||
break
|
||||
n += 1
|
||||
return n
|
||||
|
||||
def handler(signum, frame):
|
||||
print "stop timestamp:", str(time.time()) + ", cyclecount=", cyclecount, ", caught signal", signum
|
||||
sys.exit(0)
|
||||
|
||||
class ServerMetrics(object):
|
||||
def __init__(self):
|
||||
self.smetrics = { "serverloadavg1" : 0.0,
|
||||
"serverloadavg5" : 0.0,
|
||||
"serverloadavg15" : 0.0,
|
||||
"serverusedmemory" : 0.0,
|
||||
"serverusedcputime" : 0.0,
|
||||
"processorusedcputime" : [] }
|
||||
|
||||
# set values from val = (nump, ldavg1, ldavg5, adavg15, mem, cpu, p1cpu, p2cpu...)
|
||||
def setvalues(self, val):
|
||||
self.smetrics["serverloadavg1"] = val[0]
|
||||
self.smetrics["serverloadavg5"] = val[1]
|
||||
self.smetrics["serverloadavg15"] = val[2]
|
||||
self.smetrics["serverusedmemory"] = val[4]
|
||||
self.smetrics["serverusedcputime"] = val[5]
|
||||
#print self.smetrics.keys(), self.smetrics.values()
|
||||
|
||||
pcpu = []
|
||||
for ind in range(5,len(val)):
|
||||
pcpu.append(val[ind])
|
||||
# print "[" + ",".join(map(lambda(x):str(round(x, 2)), pcpu)) +"]"
|
||||
|
||||
self.smetrics["processorusedcputime"] = pcpu
|
||||
#print self.smetrics.keys(), self.smetrics.values()
|
||||
|
||||
def setvalue(self, key, val):
|
||||
self.smetrics[key] = val
|
||||
|
||||
def getvalue(self, key):
|
||||
return self.smetrics[key]
|
||||
|
||||
def getkeys(self):
|
||||
return self.smetrics.keys()
|
||||
|
||||
def tocsv(self):
|
||||
rv = "Server"
|
||||
for k in self.smetrics:
|
||||
# print k, self.smetrics[k]
|
||||
if isinstance(self.smetrics[k], float):
|
||||
rv += ", %.2f" % self.smetrics[k]
|
||||
else:
|
||||
if isinstance(self.smetrics[k], list):
|
||||
rv += ", [" + \
|
||||
", ".join(map(lambda(x):str(round(x, 2)), self.smetrics[k])) \
|
||||
+ "]"
|
||||
else:
|
||||
rv += ", " + str(self.smetrics[k])
|
||||
return rv
|
||||
|
||||
def readserverthresholds(filename):
|
||||
if filename is None:
|
||||
return
|
||||
|
||||
lines = readfile(filename)
|
||||
for l in lines:
|
||||
mval = l.strip().split('=')
|
||||
#print "read line %s" % mval
|
||||
if len(mval) > 1 :
|
||||
thekey = mval[0].strip()
|
||||
theval = mval[1].strip()
|
||||
if thekey in serverthresholds.getkeys():
|
||||
serverthresholds.setvalue(thekey, float(theval))
|
||||
# print thekey," = %.2f" % float(theval)
|
||||
|
||||
def checkserverthreshold(metricval):
|
||||
# print out an alarm if a ServerMetrics value crosses threshold
|
||||
for key in serverthresholds.getkeys():
|
||||
# print "checking threshold of key = ", key
|
||||
if key == "processorusedcputime":
|
||||
pcpus = metricval.getvalue(key)
|
||||
# print key, pcpus, serverthresholds[key]
|
||||
for ind in range(0, len(pcpus)):
|
||||
# print ind, pcpus[ind]
|
||||
if pcpus[ind] > serverthresholds.getvalue(key):
|
||||
alarm = ["server", os.uname()[1], str(ind) + key,
|
||||
"%.2f" % pcpus[ind], ">", serverthresholds.getvalue(key)]
|
||||
if options.timestamp:
|
||||
print str(time.time()) + ",",
|
||||
print ", ".join(map(lambda(x):str(x), alarm))
|
||||
else:
|
||||
if metricval.getvalue(key) > serverthresholds.getvalue(key):
|
||||
alarm = ["server", os.uname()[1], key,
|
||||
"%.2f" % metricval.getvalue(key), ">", serverthresholds.getvalue(key)]
|
||||
if options.timestamp:
|
||||
print str(time.time()) + ",",
|
||||
print ", ".join(map(lambda(x):str(x), alarm))
|
||||
|
||||
def collectservercputimes():
|
||||
# return cpu times in ticks of this server total and each processor 3*(1+#cpu) columns
|
||||
# (user+nice, sys, idle) from each /proc/stat cpu lines assume columns are:
|
||||
# cpu# user nice sys idle iowait irq softirq steal guest (man 5 proc)
|
||||
rval = {}
|
||||
lines = readfile("/proc/stat")
|
||||
for i in range(ncpus + 1):
|
||||
items = lines[i].split()
|
||||
(user, nice, sys, idle) = map(lambda(x): int(x), items[1:5])
|
||||
rval[i] = [user+nice, sys, idle]
|
||||
return rval
|
||||
|
||||
def csvservercputimes(cputimes):
|
||||
# return a csv string of this server total and each processor's cpu times
|
||||
# (usr, sys, idle) in ticks
|
||||
rval = ''
|
||||
for i in range(len(cputimes)):
|
||||
rval += ', '.join(map(lambda(x):str(x), cputimes[i]))
|
||||
return rval
|
||||
|
||||
def calcservercputimes(cputimea, cputimeb):
|
||||
# return cpu used/total % of this server total and each processor (1+#cpu columns)
|
||||
p = {}
|
||||
for n in range(ncpus + 1):
|
||||
# print cputimeb[n]
|
||||
p[n] = []
|
||||
for i in range(len(cputimea[n])):
|
||||
p[n].append(cputimeb[n][i] - cputimea[n][i])
|
||||
# print p[n]
|
||||
total = sum(p[n]) # cpu times total delta
|
||||
# print total
|
||||
if total == 0:
|
||||
p[n] = 0.0
|
||||
else:
|
||||
p[n] = 100 - ((100.0 * p[n][-1]) / total)
|
||||
return p
|
||||
|
||||
def collectservermems():
|
||||
# return memory (total, free) in KB from proc/meminfo
|
||||
lines = readfile("/proc/meminfo")
|
||||
mem = map(lambda(x):x.split(), lines[0:2])
|
||||
return map(lambda(x):int(x), zip(*mem)[1])
|
||||
|
||||
def csvservermems(mems):
|
||||
# return a csv string of this server memory (total, free)
|
||||
return ", ".join(map(lambda x: str(x), mems))
|
||||
|
||||
def calcserverusedmem(mems):
|
||||
# return int(100*(MemTotal-MemFree)/MemTotal) from /proc/meminfo
|
||||
return 100 * (mems[0] - mems[1]) / mems[0]
|
||||
|
||||
def collectservermetrics(cputimes, mems, thresholdcheck):
|
||||
# return ServerMetrics object with a dictionary of
|
||||
# loadavg1,loadavg5,loadavg15, usedmem%, usedcpu% for total, cpu1, cpu2, ...
|
||||
metricval = []
|
||||
ldavgs=os.getloadavg()
|
||||
for v in ldavgs:
|
||||
metricval.append(v)
|
||||
metricval.append(calcserverusedmem(mems))
|
||||
|
||||
for i in range(ncpus + 1):
|
||||
metricval.append(cputimes[i])
|
||||
# print cputimes[i]
|
||||
|
||||
srvmetrics = ServerMetrics()
|
||||
srvmetrics.setvalues(metricval)
|
||||
# print srvmetrics.tocsv()
|
||||
|
||||
if thresholdcheck:
|
||||
checkserverthreshold(srvmetrics)
|
||||
|
||||
return srvmetrics
|
||||
|
||||
def csvservermetrics(srvmetrics):
|
||||
# return a csv string of ServerMetrics.tocsv()
|
||||
# loadavg1,loadavg5,loadavg15, usedmem%, usedcpu% for total, cpu1, cpu2, ...
|
||||
rv = ""
|
||||
if options.timestamp:
|
||||
rv = str(time.time()) + ", "
|
||||
rv += srvmetrics.tocsv()
|
||||
return rv
|
||||
|
||||
def csvserverbaseline():
|
||||
# return a csv string of raw server metrics data: memfree, memtotal, cpuused, cpusystem, cpuidle
|
||||
return "memory (total, free) = " + csvservermems(collectservermems()) + "\ncputime (used, sys, idl) = " + csvservercputimes(collectservercputimes())
|
||||
|
||||
class NodeMetrics(object):
|
||||
def __init__(self):
|
||||
self.nmetrics = {"nodethroughput" : 0.0,
|
||||
"nodeusedmemory" : 0.0,
|
||||
"nodetotalcpu" : 0.0,
|
||||
"nodeusercpu" : 0.0,
|
||||
"nodesystemcpu" : 0.0,
|
||||
"nodewaitcpu" : 0.0}
|
||||
|
||||
# set values from val = (throughput, mem, tcpu, ucpu, scpu, wcpu):
|
||||
def setvalues(self, val):
|
||||
self.nmetrics["nodethroughput"] = val[0]
|
||||
self.nmetrics["nodeusedmemory"] = val[1]
|
||||
self.nmetrics["nodetotalcpu"] = val[2]
|
||||
self.nmetrics["nodeusercpu"] = val[3]
|
||||
self.nmetrics["nodesystemcpu"] = val[4]
|
||||
self.nmetrics["nodewaitcpu"] = val[5]
|
||||
|
||||
def setvalue(self, key, val):
|
||||
self.nmetrics[key] = val
|
||||
|
||||
def getvalue(self, key):
|
||||
return self.nmetrics[key]
|
||||
|
||||
def getkeys(self):
|
||||
return self.nmetrics.keys()
|
||||
|
||||
def tocsv(self):
|
||||
return ", ".join(map(lambda(x):str(x), self.nmetrics.values()))
|
||||
|
||||
|
||||
class LogSession(object):
|
||||
def __init__(self):
|
||||
self.nodethresholds = NodeMetrics()
|
||||
# set node threshold default values:
|
||||
# nodethroughput=20.0, nodeusedmemory=15.0, nodetotalcpu=90.0,
|
||||
# nodeusercpu=30.0, nodewaitcpu=50.0, nodesystemcpu=20.0}
|
||||
self.nodethresholds.setvalues([20.0, 15.0, 90.0, 30.0, 50.0, 20.0])
|
||||
if options.configfile is not None:
|
||||
self.readnodethresholds(options.configfile)
|
||||
self.pids = {}
|
||||
self.nodemetricsA = {}
|
||||
self.nodemetricsB = {}
|
||||
self.nodemetricsC = {}
|
||||
|
||||
def getpids(self):
|
||||
# return dict of all CORE session pids in a dict using node name as the keys
|
||||
# parent pid (vnoded) is the first value
|
||||
self.pids = {}
|
||||
nodes = commands.getstatusoutput("ls /tmp/pycore.%s/*pid" % options.session)
|
||||
if nodes[0] != 0:
|
||||
# if options.timestamp == True:
|
||||
# print str(time.time()),
|
||||
# print "CORE session %s has not created nodes" % options.session
|
||||
return
|
||||
|
||||
nodes = nodes[1].split('\n')
|
||||
for nod in nodes:
|
||||
nodename = nod.split('/')[-1].strip(".pid")
|
||||
self.pids[nodename] = commands.getoutput("cat %s" % nod)
|
||||
|
||||
# do not expect failure of this command
|
||||
procs = commands.getoutput('ps -eo ppid,pid,comm').split('\n')
|
||||
|
||||
# build self.pids dict with key=nodename and val="ppid,pid,cmd"
|
||||
for nname in self.pids:
|
||||
# print nname, self.pids[nname]
|
||||
if self.pids[nname] == "":
|
||||
if options.timestamp == True:
|
||||
print str(time.time()),
|
||||
print "ERROR: null vnoded pid of node: %s" % nname
|
||||
else:
|
||||
childprocs = []
|
||||
ppid = self.pids[nname]
|
||||
for proc in procs:
|
||||
val=proc.split()
|
||||
if ppid == val[1]:
|
||||
childprocs.append([val[1], val[2]] )
|
||||
if ppid == val[0]:
|
||||
childprocs.append([val[1], val[2]])
|
||||
self.pids[nname] = childprocs
|
||||
# print nname, self.pids[nname]
|
||||
return self.pids
|
||||
|
||||
def printsesspids(self):
|
||||
if self.pids == {}:
|
||||
return {}
|
||||
for pp in self.pids:
|
||||
if self.pids[pp] != []:
|
||||
for ap in range(len(self.pids[pp]) - 1):
|
||||
print ", " + self.pids[pp][ap][0], # ap pid
|
||||
print ", " + self.pids[pp][ap][1], # ap cmd
|
||||
procmetrics = map(lambda(x):str(x),self.pids[pp][ap][-1])
|
||||
print ", " + ", ".join(procmetrics),
|
||||
nodemetrics = map(lambda(x):str(x), self.pids[pp][-1])
|
||||
print ", " + ", ".join(nodemetrics)
|
||||
|
||||
def getprocessmetrics(self, pid):
|
||||
# return [cpu#, vsize(kb), ttime, utime, stime, wtime]
|
||||
# from a /proc/pid/stat (a single line file) assume columns are:
|
||||
# pid(0) comm(1) state ppid pgrp sess tty_nr tpgid flags
|
||||
# minflt cmiflt majflt cmajflt # utime(12) stime cutime cstime
|
||||
# priority nice num_threads itrealvalue starttime vsize(22) rss rsslim
|
||||
# startcode endcode startstack kstkesp signal blocked sigignore sigcatch
|
||||
# wchan nswap cnswap exit_signal processor(38) rt_priority
|
||||
# policy ioblock guest_time cguest_time (man 5 proc)
|
||||
#rval = ProcessMetrics()
|
||||
#rval.__init__()
|
||||
rval = {}
|
||||
lines = readfile("/proc/" + pid + "/stat")
|
||||
if lines == []:
|
||||
return rval
|
||||
items = lines[0].split()
|
||||
(utime, stime, cutime, cstime) = map(lambda(x):int(x), items[13:17])
|
||||
# print ">???", utime, stime, cutime, cstime
|
||||
rval = (items[38], # last run processor
|
||||
int(items[22])/1000, # process virtual mem in kb
|
||||
utime + stime + cutime + cstime,# totoal time
|
||||
utime, # user time
|
||||
stime, # system time
|
||||
cutime + cstime) # wait time
|
||||
# print "pid --- processmetrics", rval
|
||||
return rval
|
||||
|
||||
def getnodethroughput(self, pid):
|
||||
# return node throughput of total receive and transmit packets in kb
|
||||
lines = readfile("/proc/" + pid + "/net/dev")
|
||||
if lines == []:
|
||||
return -0.00
|
||||
ifs = map(lambda(x): x.split(), lines[2:])
|
||||
ifm = zip(*ifs)
|
||||
rv = sum(map(lambda(x):int(x), ifm[1])) # received bytes
|
||||
tr = sum(map(lambda(x):int(x), ifm[9])) # transmited bytes
|
||||
#print 'node thruput :', rv, tr, (rv + tr)/1000
|
||||
return (rv + tr)/1000
|
||||
|
||||
def getnodemetrics(self, mindex):
|
||||
# return NodeMetrics with indexed by nodename, values are rows of
|
||||
# [ [ppid, vnoded, [cpu#, vmem(kb), ttime, utime, stime, wtime]],
|
||||
# [cpid, cmd, [cpu#, vmem(kb), ttime, utime, stime, wtime]], ... ,
|
||||
# [thrput, vmem(kb), ttime, utime, stime, wtime]]
|
||||
if mindex == 'a':
|
||||
metricref = self.nodemetricsA
|
||||
else:
|
||||
metricref = self.nodemetricsB
|
||||
|
||||
self.getpids()
|
||||
# print " inside getnodemetrics()", self.pids
|
||||
if self.pids == {}:
|
||||
return {}
|
||||
|
||||
|
||||
for nod in self.pids:
|
||||
nmetric = NodeMetrics()
|
||||
nmetric.__init__()
|
||||
nodeapps = {}
|
||||
for ap in range(len(self.pids[nod])): # get each process metrics
|
||||
procm = self.getprocessmetrics(self.pids[nod][ap][0])
|
||||
if procm == []:
|
||||
if options.timestamp == True:
|
||||
print str(time.time()),
|
||||
print "WARNING: transient process", self.pids[nod][ap][1], \
|
||||
"/", self.pids[nod][ap][0], "on node %s" % nod
|
||||
else:
|
||||
nodeapps[ap] = procm
|
||||
self.pids[nod][ap].append(nodeapps[ap])
|
||||
processm = zip(*nodeapps.values()) # get overall node metrics
|
||||
# print processm
|
||||
if len(processm) > 0:
|
||||
# if nod == 'n6':
|
||||
# print nod, self.getnodethroughput(self.pids[nod][0][0])
|
||||
nmetric.setvalues(( self.getnodethroughput(self.pids[nod][0][0]),
|
||||
sum(map(lambda(x):int(x), processm[1])), # vsize(kb)
|
||||
sum(map(lambda(x):int(x), processm[2])), # ttime
|
||||
sum(map(lambda(x):int(x), processm[3])), # utime
|
||||
sum(map(lambda(x):int(x), processm[4])), # stime
|
||||
sum(map(lambda(x):int(x), processm[5])))) # wtime
|
||||
metricref[nod] = nmetric
|
||||
# print nod, self.pids[nod][0][0], metricref[nod].tocsv()
|
||||
return metricref
|
||||
|
||||
def setnodemetricsC(self, key, val):
|
||||
self.nodemetricsC[key] = val
|
||||
|
||||
def printnodemetrics(self, mindex):
|
||||
if mindex == 'c':
|
||||
mm = self.nodemetricsC
|
||||
else:
|
||||
if mindex == 'a':
|
||||
mm = self.nodemetricsA
|
||||
else:
|
||||
mm = self.nodemetricsB
|
||||
|
||||
for k in self.nodemetricsC:
|
||||
if options.timestamp:
|
||||
print str(time.time()) + ",",
|
||||
print k, ",", mm[k].tocsv()
|
||||
|
||||
def readnodethresholds(self, filename):
|
||||
if filename is None:
|
||||
return
|
||||
lines = readfile(filename)
|
||||
for l in lines:
|
||||
mval = l.strip().split('=')
|
||||
# print "read line %s" % mval
|
||||
if len(mval) > 1 :
|
||||
thekey = mval[0].strip()
|
||||
theval = mval[1].strip()
|
||||
if thekey in self.nodethresholds.getkeys():
|
||||
self.nodethresholds.setvalue(thekey, float(theval))
|
||||
#print thekey," = %.2f" % float(theval)
|
||||
|
||||
def checknodethresholds(self, nname):
|
||||
# print "check node thresholds", nname
|
||||
calcm = self.nodemetricsC[nname]
|
||||
for keyname in self.nodethresholds.getkeys():
|
||||
# print "HIII", keyname, calcm.getvalue(keyname), self.nodethresholds.getvalue(keyname)
|
||||
if float(calcm.getvalue(keyname)) > float(self.nodethresholds.getvalue(keyname)):
|
||||
# print calculatednodem.getvalue(m)
|
||||
alarm = ["node", nname + "/" + self.pids[nname][0][0], keyname,\
|
||||
calcm.getvalue(keyname), ">", self.nodethresholds.getvalue(keyname)]
|
||||
if options.timestamp:
|
||||
print str(time.time()) + ",",
|
||||
print ", ".join(map(lambda(x):str(x), alarm))
|
||||
|
||||
def calcnodemetrics(self, cputimea, cputimeb, mems):
|
||||
# return a dict of nodemetrics indexed by node name
|
||||
# nodemetrics[nodename][-1] = node/host%
|
||||
p = []
|
||||
for i in range(len(cputimeb[0])):
|
||||
p.append(cputimeb[0][i] - cputimea[0][i])
|
||||
hostusedcpu = p[0] + p[1]
|
||||
hostusedmem = mems[0] - mems[1]
|
||||
if hostusedcpu == 0:
|
||||
print "WARNING: host used cpu = 0, ", p[0], p[1]
|
||||
hostusedcpu = 1
|
||||
if hostusedmem == 0:
|
||||
print "WARNING: host used mem = 0, ", mems[0], mems[1]
|
||||
hostusedmem = 1
|
||||
|
||||
nodesa = self.nodemetricsA
|
||||
nodesb = self.nodemetricsB
|
||||
for nod in nodesb:
|
||||
calcm = self.nodemetricsC
|
||||
calcm = NodeMetrics()
|
||||
calcm.__init__()
|
||||
if (nod in nodesa):
|
||||
try:
|
||||
if (nodesb[nod] == []) | (nodesa[nod] == []) | \
|
||||
( False == isinstance(nodesb[nod], NodeMetrics)) | \
|
||||
( False == isinstance(nodesa[nod], NodeMetrics)):
|
||||
if options.timestamp == True:
|
||||
print str(time.time()),
|
||||
print "Warning: nodes %s is not fully instanciated" % nod
|
||||
else:
|
||||
# calc throughput kbps
|
||||
#print "node b : ", nodesb[nod].tocsv()
|
||||
#print "node a : ", nodesa[nod].tocsv()
|
||||
#if nod == 'n6':
|
||||
#print nodesb[nod].getvalue("nodethroughput"), nodesa[nod].getvalue("nodethroughput")
|
||||
calcm.setvalue("nodethroughput", "%.2f" % (8 * (nodesb[nod].getvalue("nodethroughput") \
|
||||
- nodesa[nod].getvalue("nodethroughput")) / options.interval))
|
||||
# calc mem node used / host used
|
||||
calcm.setvalue("nodeusedmemory", "%.2f" % (100.0 * (nodesb[nod].getvalue("nodeusedmemory") / hostusedmem)))
|
||||
|
||||
# calc total cpu time node / host
|
||||
calcm.setvalue("nodetotalcpu", "%.2f" % (100.0 * (nodesb[nod].getvalue("nodetotalcpu")\
|
||||
- nodesa[nod].getvalue("nodetotalcpu")) /hostusedcpu))
|
||||
# calc user cpu time node / host
|
||||
calcm.setvalue("nodeusercpu", "%.2f" % (100.0 * (nodesb[nod].getvalue("nodeusercpu")\
|
||||
- nodesa[nod].getvalue("nodeusercpu")) /hostusedcpu))
|
||||
# calc system cpu time node / host
|
||||
calcm.setvalue("nodesystemcpu", "%.2f" % (100.0 * (nodesb[nod].getvalue("nodesystemcpu")\
|
||||
- nodesa[nod].getvalue("nodesystemcpu")) /hostusedcpu))
|
||||
# calc waitcpu time node / host
|
||||
calcm.setvalue("nodewaitcpu", "%.2f" % (100.0 * (nodesb[nod].getvalue("nodewaitcpu")\
|
||||
- nodesa[nod].getvalue("nodewaitcpu")) /hostusedcpu))
|
||||
|
||||
#print nod, calcm.tocsv()
|
||||
#print '=========================='
|
||||
logsession.nodemetricsC[nod] = calcm
|
||||
# logsession.printnodemetrics('c')
|
||||
|
||||
if options.alarm is not None:
|
||||
logsession.checknodethresholds(nod)
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
print "Warning: transient node %s " % nod
|
||||
|
||||
return nodesb
|
||||
|
||||
def main():
|
||||
usagestr = "%prog [-h] [options] [args]\n\nLog server and optional CORE session metrics to stdout."
|
||||
parser = optparse.OptionParser(usage = usagestr)
|
||||
parser.set_defaults(interval=2, timestamp=False,
|
||||
configfile = "/etc/core/perflogserver.conf",\
|
||||
alarm = True, session = None)
|
||||
parser.add_option("-i", "--interval", dest = "interval", type = int,
|
||||
help = "seconds to wait between samples; default=%s" %
|
||||
parser.defaults["interval"])
|
||||
parser.add_option("-t", "--timestamp", action = "store_true",
|
||||
dest = "timestamp",
|
||||
help = "include timestamp on each line")
|
||||
parser.add_option("-c", "--configfile", dest = "configfile",
|
||||
type = "string",
|
||||
help = "read threshold values from the specified file;\
|
||||
default=%s" % parser.defaults["configfile"])
|
||||
parser.add_option("-a", "--alarm", action = "store_true",
|
||||
dest = "alarm",
|
||||
help = "generate alarms based threshold check on each cycle")
|
||||
parser.add_option("-s", "--session", dest = "session", type = int,
|
||||
help = "CORE session id; default=%s" %
|
||||
parser.defaults["session"])
|
||||
global options
|
||||
global ncpus
|
||||
global serverthresholds
|
||||
global logsession
|
||||
global cyclecount
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
# print options
|
||||
|
||||
signal.signal(signal.SIGINT, handler)
|
||||
signal.signal(signal.SIGTERM, handler)
|
||||
|
||||
ncpus = numcpus()
|
||||
|
||||
# server threshold dictionary - a ServerMetrics instant with default values
|
||||
serverthresholds = ServerMetrics()
|
||||
# set to server threshold default values: serverloadavg1=3.5,
|
||||
# serverloadavg5=3.5, serverloadavg15=3.5, serverusedmemory=80.0,
|
||||
# serverusedcputime=80.0, processorusedcputime=90.0
|
||||
serverthresholds.setvalues([3.5, 3.5, 3.5, 80.0, 80.0, 90.0])
|
||||
if options.alarm is True:
|
||||
# read server threshold values from configuration file
|
||||
readserverthresholds(options.configfile)
|
||||
|
||||
if options.session is not None:
|
||||
logsession = LogSession()
|
||||
# print logsession
|
||||
|
||||
# mark host log baseline
|
||||
print "server: ", ", ".join(map(lambda(x):str(x), os.uname())), ",", ncpus, "CPU cores"
|
||||
print "start timestamp:", time.time(), ", baseline data: "
|
||||
print csvserverbaseline()
|
||||
print "server metrics: ", ", ".join(map(lambda(x):str(x), serverthresholds.getkeys()))
|
||||
if options.session is not None:
|
||||
print "node metrics: nodename, ", ", ".join(map(lambda(x):str(x), logsession.nodethresholds.getkeys()))
|
||||
|
||||
cyclecount = 0
|
||||
while True:
|
||||
cputimea = collectservercputimes()
|
||||
if options.session is not None:
|
||||
nodesa = logsession.getnodemetrics('a')
|
||||
# print "nodes a:", nodesa
|
||||
|
||||
time.sleep(options.interval)
|
||||
|
||||
cputimeb = collectservercputimes()
|
||||
mems = collectservermems()
|
||||
|
||||
calccputime = calcservercputimes(cputimea, cputimeb)
|
||||
m = csvservermetrics(collectservermetrics(calccputime, mems, options.alarm))
|
||||
print m
|
||||
|
||||
if options.session is not None:
|
||||
nodesb = logsession.getnodemetrics('b')
|
||||
# print "nodes b:", nodesb
|
||||
if nodesb != {}:
|
||||
logsession.calcnodemetrics(cputimea, cputimeb, mems)
|
||||
logsession.printnodemetrics('c')
|
||||
|
||||
sys.stdout.flush()
|
||||
cyclecount = cyclecount + 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
10
scripts/perf/perflogstart.sh
Normal file
10
scripts/perf/perflogstart.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
# (c)2010-2012 the Boeing Company
|
||||
# author: Yueli Yang <yueli.yang@boeing.com>
|
||||
#
|
||||
# start core performance logging and collect output to file
|
||||
# /tmp/pycore.nnnn/perf<sessionid>.log
|
||||
HOOKS_DIR=`dirname $0`
|
||||
|
||||
sid=` pwd | awk -F / {'print $3'} | awk -F . {'print $2'} `
|
||||
python $HOOKS_DIR/perflogserver.py -t -a -c /etc/core/perflogserver.conf -s $sid > perf$sid.log &
|
11
scripts/perf/perflogstop.sh
Normal file
11
scripts/perf/perflogstop.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
# (c)2010-2012 the Boeing Company
|
||||
# author: Yueli Yang <yueli.yang@boeing.com>
|
||||
#
|
||||
# terminate core perfromance logging process
|
||||
|
||||
perfproc=` ps aux | grep perflogserver | grep python | awk {'print $2'} `
|
||||
if [ ! $perfproc = "" ]; then
|
||||
echo "terminating core performance log process $perfproc"
|
||||
kill -9 $perfproc
|
||||
fi
|
52
scripts/perf/sessiondatacollect.sh
Normal file
52
scripts/perf/sessiondatacollect.sh
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
# (c)2010-2012 the Boeing Company
|
||||
# author: Yueli Yang <yueli.yang@boeing.com>
|
||||
#
|
||||
# Create a tar ball of the CORE session's runtime folder /tmp/pycore.nnnn
|
||||
# Collection such runtime tar balls from all distributed servers to folder
|
||||
# /tmp/<sessionid>-<date>-<time> for example: /tmp/56779-11Oct14-09:33:13
|
||||
|
||||
currentdir=` pwd `
|
||||
sid=${currentdir##*.}
|
||||
ts=` date +%y%h%d-%T `
|
||||
logfile=/tmp/corelog.tgz
|
||||
echo Collect data from localhost:$currentdir to $logfile
|
||||
cd ..
|
||||
tar -czf $logfile ${currentdir##*/}
|
||||
if [ ! $? = 0 ]; then
|
||||
echo Failed to collect CORE data from localhost:$currentdir to $logfile
|
||||
fi
|
||||
cd $currentdir
|
||||
|
||||
m=` grep master $currentdir/servers `
|
||||
if [ ! $sid = ${m##*=} ]; then
|
||||
# quite if this is not a master server
|
||||
echo not a master server
|
||||
exit
|
||||
fi
|
||||
|
||||
# On a master server, create a folder to harvest overall core emulation data
|
||||
logdir=/tmp/$sid-$ts
|
||||
if [ ! -e $logdir ]; then
|
||||
echo create folder $logdir
|
||||
mkdir $logdir
|
||||
fi
|
||||
cp $logfile $logdir/localhost-${currentdir##*.}.tgz
|
||||
|
||||
# harvest CORE data from distributed servers
|
||||
hs=` grep -v master= $currentdir/servers | awk {'print $2'} `
|
||||
echo hosts are localhost $hs
|
||||
for h in $hs; do
|
||||
echo checking host $h ...
|
||||
out=` ping -c 1 -w 1 $h | grep " 0 received," `
|
||||
if [ " $out " = " " ]; then
|
||||
slavesid=` ssh $h tar -tzf $logfile | awk -F / {'print $1'} `
|
||||
if [ $? = 0 ]; then
|
||||
destlogfile=$logdir/$h-${slavesid##*.}.tgz
|
||||
echo Collect data from $h:$logfile to $destlogfile
|
||||
scp $h:$logfile $destlogfile
|
||||
else
|
||||
echo $logfile could not be found on host $h
|
||||
fi
|
||||
fi
|
||||
done
|
26
scripts/perf/timesyncstart.sh
Normal file
26
scripts/perf/timesyncstart.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
# (c)2010-2012 the Boeing Company
|
||||
# author: Yueli Yang <yueli.yang@boeing.com>
|
||||
#
|
||||
# start time sync with ntpd if it is installed but not started
|
||||
#
|
||||
# Usage: sudo timesyncstart.sh [debug]
|
||||
|
||||
dbg=$1
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
date +%y%h%d-%T-%N
|
||||
fi
|
||||
if [ -e /usr/sbin/ntpd ]; then
|
||||
/etc/init.d/ntp status
|
||||
if [ $? = 3 ]; then
|
||||
/etc/init.d/ntp start
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
echo "start ntpd process"
|
||||
ntptime
|
||||
ntpq -c peers
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
date +%y%h%d-%T-%N
|
||||
fi
|
51
scripts/perf/timesyncstop.sh
Normal file
51
scripts/perf/timesyncstop.sh
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh
|
||||
# (c)2010-2012 the Boeing Company
|
||||
# author: Yueli Yang <yueli.yang@boeing.com>
|
||||
#
|
||||
# Stop timesync service. If it was not yet in sync with any ntp server,
|
||||
# adjust its time to the first ntp server in # configured in /etc/ntp.conf
|
||||
#
|
||||
# Usage: sudo sh timesyncstop.sh [deubg]
|
||||
|
||||
dbg=$1
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
date +%y%h%d-%T-%N
|
||||
fi
|
||||
svs=""
|
||||
if [ -e /usr/sbin/ntpd ]; then
|
||||
# command "sudo /usr/sbin/ntpd -q -g" will start the ntp service and
|
||||
# keep it on until it performs a good synchronization, then it leaves.
|
||||
# It is not quick enough for our need here
|
||||
/etc/init.d/ntp status
|
||||
if [ $? = 0 ]; then
|
||||
svs=`ntpq -c peers | awk {'print $1'} | grep ^*`
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
ntpq -c peers
|
||||
echo "get time servers for later need: $svs"
|
||||
ntptime
|
||||
echo "terminate ntpd process"
|
||||
fi
|
||||
/etc/init.d/ntp stop
|
||||
fi
|
||||
|
||||
# if there are time servers configured in file /etc/ntp.conf,
|
||||
# adjust time to the first server
|
||||
if [ "$svs" = "" ]; then
|
||||
svs=`grep ^server /etc/ntp.conf | awk {'print $2'} `
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
echo "$svs"
|
||||
fi
|
||||
for sv in "$svs"; do
|
||||
ntpdate $sv
|
||||
# may use "sntp -s $sv" or "rdate" if ntpdate is deprecated
|
||||
break
|
||||
done
|
||||
else
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
echo No time adjustment because time sync was stable with $svs
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "$dbg" = "debug" ]; then
|
||||
date +%y%h%d-%T-%N
|
||||
fi
|
15
scripts/xen/Makefile.am
Executable file
15
scripts/xen/Makefile.am
Executable file
|
@ -0,0 +1,15 @@
|
|||
# CORE
|
||||
# (c)2012 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
# Makefile for installing Xen scripts.
|
||||
#
|
||||
|
||||
install-exec-hook:
|
||||
test -d "$(DESTDIR)/etc/init.d" || \
|
||||
mkdir -p $(DESTDIR)/etc/init.d
|
||||
test -d "$(DESTDIR)/etc/xen/scripts" && \
|
||||
cp -f linux/scripts/vif-core $(DESTDIR)/etc/xen/scripts
|
||||
|
48
scripts/xen/vif-core
Executable file
48
scripts/xen/vif-core
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
#============================================================================
|
||||
# ${XEN_SCRIPT_DIR}/vif-bridge
|
||||
#
|
||||
# Script for configuring a vif in bridged mode.
|
||||
# The hotplugging system will call this script if it is specified either in
|
||||
# the device configuration given to Xend, or the default Xend configuration
|
||||
# in ${XEN_CONFIG_DIR}/xend-config.sxp. If the script is specified in
|
||||
# neither of those places, then this script is the default.
|
||||
#
|
||||
# Usage:
|
||||
# vif-bridge (add|remove|online|offline)
|
||||
#
|
||||
# Environment vars:
|
||||
# vif vif interface name (required).
|
||||
# XENBUS_PATH path to this device's details in the XenStore (required).
|
||||
#
|
||||
# Read from the store:
|
||||
# bridge bridge to add the vif to (optional). Defaults to searching for the
|
||||
# bridge itself.
|
||||
# ip list of IP networks for the vif, space-separated (optional).
|
||||
#
|
||||
# up:
|
||||
# Enslaves the vif interface to the bridge and adds iptables rules
|
||||
# for its ip addresses (if any).
|
||||
#
|
||||
# down:
|
||||
# Removes the vif interface from the bridge and removes the iptables
|
||||
# rules for its ip addresses (if any).
|
||||
#============================================================================
|
||||
|
||||
dir=$(dirname "$0")
|
||||
. "$dir/vif-common.sh"
|
||||
|
||||
case "$command" in
|
||||
online)
|
||||
do_without_error ifconfig "$vif" up
|
||||
;;
|
||||
offline)
|
||||
do_without_error ifconfig "$vif" down
|
||||
;;
|
||||
esac
|
||||
|
||||
log debug "Successful vif-core $command for $vif, bridge $bridge."
|
||||
if [ "$command" == "online" ]
|
||||
then
|
||||
success
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue