-
Notifications
You must be signed in to change notification settings - Fork 7
/
varnish_varnishstat_
71 lines (60 loc) · 1.53 KB
/
varnish_varnishstat_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
use Net::Telnet ();
use Data::Dumper;
$arg = shift @ARGV;
%aspects = (
'cache' => 'Cache',
'backend' => 'Backend',
'shm' => 'SHM'
);
(my $whut = $0) =~ s/^.*\_//;
# Hvis $whut IKKE fins, men $arg fins OG er noe annet enn blabla
# så skal den trigge
if (!$whut && $arg && $arg !~ /^(suggest|autoconf)$/) {
print "Only 'suggest' and 'autoconf' may be used w/o symlinked name\n";
exit 2;
} elsif (!$whut && !$arg) {
print "Uh. Bugger.\n";
exit 2;
}
if ($arg eq 'autoconf') {
print "Autoconf starting...\n";
exit 0;
} elsif ($arg eq 'suggest') {
print "Suggest starting...\n";
exit 0;
} elsif ($arg eq 'config') {
$config = 1;
}
$grepfor = $aspects{$whut};
# print "Looking for $grepfor\n";
if ($config) {
print "graph_title Varnish $grepfor usage\n";
print "graph_args --base 1000\n";
print "graph_vlabel Activity / \${graph_period}\n";
print "graph_category Varnish\n";
}
$i = 0;
foreach $line (`varnishstat -1`) {
chomp $line;
if ($line =~ /^\s+(\d+)\s+($grepfor.*)$/) {
$val = $1;
$key = $2;
($printkey = lc ($key)) =~ s/\s/_/g;
if ($config) {
print "$printkey\.label $key\n";
print "$printkey\.type DERIVE\n";
print "$printkey\.min 0\n";
print "$printkey\.draw ";
if ($i == 0) {
print "AREA\n";
} else {
print "STACK\n";
}
$i++;
} else {
print "$printkey\.value $val\n";
}
}
}
exit;