diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-11-26 21:26:32 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-11-26 21:26:32 (GMT) |
commit | 2481a1ff41a5ee7e33807947813ad4672bdcc851 (patch) | |
tree | f4a1a27911ca895930c69e6083a3fa6ae3d61918 /utils/rhrd-sanity-check | |
parent | 7c274ec4359b20a78beb367bf5b4d9274639fe79 (diff) |
inital sanity checks for logs
Diffstat (limited to 'utils/rhrd-sanity-check')
-rwxr-xr-x | utils/rhrd-sanity-check | 186 |
1 files changed, 125 insertions, 61 deletions
diff --git a/utils/rhrd-sanity-check b/utils/rhrd-sanity-check index 0929523..640c304 100755 --- a/utils/rhrd-sanity-check +++ b/utils/rhrd-sanity-check @@ -21,6 +21,7 @@ # use strict; +use lib "../lib/"; use RHRD::rddb; sub print_usage @@ -33,7 +34,91 @@ if($num_args > 0) { print_usage(); exit(1); } -my $ret = 0; + + + +sub check_showids +{ + my ($ctx) = @_; + + my $errors = 0, + print "showids:\n"; + + my @show_ids = RHRD::rddb::list_showids($ctx); + if(!defined $show_ids[0] && defined $show_ids[1]) { + print STDERR "$show_ids[1]: $show_ids[2]"; + return -1; + } + for my $show_id (@show_ids) { + my @carts = RHRD::rddb::get_show_carts($ctx, $show_id); + if(!defined $carts[0] && defined $carts[1]) { + print " showid '" . $show_id . "': $carts[2]\n"; + $errors++; + } + if(scalar @carts == 0) { + print " showid '" . $show_id . "': log is empty\n"; + $errors++; + } + + my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $show_id); + unless(defined($group)) { + print " showid '" . $show_id . "': has no dropbox assigned\n"; + $errors++; + } else { + } + } + print "\n " . $errors . " errors found\n"; + + return $errors; +} + + + +sub check_logs +{ + my ($ctx) = @_; + + my $errors = 0, + print "logs:\n"; + + my @logs = RHRD::rddb::list_logs($ctx); + if(!defined $logs[0] && defined $logs[1]) { + print STDERR "$logs[1]: $logs[2]"; + return -1; + } + for my $log (@logs) { + my ($log_exists, $status, $errorstring) = RHRD::rddb::check_log_exists($ctx, $log); + if(!defined $log_exists) { + print STDERR "$status: $errorstring"; + return -1; + } + unless($log_exists) { + print " log '" . $log . "': does not exist\n"; + $errors++; + } + + (my $log_tab_exists, $status, $errorstring) = RHRD::rddb::check_log_table_exists($ctx, $log); + if(!defined $log_tab_exists) { + print STDERR "$status: $errorstring"; + return -1; + } + if($log_tab_exists) { + unless($log_exists) { + print " log '" . $log . "': this log shouldn't not exist but there is a table named after it\n"; + $errors++; + } + } else { + if($log_exists) { + print " log '" . $log . "': this log should exist but there is no table named after it\n"; + $errors++; + } + } + + } + print "\n " . $errors . " errors found\n"; + + return $errors; +} @@ -102,7 +187,7 @@ sub check_groups__check_musicpool_group my $errors = 0; - # TODO: check whether enough evergreens are imported: should be > 3 + # TODO: check for pool size: should be > 150 my ($nownext, $traffic, $music) = RHRD::rddb::get_group_reports($ctx, $group); unless(defined $nownext) { @@ -131,7 +216,7 @@ sub check_groups__check_jingle_group my $errors = 0; - # TODO: check for pool size: should be > 150 + # TODO: check whether enough evergreens are imported: should be > 3 my ($nownext, $traffic, $music) = RHRD::rddb::get_group_reports($ctx, $group); unless(defined $nownext) { @@ -256,6 +341,7 @@ sub check_groups } + sub check_dropboxes { my ($ctx) = @_; @@ -269,69 +355,47 @@ sub check_dropboxes } -sub check_showids -{ - my ($ctx) = @_; - - my $errors = 0, - print "showids:\n"; - - my @show_ids = RHRD::rddb::list_showids($ctx); - if(!defined $show_ids[0] && defined $show_ids[1]) { - print STDERR "$show_ids[1]: $show_ids[2]"; - return -1; - } - for my $show_id (@show_ids) { - my @carts = RHRD::rddb::get_show_carts($ctx, $show_id); - if(!defined $carts[0] && defined $carts[1]) { - print " showid '" . $show_id . "': $carts[2]\n"; - $errors++; - } - if(scalar @carts == 0) { - print " showid '" . $show_id . "': has no log assigned or log is empty\n"; - $errors++; - } - - my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $show_id); - unless(defined($group)) { - print " showid '" . $show_id . "': has no dropbox assigned\n"; - $errors++; - } else { - } - } - print "\n " . $errors . " errors found\n"; - - return $errors; -} - - -sub check_logs -{ - my ($ctx) = @_; - - my $errors = 0, - print "logs:\n"; - - print "\n " . $errors . " errors found\n"; - - return $errors; -} - +my $errors = 0; my ($ctx, $status, $errorstring) = RHRD::rddb::init(); if(defined $ctx) { - check_showids($ctx); - print "\n"; - check_logs($ctx); - print "\n"; - check_groups($ctx); - print "\n"; - check_dropboxes($ctx); - + for(;;) { + my $ret = check_showids($ctx); + if($ret < 0) { + $errors = $ret; + last; + } else { $errors += $ret } + + print "\n"; + + $ret = check_logs($ctx); + if($ret < 0) { + $errors = $ret; + last; + } else { $errors += $ret } + + print "\n"; + + $ret = check_groups($ctx); + if($ret < 0) { + $errors = $ret; + last; + } else { $errors += $ret } + + print "\n"; + + $ret = check_dropboxes($ctx); + if($ret < 0) { + $errors = $ret; + last; + } else { $errors += $ret } + + last; + } RHRD::rddb::destroy($ctx); } else { print STDERR "$errorstring\n"; - $ret = 1; + $errors = -1; } -exit $ret; +exit $errors; |