Käynnissä

UNIX Hardware Data Collection Script

I have posted a script below that needs to be improved to do the following sequence of events:

1. From one central sever, read the first ServerName/HostName from a text file that contains 100 server names

2. Log into that machine at the root

3. Determine the UNIX Operating System of the server (AIX, Linux, HP-UX, Sun)

4. Based on the Operating System capture the following command output to a text file named after the server being scanned.

a. AIX commands: uname -n, lsdev -Cc processor, lparstat -i, lsattr -El "proc0", prtconf, ps -ef, lslpp -l

b. Linux commands: uname -n, cat /proc/cpuinfo, vmstat, ps -ef, rpm - qa, cat /proc/devices, ps aux,

c. HP-UX commands: uname -n, usr/sbin/ioscan -fnC processor, /usr/sbin/ioscan -fnkC processor, vparstatus, swlist

d. Sun commands: uname -n, psrinfo -v, psrinfo -pv, prtconf -vpPD | grep i- "sparc", prtdiag, pkginfo -i, ps -ef, ps aux

5. Move to the next server in # 1 and loop thru the list

Additional Requirements:

1. Error handling

2. Summary Text file of # of servers in list, number logged into successfully, etc

3. This script assumes that the admin running it has root access and credentials to all servers in the list

Original Script:

#!/bin/sh

###############################

# [url removed, login to view]

# v1

#

# OS: Linux, AIX, HP-UX, SunOS

###############################

## Global variables

#PATH=/tmp/Audit/

PATH=./

FILENAME=${PATH}-Audit_UNIX-`uname -n`.txt

#mkdir -p $PATH

touch $FILENAME

## Print header to file

echo "============================================" >>$FILENAME

echo "= DATE : "`date` >>$FILENAME

echo "= HOSTNAME : "`uname -n` >>$FILENAME

echo "= SYSTEM : "`uname -a` >>$FILENAME

echo "= OS : "`uname -s` >>$FILENAME

echo "= UPTIME : "`uptime` >>$FILENAME

echo "============================================" >>$FILENAME

echo >>$FILENAME

if [ "`uname -s`" = "Linux" ];

then

echo "============ " >>$FILENAME

echo "= CPU : " >>$FILENAME

cat /proc/cpuinfo >> $FILENAME

echo "============ " >>$FILENAME

echo "= DEVICES : " >>$FILENAME

cat /proc/devices >> $FILENAME

echo "============" >>$FILENAME

echo "= PROCESS : " >>$FILENAME

ps aux >> $FILENAME

echo "============" >>$FILENAME

echo "= SOFTWARE : " >>$FILENAME

rpm -qa --queryformat "%{INSTALLTIME:date} - %{NAME} - %{VERSION} - % {DISTRIBUTION} - % {LICENSE}\n" | sort -n >> $FILENAME

echo "============" >>$FILENAME

echo >> $FILENAME

elif [ "`uname -s`" = "SunOS" ];

then

echo "============ " >>$FILENAME

echo "= CPU : " >>$FILENAME

/usr/platform/`uname -i`/sbin/prtdiag >> $FILENAME

echo "============ " >>$FILENAME

echo "= CPU2 : " >>$FILENAME

psrinfo -v >> $FILENAME

echo "============" >>$FILENAME

echo "= PROCESS : " >>$FILENAME

ps aux >> $FILENAME

echo "============" >>$FILENAME

echo "= SOFTWARE : " >>$FILENAME

pkginfo >> $FILENAME

echo "============" >>$FILENAME

echo >> $FILENAME

elif [ "`uname -s`" = "HP-UX" ];

then

echo "============ " >>$FILENAME

echo "= CPU : " >>$FILENAME

/usr/sbin/ioscan -fnkC processor >> $FILENAME

echo "============ " >>$FILENAME

echo "= CPU2 : " >>$FILENAME

psrinfo -v >> $FILENAME

echo "============" >>$FILENAME

echo "= PROCESS : " >>$FILENAME

ps aux >> $FILENAME

echo "============" >>$FILENAME

echo "= SOFTWARE : " >>$FILENAME

/usr/sbin/swlist >> $FILENAME

echo "============" >>$FILENAME

echo >> $FILENAME

elif [ "`uname -s`" = "AIX" ];

then

echo "============ " >>$FILENAME

echo "= CPU : " >>$FILENAME

echo "= prtconf : " >>$FILENAME

prtconf >> $FILENAME

echo "============ " >>$FILENAME

echo "= CPU : " >>$FILENAME

echo "= lparstat -i : " >>$FILENAME

lparstat -i >> $FILENAME

echo "============ " >>$FILENAME

echo "= pmcycles : " >>$FILENAME

pmcycles >> $FILENAME

echo "============ " >>$FILENAME

echo "= lsdev : " >>$FILENAME

lsdev -Cc processor >> $FILENAME

echo "============ " >>$FILENAME

echo "= lscfg : " >>$FILENAME

lscfg -v >> $FILENAME

echo "============ " >>$FILENAME

echo "= lsmcode : " >>$FILENAME

lsmcode -A >> $FILENAME

echo "============" >>$FILENAME

echo "= PROCESS : " >>$FILENAME

ps aux >> $FILENAME

echo "============" >>$FILENAME

echo "= SOFTWARE : " >>$FILENAME

lslpp –L all >> $FILENAME

echo "============" >>$FILENAME

echo "= LICENSE : " >>$FILENAME

lslicense >> $FILENAME

echo "============" >>$FILENAME

echo >> $FILENAME

else echo "ERROR: OS not found. Stopping."

fi

##FREEBSd

## cpu sysctl [url removed, login to view]

#End.

Taidot: C-ohjelmointi, Linux

Näytä lisää: aix lparstat, unix data collection script, hardware data script, global p, file processor, audit needs, audit file, unix hardware path, linux hardware data, unix hardware script, script uname filename, lparstat linux, hp unix, audit process, unix, unix c, unix admin, sh, sever, script linux, pv, proc, p v, linux script, hw

About the Employer:
( 1 review ) Houston, United States

Projektin tunnus: #475011

Myönnetty käyttäjälle:

smcoder

I can do the script

50 $ USD 2 päivässä
(0 arvostelua)
1.4
polymetr

Hi. I can create this script. I'm ready to start.

30 $ USD 1 päivässä
(0 arvostelua)
0.0

3 freelanceria on tarjonnut keskimäärin 37 $ tähän työhön

saksua

Dear sir/madam I have experience in working in Linux environment, scripting linux shell And very interested in your project. Ready to start immidiately and finish as soon as possible. Please check PM

30 $ USD 1 päivässä
(0 arvostelua)
0.0