#! /usr/bin/perl # anders@aftenposten.no, 2007-05-08 # Graph size of Varnish sub findvsz { foreach $line (`ps axww -ovsz,command`) { chomp($line); if ($line =~ /^\s*(\d+)\s+varnishd: Varnish-Chld/) { $vsz = $1; last; } } } sub printconfig { print "graph_title Size (virtual size/vsz)\n"; print "graph_vlabel size\n"; print "graph_category varnish\n"; print "graph_info This graph shows the total (virtual) memory size of the Varnish-Chld process\n"; print "size.label size\n"; print "size.type GAUGE\n"; print "size.graph yes\n"; } sub printvalues { if ($vsz eq "") { $vsz = 0; } # number is given in kilobytes $vsz = $vsz * 1024; print "size.value $vsz\n"; } if ($ARGV[0] eq "autoconf") { print "yes\n"; } elsif ($ARGV[0] eq "config") { printconfig; } else { findvsz; printvalues; }