archive mirror
 help / color / mirror / Atom feed
* [RFC] Script for doing unattended kernel benchmarks using contest
@ 2002-09-26  7:25 Robinson Maureira Castillo
  0 siblings, 0 replies; only message in thread
From: Robinson Maureira Castillo @ 2002-09-26  7:25 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Con Kolivas

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1176 bytes --]

Hi all,
this is the first release of

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 <>, 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 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

[-- Attachment #2: Type: TEXT/PLAIN, Size: 4620 bytes --]

# Automatic execution of contest <>
# against kernel images listed in /etc/lilo.conf
# v0.04a Run it @ your own risk.
# Copyright 2002, Robinson Maureira, all rights reserved.
# Author:  Robinson Maureira Castillo <>
# 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
# 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
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;
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";
	if(grep /label/,$_) {
		push @labels,$_;
close FD;

# Let's erase any previous version of /.labels

foreach $line (@labels) {
	($x,$label) = split /=/, $line;
	push @lb,$label;
	$com = "/bin/echo \"$label\" >> /.labels";
$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

$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";
$com = "/bin/echo \"c:$new:once:/bin/bash --init-file /.contest\" >> /etc/inittab";
$com = "/bin/echo $times > /.num";

# Now we create the initfile for each reboot
open FD, "> /.contest" or die "$!\n";
print FD<<EOF;
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 ] ;
        cp -f /etc/inittab.contest /etc/inittab
        rm -fr /etc/rc\$RUNLEVEL.d/
	rm -fr /.num
	rm -fr /.labels
	exit 0
echo \$TIMES > /.num
lilo -R \$NAME \$RUNLEVEL vga=normal apm=off
close FD;

# Finally, set lilo for the first reboot, and reboot.

# We should never get here 8)
exit 0;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-26  7:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-26  7:25 [RFC] Script for doing unattended kernel benchmarks using contest Robinson Maureira Castillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).