#!/bin/bash ############################################################################### # # Copyright (c) 2016 Ramon Novoa # Copyright (c) 2016 Artica Soluciones Tecnologicas S.L. # # sockstat.sh Pandora FMS agent plug-in to retrieve socket statistics. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # ############################################################################### OUT=`cat /proc/net/sockstat | grep TCP` MAX=`cat /proc/sys/net/ipv4/tcp_mem | cut -d' ' -f 3` INUSE=`echo $OUT | cut -d' ' -f 3` ORPHAN=`echo $OUT | cut -d' ' -f 5` TW=`echo $OUT | cut -d' ' -f 7` ALLOC=`echo $OUT | cut -d' ' -f 9` MEM=`echo $OUT | cut -d' ' -f 11` echo '' echo 'TCP sockets in use' echo 'generic_data' echo "$INUSE" echo '' echo '' echo 'TCP orphan sockets' echo 'generic_data' echo "$ORPHAN" echo '' echo '' echo 'TCP sockets in TIME_WAIT' echo 'generic_data' echo "$TW" echo '' echo '' echo 'TCP sockets allocated' echo 'generic_data' echo "$ALLOC" echo '' echo '' echo 'TCP pages allocated' echo 'generic_data' echo 'pages' echo "$MEM" echo '' echo '' echo 'TCP pages maximum' echo 'generic_data' echo 'pages' echo "$MAX" echo ''