miércoles, 27 de julio de 2016

Script - Kill inactive non dedicated connections

This killing procedure will allow us to close connections from inactive and non dedicated connections, (if we have to kill active or dedicated connections we already have database/so tools to do this (db.killOp, kill)):

     1) Locate the process :
  
netstat -lnap|grep 127

tcp        0      0 127.0.0.1:27017  127.0.0.1:55798 ESTABLISHED 2516/mongod


    2) Locate the the socket's FD (file descriptor)

lsof -np 2516|grep 127

COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
mongod  2516 mongod   98u  IPv4 458536      0t0    TCP 127.0.0.1:27017->127.0.0.1:55798 (ESTABLISHED)
  
    3) Connect to the master process, close the socket and exit:
  
gdb -p 2516
call close(98u)
quit