The ipcmk command is used to create shared memory segments, message queues and semaphore arrays. Whereas ipcrm let’s us delete them. So they are not monitoring commands in any way but they will be handy to show what ipcs does.
Let’s create one of each first:
root:~> ipcmk –shmem 1024
Shared memory id: 36634640
.
root:~> ipcmk –queue
Message queue id: 0
.
root:~> ipcmk –semaphore 100
Semaphore id: 163841
Now let’s have a look at existing IPC resources in use:
root:~> ipcs –shmems
.
—— Shared Memory Segments ——
key shmid owner perms bytes nattch status
0x00000000 19398656 marc 600 1048576 2 dest
[…]
0x703e8324 36634640 root 644 1024 0
0x00000000 36405265 marc 600 33554432 2 dest
0x00000000 26804244 marc 600 33554432 2 dest
0x00000000 23560213 marc 600 4194304 2 dest
.
root:~> ipcs –queues
.
—— Message Queues ——
key msqid owner perms usedbytes messages
0x045d3c39 0 root 644 0 0
.
root:~> ipcs –semaphores
.
—— Semaphore Arrays ——
key semid owner perms nsems
0x002fa327 131072 root 600 2
0xfaa6ca13 163841 root 644 100
.
root:~> ipcs –all
.
—— Shared Memory Segments ——
key shmid owner perms bytes nattch status
0x00000000 19398656 marc 600 1048576 2 dest
[…]
0x703e8324 36634640 root 644 1024 0
0x00000000 36405265 marc 600 33554432 2 dest
0x00000000 26804244 marc 600 33554432 2 dest
0x00000000 23560213 marc 600 4194304 2 dest
.
—— Message Queues ——
key msqid owner perms usedbytes messages
0x045d3c39 0 root 644 0 0
.
—— Semaphore Arrays ——
key semid owner perms nsems
0x002fa327 131072 root 600 2
0xfaa6ca13 163841 root 644 100
We can query the owner and creator of all IPC resources:
root:~> ipcs –queues –creator
.
—— Message Queues Creators/Owners ——
msqid perms cuid cgid uid gid
0 644 root root root root
We can query the IPC limits:
root:~> ipcs –limits –all
.
—— Messages Limits ——
max queues system wide = 32000
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
.
—— Shared Memory Limits ——
max number of segments = 4096
max seg size (kbytes) = 4194303
max total shared memory (kbytes) = 1073741824
min seg size (bytes) = 1
.
—— Semaphore Limits ——
max number of arrays = 32000
max semaphores per array = 128
max semaphores system wide = 128
max ops per semop call = 500
semaphore max value = 32767
We can query the PID of the resource creator and last user:
root:~> ipcs –all –pid
.
—— Message Queues PIDs ——
msqid owner lspid lrpid
0 root 0 0
.
—— Shared Memory Creator/Lastop PIDs ——
shmid owner cpid lpid
19398656 marc 5001 14521
[…]
36634640 root 19874 0
36798481 marc 20627 1535
26804244 marc 9844 30670
23560213 marc 2681 20418
We can query the timings of changes and access:
root:~> ipcs –all –time
.
—— Message Queues Send/Recv/Change Times ——
msqid owner send recv change
0 root Not set Not set Oct 27 19:58:35
.
—— Shared Memory Attach/Detach/Change Times ——
shmid owner attached detached changed
19398656 marc Oct 27 18:58:39 Oct 27 18:58:39 Oct 18 20:00:43
[…]
36634640 root Not set Not set Oct 27 19:58:15
36798481 marc Oct 27 20:03:47 Not set Oct 27 20:03:47
26804244 marc Oct 24 21:22:00 Oct 24 21:22:00 Oct 23 13:03:37
23560213 marc Oct 27 11:51:26 Oct 27 11:51:26 Oct 21 18:22:28
.
—— Semaphore Operation/Change Times ——
semid owner last-op last-changed
131072 root Sun Oct 25 19:07:45 2015 Sat Oct 24 19:06:23 2015
163841 root Not set Tue Oct 27 19:58:50 2015
And we can extract an utilisation report: