Solved

Modifying script for another machine

Posted on 2011-09-23
7
262 Views
Last Modified: 2012-05-12
Hello,

I have some files on a solaris machine that are processed by an "inherited" script ( :D ), and I would really appreciate that someone could help me adjust it for different files on a similar server, new one.

The outcome files should contain one line only with:
1) q,timestamp,server,InapReq,first interrogation succes,first interrogation failed,intermediate interrogation succes,intermediate interrogation failed,final interrogation succes,final interrogation failed, regulated first succes, regulated first failed
2) q,timestamp,server,InapReT,first interrogation average response time,intermediate interrogation average response time, final interrogation average response time, regulated first average response time.


For the old_file attached, the results extracted from databases were:
1)
+-----+---------------------+-------+---------+-------+-------+------+------+-------+-------+
| Res | Time                | NE    | Obj     | FIi   | FIo   | IIi  | IIo  | FRi   | FRo   |
+-----+---------------------+-------+---------+-------+-------+------+------+-------+-------+
| q   | 2011-09-23 11:00:00 |server | InapReq | 21164 | 21164 | 1231 | 1231 | 15654 | 15656 |
| q   | 2011-09-23 11:05:00 |server | InapReq | 21010 | 21006 | 1209 | 1209 | 15782 | 15784 |
| q   | 2011-09-23 11:10:00 |server | InapReq | 20879 | 20881 | 1186 | 1186 | 15512 | 15509 |
| q   | 2011-09-23 11:15:00 |server | InapReq | 21193 | 21191 | 1197 | 1197 | 15252 | 15251 |
| q   | 2011-09-23 11:20:00 |server | InapReq | 21142 | 21143 | 1164 | 1164 | 15397 | 15397 |
| q   | 2011-09-23 11:25:00 |server | InapReq | 20988 | 20988 | 1187 | 1187 | 15835 | 15835 |
| q   | 2011-09-23 11:30:00 |server | InapReq | 21007 | 21007 | 1141 | 1141 | 16058 | 16057 |
| q   | 2011-09-23 11:35:00 |server | InapReq | 20755 | 20754 | 1177 | 1177 | 15908 | 15907 |
+-----+---------------------+-------+---------+-------+-------+------+------+-------+-------+

2)
+-----+---------------------+-------+---------+------+------+------+
| Res | Time                | NE    | Obj     | FI   | II   | FR   |
+-----+---------------------+-------+---------+------+------+------+
| q   | 2011-09-23 11:00:00 |server | InapReT | 6.74 | 6.82 | 4.27 |
| q   | 2011-09-23 11:05:00 |server | InapReT | 6.84 | 6.84 | 4.18 |
| q   | 2011-09-23 11:10:00 |server | InapReT | 6.75 | 6.68 | 4.16 |
| q   | 2011-09-23 11:15:00 |server | InapReT | 6.98 | 6.75 | 4.23 |
| q   | 2011-09-23 11:20:00 |server | InapReT | 7.05 | 6.71 | 4.20 |
| q   | 2011-09-23 11:25:00 |server | InapReT | 6.61 | 6.84 | 4.36 |
| q   | 2011-09-23 11:30:00 |server | InapReT | 6.60 | 6.92 | 4.28 |
| q   | 2011-09-23 11:35:00 |server | InapReT | 6.75 | 6.89 | 4.29 |
+-----+---------------------+-------+---------+------+------+------+

Thank you in advance.       old-script new-file old-file
0
Comment
Question by:lyncks
  • 4
  • 2
7 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 36591900
Check the print lines in the old script around the lines:

      # correct if it was trimmed
      if (n<30)  
      {
            FIInc=int(FIInc*30/n);IIInc=int(IIInc*30/n);FRInc=int(FRInc*30/n)
            FIOut=int(FIOut*30/n);IIOut=int(IIOut*30/n);FROut=int(FROut*30/n)
      }
      # print results
      print "q," ts1 "," host ",InapReq," FIInc ","  FIOut "," IIInc "," IIOut "," FRInc "," FROut>>f1
      print "q," ts1 "," host ",InapReT," int(100*FIART/n)/100 "," int(100*IIART/n)/100 "," int(100*FRART/n)/100>>f2


This is where the output takes place. You do not need more information you just want to have less. So just modifiy it the output you like.

I don't feel it's fair usage to expect that this is done for free from us.
0
 
LVL 1

Author Comment

by:lyncks
ID: 36591983
Hello, you are not right to what you are saying regarding that part of the old script. That part was made for a particular period of 5min where the values were less than 30 ( the period of 5 minutes in real time - as you can see in the first part made in perl). I know where I should modify and it's not there.
I've tried my best over a number of weeks, but this is over my knowledge. I managed to take out the values I need and to add all of them not for 5 minutes as the old script does but I still have values I don't need like hours and dates.
I'll keep trying to get the result and I have all the respect for those that never give up and do like me asking for help.
Thanks for you response but it doesn't help me.
0
 
LVL 77

Accepted Solution

by:
arnold earned 500 total points
ID: 36592443
The current script is at its core a shell script.  Perl is only used to generate a date/time.
nawk does the data extraction/conversion

IMHO it is simpler if the entire script is in perl.
Do you have an option for this data to be inserted into a mysql database or does it have to be processed in memory?

pattern matching and constructing a hash date->time->variable->array of the values.
Row 1: date/column headers
Row 2: units
row 3: time :total
.
.
.
.
row 9
row 3
new date(row1/2 reoccur) every 30 minutes.

i.e. once you get the first two rows out, the pattern repeats and can be broken down by the time/row
/^\s+([0-9:]+)\s+Total/

This is the first step collecting and assembling the information into a manageable access mechanism.


Some more thought has to go into it.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 1

Author Comment

by:lyncks
ID: 36597951
Hello,

Thank you for you response. I kept trying to understand what you told me, I kinda did but I don't know perl at all and have no ideea how to insert into my script the line you gave me.
The script I should modify runs from crontab every 5minutes and generates two files for the last 5minutes, and then another script inserts the fields terminated by "," into database in two tables.
From the databases, using rrdtool grafical statistics are generated.
I can't change the flow. I managed to extract the information I need in this format:

15:23:11,0,0,0,0,0,0,0,0
15:23:21,0,0,0,0,0,0,0,0
15:23:31,0,0,0,0,0,0,0,0
15:23:41,0,0,0,0,0,0,0,0

but this doesn't help me.
0
 
LVL 77

Expert Comment

by:arnold
ID: 36599340
What are you comfortable with?


You can split each line based on the comma.
Using awk the assignment will be from $1 through $9 with $1 being the time while $2-$9 will have the other values.


0
 
LVL 1

Author Comment

by:lyncks
ID: 36718307
I managed to adjust the old script to the new file (with external help of course :( ).
Thanks for interest.
0
 
LVL 1

Author Closing Comment

by:lyncks
ID: 36718377
The solution is good, used something else because of the internal procedure
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Utilizing an array to gracefully append to a list of EmailAddresses
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question