[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: looking for packages versions of running daemons

On 2009-09-09 23:30, Israel Garcia wrote:
On 9/9/09, Cameron Hutchison <lists@xdna.net> wrote:
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.
Hi Camaron

That's really nice. It gives what I'm looking for..BUT, I have other
daemons installed from source, so dpkg -S returns an error.  In my
case ruby. See below:

Right after the "bin=$(readlink /proc/$pid/exe)", I'd add a check which checks for the string "/usr/local" inside ${bin}, then skips down to the end of the while loop if the string actually is in ${bin}.

server:~# /usr/local/bin/check.sh
/opt/splunk/bin/python2.6 on port 8000/tcp from package splunk
(version 4.0.3-65638)
/usr/sbin/mysqld on port 3306/tcp from package mysql-server-5.0
(version 5.0.51a-24+lenny2)
/usr/sbin/monit on port 80/tcp from package monit (version 1:5.0.3-3)
/usr/local/bin/ruby on port 10000/tcp from package  (version
/usr/sbin/sshd on port 22/tcp from package openssh-server (version 1:5.1p1-5)
/usr/lib/postfix/master on port 25/tcp from package postfix (version 2.5.5-1.1)
/opt/splunk/bin/splunkd on port 8089/tcp from package splunk (version
/usr/sbin/sshd on port 22/tcp6 from package openssh-server (version 1:5.1p1-5)
/usr/sbin/collectd on port 32918/udp from package collectd (version 4.7.2-1)

Ruby was compile from source, How can I modify this script to remove
this error or better run -v option on daemons not installed by APT.

thanks again.

Here's a script I just wrote to do what you want (it was an interesting

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=$(apt-cache show -a $pkg | grep "^Version:" | { while
read x ver ; do
                        if dpkg --compare-versions $latest lt $ver ; then
                done ; echo $latest; } )

                echo -n "$bin on port $port from package $pkg (version
                if [ $latest != $version ] ; then
                        echo -n ", $latest available"
                echo ")"

To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact

Brawndo's got what plants crave.  It's got electrolytes!

Reply to: