lkml.org 
[lkml]   [2002]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[RFC] Script for doing unattended kernel benchmarks using contest
Hi all,
this is the first release of autocontest.pl

Use it at your own risk, I just can say that "It works for me(tm)"

What's that?

A simple (and ugly) PERL script for automated kernel benchmarks, it was
written for contest <http://contest.kolivas.net/>, it simply generates a
custom (dummy) runlevel and boot every kernel image found in
/etc/lilo.conf in this runlevel, perform contest, reboot the next image,
perform contest, etc.


Err OK, what do I need to run it?

PERL 5 will do, hopefully.
LILO, with it's config file in /etc/lilo.conf otherwise edit the script 8)
Bash, along with cp, cat, rm, and find
A directory /usr/src/linux-2.4.19 with the 2.4.19 kernel sources in (this
is for contest)


How do I run it?

perl autoncontest.pl and then cross your fingers 8)


Will it screw my initscripts?

I don't know


Why your english is so crappy?

I'm Chilean, I speak Spanish 8)


How it works?

Read the source, Luke.


It was tested on RedHat 7.3 and (null), and debian 2.2, if it runs in
another version/distro, please let me know

Questions/Comments/Patches/Rewrites/Rants/Flames are welcome.

Best regards.
--
Robinson Maureira Castillo
Asesor DAI
INACAP
#!/usr/bin/perl
#
# Automatic execution of contest <http://contest.kolivas.net/>
# against kernel images listed in /etc/lilo.conf
#
# autocontest.pl v0.04a Run it @ your own risk.
#
# Copyright 2002, Robinson Maureira, all rights reserved.
#
# Author: Robinson Maureira Castillo <rmaureira@alumno.inacap.cl>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# The script takes care of boot each kernel image and run
# contest a couple of times with each one.
#
# Following assumptions are made:
#
# - You're using LILO, GRUB version will follow if this one probes useful
# - Your system is compatible with redhat or debian (It was tested on those)
# With "compatible" I mean:
# It has /etc/inittab, /etc/rc*.d, and a SysV way of "init"
# - You have PERL installed, if not, it won't run, believe me 8)
# - You have a directory /usr/src/linux-2.4.19 for make the compiles
# - Options used to boot are vga=normal and apm=off
#
# I can't say it will work on your system, "It works for me(tm)"
# Feedback is of course welcome, rants about PERL Monkey Style goes to /dev/null
#
# Changelog:
#
# v0.04a - User definable variables
# v0.03b - Some code commenting
# v0.02 - uid(0) check, autoselection of runlevel number
# v0.01 - insane first version
#

# Customize at your taste, defaults should be ok
# nload = how many times noload will run
# pload = the same for process load
# mload = memory load
# ioload = io load

$nload = 1;
$pload = 1;
$mload = 3;
$ioload = 5;


# If you're not root, you can't run autocontest.pl
die "Yay! you're not root, su and try again" if ($< ne 0);

# Let's see if we can create a new dummy runlevel directory
# If we can't, we die.
for ($rl = 7; $rl <= 9; $rl++) {
next if ((-d "/etc/rc$rl.d/") || (-l "/etc/rc$rl.d/"));
$new = $rl;
last;
}
die "There's no space to create a new runlevel, this is needed for autocontest" if !$new;

# Now we parse the configuration file for lilo
# After this, we'll have a list of images (labels)
# and the total number of those.
open FD, "/etc/lilo.conf" or die "$!\n";
while(<FD>){
if(grep /label/,$_) {
chop;
push @labels,$_;
}
}
close FD;

# Let's erase any previous version of /.labels
system("/bin/rm","-f","/.labels");

foreach $line (@labels) {
($x,$label) = split /=/, $line;
push @lb,$label;
$com = "/bin/echo \"$label\" >> /.labels";
system($com);
}
$times = scalar(@lb);
$kernel = $lb[$times - 1];


# OK then, let's create the dummy dir
# backup inittab and make some changes
# after that, let's put the number of reboots in the /.num file
system("/bin/mkdir","-p","/etc/rc$new.d/");
system("/bin/cp","/etc/inittab","/etc/inittab.contest");

$rc = `/usr/bin/find /etc/ -name rc 2> /dev/null | head -n 1`;
chomp $rc;

$com = "/bin/echo \"l$new:$new:wait:$rc $new\" >> /etc/inittab";
system($com);
$com = "/bin/echo \"c:$new:once:/bin/bash --init-file /.contest\" >> /etc/inittab";
system($com);
$com = "/bin/echo $times > /.num";
system($com);

# Now we create the initfile for each reboot
open FD, "> /.contest" or die "$!\n";
print FD<<EOF;
#!/bin/sh
#
RUNLEVEL=$new
TIMES=`cat /.num`
NAME=`head -n \$TIMES /.labels | tail -n 1`
cd /usr/src/linux-2.4.19
contest -k \$NAME -l noload -n $nload
contest -k \$NAME -l process_load -n $pload
contest -k \$NAME -l mem_load -n $mload
contest -k \$NAME -l io_load -n $ioload -r
TIMES=`perl -e "print (\$TIMES - 1)"`
NAME=`head -n \$TIMES /.labels | tail -n 1`
if [ -z \$NAME ] ;
then
cp -f /etc/inittab.contest /etc/inittab
rm -fr /etc/rc\$RUNLEVEL.d/
rm -fr /.num
rm -fr /.labels
lilo
reboot
exit 0
fi
echo \$TIMES > /.num
lilo -R \$NAME \$RUNLEVEL vga=normal apm=off
reboot
EOF
close FD;

# Finally, set lilo for the first reboot, and reboot.
system("lilo","-R",$kernel,$new,"vga=normal","apm=off");
system("reboot");

# We should never get here 8)
exit 0;

\
 
 \ /
  Last update: 2005-03-22 13:29    [W:0.048 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site