ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116
Rep:
script to get 100% cpu/disk usage
Hi all,
I want to create a test case by writing a script that will fill up the filesystem and lead to a crash. How can i accomplish this, script code? I also want to try and cause 100% cpu usage, how would i do this?
i thought in order to increase cpu usage/priority you have to have root access (is 100% even possible?). also, i dont know of a way to make such a script, because ive never had to think about it. since this seems malicious, i dont know how much help youll get.
if you're wanting a virus or a virus type of program try some of the hackers forums as they give them out for free, or have i got the question wrong?
paul
/dev/null is implemented within the system so the zero-bytes is produces are super-fast to read by cat. Throughput is limited by your filesystem I/O rate.
True, but not much use if you are trying to track interference to some other task - you really need something that isn't as easily pre-empted. I tend to use something like a stress test program - there are a few around.
I also generally use cpusets to contain the test to a subset of CPUs so I can monitor the effect(s) realtime without being locked out myself.
it's 2 little perl scripts, one writes to the other through a pipe
something like:
buffer_write.pl -size=10000000 |buffer_read.pl
as the writer doesn't append a newline the reader never reads it.
so the internal buffer fills up and up and up and up.
eventually it fills up, interestingly on linux most often it brings the
OS to it's knees and you get a freeze up. With solaris however it
always chucks you off eventually with: Out of memory!
Code:
#!/usr/bin/perl -s
# write to the stdout, but with no '\n' character causes
# the internal (stdio?) buffer to fill up.
# when used with the perl buffered <> operation
#
# use -size=n
#
# to increase the write
$main::size ||= 10_000;
$count;
sub do_write {
$buf = chr int(rand(25)+65);
$message = $buf x $size;
$message .= "\n" if $line;;
print "$message"; # no new line !!!
$count += length $message;
warn "$count bytes\n";
}
while ("hell" ne "frozen over") {
do_write;
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.