node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Add System V semaphores and shared memory metrics

Open sathieu opened this issue 7 years ago • 7 comments

What did you expect to see?

Same metrics as:

# ipcs -u

------ Messages Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes

------ Shared Memory Status --------
segments allocated 1117
pages allocated 1535
pages resident  1535
pages swapped   0
Swap performance: 0 attempts	 0 successes

------ Semaphore Status --------
used arrays = 1006
allocated semaphores = 1006

i. e. semctl(IPC_INFO, ...):

       IPC_INFO (Linux-specific)
                 Return information about system-wide semaphore limits and parameters in the structure pointed to by arg.__buf.  This structure  is  of  type  seminfo,  defined  in
                 <sys/sem.h> if the _GNU_SOURCE feature test macro is defined:

                     struct  seminfo {
                         int semmap;  /* Number of entries in semaphore
                                         map; unused within kernel */
                         int semmni;  /* Maximum number of semaphore sets */
                         int semmns;  /* Maximum number of semaphores in all
                                         semaphore sets */
                         int semmnu;  /* System-wide maximum number of undo
                                         structures; unused within kernel */
                         int semmsl;  /* Maximum number of semaphores in a
                                         set */
                         int semopm;  /* Maximum number of operations for
                                         semop(2) */
                         int semume;  /* Maximum number of undo entries per
                                         process; unused within kernel */
                         int semusz;  /* Size of struct sem_undo */
                         int semvmx;  /* Maximum semaphore value */
                         int semaem;  /* Max. value that can be recorded for
                                         semaphore adjustment (SEM_UNDO) */
                     };

                 The semmsl, semmns, semopm, and semmni settings can be changed via /proc/sys/kernel/sem; see proc(5) for details.

We need this because Apache is consuming a lot of semaphores on some servers.

What did you see instead?

nothing

sathieu avatar Dec 06 '17 10:12 sathieu

Great idea, I did a quick check but it looks like semctl() isn't implemented by Go syscal_linux(etc).

SuperQ avatar Dec 06 '17 11:12 SuperQ

Should be easy enough to add to x/sys/unix.

mdlayher avatar Dec 06 '17 14:12 mdlayher

We're looking to get some of the message queue IPC stats. Would that be covered as part of this issue, or should I create a new issue that is specifically for message queue stats?

gtaylor avatar Feb 01 '18 17:02 gtaylor

@gtaylor Doesn't look like this issue here has much traction, so whatever works best for you. IPC Queue stats seem useful! Preferably the actual logic should go into the procfs lib (or even x/sys/unix, not sure about the scope though)

discordianfish avatar Aug 18 '18 10:08 discordianfish

I am fairly new to Grafana-Prometheus and exporters. Is this enhancement available yet? I too stumbled upon the same requirement today and could not find semaphores and shared memory stats being exported.

adiithyan avatar Apr 06 '20 10:04 adiithyan

Afaik, nothing has changed since my last comment. So to get there:

  1. Add the syscall to x/sys/unix
  2. Add the parsing for procfs
  3. Add the collector here

discordianfish avatar Apr 17 '20 09:04 discordianfish

Hi,

Would there be somewhere else to get "ipcs -u" inside node_exporter?

focabr avatar Jun 08 '22 17:06 focabr