[munin/sockets] on factorise le code
darcs-hash:20090421211242-bd074-3e936372c575ab42848a053f78281a9044dc0dcd.gz
This commit is contained in:
parent
17c310a250
commit
6e61a4a029
1 changed files with 19 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# # Parameters:
|
# # Parameters:
|
||||||
#
|
#
|
||||||
|
@ -13,6 +13,8 @@ myname="connexions"
|
||||||
|
|
||||||
name="${name-\<$myname\>}"
|
name="${name-\<$myname\>}"
|
||||||
REGEX="${regex-\<$name\>}"
|
REGEX="${regex-\<$name\>}"
|
||||||
|
services=(http ssh smtp imap nfs ldap)
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
if [ "$1" = "autoconf" ]; then
|
||||||
echo yes
|
echo yes
|
||||||
|
@ -24,37 +26,32 @@ if [ "$1" = "suggest" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
|
cat <<EOF
|
||||||
echo graph_title Number of $myname
|
graph_title Number of $myname
|
||||||
echo 'graph_args --base 1000 --vertical-label connexions -l 0'
|
graph_args --base 1000 --vertical-label connexions -l 0
|
||||||
echo 'graph_category network'
|
graph_category network
|
||||||
echo "imap.label Connexions imap"
|
`for dmn in ${services[@]}; do echo $dmn.label Connexions $dmn; done`
|
||||||
echo "ssh.label Connexions ssh"
|
other.label Connexions diverses
|
||||||
echo "http.label Connexions web"
|
in.label Connexions entrantes
|
||||||
echo "other.label Connexions diverses"
|
out.label Connexions sortantes
|
||||||
echo "in.label Connexions entrantes"
|
EOF
|
||||||
echo "out.label Connexions sortantes"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ip=`ifconfig | perl -ne 'print ${^MATCH} if /10\.231\.136\.\d+/p'`
|
ip=$(ifconfig | perl -ne 'print ${^MATCH} if /10\.231\.136\.\d+/p')
|
||||||
ips=${IP/10/}
|
ips=${IP/10/}
|
||||||
TMP=`mktemp -t sockets.XXXXXX`
|
TMP=`mktemp -t sockets.XXXXXX`
|
||||||
trap "rm $TMP* 2>/dev/null" 0
|
trap "rm $TMP* 2>/dev/null" 0
|
||||||
|
|
||||||
/sbin/ss > $TMP
|
/sbin/ss > $TMP
|
||||||
|
|
||||||
printf "imap.value "
|
for dmn in ${services[@]}; do
|
||||||
grep "$ips:imap" $TMP | wc -l
|
printf "$dmn.value "
|
||||||
|
grep "$ips:$dmn" $TMP | wc -l
|
||||||
printf "ssh.value "
|
done
|
||||||
grep "$ips:ssh" $TMP | wc -l
|
|
||||||
|
|
||||||
printf "http.value "
|
|
||||||
grep "$ips:http" $TMP | wc -l
|
|
||||||
|
|
||||||
printf "other.value "
|
printf "other.value "
|
||||||
perl -ne "print if ! /$ips:(imap|ssh|http)/" $TMP | wc -l
|
perl -ne "print if ! /$ips:`echo ${services[@]} | sed 's/ /|/g'`/" $TMP | wc -l
|
||||||
|
|
||||||
printf "in.value "
|
printf "in.value "
|
||||||
perl -ne "print if ! /$ips:\d{5}/" $TMP | wc -l
|
perl -ne "print if ! /$ips:\d{5}/" $TMP | wc -l
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue