--- omni2db.pl 2002/09/13 12:38:25 1.5 +++ omni2db.pl 2003/10/05 10:12:44 1.7 @@ -47,34 +47,41 @@ } close(O); } - - $dbh->do ("insert into gantt (sessionid,type,status, + + $sql = "insert into gantt (sessionid,type,status, user_group_host,specification,device,host) values ('$omni{SessionID}','$omni{Session_type}', '$omni{Session_status}', '".$omni{'User.Group@Host'}."', '$omni{Backup_Specification}', - '$device','$host')") + '$device','$host')"; + + $dbh->do($sql) || warn "$sql : ".$dbh->errstr(); + } } open(O, "/usr/omni/bin/omnistat -detail |") || die "omnistat: $!"; -while() { - chomp; - if (/^$/) { - db(); - %omni = (); - print "------------\n" if ($debug); - next; - } - s/^[\t\s]+//; - my ($l,$r) = split (/\s*:\s*/,$_,2); - if ($r) { - $l =~ s/\s+/_/g; - $r =~ s/\s+$//g; - print "$l -> $r\n" if ($debug); - $omni{$l} = $r; +if (!eof(O)) { + # somehow, from time to time omnistats dies before we get here + # this is a workaround to keep cron e-mails from reporting it. + while() { + chomp; + if (/^$/) { + db(); + %omni = (); + print "------------\n" if ($debug); + next; + } + s/^[\t\s]+//; + my ($l,$r) = split (/\s*:\s*/,$_,2); + if ($r) { + $l =~ s/\s+/_/g; + $r =~ s/\s+$//g; + print "$l -> $r\n" if ($debug); + $omni{$l} = $r; + } } + db(); + close(O); } -db(); -close(O);