Re: looking for packages versions of running daemons
Israel Garcia <igalvarez@gmail.com> writes:
>I have more than 10 debian (etch and lenny) servers and I want to find
>a way to know remotely on every server:
>1. Name of running daemons and ports (tcp/udp) they're using.
>2. Version of the package (installed by APT) used by these daemons.
>3. Version of the latest package (from deb mirros) used by these daemons.
>I tried to make a script but didn't resolve my problem.
Here's a script I just wrote to do what you want (it was an interesting
diversion).
For requirement #3, I'm not sure exactly what you wanted, so I took the
easy way out. I assumed you wanted the latest version for the
distribution you have in your /etc/apt/sources.list. To make the script
work, run apt-get update first so that your apt-cache has the latest
versions from your mirror.
netstat -lntup \
| awk '/^tcp/ { print $4"/"$1, $7 } /^udp/ { print $4"/"$1, $6 }' \
| sed -n 's|^[^ ]*:\([^ ]*\) \([0-9]*\)/.*|\1 \2|p' \
| while read port pid ; do
bin=$(readlink /proc/$pid/exe)
pkg=$(dpkg -S $bin | cut -d: -f1)
version=$(dpkg-query -W --showformat='${Version}' $pkg)
latest=$version
latest=$(apt-cache show -a $pkg | grep "^Version:" | { while read x ver ; do
if dpkg --compare-versions $latest lt $ver ; then
latest=$ver
fi
done ; echo $latest; } )
echo -n "$bin on port $port from package $pkg (version $version"
if [ $latest != $version ] ; then
echo -n ", $latest available"
fi
echo ")"
done
Reply to: