"Fossies" - the Fresh Open Source Software Archive

Member "munin-2.0.67/plugins/node.d.linux/netstat.in" (22 Feb 2021, 3376 Bytes) of package /linux/misc/munin-2.0.67.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "netstat.in": 2.0.66_vs_2.0.67.

    1 #!@@GOODSH@@
    2 # -*- sh -*-
    3 
    4 set -e
    5 
    6 : << =cut
    7 
    8 =head1 NAME
    9 
   10 netstat - Plugin to monitor network connections
   11 
   12 =head1 CONFIGURATION
   13 
   14 No configuration
   15 
   16 =head1 AUTHOR
   17 
   18 Unknown author
   19 
   20 =head1 LICENSE
   21 
   22 GPLv2
   23 
   24 =head1 BUGS
   25 
   26 =over 4
   27 
   28 =item SuSE: passive connections rejected
   29 
   30 At least one SuSE netstat appears to report "passive connections
   31 rejected because of time stamp"
   32 
   33 We have never seen that, patch requested.
   34 
   35 =back
   36 
   37 =head1 MAGIC MARKERS
   38 
   39  #%# family=auto
   40  #%# capabilities=autoconf
   41 
   42 =cut
   43 
   44 . "$MUNIN_LIBDIR/plugins/plugin.sh"
   45 
   46 
   47 NETSTAT_CMD=netstat
   48 
   49 
   50 if [ "$1" = "autoconf" ]; then
   51 	if ( "$NETSTAT_CMD" -s 2>/dev/null >/dev/null ); then
   52 		echo yes
   53 		exit 0
   54 	else
   55 		if [ $? -eq 127 ]
   56 		then
   57 			echo "no (program $NETSTAT_CMD not found)"
   58 			exit 0
   59 		else
   60 			echo "no (unknown netstat return value $?)"
   61 			exit 0
   62 		fi
   63 	fi
   64 fi
   65 
   66 if [ "$1" = "config" ]; then
   67 
   68 	echo 'multigraph netstat'
   69 	echo 'graph_title Netstat, combined'
   70 	echo 'graph_args --units=si -l 1 --base 1000 --logarithmic'
   71 	echo 'graph_vlabel TCP connections'
   72 	echo 'graph_category network'
   73 	echo 'graph_period second'
   74 	echo 'graph_info This graph shows the TCP activity of all the network interfaces combined.'
   75 	echo 'active.label active'
   76 	echo 'active.type DERIVE'
   77 	echo 'active.min 0'
   78 	echo 'active.max 50000'
   79 	echo 'active.info The number of active TCP openings per second.'
   80 	print_warning active
   81 	print_critical active
   82 	echo 'passive.label passive'
   83 	echo 'passive.type DERIVE'
   84 	echo 'passive.min 0'
   85 	echo 'passive.max 50000'
   86 	echo 'passive.info The number of passive TCP openings per second.'
   87 	print_warning passive
   88 	print_critical passive
   89 	echo 'failed.label failed'
   90 	echo 'failed.type DERIVE'
   91 	echo 'failed.min 0'
   92 	echo 'failed.max 50000'
   93 	echo 'failed.info The number of failed TCP connection attempts per second.'
   94 	print_warning failed
   95 	print_critical failed
   96 	echo 'resets.label resets'
   97 	echo 'resets.type DERIVE'
   98 	echo 'resets.min 0'
   99 	echo 'resets.max 50000'
  100 	echo 'resets.info The number of TCP connection resets.'
  101 	print_warning resets
  102 	print_critical resets
  103 	echo 'established.label established'
  104 	echo 'established.type GAUGE'
  105 	echo 'established.info The number of currently open connections.'
  106 	print_warning established
  107 	print_critical established
  108 
  109 	echo ''
  110 
  111 	echo 'multigraph netstat_established'
  112 	echo 'graph_title Netstat, established only'
  113 	echo 'graph_args --lower-limit 0'
  114 	echo 'graph_vlabel TCP connections'
  115 	echo 'graph_category network'
  116 	echo 'graph_period second'
  117 	echo 'graph_info This graph shows the TCP activity of all the network interfaces combined.'
  118 	echo 'established.label established'
  119 	echo 'established.type GAUGE'
  120 	echo 'established.info The number of currently open connections.'
  121 	print_warning established
  122 	print_critical established
  123 
  124 	exit 0
  125 fi
  126 
  127 # Newer versions of net tools' netstat have fixed the 'active connection
  128 # openings' string from plural connections to singular. The match hereby is for
  129 # both cases.
  130 #
  131 echo 'multigraph netstat'
  132 "$NETSTAT_CMD" -s | awk '
  133 /active connection(s)? ope/  { print "active.value " $1 }
  134 /passive connection ope/  { print "passive.value " $1 }
  135 /failed connection/       { print "failed.value " $1 }
  136 /connection resets/       { print "resets.value " $1 }
  137 /connections established/ { print "established.value " $1 }'
  138 
  139 echo
  140 
  141 echo 'multigraph netstat_established'
  142 "$NETSTAT_CMD" -s | awk '
  143 /connections established/ { print "established.value " $1 }'