Operating System - Linux
1748122 Members
3537 Online
108758 Solutions
New Discussion

Re: shell script help in RHEL 5.4

 
rajesh73
Super Advisor

shell script help in RHEL 5.4

Hi ,

 

i need to collect the below system information , please find the commands and provide the shell script.

 

commands

df

crontab

vg details

sendmail

dmesg

ioscan

free -g

top

sar

vmstat

iostat

ifconfig -a

uname -m

uanme -r

runlevel

rpm -ql pakage

 

 

the above commands we need to collect ,each and every server. we need the final output    testserver.tar.qz

2 REPLIES 2
Patrick Wallek
Honored Contributor

Re: shell script help in RHEL 5.4

Something like this maybe:

 

# cat script.sh

#!/bin/bash

HOST=$(hostname)

mkdir /tmp/${HOST}-data

cd /tmp/${HOST}-data

df > ${HOST}-df

crontab -l > ${HOST}-crontab

vgdisplay -v > ${HOST}-vgdisplay

cp /etc/mail/sendmail.cf ${HOST}-sendmail.cf

dmesg > ${HOST}-dmesg

free -g > ${HOST}-free

top -n 1 > ${HOST}-top

vmstat > ${HOST}-vmstat

iostat > ${HOST}-iostat

ifconfig -a > ${HOST}-ifconfig

uname -m > ${HOST}-uname-m

uname -r > ${HOST}-uname-r

runlevel > ${HOST}-runlevel

tar -cvzf ${HOST}.tar.gz ${HOST}-*

 

There are a couple of commands that you need to look at and determine exactly what you need.

 

For example the 'sar' command has a lot of options.  Which ones do you want output from?

 

The 'rpm - ql' command requires a package  name as an option.  Which packages do you want information on?

rajesh73
Super Advisor

Re: shell script help in RHEL 5.4

Hi patrick,

thanks you very much for providing the script.