1N/A# dnlcstat - DNLC statistics. 1N/A# Written in DTrace (Solaris 10 3/05). 1N/A# The DNLC is the Directory Name Lookup Cache. Filename lookups often 1N/A# return a hit from here, before needing to traverse the regular file 1N/A# system cache or go to disk. 1N/A# $Id: dnlcstat 3 2007-08-01 10:50:08Z brendan $ 1N/A# USAGE: dnlcstat [interval [count]] 1N/A# %hit hit percentage for this sample 1N/A# hit number of DNLC hits in this sample 1N/A# miss number of DNLC misses in this sample 1N/A# (contains a dnlcstat written in Perl, which uses less CPU) 1N/A# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. 1N/A# The contents of this file are subject to the terms of the 1N/A# Common Development and Distribution License, Version 1.0 only 1N/A# (the "License"). You may not use this file except in compliance 1N/A# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# 27-Mar-2004 Brendan Gregg Created this. 1N/A# 14-Jun-2005 " " Updated style. 1N/A# 14-Jun-2005 " " Last update. 1N/A############################## 1N/A# --- Process Arguments --- 1N/Aif [
"$1" =
"-h" -o
"$1" =
"--help" ];
then 1N/A USAGE: dnlcstat [interval [count]] 1N/A dnlcstat # 1 second samples, infinite 1N/A dnlcstat 1 # print every 1 second 1N/A dnlcstat 5 6 # print every 5 seconds, 6 times 1N/Aif [ "$1" -gt 0 ]; then 1N/A interval=$1; count=-1; shift 1N/Aif [ "$1" -gt 0 ]; then 1N/Aif [ $interval -eq 0 ]; then 1N/A################################# 1N/A# --- Main Program, DTrace --- 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A * Command line arguments 1N/A inline int INTERVAL = '$interval'; 1N/A inline int COUNTER = '$count'; 1N/A inline int SCREEN = 21; 1N/A int hits; /* hits */ 1N/A int misses; /* misses */ 1N/A * Initialise variables 1N/A /first || (secs == 0 && lines > SCREEN)/ 1N/A printf("%10s %8s %8s\n","dnlc %hit","hit","miss"); 1N/A * Probe DNLC lookups 1N/A fbt:genunix:dnlc_lookup:return 1N/A hits += arg1 == 0 ? 0 : 1; 1N/A misses += arg1 == 0 ? 1 : 0; 1N/A /* calculate hit percent */ 1N/A this->divide = misses + hits == 0 ? 1 : misses + hits; 1N/A ratio = hits * 100 / this->divide; 1N/A printf("%10d %8d %8d\n",ratio,hits,misses); 1N/A /* clear counters */ 1N/A /* process counts */