- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Sorting Data
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 04:51 PM
тАО01-22-2009 04:51 PM
I have some stats from the wget command I ran last night to troubleshoot a network latency issue. I am attaching the results in an excel sheet.
There are 3 sheets , the two sheets have results and the last sheet has a sample of results the way I want it to present. Is there a way to format the data the way I want it to be presented.
Thanks,
Allan.
Solved! Go to Solution.
- Tags:
- Sort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 05:29 PM
тАО01-22-2009 05:29 PM
Re: Sorting Data
Irrespective of that, this question is posted in an HPUX forum which natively does not grow excel speadsheets.
The original layout of the the data may well influence the right choice of tools to help you solve the problem.
How is the data originally delivered?
How would the output idealy be presented?
Fixed width columns, Comma-Seperated-Values, XML, ...
Please retry a reply with the zip file, or better still a (single) .TXT file showing a good chunk of the original input and desired output?
Hein.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 05:55 PM
тАО01-22-2009 05:55 PM
Re: Sorting Data
There are two script, here is the one which I use from a remote server:
#!/bin/bash
export http_proxy="http://proxy"
export https_proxy="http://proxy"
exec > /tmp/wget_output.txt 2>&1
while true; do
echo -n "> " && date
echo -n "web1 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web1.com/testweb.html 2>&1 |grep user|awk '{print $3}'
echo -n "web2 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web2.com/testweb.html 2>&1 |grep user|awk '{print $3}'
echo -n "web3 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web3.com/testweb.html 2>&1 |grep user|awk '{print $3}'
echo -n "web4 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web4.com/testweb.html 2>&1 |grep user|awk '{print $3}'
echo -n "web5 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web5.com/testweb.html 2>&1 |grep user|awk '{print $3}'
echo -n "web6 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web6.com/testweb.html 2>&1 |grep user|awk '{print $3}'
echo -n "web7 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web7.com/testweb.html 2>&1 |grep user|awk '{print $3}'
sleep 1
done | sed 's/elapsed//'
Here is the one which I used locally on the web server:
#!/bin/bash
exec > /tmp/wget_output.txt 2>&1
while true; do
echo -n "> " && date
echo -n "web1 ";/usr/bin/time wget -q --no-check-certificate -O /dev/null https://web1.com/testweb.html 2>&1 |grep user|awk '{print $3}'
sleep 1
done | sed 's/elapsed//'
Through the two scripts I compare as to what the issue is, through script one I am trying to look for network latency and through script two I am trying to look for apache issues.
I am attaching a word file with the screen shots of the excel sheet that I attached earlier, so you can derive as to which way I want the data to be presented and then I can work on getting a graph from that data.
I am not good at perl but I am wondering if there can a perl script which can make my life easier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 05:58 PM
тАО01-22-2009 05:58 PM
Re: Sorting Data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 09:29 PM
тАО01-22-2009 09:29 PM
SolutionAnd I could not read get to the ZP file with IE 6.0, but it worked with chrome.
>>... testweb.html 2>&1 |grep user|awk '{print $3}'
First a side comment to get that out of my system:
Why pipe from grep to awk?
awk will be happy to do the filter:
.. testweb.html 2>&1 |awk '/user/{print $3}'
More importantly... don't print it just yet.
Stick it in a variable and glue that with a comma (or tab) to a variable for a line being build.
At the end of the while loop, print the whole line with seperators and all!
>> I am attaching a word file with the screen shots
An other side command to get it out of my system. Why hide a PICTURE of a spreadsheet in a non-HPUX WORD format file when the DATA for the spreadsheet is just plain old text? Worse than Useless!
If it is text, present it as text pretty please! Leave Microsoft out of it!
>> two sheets have results and the last sheet has a sample of results the way I want it to present
Unfortunately the example output failed to use real data.
So it is not clear whether the column for 'web1' should come from the first dataset, or the second or should just be 0:00.14 !
But enough nit-picking already!
Here is a starting point.
This is a PERL script to read the second file and produce an excel-ready CSV file like:
#perl test.pl test.txt
Date,web1,web2,web3,web4,web5,web6,web7
Tue Jan 20 16:17:49 PST 2009,0:00.14,0:00.07,0:00.08,0:00.08,0:00.09,0:00.06,0:00.07
Tue Jan 20 16:17:51 PST 2009,0:00.07,0:00.07,0:00.09,0:00.11,0:00.07,0:00.06,0:00.07
-------------------- test.pl ---------
use strict;
use warnings;
my (@values, @names);
my $header = -1;
push @names, 'Date'; # provide first column name
while (<>) {
chomp;
if ( /\s\d\d\d\d$/ ) { # date line has 4 digits at end.
print join (',',@names), "\n" unless $header++;
print join (',',@values), "\n";
@values = ($_); # array becomes just the date line.
}
if ( /^(\S+)\s+(\d+:\d\d\.\d\d)/ ) {
push @names, $1 unless $header;
push @values, $2; # add values to array
}
}
print join (',',@values), "\n"; # last line.
Now if you wanted to COMBINE the data from the two files, then you may want to run the above twice and use the 'join' command, or a csv tool to combine the results.
Or you can augment the script to read two streams and keep them in sync, skipping ahead one or the other to catch up if need be... but that's like 'work'.
If you promiss to just deal with a day at a time or so (86400 sample?) then you could easily use two perl associative array, keyed by time&date to combine the data.
Just fill the arrays and print at the end, The 'remote' array can just have whole lines or read up on 'Arrays of Arrays'.
Before having some nice reader here dive into that, please provide more clear details.
1) a plain TEXT sample for 3 or 4 corresponding seconds for input and desired output.
2) what to do when a timestamp is missing in either file, or when a column value is missing in the remote file.
3) Don't you need an avg, min, max, and time for those as you are processing the data anyway?
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2009 11:06 PM
тАО01-22-2009 11:06 PM
Re: Sorting Data
1) a plain TEXT sample for 3 or 4 corresponding seconds for input and desired output. - attached
2) what to do when a timestamp is missing in either file, or when a column value is missing in the remote file. - no need to deal with this condition
3) Don't you need an avg, min, max, and time for those as you are processing the data anyway? - not really needed but if its relatively simple then yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 04:46 AM
тАО01-23-2009 04:46 AM
Re: Sorting Data
If that's the case, then perl script I first publishes already solved the problem.
You can let it loose on both inputs.
Here is is again with a TAB as seperator, and collecting MAX values as you go, and with indent spaces in the reply.
( Any more bells and wissles is work... send money first! ;-)
Use as: # perl test.pl test.txt > test.tsv
------------------- test.pl -------------
use strict;
use warnings;
my $seperator = "\t";
my ($i, @values, @names, @max);
my $header = -1;
push @names, 'Date'; # provide first column name
push @max, 'Maximums:';
while (<>) {
chomp;
if ( /\s\d\d\d\d$/ ) { # date line has 4 digits at end.
print join ($seperator,@names), "\n" unless $header++;
print join ($seperator,@values), "\n";
@values = ($_); # array becomes just the date line.
$i = 0;
}
if ( /^(\S+)\s+(\d+:\d\d\.\d\d)/ ) {
if ( $header ) {
$i++;
$max[$i] = $2 if $2 gt $max[$i];
} else {
push @max, $2;
push @names, $1;
}
push @values, $2;
}
}
print join ($seperator,@values), "\n";
print join ($seperator,@max), "\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 02:43 PM
тАО01-23-2009 02:43 PM
Re: Sorting Data
Thanks so much Hein, I have assigned 10 points each for your posts.
Allan