This file is indexed.

/usr/share/arc/ldap-monitor/jobstat.php is in nordugrid-arc-ldap-monitor 1.1.1-1.

This file is owned by root:root, with mode 0o644.

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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
 
// Author: oxana.smirnova@hep.lu.se
/**
 * Retrieves job-specific information from a given NorduGrid queue
 * Uses LDAP functions of PHP
 * 
 * Author: O.Smirnova (May 2002)
 * inspired by the LDAPExplorer by T.Miao
 * 
 * input:
 * host (default: grid.quark.lu.se)
 * port (default: 2135)
 * status (Running|Preparing|whatever)
 * jobdn (all|DN of a single job)
 * 
 * output:
 * an HTML table, containing:
 * per each cluster:
 * - list of running or queued jobs
 */
  

set_include_path(get_include_path().":".getcwd()."/includes".":".getcwd()."/lang");

require_once('headfoot.inc');
require_once('lmtable.inc');
require_once('cnvtime.inc');
require_once('cnvname.inc');
require_once('comfun.inc');
require_once('toreload.inc');
require_once('ldap_nice_dump.inc');

// getting parameters

$host   = @( $_GET["host"] )   ? $_GET["host"]   : "quark.hep.lu.se";
$port   = @( $_GET["port"] )   ? $_GET["port"]   : 2135;
$status = @( $_GET["status"] ) ? $_GET["status"] : "Running";
$jobdn  = @( $_GET["jobdn"] )  ? $_GET["jobdn"]  : "all";
$debug  = @( $_GET["debug"] )  ? $_GET["debug"]  : 0;
$lang   = @$_GET["lang"];
if ( !$lang )    $lang    = "default"; // browser language
define("FORCE_LANG",$lang);

// Setting up the page itself

$toppage = new LmDoc("jobstat",$host);
$toptitle = $toppage->title;
$module   = &$toppage->module;
$strings  = &$toppage->strings;
$errors   = &$toppage->errors;

// Header table
  
$titles   = explode(":",$toptitle); // two alternative titles, separated by column

if ($jobdn=="all") {
  $clstring = popup("clusdes.php?host=$host&port=$port",700,620,1,$lang,$debug);
  $gtitle   = "<b><i>".$titles[0]." <a href=\"$clstring\">$host</a></i></b>";
} else {
  $jobdn     = rawurldecode($jobdn);
  $jobdn     = preg_replace("/\"/","",$jobdn);
  $dn_pieces = ldap_explode_dn($jobdn,1);
  $jobgid    = $dn_pieces[0];
  $gtitle    = "<b>".$titles[1].": <i>$jobgid</i></b>";
}

$toppage->tabletop("",$gtitle);

// Arrays defining the attributes to be returned

$lim = array( "dn", JOB_NAME, JOB_EQUE, JOB_GOWN, JOB_STAT, JOB_USET, JOB_SUBM, JOB_CPUS );

// ldapsearch filter string for jobs

$filstr="(objectclass=".OBJ_AJOB.")";

if ( $debug ) {
  ob_end_flush();
  ob_implicit_flush();
}

$tlim = 15;
$tout = 20;
if( $debug ) dbgmsg("<div align=\"left\"><i>:::&gt; ".$errors["101"].$tlim.$errors["102"].$tout.$errors["103"]." &lt;:::</div><br>");

// Establish connection to the requested LDAP server

