#! /usr/bin/perl # anders@aftenposten.no, 2007-05-08 # Graph resident size of Varnish sub findrss { foreach $line (`ps axww -orss,command`) { chomp($line); if ($line =~ /^\s*(\d+)\s+varnishd: Varnish-Chld/) { $rss = $1; last; } } } sub printconfig { print "graph_title Size (resident size/rss)\n"; print "graph_vlabel size\n"; print "graph_category varnish\n"; print "graph_info This graph shows the resident 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 ($rss eq "") { $rss = 0; } # number is given in kilobytes $rss = $rss * 1024; print "size.value $rss\n"; } if ($ARGV[0] eq "autoconf") { print "yes\n"; } elsif ($ARGV[0] eq "config") { printconfig; } else { findrss; printvalues; }