| |||
how to read log and display in csv file using perl Posted by jeetu (jeetu), 20 May 2008 Can any one help me writting a program to read log and display in csv file using perl.Following is the Data of Log file. avg-cpu: %user %nice %system %iowait %steal %idle 4.61 0.00 0.31 0.34 0.00 94.75 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn sda 4.26 100.09 77.30 336740 260084 dm-0 12.09 98.94 77.30 332898 260080 dm-1 0.03 0.27 0.00 896 0 top - 12:30:45 up 56 min, 1 user, load average: 0.04, 0.01, 0.09 Tasks: 110 total, 1 running, 109 sleeping, 0 stopped, 0 zombie Cpu(s): 4.6%us, 0.3%sy, 0.0%ni, 94.7%id, 0.3%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 775016k total, 422808k used, 352208k free, 26012k buffers Swap: 1572856k total, 0k used, 1572856k free, 160152k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND Want to write the CSV with following values from the log file. Device:Blk_read/s Blk_wrtn/s time, load average, Tasks: total, running, sleeping, stopped, Cpu(s): us, sy, id, wa, Mem: total, used, free, Swap: total, used, free, cached Posted by KevinAD (KevinAD), 20 May 2008 What have you tried so far? Do you know any perl?Posted by KevinAD (KevinAD), 27 May 2008 Iguess the answer is nothing and no.Posted by zamanfou (zamanfou), 28 May 2008 Very simple.You can do it in many different ways.. 1. dump the data into a variable. 2. clear the data from useless info. or go str8 to regexp stuff. example: if ($data =~ /(Tasks:.*?sleeping)/) { $tasks = $1 } Well, if you dont know any perl, just forget it. You better learn the basics. Posted by jeetu (jeetu), 28 May 2008 well i was able to do it in PHP... it was quite easy....This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| |||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |