Disk report generation problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Disk report generation problem
# 1  
Old 12-13-2011
Disk report generation problem

Hello everyone,

I have a list of inputs as below. My logic is to get the particular powerdisk which matches for ASM disk which means take the major & minor number of each asm disk and matches with powerdisk info then get the particular powerdisk

HTML Code:
$ ls -l /dev/asm_* ---> ASM disk info
crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
crw-r--r-- 1 oracle dba 34, 4 Jun 21 20:06 /dev/asm_disk2
crw-r--r-- 1 oracle dba 34, 5 Jun 21 20:06 /dev/asm_disk3
crw-r--r-- 1 oracle dba 34, 11 Jun 21 20:05 /dev/asm_spfile
HTML Code:
$ ls -l /dev/hdiskpower* --> Powerdisk info
brw-rw---- 1 root system 34, 3 Apr 7 2011 /dev/hdiskpower3
brw-rw---- 1 root system 34, 4 Apr 7 2011 /dev/hdiskpower4
brw-rw---- 1 root system 34, 5 Apr 7 2011 /dev/hdiskpower5
brw-rw---- 1 root system 34, 6 May 16 2011 /dev/hdiskpower6
brw-rw---- 1 root system 34, 7 May 16 2011 /dev/hdiskpower7
brw-rw---- 1 root system 34, 8 May 16 2011 /dev/hdiskpower8
brw-rw---- 1 root system 34, 9 May 16 2011 /dev/hdiskpower9
Below is the code i am using

Code:
============

HTML Code:
ls -l /dev/asm_* > /tmp/input$$
cat /tmp/input$$ | while read line
do
mj=`echo $line | awk '{print $5}'`
mi=`echo $line | awk '{print $6}'`
asm_disk=`echo $line | awk '{print $10}'`
ls -l /dev/hdiskpower* | grep '"'$mj $mi'"' | awk '{print $10}' > /tmp/powerdiskinfo.rpt
done
=============
above code is not working while matching with major and minor number with the hdiskpower disks. Please advice how i can achive it . I need the output as below

HTML Code:
ex:
==
asm_disk1     hdiskpower1
asm_disk2     hdiskpower3
asm_disk3     hdiskpower5
Kindly provide your suggetions and ideas. Thanks !

Regards
Kannan
# 2  
Old 12-13-2011
Where is the "comma" in there?

Code:
ls -l /dev/hdiskpower* | grep '"'$mj $mi'"' | awk '{print $10}' > /tmp/powerdiskinfo.rpt

Try this instead, lets see, paste this instead of the line above and post your results

Code:
ls -l /dev/hdiskpower* | grep "$mj, $mi" | awk '{print $10}' > /tmp/powerdiskinfo.rpt

# 3  
Old 12-13-2011
Try this...
Code:
ls -l /dev/asm_* > asm.txt
ls -l /dev/hdiskpower* > power.txt

awk 'NR==FNR{match($NF,".*/(.*)$",a);x[$5$6]=a[1];next} x[$5$6]{match($NF,".*/(.*)$",a);print x[$5$6],a[1]} ' asm.txt power.txt

--ahamed

Last edited by ahamed101; 12-13-2011 at 10:22 PM..
# 4  
Old 12-13-2011
dude2cool,
Thanks for the reply

"comma" is already there in the variable $mj. Below is the debug output. Problem is grepping the major & minor number from the hdiskpower lists


HTML Code:
+ ls -l /dev/asm_disk1 /dev/asm_disk2 /dev/asm_disk3 /dev/asm_spfile
+ 1> /tmp/input10158174
+ cat /tmp/input10158174
+ read line
+ + echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
+ awk {print $5}
mj=34,
+ + awk {print $6}
+ echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
mi=3
+ + awk {print $10}
+ echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
asm_disk=/dev/asm_disk1
+ ls -l /dev/hdiskpower0 /dev/hdiskpower1 /dev/hdiskpower10 /dev/hdiskpower11 /dev/hdiskpower2 /dev/hdiskpower3 /dev/hdiskpower4 /dev/hdiskpower5 /dev/hdiskpower6 /dev/hdiskpower7 /dev/hdiskpower8 /dev/hdiskpower9
+ grep 34, 3
+ awk {print $10}
+ 1> /tmp/powerdiskinfo.rpt
Below is the error i am getting while grepping the major & minor number

HTML Code:
 
$ ls -l /dev/hdiskpower* |  grep 34, 11
grep: can't open 11
 
need to grep like below.

HTML Code:
ls -l /dev/hdiskpower* |  grep '34, 11'
 
