-
Notifications
You must be signed in to change notification settings - Fork 0
/
slabviewlite
executable file
·43 lines (32 loc) · 1.42 KB
/
slabviewlite
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
#!/usr/bin/perl
use strict;
use warnings;
#use Data::Dumper;
use Getopt::Long;
require "util.pl";
my $opt_num = 0;
GetOptions('num' => \$opt_num);
my $host = shift || "localhost";
my $port = shift || "11211";
my $sock = &getSocket("$host:$port");
die "Could not connect to $host\n" unless $sock;
my ($maxid, %classes) = &getAllStatus($sock);
die "No items in $host" unless $maxid;
printf(" # ID SIZE FREE / TOTAL REQUESTED EVICTED SPARE MULTI FAILED SIZExTOTAL SIZExUSED SIZExEVICT \n") if $opt_num != 0;
for my $n (1..$maxid) {
my $cls = $classes{$n};
if ($opt_num != 0) {
# my $usage_rate = $cls->{mem_requested} / $cls->{chunk_size} * $cls->{total_chunks};
printf("Class%3d %8d %8d / %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", $n, $cls->{chunk_size}, $cls->{free_chunks}, $cls->{total_chunks}, $cls->{mem_requested}, $cls->{evicted}, $cls->{sparelargered}, $cls->{multiblocked}, $cls->{extraalloc_failed}, ($cls->{chunk_size} * $cls->{total_chunks}), ($cls->{chunk_size} * $cls->{used_chunks}), ($cls->{chunk_size} * $cls->{evicted}));
} else {
my $free = 1;
$free = $cls->{free_chunks} / $cls->{total_chunks} * 100 unless $cls->{total_chunks} == 0;
my $freebar = int($free / 2);
$freebar = 50 if $free > 50;
my $bar = "";
for my $freechar (1..$freebar) {$bar .= "#";}
for my $usedchar ($freebar+1..50) {$bar .= "-";}
printf("Class%3d %s %.1f\n",$n,$bar,$free);
}
}
__END__