Archive for the ·

UNIX

· Category...

fuser trick

Comments Off

By default, the fuser command lists the process numbers of local processes and a letter indicating how the process uses the file:

c Uses the file as the current directory.
e Uses the file as a program’s executable object.
r Uses the file as the root directory.
s Uses the file as a shared library (or other loadable object).

Well, this letter could cause issue when you try to put it in a script or want to show all processes in one line.

 

Solution:

 

Redirecting stderr to /dev/null will do the magic trick!

 

myuserid [aixlpar1] /home/myuserid: fuser /
/: 1c 2425058c 2556030c 3080396c 3145910r 3539102c 3801206c 3866754c 3997908c 4063362c 4391064c 4522132c 4587666c 4653084c 4718782c 4849740r 5112010r 5373966r 5439664r 5701674r 5832948r 6029330c 6226112c 6553804c 6619256r 7078116r 7143446r 7209010r 7536878r 7995574r 8126552r 8519692r 9043994r 10485792r 10551534r 10682438r 11468876r 11731008r 16253040r 21037254r 21102810r 21233818r 21364978r 21430368r 21495976r 21758124r 22413370r 24510488r 24772824r 25034896r 25231476r 26345490c 27131918c 28246210c
myuserid [aixlpar1] /home/myuserid: fuser / 2>/dev/null
 1 2425058 2556030 3080396 3145910 3539102 3801206 3866754 3997908 4063362 4391064 4522132 4587666 4653084 4718782 4849740 5112010 5373966 5439664 5701674 5832948 6029330 6226112 6553804 6619256 7078116 7143446 7209010 7536878 7995574 8126552 8519692 9043994 10485792 10551534 10682438 11468880 11731008 16253040 18022610 20774944 20840492 21037254 21102810 21233818 21364978 21430368 21495976 21758124 22413370 24510488 24772824 25034896 25231476 25493754 26345490 27131918 28246210 29032688 32768174myuserid [aixlpar1] /home/myuserid: s -o pid,args -p "$(fuser / 2>/dev/null)"

One liner to show the processes names:

myuserid [aixlpar1] /home/myuserid: ps -o pid,args -p "$(fuser / 2>/dev/null)"
 PID COMMAND
 1 /etc/init
 2425058 /usr/sbin/biod 6
 2556030 /usr/sbin/syncd 60
 3080396 /usr/ccs/bin/shlap64
 3145910 /usr/lib/errdemon
 3539102 /usr/sbin/srcmstr
 3801206 /bin/ksh /opt/itlm/tlmagent
 3866754 /opt/itlm/tlmagent.bin
 3997908 /usr/DynamicLinkManager/bin/dlmmgr
 4063362 /usr/sbin/xntpd
 4391064 /usr/sbin/inetd
 4522132 /usr/sbin/hostmibd
 4587666 /usr/sbin/snmpmibd
 4653084 /usr/sbin/aixmibd
 4718782 /usr/sbin/sshd
 4849740 /usr/sbin/rsct/bin/IBM.WLMRMd
 5112010 /usr/sbin/rsct/bin/IBM.DRMd
 5373966 /usr/sbin/rsct/bin/IBM.ServiceRMd
 5439664 /usr/sbin/rsct/bin/rmcd -a IBM.LPCommands -r
 5701674 /usr/sbin/rsct/bin/vac8/IBM.CSMAgentRMd
 5832948 /usr/sbin/cron
 6029330 /usr/lpp/diagnostics/bin/diagd
 6226112 /opt/hitachi/HNTRLib2/bin/hntr2mon -d
 6553804 /usr/sbin/getty /dev/console
 6619256 jpcah -d /opt/jp1pc/bin/action
 7078116 ./cirba-snmpd -P 3161 -f
 7143446 /esm/bin/aix-ppc64/esmd -fv
 7209010 agtu/jpcsto -d /opt/jp1pc/agtu/store
 7536878 /usr/HDVM/HBaseAgent/agent/bin/hbsa_service
 7995574 /opt/opsware/agent/bin/python /opt/opsware/agent/pylibs/shadowbot/daemonbot.pyc --conf /etc/opt/opsware/agent/agent.args
 8126552 /opt/opsware/agent/bin/python /opt/opsware/agent/pylibs/shadowbot/daemonbot.pyc --conf /etc/opt/opsware/agent/agent.args
 8519692 /usr/sbin/rsct/bin/IBM.ConfigRMd
 9043994 agte/jpcsto -d /opt/jp1pc/agte/store
