How to clear Semaphore queues in server

Sometimes, servers usually encounter HTTP service warnings in Nagios. Normally, we can fix this issue by restarting HTTP service. But in some cases, it may fail to start. The following steps should be used in such instances

1) Check ipcs

=============
-bash-3.00# ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x0052e2c1 0          postgres  600        10469376   2                       
0x0105823d 997031937  root      600        1167812    0                       

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0x00000000 294617088  nobody    600        1         
0x00000000 294649857  nobody    600        1         
0x00000000 294682626  nobody    600        1         
0x00000000 294715395  nobody    600        1         
0x00000000 294748164  nobody    600        1         
0x00000000 294977541  nobody    600        1         
0x00000000 295010310  nobody    600        1         
0x00000000 295043079  nobody    600        1         
0x00000000 295075848  nobody    600        1         
0x00000000 295108617  nobody    600        1         
0x00000000 295174154  nobody    600        1         
0x00000000 295206923  nobody    600        1         
0x00000000 295239692  nobody    600        1         
0x00000000 295272461  nobody    600        1               
0x00000000 300417151  nobody    600        1         

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages

===============

2) Use the following script to clear Semaphore queue

-bash-3.00# for i in `ipcs -s | awk '{print $2}'`; do (ipcrm -s $i); done

3) Check ipcs again

-bash-3.00# ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x0052e2c1 0          postgres  600        10469376   2                       
0x0105823d 997031937  root      600        1167812    0                       

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: