Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Modifying script for another machine

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
lyncks
Asked:
lyncks
  • 4
  • 2
1 Solution
 
fridomCommented:
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
 
lyncksAuthor Commented:
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
 
arnoldCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
lyncksAuthor Commented:
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
 
arnoldCommented:
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
 
lyncksAuthor Commented:
I managed to adjust the old script to the new file (with external help of course :( ).
Thanks for interest.
0
 
lyncksAuthor Commented:
The solution is good, used something else because of the internal procedure
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now