Operating System - HP-UX
1752806 Members
5810 Online
108789 Solutions
New Discussion юеВ

Re: Submit you HP-Ux tips and tricks and win easy 10points

 
SOLVED
Go to solution
Krishna Prasad
Trusted Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

When ever you need to name a file that will automatically be generated and not over written use date as an extension.

echo "create filename" > filename.`date +%H%M%S`
Positive Results requires Positive Thinking
Ralph Grothe
Honored Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

In the same catagory falls another nice feature of HP-UX's POSIX shell.

Just like the beloved bash is it capable of doing integer arithmetiks.

A nice goodie that always comes in handy when you have to do some mundane "calculation", say extending filesystems using OnlineJFS.

This is how I do it (say, after I extended the size of the LV to 240 MB)

fsadm -b ((240*1024)) /mount_point

Or, how to do a quick conversion from hex to dec or vice versa (sometimes you need this when tampering with certain kernel tunables

# printf %d\\n 0x1aff
6911
# printf %x\\n 6911
1aff


Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

Oops, I saw that the dollar sign slipped away in my fsadm statement.

Of course, it has to be

fsadm -b $((240*1024)) /mnt
Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

Aliases (Latin literates, shouldn't it be alii?) are always a good way to make life a little easier at the shell (of course you do have to remember them ;-)

Here are some, I usually set in my .*shrc files.

Someday I discovered, that newer HP boxes are delivered with a manifest file where amogst other things the bloody Serial No. (which you always have to know when calling HP support) is stored.
So I made me this alias (it doesn't have to be Perl for a text filter)

alias serial="perl -ane 'print \"\$F[-1]\n\" if /\s+serial\s*number/i' \ /var/opt/ignite/local/manifest/manifest"

Apropos Perl, I always want to have a quick overview of my installed CPAN modules, this alias could help

alias perlmods="perl -MConfig -MFile::Find -e 'find(sub{ print \"\$File::Find::name\\n\" if /\\.pm\$/ },
@Config{qw(installprivlib installsitelib)})'"

Another often needed number is your host's IP

# host identity
alias myip="awk -F= '/^IP_ADDRESS\[0\]/ {print \$2}' /etc/rc.config.d/netconf| sed 's/\\\"//g'"
alias myname="awk -v ip=\$(myip) '\$1==ip {print \$2}' /etc/hosts"
alias mynet="netstat -in|awk -v ip=\$(myip) '\$4==ip {print \$3}'"
alias mydomain='echo `myname`|cut -d. -f2-$NF'

Then one always has to fiddle with PVs, VGs, and LVs,
so these help me

# typeset -f pvs
pvs ()
{
/usr/sbin/vgdisplay -v $* 2>/dev/null | awk '/PV Name/ {print $NF}'
}
# typeset -f dskinfo
dskinfo ()
{
for pv in $(pvs $* | sed 's/dsk/rdsk/');
do
/usr/sbin/diskinfo $pv;
done
}
# alias vgs
alias vgs='vgdisplay 2>/dev/null|awk '\''/VG Name/{print $NF}'\'''
# typeset -f lvs
lvs ()
{
/usr/sbin/vgdisplay -v $* 2>/dev/null | awk '/LV Name/ {print $NF}'
}

So I can say

# dskinfo $(pvs vg01) | head
SCSI describe of /dev/rdsk/c1t6d0:
vendor: SEAGATE
product id: ST336704LC
type: direct access
size: 35566480 Kbytes
bytes per sector: 512
SCSI describe of /dev/rdsk/c2t6d0:
vendor: SEAGATE
product id: ST336704LC
type: direct access

# lvs vg00
/dev/vg00/lvol1
/dev/vg00/lvol2
/dev/vg00/lvol3
/dev/vg00/lvol4
/dev/vg00/lvol5
/dev/vg00/lvol6
/dev/vg00/lvol7
/dev/vg00/lvol8
/dev/vg00/gnu
/dev/vg00/lvol10
/dev/vg00/lvol11
/dev/vg00/arch_b13
/dev/vg00/zoo
/dev/vg00/lvol12


Madness, thy name is system administration
Mark Mitchell
Trusted Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

I just used this, but it doesnt seem to be well known that pvlinks can be used to load balence and increase performance

PV links are for redundancy but can be used to load balence. If you do a vgdisplay -v on a vg you will see 2 addresses for the disk. The first is used as a primary and the second is backup. If you vgreduce the first address
"vgreduce /dev/dsk/c10/t1/d0 vg02"
the second address becomes the primary. The next step is to vgextend the same disk back
"vgetend /dev/dsk/c10/t1/d0 vg02"
So now the old primary is the backup pvlink. I use this to force single contoler units to use both controlers by doing this to half of the disks. That way there is still redundance if either controler fails but performance is increased if you know where to split the disks.
Obiously on a striped system this is a no-brainer

Mike Hassell
Respected Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

Hello All,

All I have to offer is a neat way to ensure a tape is actually inserted in the DDS drive before you kick off your make_tape_recovery. See attached for actual script. Modify it to fit your needs and create a no_tape_msg flat file that contains a generic message that requests that operators place a tape in the drive. This way you feel confident that your make_tape_recovery at least has a tape in the drive to work with and if it doesn't you can make yourself and others aware of this fact.

The only other thing I can offer is my favorite telnet proggie for Windows and it's free!

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

-Mike
The network is the computer, yeah I stole it from Sun, so what?
Sudalaimani
Frequent Advisor

Re: Submit you HP-Ux tips and tricks and win easy 10points

Hi,

How abouth this tips,

A. Shared memory Check

1. # ipcs -ma
2. #ipcs -mob

B. The tools such as "cleanup" to reclaim sum spaces in cleaning the superseed patches.

1. Download & install the utility from the patch PHCO_24347 (11.00) & PHCO_24630 (11i)
2. This will also install "show_patches" & "check_patches" utility

refer man cleanup, show_patches, check_patches for further help after installing the patches, which DON'T NEED a REBOOT.

FYI

Sudalaimani




A Long Journey Starts with Single Foot Step
Kurtkarl
Frequent Advisor

Re: Submit you HP-Ux tips and tricks and win easy 10points

* Changing filenames from lowercase to uppercase:
- #! /bin/csh
for x (`ls`)
set y = `ls $x | tr a-z A-Z`
mv $x $y
end

Joey
Just starting to learn thru this forum
Kurtkarl
Frequent Advisor

Re: Submit you HP-Ux tips and tricks and win easy 10points

* Posting system information via html
- download ???nickel.tar??? at ftp://contrib:9unsupp8@hprc.external.hp.com/sysadmin/inventory
- untar nickel.tar
- run ./nickel
note: this will get all system
information and will save (default)
on /tmp
- create a cronjob
ex. 03 06 * * * /opt/contrib/bin/nickel
-n -o /tmp/tools/System.Info/ >/dev/null 2>&1
note: -o if u want to specify another
output directory
- point your browser to nickel output dir
Just starting to learn thru this forum
H.Merijn Brand (procura
Honored Contributor

Re: Submit you HP-Ux tips and tricks and win easy 10points

Here's a script to always mount the CD the way it should (CDFS vs. ISO-9660 with RR extensions)

modify line 5 with your device and mount point. Have fun.

#!/pro/bin/perl -w

use strict;

my ($cmd, $dev, $mnt) = ("mount", "/dev/cd0", "/cdrom");

sub usage ()
{
print STDERR "Usage: $0 [ ]\n",
" mount CD-ROM on $mnt for ISO-9660 with RockRidge extens
ions\n";
exit;
} # usage

@ARGV == 1 and $ARGV[0] eq "-?" || $ARGV[0] =~ m/^-+help$/ and usage;

sub stop (@)
{
print STDERR @_;
exit 1;
} # stop

@ARGV and $mnt = shift;

$< == 0 or stop "You have to be root to be able to mount\n";
$mnt =~ m:^/: or stop "Mountpoint should be an absolute pathname\n";
-d $mnt or stop "Mountpoint $mnt is not available\n";

if ($^O eq "hpux") {
my $fst = "/etc/pfs_fstab";
$cmd = "pfs_mount";
unless (-s $fst) {
-b $dev or stop "Cannot mount $mnt on $dev, device does not exist\n";
open my $fs, "> /etc/pfs_fstab" or stop "Cannot create $fst: $!";
print $fs "$dev $mnt pfs-rrip xlat=unix 0 0\n";
close $fs;
}
unless (grep m/\bpfsd$/, `ps -e`) {
print STDERR "Starting PFS\n";
system "nohup /usr/sbin/pfs_mountd &";
system "nohup /usr/sbin/pfsd &";
sleep 1;
}
unless (grep m/\bpfsd$/, `ps -e`) {
print STDERR "PFS not running\n";
exit $!;
}
}

$0 =~ m/umount/ and $cmd =~ s/mount/umount/;

if (grep m/^pfs_u?mount:/, qx "$cmd $mnt") {
$cmd =~ s/^pfs_//;
system "$cmd $mnt";
}
Enjoy, Have FUN! H.Merijn