Ad Widget

Collapse

How to monitor active connections in the squid.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flamarion
    Junior Member
    • Apr 2009
    • 8

    #1

    How to monitor active connections in the squid.

    How to monitor active connections in the squid.

    In cacti I see how many connections are active on port 3128 of my proxy's squid.

    There is a way of doing this tracking with zabbix? How do it?

    Using squidclient saw something, but nothing informative.

    Thank you in advance.

    Sorry for my bad English.

    Flamarion Jorge
  • flamarion
    Junior Member
    • Apr 2009
    • 8

    #2
    [solved]

    Reply myself....

    UserParameter=squid.conexoes,netstat -nat |grep :3128 | grep -v 0.0.0.0:3128 | grep -v 127.0.0.1:3128 | awk ‘{print $5}’ | awk -F\: ‘{print $1}’ | sort | uniq | wc -l

    Comment

    • nelsonab
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2006
      • 1233

      #3
      Here's a tweak for you.

      netstat -nat | grep :3128 | grep ESTABLISHED| awk '{print $5}'| cut -d: -f1 | sort -u | wc -l

      Sort already has a unique option, but you don't really need sort since you're piping it to word count so the question becomes is it more efficient to sort it and look for unique options or just use unique? Also I noticed you're only going for unique hosts connected to squid, not total number of connections to squid. I also dropped using the second awk, I think cut is faster.

      However, now that I think about it some more we don't need the cut or awk if you're just wanting to know the total number connected. The awk and cut are useful if you want to have a list, but you don't want that.

      netstat -nat | grep :3128 | grep ESTABLISHED| wc -l

      This will give you the total number of established connections to squid irrespective of where it starts.

      If you want the total number of unique hosts see the tweak above.

      Total number of unique hosts except local host, your original script.
      RHCE, author of zbxapi
      Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
      Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

      Comment

      Working...