Uploaded image for project: 'Observium'
  1. Observium
  2. OBS-2612

remove perl dependency from varnish agent script

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • Unix Agent
    • None

    Description

      I've managed to remove the dependency of perl from scripts/agent-local/varnish and make it from:

      #!/usr/bin/env perl
       
      use XML::Simple;
      use Data::Dumper;
       
      die unless $stat = `/usr/bin/varnishstat -x`;
       
      # create object
      $xml = new XML::Simple();
       
      # read XML file
      $data = $xml->XMLin($stat);
      #print Dumper($data);
       
      print "<<<app-varnish>>>\n";
       
       
      ######################
      ### Backend Statistics
       
      # backend_conn / Backend conn. requests
      print "$data->{stat}->{backend_req}->{value};";
       
      # backend_unhealthy / Backend conn. not attempted
      print "$data->{stat}->{backend_unhealthy}->{value};";
       
      # backend_busy / Backend conn. too many
      print "$data->{stat}->{backend_busy}->{value};";
       
      # backend_fail / Backend conn. failures
      print "$data->{stat}->{backend_fail}->{value};";
       
      # backend_reuse / Backend conn. reuses
      print "$data->{stat}->{backend_reuse}->{value};";
       
      # backend_toolate / Backend conn. was closed
      print "$data->{stat}->{backend_toolate}->{value};";
       
      # backend_recycle / Backend conn. recycles
      print "$data->{stat}->{backend_recycle}->{value};";
       
      # backend_retry / Backend conn. retry
      print "$data->{stat}->{backend_retry}->{value};";
       
       
      ####################
      ### Cache Statistics
       
      # cache_hitpass / Cache hits for pass
      print "$data->{stat}->{cache_hitpass}->{value};";
       
      # cache_hit / Cache hits
      print "$data->{stat}->{cache_hit}->{value};";
       
      # cache_miss / Cache misses
      print "$data->{stat}->{cache_miss}->{value};";
       
       
      ##################
      ### LRU Statistics
       
      # n_lru_nuked / N LRU nuked objects
      print "$data->{stat}->{n_lru_nuked}->{value};";
       
      # n_lru_moved / N LRU moved objects
      print "$data->{stat}->{n_lru_moved}->{value};";
       
       
      #EOF
      

      to this bash script:

      #!/bin/bash
       
      DATA=`/usr/bin/varnishstat -1`
       
      echo "<<<app-varnish>>>"
       
      ######################
      ### Backend Statistics
       
      # backend_conn / Backend conn. requests
      echo "$DATA" | fgrep backend_req | tr -s ' ' | cut -d ' ' -f2
       
      # backend_unhealthy / Backend conn. not attempted
      echo "$DATA" | fgrep backend_unhealthy | tr -s ' ' | cut -d ' ' -f2
       
      # backend_busy / Backend conn. too many
      echo "$DATA" | fgrep backend_busy | tr -s ' ' | cut -d ' ' -f2
       
      # backend_fail / Backend conn. failures
      echo "$DATA" | fgrep backend_fail | tr -s ' ' | cut -d ' ' -f2
       
      # backend_reuse / Backend conn. reuses
      echo "$DATA" | fgrep backend_reuse | tr -s ' ' | cut -d ' ' -f2
       
      # backend_toolate / Backend conn. was closed
      echo "$DATA" | fgrep backend_toolate | tr -s ' ' | cut -d ' ' -f2
       
      # backend_recycle / Backend conn. recycles
      echo "$DATA" | fgrep backend_recycle | tr -s ' ' | cut -d ' ' -f2
       
      # backend_retry / Backend conn. retry
      echo "$DATA" | fgrep backend_retry | tr -s ' ' | cut -d ' ' -f2
       
       
      ####################
      ### Cache Statistics
       
      # cache_hitpass / Cache hits for pass
      echo "$DATA" | fgrep cache_hitpass | tr -s ' ' | cut -d ' ' -f2
       
      # cache_hit / Cache hits
      echo "$DATA" | fgrep cache_hit | tr -s ' ' | cut -d ' ' -f2
       
      # cache_miss / Cache misses
      echo "$DATA" | fgrep cache_miss | tr -s ' ' | cut -d ' ' -f2
       
       
      ##################
      ### LRU Statistics
       
      # n_lru_nuked / N LRU nuked objects
      echo "$DATA" | fgrep n_lru_nuked | tr -s ' ' | cut -d ' ' -f2
       
      # n_lru_moved / N LRU moved objects
      echo "$DATA" | fgrep n_lru_moved | tr -s ' ' | cut -d ' ' -f2
       
      #EOF
      

      Maybe this is helpful for people (like me) who don't want to deal with perl and its dependencies on a node which hosts varnish.

      Attachments

        Activity

          People

            sid3windr Tom Laermans
            cherouvim Ioannis Cherouvim
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: