LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to write a wrapper script for iostat (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-write-a-wrapper-script-for-iostat-849039/)

srrijith 12-08-2010 08:16 AM

How to write a wrapper script for iostat
 
I need to write a wrapper script for iostat functionality . in solaris unix i have iostat but in linux i dont have iostat , so I need to write a wrapper script which does all the functionality of iostat . can anyone help me? i am entirely new to scripting

TB0ne 12-08-2010 08:43 AM

Quote:

Originally Posted by srrijith (Post 4184657)
I need to write a wrapper script for iostat functionality . in solaris unix i have iostat but in linux i dont have iostat , so I need to write a wrapper script which does all the functionality of iostat . can anyone help me? i am entirely new to scripting

First, iostat is available for Linux. If you don't have it, you can install it. Since you don't say what version/distro of Linux, we can't tell you how.

Second, if you need help writing a script, there are thousands of scripting tutorials you can find easily with Google. They can help you get started, and please come back and post any specific problems/questions you have (along with your script), and we can try to help.

srrijith 12-08-2010 09:04 AM

Thanks for your reply.
I need to writer a wrapper script for iostat -c and iostat -E . not sure how to start with.
if you can kindly help me then I would be very thankful to you...

Regards,
Sree

TB0ne 12-08-2010 10:14 AM

Quote:

Originally Posted by srrijith (Post 4184726)
Thanks for your reply.
I need to writer a wrapper script for iostat -c and iostat -E . not sure how to start with.
if you can kindly help me then I would be very thankful to you...

You don't say what you're trying to do, what you want to see, etc., so how can anyone here help you write it?

If you don't know how to write a script, then as I suggested before, go to Google, type in "linux bash scripting tutorials", and press ENTER. Pick one of the thousands of hits, and go from there. Again, we are NOT going to write your script for you, but will HELP you if you get stuck...you will need to post what you've written, and what problems you have.

stress_junkie 12-08-2010 10:21 AM

You don't really want a wrapper.

In Linux you want to install the sysstat package. That contains iostat, vmstat, mpstat, and sar.

srrijith 12-08-2010 07:25 PM

thanks...
iostat is in my linux...
but my requirement is to write a script which helps me to call iostat indirectly like .. instead of calling iostat -c
it will be myiostat -c . can you help me to write a script which does this

srrijith 12-08-2010 07:26 PM

iostat is in my linux...
but my requirement is to write a script which helps me to call iostat indirectly like .. instead of calling iostat -c
it will be myiostat -c . can you help me to write a script which does this

stress_junkie 12-08-2010 07:31 PM

Quote:

Originally Posted by srrijith (Post 4185342)
thanks...
iostat is in my linux...
but my requirement is to write a script which helps me to call iostat indirectly like .. instead of calling iostat -c
it will be myiostat -c . can you help me to write a script which does this

That is nothing like what you originally said. It doesn't make any sense to me.
Code:

#!/bin/bash

iostat "$@"

What's the point? :scratch:

onebuck 12-08-2010 08:13 PM

Hi,

Welcome to LQ!


So you've shown us your need! What's your deed?

We will aid you when you help yourself to a solution. Provide us with what you have attempted and then maybe someone will be able to assist.

Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook tutorial is designed for beginners who wish to learn the basics of shell scripting/programming plus introduction to power tools such as awk, sed, etc.

Start out at items 4, 5 and 6 below.



Just a few links to aid you to gaining some understanding;


1 Linux Documentation Project
2 Rute Tutorial & Exposition
3 Linux Command Guide
4 Bash Beginners Guide
5 Bash Reference Manual
6 Advanced Bash-Scripting Guide
7 Linux Newbie Admin Guide
8 LinuxSelfHelp
9 Getting Started with Linux

The above links and others can be found at 'Slackware-Links'. More than just Slackware® links!

srrijith 12-08-2010 08:32 PM

as you said i need a script like .

#! /bin/ksh

function myiostat
{

# Built in commands used in this function
CMD_USR_PATH="/usr/bin"
CMD_PATH="/bin"

.........
[[ $1 = "-E" ]]
then

.......




return

}


does anyone knows to write this type of script. ?

TB0ne 12-08-2010 09:06 PM

Quote:

Originally Posted by srrijith (Post 4185389)
as you said i need a script like .

#! /bin/ksh
function myiostat
{
# Built in commands used in this function
CMD_USR_PATH="/usr/bin"
CMD_PATH="/bin"

.........
[[ $1 = "-E" ]]
then
.......
return
}

does anyone knows to write this type of script. ?

Yes. Now, go back to my first post, and re-read the part about looking up scripting tutorials. Again, we are NOT going to write this script for you, but we will HELP you with it. There are many, many examples to help you along.

chrism01 12-08-2010 11:44 PM

Some scripting tutorials

http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

There's more than enough info there to make you an expert, if you only apply yourself.

srrijith 12-09-2010 12:04 AM

equivalent of iostat -E
 
Hi,
Thanks.....
what is the equivalent of iostat –E in linux ( it display all device error statics).
Linux which am using dosent support iostat -E

prodev05 12-09-2010 12:21 AM

The example script where shown is about functions in scripting. Here is one small example. Its very very simple and easy.

_____________________
#!/bin/bash

cat()
{
echo "I'm into cat"
}
cow()
{
echo "I'm into function cow"
}

cat
cow


exit 0

--------------------

reg

Happy Programming

TB0ne 12-09-2010 07:32 AM

Quote:

Originally Posted by srrijith (Post 4185547)
Hi,
Thanks.....
what is the equivalent of iostat –E in linux ( it display all device error statics).
Linux which am using dosent support iostat -E

You can look at the output of the "dmesg" command for errors, and you can also look in your system log.

Check the man pages for iostat and other utilities in the "sysstat" package.


All times are GMT -5. The time now is 04:39 PM.