/usr/lib/oar/oarnotify is in oar-server 2.5.7-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | #!/usr/bin/perl
# $Id$
# notify Almighty
use strict;
use warnings;
use Data::Dumper;
use OAR::Conf qw(init_conf dump_conf get_conf is_conf);
use Getopt::Long;
use OAR::Version;
use OAR::Tools;
use OAR::IO;
my $Old_umask = sprintf("%lo",umask());
umask(oct("022"));
init_conf($ENV{OARCONFFILE});
my $remote_host = get_conf("SERVER_HOSTNAME");
my $remote_port = get_conf("SERVER_PORT");
Getopt::Long::Configure("gnu_getopt");
my $Version;
my @Enable_queue;
my @Disable_queue;
my @Add_queue;
my @Remove_queue;
my $Enable_all;
my $Disable_all;
my $List_queues;
my $sos;
GetOptions ("version|V" => \$Version,
"enable-queue|e=s" => \@Enable_queue,
"disable-queue|d=s" => \@Disable_queue,
"Enable-all-queues|E" => \$Enable_all,
"Disable-all-queues|D" => \$Disable_all,
"add-queue=s" => \@Add_queue,
"remove-queue=s" => \@Remove_queue,
"list-queues|l" => \$List_queues,
"enable_queue=s" => \@Enable_queue,
"disable_queue=s" => \@Disable_queue,
"Enable_all_queues" => \$Enable_all,
"Disable_all_queues" => \$Disable_all,
"add_queue=s" => \@Add_queue,
"remove_queue=s" => \@Remove_queue,
"list_queues" => \$List_queues,
"help|h" => \$sos
) or exit(1);
# Display command help
sub usage {
print <<EOS;
Usage: $0 [-h] [-V] [-e str] [-d str] [-E] [-D] [--add-queue str] [--remove-queue]
[-l] [tag_to_Almighty]
Send a tag to Almighty and manage queues
Options:
-e, --enable-queue active an existing queue
-d, --disable-queue inactive an existing queue
-E, --Enable-all-queues active all queues
-D, --Disable-all-queues inactive all queues
--add-queue add a new queue; syntax is name,priority,scheduler
(ex: "name,3,oar-sched-gantt-with-timesharing")
--remove-queue remove an existing queue
-l, --list-queues list all queues and there status
-h, --help show this help screen
-V, --version print OAR version number
EOS
exit(1);
}
if (defined($sos)){
usage();
exit(0);
}
if (defined($Version)){
print("OAR version : ".OAR::Version::get_version()."\n");
exit(0);
}
my $base = OAR::IO::connect();
foreach my $q (@Add_queue){
my ($queue,$priority,$scheduler) = split(',',$q);
if (defined($queue)){
$priority = 0 if (!defined($priority));
$scheduler = "oar_sched_gantt_with_timesharing" if (!defined($scheduler));
print("Add queue $queue with the priority $priority and the scheduler $scheduler.\n");
OAR::IO::create_a_queue($base,$queue,$scheduler,$priority);
}
}
foreach my $q (@Remove_queue){
print("Remove queue $q.\n");
OAR::IO::delete_a_queue($base,$q);
}
foreach my $q (@Enable_queue){
print("Enable queue $q.\n");
OAR::IO::start_a_queue($base,$q);
}
foreach my $q (@Disable_queue){
print("Disable queue $q.\n");
OAR::IO::stop_a_queue($base,$q);
}
if (defined($Enable_all)){
OAR::IO::start_all_queues($base);
print("Enable all queues.\n");
}
if (defined($Disable_all)){
OAR::IO::stop_all_queues($base);
print("Disable all queues.\n");
}
if (defined($List_queues)){
my %queues = OAR::IO::get_all_queue_informations($base);
foreach my $q (keys(%queues)){
print("$q\n");
print("\tpriority = $queues{$q}->{priority}\n");
print("\tscheduler = $queues{$q}->{scheduler_policy}\n");
print("\tstate = $queues{$q}->{state}\n");
}
}
OAR::IO::disconnect($base);
my $tag = "Term";
if (defined($ARGV[0])){
$tag = $ARGV[0];
}
#print("tag = $tag\n");
OAR::Tools::notify_tcp_socket($remote_host,$remote_port,"$tag");
exit(0);
|