- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- convert in hpux commands, script written in linux ...
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
Forums
Discussions
Discussions
Discussions
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
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
03-14-2008 04:58 AM
03-14-2008 04:58 AM
convert in hpux commands, script written in linux commands
#!/usr/bin/perl -w
## Usage:
## perl osw_vmstat_parse.pl
## where
## The utility will produce an output file in the form of:
## osw_vm_yymmdd_hhmm.txt
## where yymmdd_hhmm is month, day, year, hours taken from the time portion of
## input archive file.
##
##
use Time::Local;
## build hash table of month name to string
%Month = (
"Jan" => 0,
"Feb" => 1,
"Mar" => 2,
"Apr" => 3,
"May" => 4,
"Jun" => 5,
"Jul" => 6,
"Aug" => 7,
"Sep" => 8,
"Oct" => 9,
"Nov" => 10,
"Dec" => 11
);
%MetaColumns = ();
%ReverseColumns = ();
# initialize stuff here
$version = "1.0";
$carlage = 0; ## handy counter
$definedMeta = "FALSE";
$lineCount = 0; ## to store overall "good" lines
if (! $ARGV[0])
{
print "\n";
print "osw_vmstat_parse.pl Version ", $version, " Usage: \n";
print "perl osw_vmstat_parse.pl
print "where
exit 1;
}
$fileName = $ARGV[0];
# will be in this form: hostname.oracle.com_vmstat_07.11.09.1300.dat
# chop up name, grab date
($host, $dummy, $date_part) = split("_", $fileName);
$year = substr($date_part, 0, 2);
$month = substr($date_part, 3, 2);
$day = substr($date_part, 6, 2);
$hours = substr($date_part, 9, 4);
## osw_vm_yymmdd_hhmm.txt
## while we have the values, build output filename
$fileOut = "osw_vm_" . $year . $month . $day . $hours . ".txt";
open(INFILE, $fileName) or die "File ", $fileName, " cannot be opened.\n";
## create output filename from input filename
##
while ($line =
{
# first, chop into array of tokens
@thisline = split(" ", $line);
# grab version of OSW
if ($thisline[1] eq "OSW" )
{
($platform, $dummy, $version, $host) = @thisline; $platform="";
}
# parse out date/time stamp
if ($thisline[0] eq "zzz" )
{
#zzz ***Mon Oct 29 10:01:24 EDT 2007
($junk, $wkday, $month, $mday, $time, $zone, $year) = split(" ", $line);
$junk = $zone; ## just to eliminate spurious warnings
$wkday = substr($wkday, 3);
($hours, $min, $sec) = split(":", $time);
$timeseconds = timelocal($sec, $min, $hours, $mday, $Month{$month}, $year);
}
if ($thisline[0] eq "procs") { }; # do nothing, header thing
if ($thisline[0] eq "r" && $definedMeta eq "FALSE") # col hdrs
{
$colCount = 0;
## save off a "list" of columns, in original order
@columnNames = @thisline;
foreach $column (@thisline)
{
# first the obverse
$MetaColumns{$column} = $colCount;
# then the reverse
$ReverseColumns{$colCount} = $column;
$colCount++;
}
$definedMeta = "TRUE";
}
## now eat first two lines of vmstat output
if ($thisline[0] =~ /^\d+$/ && $thisline[1] =~ /^\d+$/ )
{
$carlage++;
if ($carlage == 3) # ...and the number of the counting shall be three.
{
$bucketNumber = 0;
foreach $bucket (@thisline)
{
$bucketName = $ReverseColumns{$bucketNumber};
push @$bucketName, $bucket;
$bucketNumber++;
}
push @timestamp, $timeseconds;
$carlage = 0; ## reset to a value suitable for carl
$lineCount++; ## bump "good" lines, so we know later
}
}
}
## knock out a text file of stuff
## osw_vm_yymmdd_hhmm.txt
open (TXTOUT, "> $fileOut") or die "Cannot open ", $fileOut, "for writing\n";
print TXTOUT "timestamp ";
foreach $col (@columnNames)
{
print TXTOUT $col, " ";
}
print TXTOUT "\n";
$lines = 0;
while ($lines < $lineCount)
{
print TXTOUT $timestamp[$lines], " ";
foreach $col (@columnNames)
{
print TXTOUT $$col[$lines], " ";
}
print TXTOUT "\n"; ## never forget the linefeed!
$lines++; ## and bump da pointer
}
close TXTOUT;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2008 05:08 AM
03-14-2008 05:08 AM
Re: convert in hpux commands, script written in linux commands
Perl is very portable and the same script should run on Linux and HP-UX just fine.
Have you tried running this script on HP-UX? If so, did you get any errors? If you did get errors it would help immensely if you posted those errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2008 05:11 AM
03-14-2008 05:11 AM
Re: convert in hpux commands, script written in linux commands
Since this is perl, it will work similar to the linux environment.
obvious changes will concern line 1:
#!/usr/bin/perl -w
where you will have to refer to the appropriate location of perl on your hp-ux 11.11 host. (do "which perl" to get the exact path)
However, calls to hp-ux commands may require individual analysis. E.g. vmstat output can be different on Linux compared to the HP-UX environment.
I would suggest that you break the script in smaller modules and try them individually, one by one.
good luck!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2008 12:57 AM
03-15-2008 12:57 AM
Re: convert in hpux commands, script written in linux commands
It is giving following error:
$ perl osw_vmstat.pl
Unrecognized character \xCD at osw_vmstat.pl line 18.
'which perl' gives following path:
$ which perl
/usr/bin/perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2008 09:11 AM
03-15-2008 09:11 AM
Re: convert in hpux commands, script written in linux commands
Looks like that source is in UNICODE.
Paste it into a notepad, save as ANSI TEXT.
Open the TEXT file, cut & paste from there.
Ah... the seimicolons stay.
And the program works... or at least prints the help text when no args ar provided.
fwiw... is is not the pretties perl / parsin I've seen. Hard to read with constructs like:
"if ($thisline[0] eq "procs") { }; # do nothing, header thing"
I guess it serves as documentation, but why?
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2008 12:32 PM
03-15-2008 12:32 PM
Re: convert in hpux commands, script written in linux commands
Hein is right, your Perl script was probably written on a Windows machine and used
the encoding 'utf-8'.
Certain editors (in particular on win32) may
add a UTF-8 Byte Order Marker (BOM:
http://www.unicode.org/faq/utf_bom.html#BOM)
at the beginning of the file. It creates a
situation where BOM appears past the
beginning of the file...
To test it further:
# hexdump -C osw_vmstat_parse.pl (Linux)
or
# od -t a osw_vmstat_parse.pl (HP-UX)
Your script is not wrong (albeit not
the best coding technique). Encoding is.
Cheers,
VK2COT