tags:

views:

13

answers:

2

I need to pull RAM information from several cpuz reports and put them into a csv for reporting reasons. below is an example text file (snipped) which contains the text i want to extract.

I want to extract all the text following the lines beginning with DIMM but only where the next line begins with tab and SMBus address, and going down to nominal voltage. I'd then like to split them into columns (although I only really care about the type, size and max bandwidth)

the resultant csv would have the following columns (and 2 rows in this example)

computer name (from file name), Dimm #, smbus address, memory type, manufacturer, etc.

However I have fallen at the first, extraction phase. I was using sed but fell over at this multiline command:

sed -n -e 'N;/DIMM #\t*[0-9]\r\n\t/,/Nominal/p' cpuz-FHD505.txt

for some reason it only picks up the DIMM #2 block.

what sed statement should I use to just give me the two dimm blocks up to the line including Nominal voltage?

to be honest I'm probably going to give up and write this in python anyway as I'm more familiar, but I'd love to know where I've screwed up on this multiline sed statement.

cpuz output:-

    Chipset
-------------------------------------------------------------------------

Northbridge   Intel i845G rev. A1
Southbridge   Intel 82801DB (ICH4) rev. 01
Memory Type   DDR
Memory Size   1024 MBytes
Memory Frequency  132.9 MHz (1:1)
CAS# latency (CL)  2.0
RAS# to CAS# delay (tRCD) 3
RAS# Precharge (tRP)  3
Cycle Time (tRAS)  6
DRAM Idle Timer   16

Memory SPD
-------------------------------------------------------------------------

DIMM #    1
 SMBus address  0x50
 Memory type  DDR
 Manufacturer (ID) Infineon (C1494E46494E454F)
 Size   512 MBytes
 Max bandwidth  PC2700 (166 MHz)
 Part number  64D64320GU6B      
 Serial number  075ADD21
 Manufacturing date Week 56/Year 03
 Number of banks  2
 Data width  64 bits
 Correction  None
 Registered  no
 Buffered  no
 Nominal Voltage  2.50 Volts
 EPP   no
 XMP   no
JEDEC timings table  CL-tRCD-tRP-tRAS-tRC @ frequency
 JEDEC #1  2.0-3-3-6-n.a. @ 133 MHz
 JEDEC #2  2.5-3-3-7-n.a. @ 166 MHz

DIMM #    2
 SMBus address  0x51
 Memory type  DDR
 Manufacturer (ID) Samsung (CE00000000000000)
 Size   512 MBytes
 Max bandwidth  PC2700 (166 MHz)
 Part number  M3 68L6423ETN-CB3 
 Serial number  060EFC37
 Manufacturing date Week 54/Year 04
 Number of banks  2
 Data width  64 bits
 Correction  None
 Registered  no
 Buffered  no
 Nominal Voltage  2.50 Volts
 EPP   no
 XMP   no
JEDEC timings table  CL-tRCD-tRP-tRAS-tRC @ frequency
 JEDEC #1  2.0-3-3-6-n.a. @ 133 MHz
 JEDEC #2  2.5-3-3-7-n.a. @ 166 MHz

DIMM #    1
SPD registers 
  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
 00 80 08 07 0D 0A 02 40 00 04 60 70 00 82 08 00 01 
 10 0E 04 0C 01 02 20 C0 75 70 00 00 48 30 48 2A 40 
 20 75 75 45 45 00 00 00 00 00 3C 48 30 2D 55 00 00 
 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 
 40 C1 49 4E 46 49 4E 45 4F 08 36 34 44 36 34 33 32 
 50 30 47 55 36 42 20 20 20 20 20 20 01 4A 03 38 07 
 60 5A DD 21 00 00 00 00 00 00 00 00 00 00 00 00 00 
 70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 80 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 90 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 A0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 B0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 C0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 D0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 E0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 F0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

DIMM #    2
SPD registers 
  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
 00 80 08 07 0D 0A 02 40 00 04 60 70 00 82 08 00 01 
 10 0E 04 0C 01 02 20 C0 75 70 00 00 48 30 48 2A 40 
 20 80 80 45 45 00 00 00 00 00 3C 48 30 2D 55 00 00 
 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 27 
 40 CE 00 00 00 00 00 00 00 01 4D 33 20 36 38 4C 36 
 50 34 32 33 45 54 4E 2D 43 42 33 20 4E 45 04 36 06 
 60 0E FC 37 00 58 39 42 36 37 30 30 00 00 00 00 00 
 70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 80 00 03 B2 10 09 19 FF FF FF FF FF 05 12 05 FF FF 
 90 00 03 B2 10 09 39 FF FF FF FF FF 02 20 18 FF FF 
 A0 00 03 B2 10 09 19 FF FF FF FF FF 04 23 54 FF FF 
 B0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 C0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 D0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 E0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
 F0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 


Monitoring
-------------------------------------------------------------------------

Mainboard Model  07E4h (0x00000148 - 0x00024680)

LPCIO
-------------------------------------------------------------------------

LPCIO Vendor  SMSC
LPCIO Vendor ID  0x55
LPCIO Chip ID  0x6D
Config Mode I/O address 0x2E
Config Mode LDN  0x8
Config Mode registers 
  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 
 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 20 6D 01 09 00 04 00 2E 00 00 00 00 00 00 00 00 00 
 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

Hardware Monitors
-------------------------------------------------------------------------

Hardware monitor SMSC EMC6D10X
 Voltage 0 0.00 Volts [0x0] (+1.5V)
 Voltage 1 1.47 Volts [0x7D] (CPU VCORE)
 Voltage 2 3.26 Volts [0xBE] (ATX +3.3V)
 Voltage 3 5.10 Volts [0xC4] (ATX +5V)
 Voltage 4 11.98 Volts [0xBF] (ATX +12V)
 Temperature 0 0°C (32°F) [0x0] (Diode 1)
 Temperature 1 24°C (75°F) [0x18] (Internal)
 Temperature 2 33°C (91°F) [0x21] (Diode 2)
 Fan 0  1455 RPM [0xE7F] (FANIN0)
Register space  SMBus, base address = 0x0FC00
SMBus request  channel 0x0, address 0x2E

output:

DIMM #                          2
        SMBus address           0x51
        Memory type             DDR
        Manufacturer (ID)       Samsung (CE00000000000000)
        Size                    512 MBytes
        Max bandwidth           PC2700 (166 MHz)
        Part number             M3 68L6423ETN-CB3
        Serial number           060EFC37
        Manufacturing date      Week 54/Year 04
        Number of banks         2
        Data width              64 bits
        Correction              None
        Registered              no
        Buffered                no
        Nominal Voltage         2.50 Volts
        EPP                     no
A: 
 awk -vRS="" -F"\n" '/DIMM/&&$2~/SMBus/{ 
   for(i=1;i<=NF;i++) {
     print $i
     # from here, you process the columns you need
   }       
 }' file
ghostdog74
Hi, does this look at the file in terms of lines being columns, then if a line contains the text DIMM and then the second line after that contains SMBus, it will return the following rows until Nominal Voltage? I can't see how the script could know when to stop, and to move into DIMM 2. When I run it on a file (example is cpuz output above) I get nothing returned.
+1  A: 

Give this a try:

sed -n ':a; /^DIMM/,/^[[:blank:]]*Nominal Voltage/ N; /^DIMM/,/[[:blank:]]*Nominal Voltage/ ! d ;/[[:blank:]]*Nominal Voltage/ {/[[:blank:]]*Nominal Voltage/p;d}; ba' cpuz-FHD505.txt
Dennis Williamson
goodness, that worked perfectly, thanks!