$ds    = ldap_connect($host,$port);
$bdn   = DN_LOCAL;
$topdn = DN_GLOBL;
if ($ds) {
  
  // Single job info dump and quit
  
  if ($jobdn != "all") {
    //    $basedn = explode("Mds",$jobdn);
    $basedn = preg_split("/mds/i",$jobdn);
    $locdn  = $basedn[0].$bdn;
    $thisdn = ldap_nice_dump($strings,$ds,$locdn);
    ldap_close($ds);
    return 0;
  }
  
  // Loop over all the jobs
  
  $sr = @ldap_search($ds,$bdn,$filstr,$lim,0,0,$tlim,LDAP_DEREF_NEVER);
  // Fall back to conventional LDAP
  //  if (!$sr) $sr = @ldap_search($ds,$bdn,$filstr,$lim,0,0,$tlim,LDAP_DEREF_NEVER);
  
  if ($sr) {
    
    // If search returned, check that there are valid entries
      
    $nmatch = ldap_count_entries($ds,$sr);
    if ($nmatch > 0) {
        
      // HTML table initialisation
        
      $jtable = new LmTable($module,$toppage->$module);
        
      // If there are valid entries, tabulate results
        
      $entries = ldap_get_entries($ds,$sr);
      $njobs   = $entries["count"];

      define("CMPKEY",JOB_SUBM);
      usort($entries,"ldap_entry_comp");
        
      // loop on jobs
        
      $jcount = 0;
      for ($i=1; $i<$njobs+1; $i++) {
	$jdn     = rawurlencode($entries[$i]["dn"]);
	$curstat = $entries[$i][JOB_STAT][0];
          
	/*
	 * The following flags may need an adjustment, 
	 * depending on the Job Status provider
	 */

	// Running job: statail == "R" or "run"
	//          $statail = substr($curstat,-3);
	$statail = substr(strstr($curstat,"INLRMS:"),7);
	$statail = trim($statail);

	// Queued job: stahead != "FIN" && statail != "R" and "run" etc
	$stahead = substr($curstat,0,3);
          
	$flagrun = ( $status  == "Running" && 
		     ( $statail == "R" ||  /* PBS */
		       $statail == "S" ||  /* suspended by Condor */
		       $statail == "run" ) /* easypdc */
		     );
	$flagque = ( $status  != "Running" &&
		     $statail != "R" &&
		     $statail != "S" &&
		     $statail != "run" &&
		     $stahead != "FIN"     &&
		     $stahead != "FAI"     &&
		     $stahead != "EXE"     &&
		     $stahead != "KIL"     &&
		     $stahead != "DEL" );
          
	/* No changes necessary below */
          
	$flagact = ($flagrun || $flagque)?1:0;
	if ($flagact == 1 || $status == "All" ) {
	  $uname    = $entries[$i][JOB_GOWN][0];
	  $encuname = rawurlencode($uname);
	  $uname    = addslashes($uname); // In case $uname contains escape characters
	  $family   = cnvname($uname, 2);

	  $jname   = htmlentities($entries[$i][JOB_NAME][0]);
	  $jobname = ($entries[$i][JOB_NAME][0]) ? $jname : "<font color=\"red\">N/A</font>";
	  $queue   = ($entries[$i][JOB_EQUE][0]) ? $entries[$i][JOB_EQUE][0] : "";
	  $time    = ($entries[$i][JOB_USET][0]) ? $entries[$i][JOB_USET][0] : "";
	  $ncpus   = ($entries[$i][JOB_CPUS][0]) ? $entries[$i][JOB_CPUS][0] : "";
	  $newwin  = popup("jobstat.php?host=$host&port=$port&status=$status&jobdn=$jdn",750,430,4,$lang,$debug);
	  $quewin  = popup("quelist.php?host=$host&port=$port&qname=$queue",750,430,6,$lang,$debug);
	  $usrwin  = popup("userlist.php?bdn=$topdn&owner=$encuname",700,500,5,$lang,$debug);

	  $jcount++;

	  // filling the table
            
	  $jrowcont[] = "$jcount&nbsp;<a href=\"$newwin\">$jobname</a>";
	  $jrowcont[] = "<a href=\"$usrwin\">$family</a>";
	  $jrowcont[] = "$curstat";
	  $jrowcont[] = "$time";
	  $jrowcont[] = "<a href=\"$quewin\">$queue</a>";
	  $jrowcont[] = "$ncpus";
	  $jtable->addrow($jrowcont);
	  $jrowcont = array ();
	}
      }
      if ($jcount == 0) $jtable->adderror("<b>".$errors["4"].": ".$status."</b>");
      $jtable->close();
    }
    else {
      echo "<br><font color=\"red\"><b>".$errors["4"]."</b>".$errors["7"]."</font>\n";
    }
  }
  else {
    echo "<br><font color=\"red\"><b>".$errors["4"]."</b>".$errors["7"]."</font>\n";
  }
  $entries = array();
  @ldap_free_result($sr);
  ldap_close($ds);
  return 0;
}
else {
  $errno = "6";
  echo "<br><font color=\"red\"><b>".$errors[$errno]."</b></font>\n";
  return $errno;
}

// Done

$toppage->close();

?>