-
-
Save afresh1/f56f8d09437e3ed4f1c6a28e0ab73f28 to your computer and use it in GitHub Desktop.
Revisions
-
afresh1 revised this gist
Jul 22, 2017 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,9 @@ ($) my $Body = 'At ' . hostname() . " $Msg\n"; print $Body; } sub debug ($) { print localtime . " @_\n" } my $base = $FreshPorts::Config::QueueBaseDir; @@ -33,28 +36,40 @@ ($) my $CountRecent; debug("Starting sites loop"); foreach my $site (@FreshPorts::Status::sites) { debug("> SITE: $site"); $msg .= "SITE: $site "; foreach my $queue (sort keys %queues) { debug("-> QUEUE: $queue"); my $pattern = $queues{$queue} || '*'; my $Count = glob( "$base/$site/msgs/FreeBSD/$queue/$pattern" ); $msg .= " $queue: $Count "; debug("-> COUNT: $count"); if ($Count && defined($report_non_zero{$queue})) { debug("-> Checking report"); if (!defined($CountRecent)) { debug("-> Getting dbh"); my $dbh = FreshPorts::Database::GetDBHandle(); debug("-> Getting CountRecent"); $CountRecent = FreshPorts::Utilities::CommitCountPeriod($dbh, $Interval); debug("-> CountRecent: $CountRecent"); $dbh->disconnect(); } if ($Count > $CountRecent) { debug("-> Enabling Report"); $send_report = 1; } } debug("-> Done: $queue"); } $msg .= " "; debug("> DONE: $site"); } debug($msg); if ($send_report) { # Sys::Syslog::syslog('notice', 'There is a problem with the FreshPorts queues'); -
afresh1 revised this gist
Jul 22, 2017 . 1 changed file with 14 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,28 +1,26 @@ #!/usr/bin/perl # # $Id: queue-status.pl,v 1.3 2012/10/17 18:10:22 dan Exp $ # # Copyright (c) 2001-2006 DVL Software # use strict; use warnings; use config; use database; use utilities; use status; use Sys::Hostname 'hostname'; sub SendNotice($) { my $Msg = shift; my $Body = 'At ' . hostname() . " $Msg\n"; print $Body; } my $base = $FreshPorts::Config::QueueBaseDir; my %queues = ('incoming' => '*.txt', 'retry' => '*.txt', 'recent' => '*.xml'); my %queue_names = ('incoming' => 'incoming', 'retry' => 'retry', 'recent' => 'processed'); @@ -35,20 +33,19 @@ ($) my $CountRecent; foreach my $site (@FreshPorts::Status::sites) { $msg .= "SITE: $site "; foreach my $queue (sort keys %queues) { my $pattern = $queues{$queue} || '*'; my $Count = glob( "$base/$site/msgs/FreeBSD/$queue/$pattern" ); $msg .= " $queue: $Count "; if ($Count && defined($report_non_zero{$queue})) { if (!defined($CountRecent)) { my $dbh = FreshPorts::Database::GetDBHandle(); $CountRecent = FreshPorts::Utilities::CommitCountPeriod($dbh, $Interval); $dbh->disconnect(); } if ($Count > $CountRecent) { $send_report = 1; @@ -62,9 +59,8 @@ ($) if ($send_report) { # Sys::Syslog::syslog('notice', 'There is a problem with the FreshPorts queues'); SendNotice($msg); } else { print 'Queues are OK'; } exit($send_report) -
afresh1 revised this gist
Jul 22, 2017 . 1 changed file with 3 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,20 +41,9 @@ ($) foreach my $site (@FreshPorts::Status::sites) { $msg .= "SITE: $site "; foreach my $queue (keys %queues) { my $pattern = $queues{$queue} || '*'; my $Count = glob( "$base/$site/msgs/FreeBSD/$queue/$pattern" ); $msg .= " $queue: $Count "; if ($Count && defined($report_non_zero{$queue})) { -
dlangille created this gist
Jul 22, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ #!/usr/bin/perl -w # # $Id: queue-status.pl,v 1.3 2012/10/17 18:10:22 dan Exp $ # # Copyright (c) 2001-2006 DVL Software # use strict; use config; use database; use utilities; use status; sub SendNotice($) { my $Msg = shift; my $hostname = `hostname`; chomp $hostname; my $Body = 'At ' . $hostname . ' ' . $Msg . "\n"; print $Body; } my $base=$FreshPorts::Config::QueueBaseDir; my %queues = ('incoming' => '*.txt', 'retry' => '*.txt', 'recent' => '*.xml'); my %queue_names = ('incoming' => 'incoming', 'retry' => 'retry', 'recent' => 'processed'); my %report_non_zero = ('retry' => 1, 'incoming' => 1); my $Interval = '10 minutes'; my $send_report = 0; my $msg = ''; my $CountRecent; undef($CountRecent); my $dbh = FreshPorts::Database::GetDBHandle(); foreach my $site (@FreshPorts::Status::sites) { $msg .= "SITE: $site "; while (my ($queue, $pattern) = each %queues) { my $Command = "find $base/$site/msgs/FreeBSD/$queue/"; # print $Command . "\n"; if ($pattern ne '') { $Command .= " -name \"$pattern\""; } $Command .= ' -maxdepth 1 | wc -l'; # print $Command . "\n"; my $Count = `$Command`; chomp $Count; $Count = FreshPorts::Utilities::trim($Count); $msg .= " $queue: $Count "; if ($Count && defined($report_non_zero{$queue})) { if (!defined($CountRecent)) { $CountRecent = FreshPorts::Utilities::CommitCountPeriod($dbh, $Interval); } if ($Count > $CountRecent) { $send_report = 1; } } } $msg .= " "; } if ($send_report) { # Sys::Syslog::syslog('notice', 'There is a problem with the FreshPorts queues'); SendNotice($msg); $dbh->disconnect(); exit(1) } else { print 'Queues are OK'; $dbh->disconnect(); }