App-FQStat
view release on metacpan or search on metacpan
generated_by: ExtUtils::MakeMaker version 6.44
distribution_type: module
requires:
DateTime: 0
File::HomeDir: 0
String::ShellQuote: 0
String::Trigram: 0
Term::ANSIScreen: 0
Term::CallEditor: 0
Term::ReadKey: 0
threads: 0
threads::shared: 0
Time::HiRes: 0
Time::Zone: 0
YAML::Tiny: 0
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
Makefile.PL view on Meta::CPAN
DateTime => '0',
File::HomeDir => '0',
String::ShellQuote => '0',
String::Trigram => '0',
Term::ANSIScreen => '0',
Term::CallEditor => '0',
Time::HiRes => '0',
Term::ReadKey => '0',
Time::Zone => '0',
YAML::Tiny => '0',
threads => '0',
threads::shared => '0',
}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/App/FQStat.pm', # retrieve abstract from module
AUTHOR => 'Steffen Mueller <smueller@cpan.org') : ()),
);
lib/App/FQStat/Scanner.pm view on Meta::CPAN
use Time::Zone ();
use App::FQStat::Debug;
# run qstat
sub run_qstat {
warnenter if ::DEBUG;
my $forced = shift;
lock($::ScannerStartRun);
if (not defined $::ScannerThread) {
warnline "Creating new (initial?) scanner thread" if ::DEBUG;
$::ScannerThread = threads->new(\&App::FQStat::Scanner::scanner_thread);
}
elsif ($::ScannerThread->is_joinable()) {
warnline "Joining scanner thread" if ::DEBUG;
my $return = $::ScannerThread->join();
($::Records, $::NoActiveNodes) = @$return;
$::Summary = [];
$::Initialized = 1;
{ lock($::RecordsChanged); $::RecordsChanged = 1; }
warnline "Joined scanner thread. Creating new scanner thread" if ::DEBUG;
$::ScannerThread = threads->new(\&App::FQStat::Scanner::scanner_thread);
}
elsif (!$::ScannerThread->is_running()) {
warnline "scanner thread not running. Creating new scanner thread" if ::DEBUG;
undef $::ScannerThread;
$::ScannerThread = threads->new(\&App::FQStat::Scanner::scanner_thread);
}
elsif ($forced) {
warnline "scanner thread running. Force in effect, setting StartRun" if ::DEBUG;
$::ScannerStartRun = 1;
}
}
sub scanner_thread {
warnenter if ::DEBUG;
{
lock($::ScannerStartRun);
$::ScannerStartRun = 0;
}
my @lines;
my @args;
{
lock($::SummaryMode);
lib/App/FQStat/Scanner.pm view on Meta::CPAN
sort_current(\@lines);
lock($::DisplayOffset);
lock(@::Termsize);
my $limit = @lines - $::Termsize[1]+4;
if ($::DisplayOffset and $::DisplayOffset > $limit) {
$::DisplayOffset = $limit;
}
sleep 0.1; # Note to self: fractional sleep without HiRes => CPU=100%
warnline "End of scanner_thread" if ::DEBUG;
return [\@lines, $noActiveNodes];
}
# sorts the qstat output by $::SortField
sub sort_current {
script/fqstat.pl view on Meta::CPAN
#!/usr/bin/perl
use 5.008;
# fqstat.pl (version see FQStat.pm) is (c) 2007-2009 Steffen Mueller
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
use strict;
use warnings;
use threads;
use threads::shared;
use IO::Handle;
use Time::HiRes qw/sleep time/;
use Term::ANSIScreen qw/RESET cls/;
use Term::ReadKey;
use Getopt::Long;
use constant DEBUG => 0;
use constant STARTTIME => Time::HiRes::time();
script/fqstat.pl view on Meta::CPAN
our @SummaryColumns = qw(user name n_run n_err n_hld n_wait prio time maxtime);
# Data structure to hold information about the current state of affairs
our $Records = [];
our $RecordsChanged : shared = 0;
our $RecordsReversed : shared = 0;
our $NoActiveNodes = 0;
our $Summary = [];
# scanner thread globals, see below.
##############
# Get Command line arguments
our $User : shared;
our $UserInterval = 30;
our $SlowRedraw = 0;
my $SSHCommand;
our $ResetConfig;
Getopt::Long::Configure("no_ignore_case");
GetOptions(
'u|user=s' => \$User,
'H|highlight=s' => \$HighlightUser,
'i|interval=f' => \$UserInterval,
's|slow' => \$SlowRedraw,
'ssh=s' => \$SSHCommand,
'resetconfig' => \$ResetConfig,
'h|help|?' => sub {
ReadMode 1;
print RESET;
print usage();
thread_cleanup();
exit(1);
},
);
$UserInterval ||= 30;
$Interval = $UserInterval; # start out with requested interval
##############
# Get/prepare configuration
if ($ResetConfig) {
App::FQStat::Config::reset_configuration();
script/fqstat.pl view on Meta::CPAN
if (not App::FQStat::System::module_install_can_run($QStatCmd)) {
print <<HERE;
ERROR!
You cannot run fqstat without having a working "qstat" command in your
application search path. Please add a "qstat" to \$PATH and retry.
(Or use the --ssh option correctly.)
HERE
print RESET;
thread_cleanup();
ReadMode 1;
exit(1);
}
# XXX Check for qdel and qalter too?
###################
# setup scanner thread
our $ScannerStartRun : shared = 0;
our $ScannerThread;# = threads->new(\&App::FQStat::Scanner::scanner_thread);
# thread exit handler
sub thread_cleanup {
warnenter if ::DEBUG;
if (defined $ScannerThread and $ScannerThread->is_running()) {
print "Cleaning up polling threads...\n";
$ScannerThread->kill('SIGKILL');
}
}
# exit handler
sub cleanup_and_exit {
warnenter if ::DEBUG;
print RESET;
Term::ANSIScreen::locate($Termsize[1],1);
thread_cleanup();
ReadMode 1;
print "Have a nice day!\n" unless @_;
exit();
}
$SIG{INT} = \&cleanup_and_exit;
$SIG{HUP} = \&cleanup_and_exit;
$SIG{TERM} = \&cleanup_and_exit;
$SIG{__DIE__} = sub{warn @_;ReadMode 1;exit(1);};
script/fqstat.pl view on Meta::CPAN
if (defined $innerkey and exists($ControlKeysHash->{"$key$innerkey"})) {
my $redraw = $ControlKeysHash->{"$key$innerkey"}->("$key$innerkey");
$Redraw = 1 if $redraw;
}
}
} # end control keys
} # end if defined input
# Fetch new scanner results if applicable
if (defined $ScannerThread and $ScannerThread->is_joinable()) {
warnline "Scanner thread joinable in main loop. Joining" if ::DEBUG;
my $return = $ScannerThread->join();
($Records, $NoActiveNodes) = @$return;
$Initialized = 1;
warnline "Scanner thread joined in main loop" if ::DEBUG;
lock($RecordsChanged);
$RecordsChanged = 1;
$Summary = [];
}
my $startRun;
{
lock($ScannerStartRun);
$startRun = $ScannerStartRun;
}
( run in 0.570 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )