LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2015, 04:54 PM   #1
rmcateer
Member
 
Registered: Oct 2014
Posts: 41

Rep: Reputation: Disabled
write stress to file? run vmstat/iostat simultaneously with stress commands


I have written two scripts: one to output vmstat etc and another to stress the system. I had included a link to output the stress statistics to file, but when I go to look for it in the Ubuntu desktop home folder, it says it is not found and when I provide the directories for sftp of
Code:
home/roryhbmc/tmp/stress_cpu_stat_$D
and
Code:
home/roryhbmc/stress_cpu_stat_$D
it tells me that the files are not found. It seems to do this no matter how much I adapt the filename.

Is it therefore not possible to write stress to file? If not, is it possible to run vmstat etc simultaneously to stress? I want to compare the system unstressed to being stressed-is the only way to do this to run vmstat etc first, then run stress on it's own and then vmstat etc again?

Below is the stress script I have at the moment.


Code:
#!/bin/bash
#
# Script to get stress statistics#

echo "How many would you like to stress?"

echo -n "Number of cores being stressed: "
read cores
# the variable "cores" now has the value entered by keyboard


echo "Enter the number of intervals (seconds) for running the stress statistics:"

read seconds_to_run
# the variable "seconds_to_run" now has the value entered by keyboard

D=`/bin/date '+%B.%d'`
#Variable to read the date that the command runs

while true; do
    clear
    echo "*******************************"
    echo "* Choose from the following: *"
    echo "*******************************"
    echo "* [1] Stress the CPU. *"
    echo "* [2] Stress the Memory(RAM). *"
    echo "* [3] Stress the disk drive. *"
    echo "* [4] Stress the  hard disk drive. *"
    echo "Press A to quit."
    echo "************************"
    echo -n "Enter your menu choice [1-4]: "

    read choice



    case $choice in    
        1) echo "Stressing the CPU"
            stress -c $cores -t $seconds_to_run |tee /tmp/stress_cpu_stat_$D
            echo "This file will be saved to /tmp/stress_cpu_stat_$D"
            sleep 5 ;;

        2) echo "Stressing the Memory(RAM)"
            stress -m $cores -t $seconds_to_run |tee /tmp/stress_ram_stat_$D
            echo "This file will be saved to /tmp/stress_ram_stat_$D"
            sleep 5 ;;

        3) echo "Stressing the disk"
            stress -i $cores -t $seconds_to_run |tee /tmp/stress_disk_stat_$D
            echo "This file will be saved to /tmp/stress_disk_stat_$D"
            sleep 5 ;;

        4) echo "Stressing the  hard disk drive"
            stress --hdd $cores -t $seconds_to_run |tee /tmp/stress_hard_disk_stat_$D 
            echo "This file will be saved to /tmp/stress_hard_disk_stat_$D"
            sleep 5 ;;

        A) #Quit option
            echo You have chosen to quit.
            exit;;   

        *) #Wildcard option in case user enters an invalid option such as "e"
            echo Invalid choice, please make another choice
            sleep 3;;


    esac
done
 
Old 02-27-2015, 05:11 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
/tmp/stress_ram_stat_$D
 
Old 02-27-2015, 05:15 PM   #3
rmcateer
Member
 
Registered: Oct 2014
Posts: 41

Original Poster
Rep: Reputation: Disabled
what do you mean by that? when i type that filename or any the full extension with it, it tells it doesn't exist

---------- Post added 02-27-15 at 06:15 PM ----------

can i write them to file, and if so, what is the full extension to use for the sftp of those statistics?
 
Old 02-27-2015, 06:07 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Try setting "D" to a constant value
 
Old 02-27-2015, 06:17 PM   #5
rmcateer
Member
 
Registered: Oct 2014
Posts: 41

Original Poster
Rep: Reputation: Disabled
the same D variable works fine in another script I wrote though. Any ideas?
 
Old 02-27-2015, 07:27 PM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by rmcateer View Post
the same D variable works fine in another script I wrote though. Any ideas?
You have to do something to eliminate possibilities. Either that or do something you know would create a file
like touch <file> or echo test > <file>
 
  


Reply

Tags
bash scripting, testing, ubuntu 12.04, vmstat


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux performance tuning commands, uptime,top,mpstat,iostat,vmstat ,free,ping,Dstat T anish2good Linux - Newbie 2 07-16-2013 02:00 PM
Im am running a stress autocorrelation function,to calculate stress correlation funct lehloks Programming 4 07-08-2013 05:59 AM
coverage area for file system stress tests IndhuDurai Linux - General 0 11-15-2007 01:07 AM
how to install iostat, mpstat, vmstat commands in RHEL 3.0 kgvs_prasad Linux - Enterprise 2 02-08-2005 12:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration