IPCS commands

Shared parsers for parsing output of the ipcs commands.

IpcsM - command ipcs -m

IpcsMP - command ipcs -m -p

IpcsS - command ipcs -s

IpcsSI - command ipcs -s -i {semaphore ID}

class insights.parsers.ipcs.IPCS(context, extra_bad_lines=None)[source]

Bases: insights.core.CommandParser

Base class for parsing the output of ipcs -X command in which the X could be m, s or q.

get(sid, default=None)[source]

Returns value of key item in self.data or default if key is not present.

Parameters
  • sid (str) -- Key to get from self.data.

  • default (str) -- Default value to return if key is not present.

Returns

the stored dict item, or the default if not found.

Return type

{dict}

parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.ipcs.IpcsM(context, extra_bad_lines=None)[source]

Bases: insights.parsers.ipcs.IPCS

Class for parsing the output of ipcs -m command.

Typical output of the command is:

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x0052e2c1 0          postgres   600        37879808   26

Examples

>>> '0' in shm
True
>>> shm.get('0', {}).get('bytes')
'37879808'
>>> '2602' in shm
False
>>> shm.get('2602', {}).get('bytes')
class insights.parsers.ipcs.IpcsMP(context, extra_bad_lines=None)[source]

Bases: insights.parsers.ipcs.IPCS

Class for parsing the output of ipcs -m -p command.

Typical output of the command is:

------ Shared Memory Creator/Last-op --------
shmid      owner      cpid       lpid
0          postgres   1833       14111

Examples

>>> '0' in shmp
True
>>> shmp.get('0').get('cpid')
'1833'
class insights.parsers.ipcs.IpcsS(context, extra_bad_lines=None)[source]

Bases: insights.parsers.ipcs.IPCS

Class for parsing the output of ipcs -s command.

Typical output of the command is:

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x00000000 557056     apache     600        1
0x00000000 589825     apache     600        1
0x00000000 131074     apache     600        1
0x0052e2c1 163843     postgres   600        17
0x0052e2c2 196612     postgres   600        17
0x0052e2c3 229381     postgres   600        17
0x0052e2c4 262150     postgres   600        17
0x0052e2c5 294919     postgres   600        17
0x0052e2c6 327688     postgres   600        17
0x0052e2c7 360457     postgres   600        17
0x00000000 622602     apache     600        1
0x00000000 655371     apache     600        1
0x00000000 688140     apache     600        1

Examples

>>> '622602' in sem
True
>>> '262150' in sem
True
>>> sem.get('262150').get('owner')
'postgres'
class insights.parsers.ipcs.IpcsSI(context, extra_bad_lines=None)[source]

Bases: insights.core.CommandParser

Class for parsing the output of ipcs -s -i ## command. ## will be replaced with specific semid

Typical output of the command is:

# ipcs -s -i 65536

Semaphore Array semid=65536
uid=500  gid=501     cuid=500    cgid=501
mode=0600, access_perms=0600
nsems = 8
otime = Sun May 12 14:44:53 2013
ctime = Wed May  8 22:12:15 2013
semnum     value      ncount     zcount     pid
0          1          0          0          0
1          1          0          0          0
0          1          0          0          6151
3          1          0          0          2265
4          1          0          0          0
5          1          0          0          0
0          0          7          0          6152
7          1          0          0          4390

Examples

>>> semi.semid
'65536'
>>> semi.pid_list
['0', '2265', '4390', '6151', '6152']
parse_content(content)[source]

This method must be implemented by classes based on this class.

property pid_list

Return the ID list of the processes which use this semaphore.

Returns

the processes’ ID list

Return type

[list]

property semid

Return the semaphore ID.

Returns

the semaphore ID.

Return type

str