IPCS Semaphores

Combiner for parsing all semaphores. It uses the results of the IpcsS and IpcsSI parsers to collect complete semaphore information,and use PsAuxcww parsers to determine if one semaphore is orphan.

class insights.combiners.ipcs_semaphores.IpcsSemaphore(data)[source]

Bases: object

Class for holding information about one semaphore.

is_orphan = None

Is it an orphan semaphore?

Type:bool
owner = None

Owner of the semaphore.

Type:str
pid_list = None

List of the related PID.

Type:list
semid = None

Semaphore ID.

Type:str
class insights.combiners.ipcs_semaphores.IpcsSemaphores(sem_s, sem_si, ps)[source]

Bases: object

Class for parsing all semaphores. Will generate IpcsSemaphore objects for each semaphores.

Below is the logic to determine if semaphore an orphan:

- PID=0 does not included in the related PID
- Related PID cannot be found in running PIDs

Examples

>>> oph_sem.count_of_all_sems()
5
>>> oph_sem.count_of_all_sems(owner='apache')
4
>>> oph_sem.count_of_orphan_sems()
2
>>> oph_sem.count_of_orphan_sems('apache')
2
>>> oph_sem.get_sem('65536').is_orphan
False
count_of_all_sems(owner=None)[source]

Return the count of all semaphores by default, when owner is provided return the count of semaphores belong to owner.

Parameters:owner (str) -- Owner of semaphores.
Returns:the count of semaphores.
Return type:(int)
count_of_orphan_sems(owner=None)[source]

Return the count of orphan semaphores by default, when owner is provided return the count of orphan semaphores belong to owner.

Parameters:owner (str) -- Owner of semaphores.
Returns:the count of orphan semaphores
Return type:(int)
get_sem(semid)[source]

Return an IpcsSemaphore instance which semid is semid

Returns:the instance of IpcsSemaphore
Return type:(IpcsSemaphore)
orphan_sems(owner=None)[source]

Return all the orphan semaphores by default, when owner is provided return the orphan semaphores belong to owner.

Parameters:owner (str) -- Owner of semaphores.
Returns:the ID list of orphan semaphores
Return type:(list)