# [SOLVED]  Squid - Get No. of connected Clients Via SNMP

## asankaan

Hi,

I'm using squid 3.0.STABLE18.

I want to monitor how many clients currently connected to the squid via snmp.

I've successfully installed snmpd & it is working fine.

I want to know which object(MIB) i should query for this purpose(if it is possible to get it via snmp)?

Thanks in advanceLast edited by asankaan on Fri Oct 09, 2009 11:19 am; edited 1 time in total

----------

## massimo

It is not possible to query how many clients are currently connected to the proxy.

----------

## think4urs11

you can gather that information via cachemgr/cache client list. But that needs some scripting to get a 'one value only' view.

----------

## nativemad

Nothing is impossible!  :Wink: 

I've done something similar for Jabber-usage...

You could attach an external script to snmpd (1) which generates the desired values perhaps via netstat or similar(2).

(1) add a line like this one to snmpd.conf

```
exec Input /path/to/your-script.sh
```

(2) something like the following should do the job:

```
#!/bin/bash

PROXYPORT=8080

netstat --inet -n | grep ":$PROXYPORT" | awk '{print $5}' | grep 10.16. | cut -d ":" -f 1 | while read line; do     #10.16.0.0 is my client-net!

        IPFOUND="no"

        for IPNOW in ${ALLIPS[*]}; do

                if [ $IPNOW = $line ]; then

                        IPFOUND="yes"

                fi

        done

        if [ $IPFOUND = "no" ]; then

                ALLIPS[$count]=$line

                count=$(expr $count + 1)

        fi

echo $count>/tmp/userscount

done

cat /tmp/userscount

rm /tmp/userscount

```

This should then be accessible on .1.3.6.1.4.1.2021.8.1.extOutput.1 or something like that!  :Wink: 

I know... this solution will not win any beauty-contest! But it works!   :Razz: 

Cheers

-----edit

i've added the PROXYPORT variable, as there could be more than just squid running on the server...  :Wink: 

----------

## asankaan

Thanks, nativemad!

This works fine.

Thank you.

 *nativemad wrote:*   

> Nothing is impossible! 
> 
> I've done something similar for Jabber-usage...
> 
> You could attach an external script to snmpd (1) which generates the desired values perhaps via netstat or similar(2).
> ...

 

----------