10485792 jpcagtu -d /opt/jp1pc/agtu/agent
10551534 ./jpc_hostutil /opt/jp1pc/agtu/jpc_hostutil_ off
10682438 jpcagte -d /opt/jp1pc/agte/agent
11731008 jpcstatsvr -d /opt/jp1pc/bin/statsvr
16253040 -ksh
21037254 /usr/opt/itm/aix526/ux/bin/kuxagent
21102810 /usr/opt/itm/aix526/ux/bin/nfs_stat AIX 30 9
21233818 /usr/opt/itm/aix526/ux/bin/kux_vmstat 30 6
21364978 /usr/opt/itm/aix526/ux/bin/mount_stat 12
21430368 /usr/opt/itm/aix526/ul/bin/kulagent
21495976 /usr/opt/itm/aix523/px/bin/aixDataProvider-61
21758124 /usr/opt/itm/aix526/ux/bin/stat_daemon 13
22413370 /usr/opt/itm/aix526/ux/bin/kcawd
24510488 /usr/bin/topas_nmon -fT -I 0.05 -s120 -c710 -m /monitoring/logs/nmon -youtput_dir=/monitoring/logs/nmon/aixlpar1 -ystart_time=00:05:01,Jul08,2012
24772824 /usr/opt/itm/aix526/ux/bin/ifstat 30 7
25034896 /bin/iostat -ds 30
25231476 /usr/opt/itm/aix523/px/bin/kpxagent
26345490 sshd: myuserid [priv]
27131918 sshd: myuserid@pts/0
28246210 /usr/sbin/syslogd

 

Comments Off

Redefining TSM Library and Drives for UNIX OS

Comments Off

Question

Frequently when hardware or firmware has changed it is necessary to remove the tape library and drive definitions from the (IBM Tivoli Storage Manager) TSM Server, then re-define them.

Cause

Sometimes there are specific errors, such as:
ANR0523W Transaction failed – error on output storage device
ANR8300E I/O error on library (OP=xx, CC=xx, KEY=xx, ASC=xx, ASCQ=xx, SENSE=xx)
ANR8301E I/O Error on library
ANR8355E I/O error reading label for volume NNNNNN on drive XXXXX
ANR8359E Media fault detected on volume NNNNNN in drive XXXXX
ANR8441E Initialization failed for SCSI library
ANR8779E Unable to open drive XXXXX, error number=ZZZ
ANR8944E Hardware or media error on drive
ANR8963E Unable to find path to match the serial number defined for drive

Frequently the TSM Server can automatically rediscover devices when using “SANDISCOVERY ON” or by using “UPDATE PATH” with “AUTODETECT=YES” to refresh the values.

However, there are times when that may not be successful. For example, if a tape drive, tape library, fibre/SCSI HBA, or SAN has experienced changes (such as hardware, firmware or device drivers) it may require rebuilding the TSM “special files” to re-establish connectivity to the library and drives. To rebuild the “special files,” we must delete and re-define the hardware devices to the TSM Server (UPDATE does not rebuild).

 

Answer

Perform these tasks in this sequence to totally re-define the tape devices to TSM. These steps should be taken only if attempts to update the devices/paths using the autodetect features have failed:
1) Before deleting anything, gather the output from these commands, so you can use the same naming conventions when re-defining the tape devices:
  QUERY STATUS (get SERVERNAME value for “<tsm_server>”)
  QUERY DEVCLASS
  QUERY LIBRARY FORMAT=DETAIL
  QUERY DRIVE FORMAT=DETAIL
  QUERY PATH FORMAT=DETAIL

