/usr/share/sadms-2.0.15/_test-network.sh is in sadms 2.0.15.repack-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | #!/bin/bash
# bbou@ac-toulouse.fr
# 2007-11-03 14:17:28
# _test-network.sh
### P A R A M S
MYVERBOSE=
if [ "$1" = "-v" ]; then
MYVERBOSE="True"
shift
fi
MYDNS="$1"
MYDOMAIN="$2"
MYDC="$3"
MYSERVER="$4"
MYHOSTALLOW="$5"
MYWINS="$6"
### I N C L U D E
. ./_include.sh
### S T A R T
function gethn()
{
python -c "import socket;hn=socket.gethostname();print hn" 2> /dev/null
return $?
}
function gethbn()
{
python -c "import socket;hn,al,ips=socket.gethostbyname_ex(\"$1\");print hn" 2> /dev/null
return $?
}
function getaliases()
{
python -c "import socket;hn,al,ips=socket.gethostbyname_ex(\"$1\");print al" 2> /dev/null
return $?
}
function getips()
{
python -c "import socket;hn,al,ips=socket.gethostbyname_ex(\"$1\");print ips" 2> /dev/null
return $?
}
function getfqdn()
{
python -c "import socket;print socket.getfqdn(\"$1\")" 2> /dev/null
return $?
}
function resolve()
{
python -c "import socket;print socket.gethostbyname(\"$1\")" 2> /dev/null
return $?
}
function resolveDns()
{
output=`host "$1" 2> /dev/null | grep -v '^;;' | grep -v 'not found'`
if [ "${output}" != "" ];then
echo ${output}
return 0
fi
return 1
}
echo "--------------------------------------------------------------------------------"
echo "NETWORK TEST"
echo "--------------------------------------------------------------------------------"
result=0
echo "+HOSTNAME"
echo "+hostname"
hn=`hostname`
echo ${hn}
echo "+shortname"
sn=`hostname -s`
echo ${sn}
echo "+fqdn"
fqdn=`hostname -f`
echo ${fqdn}
echo "+gethostname (socket)"
hn2=`gethn ${hn}`
echo ${hn2}
echo "+gethostbyname(gethostname) (socket)"
hn3=`gethbn ${hn2}`
echo ${hn3}
echo "+fqdn (socket)"
fqdn2=`getfqdn`
echo ${fqdn2}
echo "+aliases (socket)"
al=`getaliases ${hn} | sed "s/[']//g"`
echo ${al}
echo "+ips (socket)"
al=`getips ${hn} | sed "s/[']//g"`
echo ${al}
echo "+dn"
dn=${fqdn##${sn}.}
echo ${dn}
echo "+target fqdn"
if [ "${dn}" != "${MYDNS}" ]; then
echo "hostname ${fqdn} not in domain ${MYDNS}" >&2
else
echo "hostname ${fqdn} in target domain ${MYDNS}"
fi
if [ -e /etc/hostname ];then
echo "+/etc/hostname"
cat /etc/hostname
fi
if [ -e /etc/sysconfig/network ];then
echo "+/etc/sysconfig/network"
grep HOSTNAME /etc/sysconfig/network
fi
echo "+entry in /etc/hosts"
cat /etc/hosts | grep ${sn}
echo "+CHECK HOSTNAME IS RESOLVABLE"
echo "+resolve ${sn}"
resolve ${sn}
if [ "$?" != "0" ]; then
echo "ip: unresolved host ${sn}" >&2
result=110
fi
echo "+resolve ${fqdn}"
resolve ${fqdn}
if [ "$?" != "0" ]; then
echo "ip: unresolved host ${fqdn}" >&2
result=111
fi
echo "+CHECK HOSTNAME IS REACHABLE (PING)"
echo "+ping ${sn}"
ping -q -c 1 ${sn} > /dev/null
if [ "$?" != "0" ]; then
echo "ping: unreachable host ${sn} (firewall may drop pings)" >&2
result=130
else
echo "ok"
fi
echo "+ping ${fqdn}"
ping -q -c 1 ${fqdn} > /dev/null
if [ "$?" != "0" ]; then
echo "ping: unreachable host ${fqdn} (firewall may drop pings)" >&2
result=131
else
echo "ok"
fi
echo "+CHECK DOMAIN CONTROLLER IS RESOLVABLE"
echo "+resolve ${MYDC}"
resolve ${MYDC}
if [ "$?" != "0" ]; then
echo "ip: unresolved host ${MYDC}" >&2
result=10
fi
echo "+resolve ${MYDC}.${MYDNS}"
resolve ${MYDC}.${MYDNS}
if [ "$?" != "0" ]; then
echo "ip: unresolved host ${MYDC}.${MYDNS}" >&2
result=11
fi
echo "+CHECK DOMAIN CONTROLLER IS DNS-RESOLVABLE"
echo "+resolve ${MYDC}"
resolveDns ${MYDC}
if [ "$?" != "0" ]; then
echo "dns: unresolved host ${MYDC}" >&2
result=20
fi
echo "+resolve ${MYDC}.${MYDNS}"
resolveDns ${MYDC}.${MYDNS}
if [ "$?" != "0" ]; then
echo "dns: unresolved host ${MYDC}.${MYDNS}" >&2
result=21
fi
echo "+CHECK DOMAIN CONTROLLER IS REACHABLE (PING)"
echo "+ping ${MYDC}"
ping -q -c 1 ${MYDC} > /dev/null
if [ "$?" != "0" ]; then
echo "ping: unreachable host ${MYDC} (firewall may drop pings)" >&2
result=30
else
echo "ok"
fi
echo "+ping ${MYDC}.${MYDNS}"
ping -q -c 1 ${MYDC}.${MYDNS} > /dev/null
if [ "$?" != "0" ]; then
echo "ping: unreachable host ${MYDC}.${MYDNS} (firewall may drop pings)" >&2
result=31
else
echo "ok"
fi
exit ${result}
|