Commit 9b2ccbcb authored by Andrew McNab's avatar Andrew McNab
Browse files

Add mjf-get-total-cpu

parent 193274f8
......@@ -31,9 +31,9 @@
include VERSION
INSTALL_FILES=VERSION prologue.user epilogue.user mjf.init mjf.sh mjf.csh
INSTALL_FILES=VERSION prologue.user epilogue.user mjf.init mjf.sh mjf.csh mjf-get-total-cpu.torque
TGZ_FILES=$(INSTALL_FILES) Makefile mjf-scripts.spec
TGZ_FILES=$(INSTALL_FILES) Makefile mjf-torque.spec mjf-htcondor.spec
GNUTAR ?= tar
mjf-scripts.tgz: $(TGZ_FILES)
......@@ -43,21 +43,38 @@ mjf-scripts.tgz: $(TGZ_FILES)
rm -R TEMPDIR
install: $(INSTALL_FILES)
mkdir -p $(RPM_BUILD_ROOT)/var/lib/torque/mom_priv \
$(RPM_BUILD_ROOT)/etc/rc.d/init.d \
$(RPM_BUILD_ROOT)/etc/profile.d
cp prologue.user epilogue.user \
$(RPM_BUILD_ROOT)/var/lib/torque/mom_priv
mkdir -p $(RPM_BUILD_ROOT)/etc/rc.d/init.d \
$(RPM_BUILD_ROOT)/etc/profile.d
cp mjf.init \
$(RPM_BUILD_ROOT)/etc/rc.d/init.d/mjf
$(RPM_BUILD_ROOT)/etc/rc.d/init.d/mjf
cp mjf.sh mjf.csh \
$(RPM_BUILD_ROOT)/etc/profile.d
$(RPM_BUILD_ROOT)/etc/profile.d
install-torque: $(INSTALL_FILES) install
mkdir -p $(RPM_BUILD_ROOT)/var/lib/torque/mom_priv \
mkdir -p $(RPM_BUILD_ROOT)/usr/bin \
cp prologue.user epilogue.user \
$(RPM_BUILD_ROOT)/var/lib/torque/mom_priv
cp mjf-get-total-cpu.torque \
$(RPM_BUILD_ROOT)/usr/bin/mjf-get-total-cpu
torque-rpm: mjf-scripts.tgz
rm -Rf RPMTMP
mkdir -p RPMTMP/SOURCES RPMTMP/SPECS RPMTMP/BUILD \
RPMTMP/SRPMS RPMTMP/RPMS/noarch RPMTMP/BUILDROOT
cp -f mjf-scripts.tgz RPMTMP/SOURCES
export MJF_VERSION=$(VERSION) ; rpmbuild -ba \
--define "_topdir $(shell pwd)/RPMTMP" \
--buildroot $(shell pwd)/RPMTMP/BUILDROOT mjf-torque.spec
install-htcondor: $(INSTALL_FILES) install
rpm: mjf-scripts.tgz
htcondor-rpm: mjf-scripts.tgz
rm -Rf RPMTMP
mkdir -p RPMTMP/SOURCES RPMTMP/SPECS RPMTMP/BUILD \
RPMTMP/SRPMS RPMTMP/RPMS/noarch RPMTMP/BUILDROOT
cp -f mjf-scripts.tgz RPMTMP/SOURCES
export MJF_VERSION=$(VERSION) ; rpmbuild -ba \
--define "_topdir $(shell pwd)/RPMTMP" \
--buildroot $(shell pwd)/RPMTMP/BUILDROOT mjf-scripts.spec
--buildroot $(shell pwd)/RPMTMP/BUILDROOT mjf-htcondor.spec
VERSION=00.03
VERSION=00.04
#!/bin/sh
#
# Output the number of processors assigned by Torque/PBS to this node.
# Requires that the pbsnodes command is installed and that you have
# permission to run it.
#
# This script must be installed as /usr/bin/mjf-get-total-cpu to be
# picked up by the generic /etc/rc.d/init.d/mjf !
#
# Andrew.McNab@cern.ch
#
total_cpu=`pbsnodes \`hostname\` | grep '^ * np = '| head -1 | sed 's/^ * np = //'`
if [ "$total_cpu" != "" ] ; then
echo $total_cpu
exit 0
fi
total_cpu=`pbsnodes \`hostname -s\` | grep '^ * np = '| head -1 | sed 's/^ * np = //'`
if [ "$total_cpu" != "" ] ; then
echo $total_cpu
exit 0
fi
exit 1
Name: mjf-htcondor
Version: %(echo ${MJF_VERSION:-0.0})
Release: 1
BuildArch: noarch
Summary: Machine/Job Features for HTCondor
License: BSD
Group: System Environment/Daemons
Source: mjf-scripts.tgz
Vendor: GridPP
Packager: Andrew McNab <Andrew.McNab@cern.ch>
%description
Currently this only creates $MACHINEFEATURES!
%prep
%setup -n mjf-scripts
%build
%install
make install-htcondor
%post
chkconfig mjf on
service mjf start
%preun
if [ "$1" = "0" ] ; then
# if uninstallation rather than upgrade then stop
chkconfig mjf off
service mjf stop
fi
%files
/etc/rc.d/init.d/*
/etc/profile.d/*
Name: mjf-scripts
Name: mjf-torque
Version: %(echo ${MJF_VERSION:-0.0})
Release: 1
BuildArch: noarch
......@@ -12,21 +12,6 @@ Packager: Andrew McNab <Andrew.McNab@cern.ch>
%description
MJF implementations following HSF-TN-2016-02
%package -n mjf-torque
Group: System Environment/Daemons
Summary: Machine/Job Features for Torque/PBS
%description -n mjf-torque
MJF following HSF-TN-2016-02 for Torque/PBS
%package -n mjf-htcondor
Group: System Environment/Daemons
Summary: Machine/Job Features for HTCondor
%description -n mjf-htcondor
MJF following HSF-TN-2016-02 for HTCondor
Currently this only creates $MACHINEFEATURES!
%prep
%setup -n mjf-scripts
......@@ -34,35 +19,21 @@ Currently this only creates $MACHINEFEATURES!
%build
%install
make install
make install-torque
%post -n mjf-torque
%post
chkconfig mjf on
service mjf start
%preun -n mjf-torque
%preun
if [ "$1" = "0" ] ; then
# if uninstallation rather than upgrade then stop
chkconfig mjf off
service mjf stop
fi
%files -n mjf-torque
%files
/var/lib/torque/mom_priv
/etc/rc.d/init.d/*
/etc/profile.d/*
%post -n mjf-htcondor
chkconfig mjf on
service mjf start
%preun -n mjf-htcondor
if [ "$1" = "0" ] ; then
# if uninstallation rather than upgrade then stop
chkconfig mjf off
service mjf stop
fi
%files -n mjf-htcondor
/etc/rc.d/init.d/*
/etc/profile.d/*
/usr/bin/*
......@@ -38,8 +38,15 @@ start() {
mkdir -p /etc/machinefeatures.tmp
if [ "$total_cpu" == "" ] ; then
# If not explicitly configured then calculate from hardware
total_cpu=`grep '^processor[[:space:]]*:' /proc/cpuinfo | wc --lines`
# If not explicitly configured then try to get it from the batch system
if [ -x /usr/bin/get-total-cpu ] ; then
$total_cpu=`/usr/bin/get-total-cpu`
fi
# If still not explicitly configured then it get from the OS
if [ "$total_cpu" == "" ] ; then
total_cpu=`grep '^processor[[:space:]]*:' /proc/cpuinfo | wc --lines`
fi
fi
echo -n "$total_cpu" > /etc/machinefeatures.tmp/total_cpu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment