/[psinib]/psinib.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /psinib.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by dpavlin, Sun Oct 12 18:47:35 2003 UTC revision 1.16 by dpavlin, Sun Oct 26 12:55:56 2003 UTC
# Line 30  use Getopt::Long; Line 30  use Getopt::Long;
30  my $LOG_TIME_FMT = '%Y-%m-%d %H:%M:%S'; # strftime format for logfile  my $LOG_TIME_FMT = '%Y-%m-%d %H:%M:%S'; # strftime format for logfile
31  my $DIR_TIME_FMT = '%Y%m%d';            # strftime format for backup dir  my $DIR_TIME_FMT = '%Y%m%d';            # strftime format for backup dir
32    
33    # define timeout for ping
34    my $PING_TIMEOUT = 5;
35    
36  my $LOG = '/var/log/backup.log';        # add path here...  my $LOG = '/var/log/backup.log';        # add path here...
37  #$LOG = '/tmp/backup.log';  #$LOG = '/tmp/backup.log';
38    
# Line 72  my $mounts = shift @ARGV || Line 75  my $mounts = shift @ARGV ||
75    
76  my @in_backup;  # shares which are backeduped this run  my @in_backup;  # shares which are backeduped this run
77    
78    # init Net::Ping object
79  my $ping;  my $ping;
80  if ($use_ping) {  if ($use_ping) {
81          $ping = new Net::Ping->new("tcp", 2);          $ping = new Net::Ping->new("syn", 2);
82          # ping will try tcp connect to netbios-ssn (139)          # ping will try tcp connect to netbios-ssn (139)
83          $ping->{port_num} = getservbyname("netbios-ssn", "tcp");          $ping->{port_num} = getservbyname("netbios-ssn", "tcp");
84  }  }
85    
86    # do syn ping to cifs port
87    sub host_up {
88            my $ping = shift || return;
89            my $host_ip = shift || xlog("host_up didn't get IP");
90            my $timeout = shift;
91            return 1 if (! $use_ping);
92    
93            $ping->ping($host_ip,$timeout);
94            my $return = 0;
95    
96            while (my ($host,$rtt,$ip) = $ping->ack) {
97                    xlog("","HOST: $host [$ip] ACKed in $rtt seconds");
98                    $return = 1 if ($ip eq $host_ip);
99            }
100            return $return;
101    }
102    
103  my $backup_ok = 0;  my $backup_ok = 0;
104    
105  my $smb;  my $smb;
# Line 139  while(<M>) { Line 160  while(<M>) {
160    
161          if ($ip) {          if ($ip) {
162                  xlog($share,"IP is $ip");                  xlog($share,"IP is $ip");
163                  if (($use_ping && $ping->ping($ip)) || 1) {                  if (host_up($ping, $ip,$PING_TIMEOUT)) {
164                          if (snap_share($share,$user,$passwd,$workgroup)) {                          if (snap_share($share,$user,$passwd,$workgroup)) {
165                                  $backup_ok++;                                  $backup_ok++;
166                          }                          }
# Line 678  be renamed to I<YYYYMMDD.partial> and sn Line 699  be renamed to I<YYYYMMDD.partial> and sn
699  linking same files (other alternative would be to erase that dir and find  linking same files (other alternative would be to erase that dir and find
700  second-oldest directory, but this seemed like more correct approach).  second-oldest directory, but this seemed like more correct approach).
701    
702    =head2 I can't connect to any share
703    
704    Please verify that nmblookup (which is part of samba package) is in /bin or
705    /usr/bin. Also verify that nmblookup returns IP address for your server
706    using:
707    
708       $ nmblookup tvhouse
709       querying tvhouse on 192.168.34.255
710       192.168.34.30 tvhouse<00>
711    
712    If you don't get any output, your samba might not listen to correct interface
713    (see interfaces in smb.conf).
714    
715  =head1 AUTHOR  =head1 AUTHOR
716    
717  Dobrica Pavlinusic <dpavlin@rot13.org>  Dobrica Pavlinusic <dpavlin@rot13.org>

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.26