File: ch11.bind_debug.perl

package info (click to toggle)
bind 1%3A8.4.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,752 kB
  • ctags: 22,385
  • sloc: ansic: 159,091; sh: 19,593; perl: 14,224; makefile: 5,554; yacc: 2,475; cpp: 2,154; csh: 848; awk: 753; tcl: 674; lex: 423; fortran: 240
file content (29 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl
#
# Turn name server debugging on or off.  
#
# To turn off debugging, use "binddebug 0"
# To turn on debugging to level 3, use "binddebug 3"

# Find the process ID in /etc/named.pid.
open(PID, "/etc/named.pid") || die "Can\'t open /etc/named.pid\n";
$pid = <PID>;
chop($pid);
$pid || die "No process ID in /etc/named.pid\n";

# Get the debugging level from the command line.
$savelevel = $level = $ARGV[0];
$level =~ /^[0-9]+$/ || die "Integer argument required\n";

# Turn off debugging if it is on.
if(!kill 'USR2', $pid){ die "Kill of process ID $pid failed.\n"; }

if($level == 0){
  print "Debugging turned off.\n";
} else {
  while($level-- > 0) { 
    select(undef, undef, undef, 0.25);  # spread out signals
    kill 'USR1', $pid; 
  }
  printf "Name server now at debugging level $savelevel.\n";
}