diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-10-06 15:17:50 -0700 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-10-06 15:17:50 -0700 |
commit | 730d6e3fdbf57afe013d9ebfad93c48d7690244f (patch) | |
tree | d4d180f5505f4ae6ee3fb99a74cdf2b5966e8900 /scripts/vyatta-op-dns-forwarding.pl | |
parent | 095b95a0e944326a71f848221484c94ca48a23f7 (diff) | |
download | vyatta-op-730d6e3fdbf57afe013d9ebfad93c48d7690244f.tar.gz vyatta-op-730d6e3fdbf57afe013d9ebfad93c48d7690244f.zip |
make sure file has been written to before extracting
stuff for 'show dns forwarding statistics' command
Diffstat (limited to 'scripts/vyatta-op-dns-forwarding.pl')
-rw-r--r-- | scripts/vyatta-op-dns-forwarding.pl | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/vyatta-op-dns-forwarding.pl b/scripts/vyatta-op-dns-forwarding.pl index 24a64e6..1f8f96d 100644 --- a/scripts/vyatta-op-dns-forwarding.pl +++ b/scripts/vyatta-op-dns-forwarding.pl @@ -210,6 +210,26 @@ sub print_nameservers { print $show_nameservers_output; } +sub wait_for_write { + + my $last_size = (stat($dnsmasq_log))[7]; + my $cnt=0; + while(1) { + system("usleep 10000"); # sleep for 0.01 second + my $curr_size = (stat($dnsmasq_log))[7]; + if( $curr_size == $last_size ) { + # Not modified + $cnt++; + last if($cnt > 1); + } else { + # Modified\n + $cnt=0; + } + $last_size = $curr_size; + } + +} + # # main # @@ -229,7 +249,8 @@ if (defined $clear_all) { } if (defined $show_statistics) { - system("echo > /var/log/dnsmasq.log; kill -10 `pidof dnsmasq`"); + system("echo > $dnsmasq_log; kill -10 `pidof dnsmasq`"); + wait_for_write; get_cache_stats; get_nameserver_stats; print_stats; |