saposcol shared memory

saposcol is one of at least two components necessary for collecting SAP performance statistics; e.g. those that can be viewed in ST03G and STAD.

On at least two occasions saposcol has failed to start with a shared memory error, e.g.

49>saposcol -l
-l
'Can't create shared memory' 

A couple of quick checks show that the collector is not running, e.g.

51> ps -ef | grep saposcol
eq1adm   22300 22103  0 08:52 pts/2    00:00:00 grep saposcol

51> saposcol -s
**************************************************************
Collector Versions :
  running : COLL 21.03 720 - v2.24, AMD/Intel x86_64 with Linux
  dialog  : COLL 20.95 701 - v2.00, AMD/Intel x86_64 with Linux, 2007/02/16
Shared Memory       : attached
Number of records   : 5991
Active Flag         : active (01)
Operating System    : Linux qa6 2.6.18-164.11.1.el5 #1 SMP Wed Jan 6
Collector PID       : 17607 (000044C7)
Collector           : not running (process ID not found).
Start time coll.    : Wed Sep 26 11:08:45 2012

Current Time        : Thu Feb  7 08:52:08 2013

Last write access   : Thu Dec 27 11:07:18 2012

Last Read  Access   : Thu Dec 27 11:06:51 2012

Collection Interval : 60 sec (next delay).
Collection Interval : 60 sec (last ).
Status              : read
Collect Details     : required
Refresh             : required

Header Extention Structure
Number of x-header      Records : 1
Number of Communication Records : 60
Number of free Com.     Records : 60
Resulting offset to 1.data rec. : 61

Trace level             : 2

Collector in IDLE - mode ? : NO
  become idle after 300 sec without read access.
  Length of Idle Interval  : 60 sec
  Length of norm.Interval  : 60 sec
**************************************************************

Check shared memory for the saposcol key which will contain 4dbe.
Note that the segment will be owned by root (if it exists).

54> ipcs -ma | grep 4dbe
0x00004dbe 1769734165 root      777        635394     0

Run saposcol in dialog mode to cleanup shared memory (kill, clean, leave, quit):

55> saposcol -d
*****************************************************************************
* This is Saposcol Version COLL 20.95 701 - v2.00, AMD/Intel x86_64 with Linux, 2007/02/16
* Please use 'help' to see the usage.
*****************************************************************************

Collector > kill
kill
08:53:21 07.02.2013   LOG:  check_remap: Switched to new shared memory.
PID 0 not found. Collecting process not running ?

Setting Stop Flag :
08:53:36 07.02.2013 WARNING: WaitFree: could not set new shared memory status after 15 sec
08:53:36 07.02.2013   LOG: ==== Stop Flag was set by saposcol (kill_collector()).

08:53:36 07.02.2013   LOG: ====  The collection process will stop as soon as possible

 Collecting process has stopped.
Process died without reaction ?
08:53:47 07.02.2013 ERROR: ShmCleanup failed (rtc = 1)

Collector > clean
Now connected to shared memory.
clean
08:53:52 07.02.2013   LOG:  check_remap: Switched to new shared memory.

Collector > leave
leave
08:54:04 07.02.2013   LOG:  check_remap: Switched to new shared memory.
08:54:04 07.02.2013   LOG: PfDeleteMonArea failed.
Shared memory deleted.
Collector >
Now connected to shared memory.
Collector > quit
quit
******************************************************************************
* leaving dialog collector Thu Feb  7 08:54:10 2013
******************************************************************************

As root, remove the memory segment (if it still exists):

#  ipcs -ma | grep 4dbe
0x00004dbe 1769734165 root      777        635394     0

# ipcrm -M 0x00004dbe
# ipcs -ma | grep 4dbe
#

As SAP admin - check the saposcol status which should correctly report shared memory as not being attached:

56> saposcol -s
**************************************************************
Shared Memory:           not attached
*** no further information available ***
**************************************************************

saposcol start should now proceed without error.

57> saposcol -l
-l
******************************************************************************
* This is Saposcol Version COLL 20.95 701 - v2.00, AMD/Intel x86_64 with Linux, 2007/02/16
* Usage:  saposcol -l: Start OS Collector
*         saposcol -k: Stop  OS Collector
*         saposcol -d: OS Collector Dialog Mode
*         saposcol -s: OS Collector Status
* Starting collector (create new process)
******************************************************************************