2) Run the appropriate OS command to produce a list of the configured HW ‘special file’ device names.
      AIX   ==>   lsdev -Cc tape           (-or- 'cfgmgr')
                  lsdev -Cc adsmtape       (for TSM devices)
                  lsdev -Cc library
   Solaris  ==>   ls -l /dev/rmt/*st       (-or- 'sysdef')
                  ls -l /dev/rmt/*smc
     HP-UX  ==>   /usr/sbin/ioscan -funC tape
                  (-or  'ioscan -kfn')
     Linux  ==>   ls -l /dev/IBM*
                  ls -l /dev/tsmscsi/*
                  (-or- 'more /etc/sysconfig/hwconf')

If the tape devices are not defined to the OS, please work with your OS or SCSI/SAN hardware support to configure them. Until the OS can use the drives (can write to them, for example using ‘tar’ or ‘dd’) the tape devices cannot be defined to TSM.

3) From the ‘/dev’ directory, write down the OS-level device definitions for the library and drives:
                  AIX     Linux         Solaris    HP-UX
  TSM Drives      mt#     tsmscsi/mt#   rmt/#      rmt/tsmmt#
  IBM Drives      rmt#    IBMtape#      rmt/#st    rmt/#m
  TSM Library     lb#     tsmscsi/lb#   rmt/#lb    tsmchgr#
  358x Library    smc#    IBMchanger#   rmt/#smc   rmt/#chng
  3494 Library    lmcp#   3494lib       libmgrc#   libmgrc#

4a) First the drives and drive paths must be deleted. From a TSM Server admin commandline, for all the drives:
   DELETE PATH  <tsm_server>  <drive_name>  SRCTYPE=SERVER  DESTTYPE=DRIVE  LIBRARY=<library_name>

4b) Then delete all the TSM drive definitions:
   DELETE DRIVE  <library_name>  <drive_name>

5a) Next, delete the path for the tape library:
   DELETE PATH  <tsm_server>  <library_name>  SRCTYPE=SERVER  DESTTYPE=LIBR

5b) And finally delete the TSM library definition:
   DELETE LIBRARY  <library_name>

If the OS cannot access the tape drives at this point, stop. Check hardware, device drivers, update firmware, swap cables; consider power-cycling the tape library then deleting and re-defining to the OS. There is no point attempting to get TSM to write to the devices if they are not recognized by the OS; work with OS and/or hardware vendors to resolve HW issues before proceeding.

6a) Now the tape library and library path can be re-defined. Use the TSM QUERY outputs from “Step 1″ as a guide for the library name and LIBTYPE; no additional parameters are necessary in the syntax below. Redefine the library:
   DEFINE LIBRARY  <library_name>  LIBTYPE=<library_type>  SERIAL=AUTODETECT

Note: If this TSM Server is hosting a tape library for other systems, for example any “TSM Server Library Clients” or “TSM Storage Agents” then you also need “SHARED=YES” on the “DEFINE LIBRARY”.

6b) Redefine the path to the library. For SCSI libraries, confirm the DEVICE value matches the latest OS-level info gathered from “Step 2″. For 3494, ACSLS, and other types of libraries using software configuration files, use the previous values from “Step 1″ to redefine the DEVICE or ACSID, and so on:
   DEFINE PATH  <tsm_server>  <library_name>  SRCTYPE=SERVER  DESTTYPE=LIBRARY  DEVICE=</dev/lb#>

7a) Redefine the drives and drive paths. Redefine all the drives using names from “Step 1″ for example:
   DEFINE DRIVE  <library_name>  <drive_name>  SERIAL=AUTODETECT  ELEMENT=AUTODETECT

7b) Redefine paths to all drives, using the OS-level info gathered from “Step 2″ for the DEVICE values. Keep in mind the OS-level DEVICE values may have changed since the they were previously defined.
   DEFINE PATH  <tsm_server>  <drive_name>  SRCTYPE=SERVER  DESTTYPE=DRIVE  LIBRARY=<library_name>  DEVICE=</dev/mt#>

Note: If this TSM Server is hosting a tape library for other systems, for example any “TSM Server Library Clients” or “TSM Storage Agents” then in addition to the “TSM Server Library Manager” DRIVE PATH, you also need to define a new PATH for each drive for those systems, substituting the SERVERNAME (shown by “Q SERVER”) for the value of “<tsm_server>” and the local DEVICE value for the drive as seen by that other system.

8) Verify the library, drives, and paths are online:
  QUERY LIBRARY  <library_name>  FORMAT=DETAIL
  QUERY DRIVE   <library_name>  *  FORMAT=DETAIL
  QUERY PATH  *  *  FORMAT=DETAIL

9) Since the library is “new” to TSM, the volumes must be checked in again to re-create the inventory (AUDIT LIBRARY does not CHECKIN). Use *this* sequence, first SCRATCH, then PRIVATE:
  CHECKIN LIBVOL  <library>  SEARCH=Y STATUS=SCR CHECKL=BARC
  CHECKIN LIBVOL  <library>  SEARCH=Y STATUS=PRIV CHECKL=BARC

NOTE: For ACSLS libraries, use “CHECKLABEL=NO” on the CHECKIN commands, because “CHECKLABEL=BARCODE” is not supported for an ACSLS Library.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

If that doesn’t resolve the issue, the tape drive problem seems beyond the control of the TSM Server (software). Review the output from the OS-level logs for additional hardware error information:
                          Remove OS    Install
      OS   Diagnostics    Devices      OS Devices
 -------   ------------   ---------    ------------
     AIX   errpt –a       rmdev        cfgmgr
   Linux   dmesg                       /dev/MAKEDEV
 Solaris   mbin/prtdiag   rem_drv      drvconfig
   HP-UX   dmesg          rmsf         insf -e

If you cannot reach HW support immediately, you could take the additional action of power-cycling in this order:
1) Tape library.
2) SAN switch (if any).
3) Consider updating to latest device drivers and/or firmware.
4) Halt TSM and reboot system with TSM Server.
5) Re-define the tape device to the OS (see commands above).
6) If tape device definitions have changed, DELETE & re-DEFINE to TSM.

And that is all we can do from a software perspective, if errors persist it points to an issue at a layer which TSM cannot repair.

 

 

Comments Off

Use screen for Session Management- No worries for losting your shell connection.

Comments Off

Using Screen for Session Management

Lost your shell connection? Need multiple shell sessions?

You are logged into your remote server via SSH and happily plucking along at your keyboard and then it happens. Suddenly, the characters stop moving and then you get the dreaded “Connection Closed” message. You have just lost your session. You were halfway through some task and now you have to start over. Ugh. Well you can prevent this from happening by using screen. The screen tool can not only save you from disconnection disasters, but it also can increase your productivity by using multiple windows within one SSH session.

Download screen utility for AIX here.

Full tutorial here.

Comments Off