/[omni_gantt]/omni2db.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 /omni2db.pl

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

revision 1.1 by dpavlin, Wed Sep 11 16:41:00 2002 UTC revision 1.4 by dpavlin, Thu Sep 12 07:59:57 2002 UTC
# Line 10  my $dbh = DBI->connect("DBI:Pg:dbname=ga Line 10  my $dbh = DBI->connect("DBI:Pg:dbname=ga
10  my %omni;  my %omni;
11    
12  sub db {  sub db {
13          my $rv = $dbh->do("update gantt          return if (scalar keys %omni != 6);
14    
15            my $sql = "update gantt
16                  set finish=now() where                  set finish=now() where
17                  sessionid='$omni{SessionID}' and                  sessionid='$omni{SessionID}' and
18                  type='$omni{Session_type}' and                  type='$omni{Session_type}' and
19                  status='$omni{Session_status}' and                  status='$omni{Session_status}' and
20                  user_group_host='".$omni{'User.Group@Host'}."' and                  user_group_host='".$omni{'User.Group@Host'}."' and
21                  specification='$omni{Backup_Specification}'");                  specification='$omni{Backup_Specification}'";
22    
23            my $rv = $dbh->do($sql);
24    
25            print "sql:\n$sql\nrv: $rv\n" if ($debug);
26    
27          $dbh->do ("insert into gantt (sessionid,type,status,          $dbh->do ("insert into gantt (sessionid,type,status,
28                  user_group_host,specification) values                  user_group_host,specification) values
29                  ('$omni{SessionID}','$omni{Session_type}',                  ('$omni{SessionID}','$omni{Session_type}',
30                  '$omni{Session_status}',                  '$omni{Session_status}',
31                  '".$omni{'User.Group@Host'}."',                  '".$omni{'User.Group@Host'}."',
32                  '$omni{Backup_Specification}')") if ($rv eq "0E0");                  '$omni{Backup_Specification}')") if ($rv eq "0E0" || !$rv);
33  }  }
34    
35  open(O, "/usr/omni/bin/omnistat -detail |") || die "omnistat: $!";  open(O, "/usr/omni/bin/omnistat -detail |") || die "omnistat: $!";
36  while(<O>) {  while(<O>) {
37          chomp;          chomp;
38          if (/^$/) {          if (/^$/) {
39                  db() if (scalar keys %omni == 4);                  db();
40                  %omni = ();                  %omni = ();
41                  print "------------\n" if ($debug);                  print "------------\n" if ($debug);
42                  next;                  next;
43          }          }
44          s/^[\t\s]+//;          s/^[\t\s]+//;
45          my ($l,$r) = split (/\s*:\s*/,$_,2);          my ($l,$r) = split (/\s*:\s*/,$_,2);
46          $l =~ s/\s+/_/g;          if ($r) {
47          $r =~ s/\s+$//g;                  $l =~ s/\s+/_/g;
48          print "$l -> $r\n" if ($debug);                  $r =~ s/\s+$//g;
49          $omni{$l} = $r;                  print "$l -> $r\n" if ($debug);
50                            $omni{$l} = $r;
51            }
52  }  }
53  db();  db();
54  close(O);  close(O);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.26