[pstubbs@burpless ~]$ sudo cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0 CTS|DSR|CD
1: uart:unknown port:000002F8 irq:3
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3
[pstubbs@burpless ~]$ cat /dev/ttyS0
cat: /dev/ttyS0: Permission denied
[pstubbs@burpless ~]$ sudo cat /dev/ttyS0
[pstubbs@burpless ~]$ sudo cu -l ttyS0 -9600
Connected.
Monday, August 25, 2008
Using linux as a serial console
Friday, July 11, 2008
find the EBN names for EMC devices in a device group
#!/usr/bin/ksh
PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/proc/bin:/usr/platform/SUNW,Sun-Fire-15000/sbin:/etc/vx/bin:/usr/local/bin:/usr/local/sbin:/usr/storapi/bin
# list the character devices in the given EMC device groups
[[ $# -lt 1 ]] && echo "[FATAL]Must give one or more EMC device groups" && exit 1
[[ $(uname -s) != 'SunOS' ]] && echo "[FATAL]Only works on Solaris" && exit 1
# show the emc device names that correspond to each of the devices in an EMC device group
dev_groups="$@"
# work through the given EMC device groups
for _dev_group in $dev_groups
do
# save the Symmetrix ID of the device group so that we get the right disks later
_sym_enc_id=$(symdg show $_dev_group | grep 'Symmetrix ID' | awk '{print $NF}')
for _sym_dev in $(symdg show $_dev_group | grep 'DEV[0-9]' | awk '{print $3}')
do
# find the disks with both device id and Symmetrix ID that match.
for _rdev in $(syminq -symmids | nawk -v sd=$_sym_dev -v se=$_sym_enc_id '{if (NF>3 && match($(NF-1), "[0-9A-E][0-9A-E][0-9A-E]"sd"[0-9A-E][0-9A-E][0-9A-E]") && $(NF-3) == se ) {print $1; exit}}')
do
_base_dev=${_rdev##*/} # basename $_rdev
_emc_path=$(vxdisk path | grep $_base_dev | awk '{print $2}')
echo $_dev_group $_sym_enc_id $_sym_dev $_emc_path
done
done
done
How to sleep until an hour has elapsed.
# in the first script
# save the current time
awk 'BEGIN { srand(); printf("%d\n", srand()+3610)}' > /tmp/start_time
# in the second script
# sleep until the rest of the hour has passed.
ONE_HOUR_LATER=$(cat /tmp/lstart_time)
SLEEP_TIME=$(awk -v ohl=$ONE_HOUR_LATER 'BEGIN { srand(); printf("%d\n", ohl-srand())}')
sleep $SLEEP_TIME
The trick is that srand will return the seconds since the epoch on it's first call. Yes it's in the man page, but on solaris it seems to be the second call. Beware!
Wednesday, July 09, 2008
Who's logged on when 'w' or 'who' won't work
- HPUX & Solaris
ps -ef | egrep 'pts/[0-9a-z]' | grep -v $$
- AIX (less than perfect, but a start)
ps -efo pid,ppid,user,tty,args | awk '$4!="-" {print}' grep -v $$
I have not idea how to communicate with them once you find them since wall won't work :~(
Tuesday, June 10, 2008
Using korn shell functions with xargs
#!/bin/ksh
function myecho_function
{
echo In myecho_function
echo $@
}
OLDIFS=$IFS
IFS='
'
for line in $(find ~ -type f -print | xargs echo myecho_function)
do
# this will call the function the minumum number times
eval $line
done
IFS=$OLDIFS
Thursday, September 21, 2006
HP/UX kernel building
- cd /stand/build
- Create a new system file from the running kernel.
/usr/lbin/sysadm/system_prep -s /stand/build/system
- Edit the kernel with the planned changes.
vi /stand/build/system
- Build the new kernel.
/usr/sbin/mk_kernel -s /stand/build/system
- Copy the old system and vmunix files so if anything goes wrong, the system can be booted from the old kernel.
cp /stand/system /stand/system.prev
cp /stand/build/system /stand/system
cp /stand/vmunix /stand/vmunix.prev
mv /stand/build/vmunix_test /stand/vmunix - Reboot the system from the new kernel.
shutdown -r
Kernel building on UX 11.xx
- cd /stand/build
- Create a new system file from the running kernel.
/usr/lbin/sysadm/system_prep -s /stand/build/system
- Edit the kernel with the planned changes.
vi /stand/build/system
- Build the new kernel.
/usr/sbin/mk_kernel -s /stand/build/system
- Copy the old system and vmunix files so if anything goes wrong, the system can be booted from the old kernel.
cp /stand/system /stand/system.prev
cp /stand/vmunix /stand/vmunix.prev
rm -rf /stand/dlkm.vmunix.prev
cp -R /stand/dlkm /stand/dlkm.vmunix.prev
cp /stand/build/system /stand/system - Move the new system file and new kernel into place, ready to be used when rebooting the system.
mv /stand/build/system /stand/system
kmupdate /stand/build/vmunix_test - Reboot the system from the new kernel.
shutdown -r
Installing an ignite boot helper
swinstall -s ignite:/swdepot/Ignite/IgniteUX Ignite-UX.MinimumRuntime
/opt/ignite/bin/instl_adm -t <IgniteServerIP>
/opt/ignite/bin/instl_adm -d
vim /etc/opt/ignite/instl_boottab
Itanium systems don't use /etc/opt/ignite/instl_boottab but have to use /etc/bootptab So on such systems edit /etc/bootptab. Then edit /etc/inetd.conf to activate bootps and
YUM update source on whitebox/Centos/RHEL
IPv6 on SLES 9
- The 'IPv6-in-IPv4' tunnel is done by the network interface sit0. It can be configured with the /sbin/ip command as per the Linux IPv6 HOWTO
- You can see the tunnels with /sbin/ip -6 tunnel show
- You can see the IPv6 routing table with /sbin/route -A inet6
SAM log viewer
/usr/sbin/audsys -fand to re-trust it sam and enter trusted mode. The option to 'untrust' a system is in the action menu on most of the applets in the sam area 'Auditing and Security'
/usr/lbin/tsconvert -r
Unix 'tree'
ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-//'
Cache Directory Tagging
Update a system to the stable branch of OpenBSD
#!/bin/sh
export CVS_RSH=/usr/bin/ssh
#export CVSROOT=anoncvs@anoncvs.de.openbsd.org:/cvs
export CVSROOT=anoncvs@anoncvs.no.openbsd.org:/cvs
VERSION=`uname -a | awk
# initial get
cd /usr; cvs checkout -P -rOPENBSD_${VERSION} src
else
# update
cd /usr/src
cvs -q up -rOPENBSD_${VERSION} -Pd
fi
Fast shutdown except when Oracle's running
ps -ef | grep [o]ra || /usr/sbin/reboot -qh; init 0; tail -f /etc/rc.log
To find the processor architecture on HP/UX
- To find the processor architecture on UX
print 'selclass qualifier cpu;info;wait;infolog' | /usr/sbin/cstm | grep 'CPU Module'
- Processor speed
print itick_per_usec/D | adb -k /stand/vmunix /dev/kmem
- How much memory is in my system?
grep Physical /var/adm/syslog/syslog.log
orprint 'memory_installed_in_machine/D' | adb -k /stand/vmunix /dev/kmem | perl -nle '/(\d+)/&print$1*4,"k"'
orprint memory_installed_in_machine/D | adb -k /stand/vmunix /dev/kmem
orprint 'selclass qualifier memory;info;wait;infolog' | /usr/sbin/cstm | grep 'Total Configured'
- What's my system's serial number?
print 'selclass qualifier system;info;wait;infolog' | /usr/sbin/cstm | grep 'System Serial Number'
Profiling a Perl script
export PERL5OPT=-d:Dprof You need to unset PERL5OPT before running profiling a script because that's a perl script too and it will overwrite your tmon.out and wreck the results. Only use PERL5OPT if you can't invoke perl directly with -d:Dprof as with inquest.
Changing the hostname on SLES 9.0
Perl regex to parse out the swinstall.hosts from /.sw/defaults.hosts
Perl regex to parse out the swinstall.hosts from /.sw/defaults.hosts The string can be like this
swinstall.hosts = {ws01 s003 s002 s001 a7altsrv a7server}
or
swinstall.hosts = {
s004
s001sdb1
s003
s002p1
s002
ws01
s001p1
s001
a7server
}
Ie. The code needs to deal with line breaks
undef $/;
open(DH, "</.sw/defaults.hosts") or die "unable to open default.hosts\n";
$file = <dh>;
close(DH);
$file =~ m/
swinstall\.hosts # Match the beginning of the hosts we want
(?:.*?) # followed by a space or not. Minimal match
= # followed by an '='
(?:.*?) # followed by a space or not. Minimal match
{ # followed by the open brace to begin the list of hosts
(.*?) # followed by some characters which are the
# hostnames saved into a back reference
} # followed by the close brace
/six;
print $1 . "\n";
To create a tape SD depot
To create a tape depot
swpackage -x autoselect_dependencies=false -x autoselect_dependencies=false -x media_type=tape -s /swdepot/depot package,r=revision @ /tmp/file.depot
To register and list the depot
swreg -l depot -x run_as_superuser=false /tmp/file.depot
swlist -l fileset -s /tmp/file.depot
To unregister the depot
swreg -l depot -u /tmp/file.depot
xauth, su and sudo with ssh X tunneling
# save the MIT-MAGIC-COOKIE for the current X display to a file (/tmp/xauth.out)
xauth extract /tmp/xauth.out $DISPLAY
# save the DISPLAY variable to a file (remember env is lost)
echo $DISPLAY > /tmp/DISPLAY
# make sure the su'd id can read the files
chmod 666 /tmp/xauth.out /tmp/DISPLAY
# su
su - oracle
# setup a new XAUTHORITY file
export XAUTHORITY=/tmp/xauth
# load DISPLAY
export DISPLAY=$(cat /tmp/DISPLAY)
# Load the MIT-MAGIC-COOKIE for root's display
xauth merge /tmp/xauth.out
# run the X application
/usr/bin/X11/xclock
Or as a single command
xauth extract /tmp/xauth.out $DISPLAY; echo $DISPLAY > /tmp/DISPLAY; \
chmod 666 /tmp/xauth.out /tmp/DISPLAY; su - oracle -c \
"export XAUTHORITY=/tmp/xauth; export DISPLAY=$(cat /tmp/DISPLAY); \
xauth merge /tmp/xauth.out ; /usr/bin/X11/xclock"
HP SmartArray RAID Controller Family config
# remove the old LV (use sam or whatever)
# save the current config details
sautil /dev/ciss4 > /tmp/current_config
# delete all the config on the array
saconfig /dev/ciss4 -D all
# create the new raid
saconfig /dev/ciss4 -R 5 -p 1:0 -p 1:1 -p 1:2 -p 1:3 -p 1:4 -p 1:5 -p 1:8 -p 1:9 -p 1:10 -p 1:11 -p 1:12 -p 1:13 -p 1:14 -p 1:15
ioscan
insf -e
# Create the new LV. Don't forget to allow for largefiles!
Cisco IP accounting info
router(config)# interface
router(config-if)# ip accounting
router(config)# ip accounting-threshold 10000
router# show ip accounting
Accounting can be reset with
router# clear ip accounting
It's best not to leave the accounting configured when it's not needed.
RDP to the console
mstsc /console /v:hostname or IP
YOU server setup notes
To setup a new YOU server start yast2 to do a YOU sync using official credentials which will put all the patches into /var/lib/YaST2/you/mnt/.
If you want to snapshot that directory, it has to be copied/moved to another place and /etc/apache2/conf.d/you_server.conf should be copied and modified share the new location. The YOU server (httpd) should be restarted for the changes to be activated. Use yast2 for this
To tune SCSI cards on HP/UX
Service Menu: Enter command > help scsi
------- SCSI Help -------------------------------------------------------------
SCSI displays the SCSI controller parameters. SCSI is also
used to set parameters for a SCSI controller at a specified path.
These parameters are used by the operating system SCSI driver.
If a parameter is set to Unknown or a path is not in the table,
a firmware suggested SCSI controller parameter is used by the
SCSI driver. The firmware suggested value for the initiator id is 7.
An exception is for the termination. If the SCSI card does not support
SCSI Parameters, then the TERM setting will be displayed as UNKNOWN.
In this case, the termination is not programmatically controlled.
SCSI Display all SCSI controller parms
SCSI
SCSI
SCSI
SCSI
SCSI
SCSI
SCSI DEFAULT Set SCSI devices to use default parms.
or NOLIMIT (where NOLIMIT means use max) Default: max
Short Command for SCSI: SCSI
HP/UX Page Deallocation Table
When bit errors occur in the memory of HP/UX systems the error is logged in the PDT (Page Deallocation Table). To see the PDT boot the system to the BCH (Boot Console Handler), go into the SERvice menu and then PDT. The HP guy said that finding a couple of dozen on older machines is normal and doesn't matter although the table is much smaller on them. The RPs have 3000 slots and the systems of the vintage of D's only have 128.
Service Menu: Enter command > help PDT
---- PDT Help ----------------------------------------------------------------
PDT will display the contents of the Page Deallocation Table.
PDT CLEAR will clear the Page Deallocation Table and then hard
boot the system. The PDT CLEAR command will cause memory to be
reconfigured when the system is rebooted.
PDT Display PDT contents
PDT CLEAR Clear the PDT
NOTE: When the CLEAR command is executed the user is first
queried before proceeding to clear the PDT.
This information is also available from STM (xstm and cstm) (thanks Dave!)
Some HP/UX LVM notes
- To make volume groups by hand
mkdir /dev/vg01 /dev/vg02
/usr/sbin/mknod /dev/vg01/group c 64 0x010000
/usr/sbin/mknod /dev/vg02/group c 64 0x020000 - Create physical volumes
/usr/sbin/pvcreate /dev/rdsk/c5t0d0
/usr/sbin/pvcreate /dev/rdsk/c6t0d0 - Add the disks to the volume groups (remember to make sure the max extents per disk are large enough for future larger disks, it can't be changed in the future)
/usr/sbin/vgcreate -e 15000 /dev/vg01 /dev/dsk/c5t0d0
/usr/sbin/vgcreate -e 15000 /dev/vg02 /dev/dsk/c6t0d0 - Create some logical volumes
/usr/sbin/lvcreate -L 23436 -s y /dev/vg01
/usr/sbin/lvcreate -L 2604 -s y /dev/vg01
/usr/sbin/lvcreate -L 23436 -s y /dev/vg02
/usr/sbin/lvcreate -L 2604 -s y /dev/vg02 - To recreate /etc/lvmtab
mv /etc/lvmtab /etc/lvmtab.old
vgscan -av - To import disks into a volume group with
vgimport -v /dev/vg01 /dev/dsk/c4t5d0 /dev/dsk/c4t12d0
don't worry if you get the disks wrong. vgimport checks the disk to see if they are all in the same LV you might be able to find which disks belong in which VG from strings /etc/lvmtab but only if they've been on that system before. - Net recovery does these things to import VG's after a recovery
/usr/sbin/vgimport -v -m /etc/lvmconf/vg01.mapfile /dev/vg01 /dev/dsk/c3t15d0
/usr/sbin/vgchange -a r vg01
test -d /dev/vg00 && /usr/sbin/vgcfgbackup /dev/vg00
test -d /dev/vg01 && /usr/sbin/vgcfgbackup /dev/vg01 - this will create the map file for use in the above
/usr/sbin/vgexport -p -m /etc/lvmconf/vg01.mapfile /dev/vg01 - if restoring a vg config to a new disk (make sure the SCSI ID is the same)
vgcfgrestore -n /dev//dev/dsk/ then activate the VG
vgchange -a y
Wednesday, September 20, 2006
Calculate pi
Sum this i = 0 -> infinity to calculate pi. It will calculate one Hex digit of pi every iteration.
pi=((4/((8*i)+1))-(2/((8*i)+4)) - (1/((8*i)+5))-(1/((8*i)+6)))/(16^i)
Update initrd
To update the contents of the SLES 9.0 initrd.
mv initrd initrd.gz
gunzip initrd.gz
mount -o loop /tmp/initrd /mnt
Edit /mnt/info as needed
cd /tmp
umount /mnt
gzip -9 initrd
mv initrd.gz initrd
Put the initrd back into place to build the install CD
To build mkcdrec for use in the labs
To build mkcdrec for use in the labs. Get the source RPM and install it onto a SLES system with gcc installed. Install the source RPM, then extract the tar ball under /usr/src/packages/SOURCE.
cd /usr/src/packages/SOURCE
tar xzvf mkCDrec_v0.8.5.tar.gz
cd mkcdrec
Change the file Config.sh with the following
CHECK_BAD_BLOCKS="-c"
EXCLUDE_LIST= Make it what ever you want
AUTODR="y"
INITRDSIZE=8192
LINUX_KERNEL="/boot/vmlinuz"
MAXCDSIZE=700000
Extract mkCDrec_v0.7.9_utils.tar.gz into the mkcdrec directory
cd /usr/src/packages/SOURCE/mkcdrec/
tar xzvf /tmp/mkCDrec_v0.7.9_utils.tar.gz
Fix a crazy scsi disk major number problem
cd /var/opt/mkcdrec/scripts
perl -i.old -pe 's/major=65/major=8/g' clone-dsk.sh make_common.sh restore-fs.sh
Create a source tarball named with the Version: number below
cd /usr/src/packages/SOURCES
tar czvf mkCDrec_v0.8.5_TSD.tar.gz mkcdreci
rm -rf mkcdrec
Alter the SPEC file to mark the build as a custom one
cd /usr/src/packages/SPECS/
vim mkcdrec.spec
Change Version: v0.8.5 to Version: v0.8.5_TSD or something. Here's a diff of the changes I made to get it working
8c8
<> Version: v0.8.5_TSD
90a91
> mkdir -p $RPM_BUILD_ROOT%{_prefix}/utilities
130a132,134
> for fname in `find utilities -type f`; do
> install -m 755 $fname $RPM_BUILD_ROOT%{_prefix}/utilities
> done
182a187
> %{_prefix}/utilities
Then rebuild the binary package
cd /usr/src/packages
rpmbuild -bb SPECS/mkcdrec.spec
The resulting binary backage will be in /usr/src/packages/RPMS/i586/
Friday, May 19, 2006
A SUN E4000: Clock board TOD does not match TOD on any IO board
Tuesday, March 28, 2006
building grubby for SLES9
cc -o grubby grubby.o mount_by_label.o -Wl,-Bstatic -lpopt -Wall -DVERSION=\"3.5.13\"
to make it statically linked, strip it, then copy it to where every it's needed.
recovering from a change in device paths under HP/UX
depot # strings lvmtab
/dev/vg00
wV60?{
/dev/dsk/c2t6d0
/dev/swdepot
wV60@
/dev/dsk/c3t0d0
/dev/tmp
wV60@
/dev/dsk/c3t0d1
The VG 'swdepot' was on /dev/dsk/c3t0d0 and tmp was on /dev/dsk/c3t0d1. To see where they've moved to
depot # ioscan -funC disk
Class I H/W Path Driver S/W State H/W Type Description
=====================================================================
disk 3 8/4.0.0 sdisk CLAIMED DEVICE DGC C2300WDR5
/dev/dsk/c4t0d0 /dev/rdsk/c4t0d0
disk 4 8/4.0.1 sdisk CLAIMED DEVICE DGC C2300WDR5
/dev/dsk/c4t0d1 /dev/rdsk/c4t0d1
disk 0 8/16/5.6.0 sdisk CLAIMED DEVICE SEAGATE ST34573N
/dev/dsk/c2t6d0 /dev/rdsk/c2t6d0
Because the old volume groups are in /etc/lvmtab it needs to be moved aside
depot # mv /etc/lvmtab /etc/lvmtab.OLD
Import the volume groups with
depot # vgimport swdepot /dev/dsk/c4t0d0
depot # vgimport tmp /dev/dsk/c4t0d1
Then activate them with
vgchange -a y swdepot
vgchange -a y tmp
Recreate /etc/lvmtab with vgscan -av and mount them or reboot.
Extending a logical volume on HP/UX
depot_host:user$ sudo lvextend -L 24000 /dev/vg01/lvol1
depot_host:user$ lvdisplay /dev/vg01/lvol1
depot_host:user$ bc
24000*1024
24576000
depot_host:user$ sudo fsadm -F vxfs -b 24576000 /depot
Creating an ignite image for the Itanium.
rcp 10.0.0.102:/opt/ignite/data/scripts/make_sys_image /tmp
init 1
/tmp/make_sys_image -l 2 -s local -m c -c g -n UX1123_0304_64bit.gz
rcp /var/tmp/UX1123_0304_64bit.gz 10.0.0.102:/swdepot/Images
It puts the image in /var/tmp
Lan booting the rx2600 Itanium system
ignite-defaults: ht=ethernet: hn: bf=/opt/ignite/boot/nbp.efi: bs=48
test4: tc=ignite-defaults: ha=00306EF34BAA: sm=255.255.255.0: gw=10.224.0.1: ip=10.224.0.234
test5: tc=ignite-defaults: ha=00306EF3FB21: sm=255.255.255.0: gw=10.224.0.1: ip=10.224.0.235
Here I've added both the cards in a particular system.
booting from an IDE cd-rom on a HP RP3410
sea IPL
doesn't find a bootable disk even when there's a CD in the drive. Just search and boot. The CD is an IDE device so that might be why.
- boot to single user mode (press any key within 10 seconds -> bo pri isl -> interact with ipl yes -> hpux -is)
- mount -a
- touch /var/adm/sw/standalone
- vi /etc/hosts (127.0.0.1 {hostname} loopback
- mv /etc/resolv.conf /etc/resolv.conf.sav
- mv /etc/nsswitch.conf /etc/nsswitch.conf.sav
- /sbin/init.d/hostname start
- /sbin/init.d/net.init start
- /sbin/init.d/net start
- /usr/sbin/swagentd &
Multiple putty keys
"C:\Program Files\PuTTY\pageant.exe" \putty.PPK \labs.PPK
Or similar
HP/UX ntp man page errors
HP B-132 workstations and 10/100 NICs
HP G-Class memory fault code
Cisco unnumbered loopback
SD and NIS
to multisite a VOB
multitool chreplica -host rgyserv /projects/VOB-name
multitool mkreplica -export -fship -work /tmp/vob_sync remote-vob-server:remote-region@/projects/VOB-name
multitool mkreplica -import \
-nc \
-workdir /tmp/vob_sync_x \
-options noauto \
-preserve \
-public -password pass\
-tag /projects/VOB-name \
-vob /data/path/VOB-name.vbs \
-host vob-server.com \
-hpath /data/path/VOB-name.vbs \
-gpath /data/path/VOB-name.vbs \
packetname
remote-host# ct lsvob -long /projects/VOB-name
Cisco router filtering example
config terminal
!
! make sure the DNS is setup
ip domain-name domain.name.com
ip name-server xx.xx.x.xx
!
! for lab-bb
! interface FastEthernet0/0
!
interface ethernet 0
no ip access-group 110 in
no ip access-group 110 out
exit
!
no access-list 110
!
! allow ssh to labgw (192.196.15.5)
access-list 110 permit tcp any host labgw eq 22
access-list 110 deny tcp any any eq 22
!
! allow ftp to ftpserv (192.196.15.6)
access-list 110 permit tcp any host ftpserv eq 21
access-list 110 deny tcp any any eq 21
!
! block rexec
access-list 110 deny tcp any any eq 512
!
! block rlogin
access-list 110 deny tcp any any eq 513
!
!block rcmd
access-list 110 deny tcp any any eq 514
!
!block telnet
access-list 110 deny tcp any any eq 23
!
! allow everything not explicitly denied.
access-list 110 permit ip any any
!
!
interface ethernet 0
ip access-group 110 out
exit
Creating an SD depot for a non-root user
swcopy -s /data/nsg/stuff/SWPackage/Depot/stuff_Alpha.depot @ dsgdepot:/mnt1/depot/NSG/Ergo
swacl -l depot -M user:nlittle:rwit @ dsgdepot:/mnt1/depot/NSG/Stuff
He will have to build his tape depot with the
-x run_as_superuser=true
And then add that to the swcopy command to be able to do things on his own.