brw-rw----    1 root     system       34, 11 May 16 2011  /dev/hdiskpower11
Please let me know how i can get it. Thanks again !

Regards
Kamal

---------- Post updated at 11:06 AM ---------- Previous update was at 11:03 AM ----------

ahamed101,
Thanks for your reply.

Below is the error i am getting

HTML Code:
awk 'NR==FNR{match($NF,".*/(.*)$",a);x[$5$6]=a[1];next} x[$5$6] {match($NF,".*/(.*)$",a);print x[$5$6],a[1]}' asm.txt power.txt
 syntax error The source line is 1.
 The error context is
                 >>> NR==FNR{match(NF),".*/(.*)$", <<< 
 awk: The statement cannot be correctly parsed.
 The source line is 1.
 syntax error The source line is 1.
 
Regards
Kamal
# 5  
Old 12-13-2011
which is your OS? If solaris, use nawk

--ahamed
# 6  
Old 12-13-2011
Quote:
Originally Posted by ahamed101
which is your OS? If solaris, use nawk

--ahamed
Hi Ahamed,

i am using AIX

Regards
Kamal
# 7  
Old 12-13-2011
See if you have gawk installed...
or try this...
Code:
while read line
do
  arr=( $(echo $line | awk '{print $5, $6, $10}') )
  val=$(grep "${arr[0]} ${arr[1]}" power.txt | awk '{print $NF}')
  test ! -z $val && echo ${arr[2]} $val
done < asm.txt

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Report generation using script

Hi all I have a unix script that generates a report with the following information: uptime, mounted file systems, disk usage (> 90% --> critical, <75%-90%> --> warning, < 75% healthy), Mem usage, CPU usage and load average. But I would like to create one single report containing all this... (5 Replies)
Discussion started by: fretagi
5 Replies

2. UNIX for Beginners Questions & Answers

UNIX cluster disk usage report generation for yesterday & today and email

HI Team, I am trying to create a shell script to generate a yesterday and today report to compare and email in daily basis. can you please help me on the same. #!/bin/bash #Author: ******************* #Description: This script will return the following set of system information: ... (2 Replies)
Discussion started by: Mi4304
2 Replies

3. Shell Programming and Scripting

Report generation using perl script

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f... (4 Replies)
Discussion started by: vel4ever
4 Replies

4. Shell Programming and Scripting

Report generation based on certain conditions

Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box. I have no idea on how to do it as I am a beginner and learning shell scripts. Suppose I have a XML: Code: ... (3 Replies)
Discussion started by: vat1kor
3 Replies

5. Shell Programming and Scripting

File Report Generation

hi all i need to generate a report file that contains the following details of files present in a directory. 1. File name 2.Complete path for each files and directory 3.File size 4.Days older example i have a directory testing that contains sub-directories and some files. i need to make a... (5 Replies)
Discussion started by: yashwantkumar
5 Replies

6. Shell Programming and Scripting

Report Generation with Grep

All, I am pretty new to Unix Environment. I am not sure if my requirement can be accomplished in Unix. I did try searching this forum and others but could not get an answer. Requirement is explained below: I have a set of files in a folder. file1_unload file2_unload file3_unload... (7 Replies)
Discussion started by: bharath.gct
7 Replies

7. Shell Programming and Scripting

Report generation

Hello, I got a requirement in writing a KSH script in unix, please help me out the requirement is there are two folders Folder1 and Folder2 and there are same files in the different folders. like file1,file2 in folder1 and file1 and file2 in folder2. I would like to compare all the similar... (3 Replies)
Discussion started by: gmahesh2k
3 Replies

8. UNIX for Dummies Questions & Answers

report generation

Hello, I got a requirement in writing a sheel script in unix, please help me out the requirement is there are two folders Folder1 and Folder2 and there are same files in the different folders. like file1,file2 in folder1 and file1 and file2 in folder2. I would like to compare all the... (2 Replies)
Discussion started by: gmahesh2k
2 Replies

9. Shell Programming and Scripting

awk- report generation from input file

I have input file with below content: Person: Name: Firstname1 lastname1 Address: 111, Straat City : Hilversum Person: Name : Fistname2 lastname2 Address: 222, street Cit: Bussum Person: Name : Firstname2 lastname3 Address: 333, station straat City: Amsterdam I need... (6 Replies)
Discussion started by: McLan
6 Replies

10. Shell Programming and Scripting

Oracle Report generation

Hi, I am beginner in shell programming.In a shell script i found a call to a script 'runrep25m',which i think is to generate oracle reports?Could anyone help me by providing some details about its usage With Thanks & Regards Dileep (7 Replies)
Discussion started by: DILEEP410
7 Replies
Login or Register to Ask a Question