Added better error handling to vlogger script in case that the mysql database connection is not available.
| | |
| | | } |
| | | |
| | | # test the connection |
| | | eval { |
| | | my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS ) |
| | | or die "DBI Error: $!"; |
| | | $dbh->disconnect; |
| | | }; |
| | | if ($@) { |
| | | print "MySQL Connection problem\n"; |
| | | } |
| | | |
| | | # SIGALRM dumps the tracker hash |
| | | $SIG{ALRM} = \&dump_tracker; |
| | |
| | | |
| | | # sub to update the database with the tracker data |
| | | sub dump_tracker { |
| | | eval { |
| | | if ( keys(%tracker) > 0 ) { |
| | | my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS ) |
| | | or warn "DBI Error: $!"; |
| | |
| | | %tracker = (); |
| | | } |
| | | alarm $DBI_DUMP; |
| | | }; |
| | | if ($@) { |
| | | print "Unable to store vlogger data in database\n"; |
| | | } |
| | | } |
| | | |
| | | # print usage info |