pbs_tclapi.3B 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. .\" Copyright (C) 1994-2018 Altair Engineering, Inc.
  2. .\" For more information, contact Altair at www.altair.com.
  3. .\"
  4. .\" This file is part of the PBS Professional ("PBS Pro") software.
  5. .\"
  6. .\" Open Source License Information:
  7. .\"
  8. .\" PBS Pro is free software. You can redistribute it and/or modify it under the
  9. .\" terms of the GNU Affero General Public License as published by the Free
  10. .\" Software Foundation, either version 3 of the License, or (at your option) any
  11. .\" later version.
  12. .\"
  13. .\" PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  14. .\" WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. .\" FOR A PARTICULAR PURPOSE.
  16. .\" See the GNU Affero General Public License for more details.
  17. .\"
  18. .\" You should have received a copy of the GNU Affero General Public License
  19. .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. .\"
  21. .\" Commercial License Information:
  22. .\"
  23. .\" For a copy of the commercial license terms and conditions,
  24. .\" go to: (http://www.pbspro.com/UserArea/agreement.html)
  25. .\" or contact the Altair Legal Department.
  26. .\"
  27. .\" Altair’s dual-license business model allows companies, individuals, and
  28. .\" organizations to create proprietary derivative works of PBS Pro and
  29. .\" distribute them - whether embedded or bundled with other software -
  30. .\" under a commercial license agreement.
  31. .\"
  32. .\" Use of Altair’s trademarks, including but not limited to "PBS™",
  33. .\" "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  34. .\" trademark licensing policies.
  35. .\"
  36. .TH pbs_tclapi 3B "29 August 2011" Local "PBS Professional"
  37. .SH NAME
  38. pbs_tclapi \- PBS TCL Application Programming Interface
  39. .SH DESCRIPTION
  40. The
  41. .B pbs_tclapi
  42. is a subset of the PBS external API wrapped in a TCL
  43. library. This functionality allows the creation of
  44. scripts that query the PBS system. Specifically,
  45. it permits the user to query the
  46. .B pbs_server
  47. about the state of PBS, jobs,
  48. queues, and nodes, and communicate with
  49. .B pbs_mom
  50. to get information about the status of running jobs, available
  51. resources on nodes, etc.
  52. .LP
  53. .SH USAGE
  54. A set of functions to communicate with the PBS
  55. server and resource monitor have been added to those normally
  56. available with Tcl. All these calls will set the Tcl variable
  57. "pbs_errno" to a value to indicate if an error occurred.
  58. In all cases, the value "0" means no error. If a call to
  59. a Resource Monitor function is made, any error value will
  60. come from the system supplied
  61. .B errno
  62. variable. If the function call communicates with the PBS
  63. Server, any error value will come from the error number returned
  64. by the server. This is the same TCL interface used by the
  65. .B pbs_tclsh
  66. and
  67. .B pbs_wish
  68. commands.
  69. .IP "openrm host ?port?" 6
  70. Creates a connection to the PBS Resource Monitor on
  71. .I host
  72. using
  73. .I port
  74. as the port number or the standard port for the resource monitor
  75. if it is not given. A connection handle is returned.
  76. If the open is successful, this will be a non-negative integer.
  77. If not, an error occurred.
  78. .IP "closerm connection" 6
  79. The parameter
  80. .I connection
  81. is a handle to a resource monitor which was previously returned from
  82. .B openrm.
  83. This connection is closed. Nothing is returned.
  84. .LP
  85. .IP "downrm connection" 6
  86. Sends a command to the connected resource monitor to shutdown.
  87. Nothing is returned.
  88. .LP
  89. .IP "configrm connection filename" 6
  90. Sends a command to the connected resource monitor to read the configuration
  91. file given by
  92. .I filename.
  93. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  94. .LP
  95. .IP "addreq connection request" 6
  96. A resource request is sent to the connected resource monitor.
  97. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  98. .LP
  99. .IP "getreq connection" 6
  100. One resource request response from the connected resource monitor is
  101. returned. If an error occurred or there are no more responses, an
  102. empty string is returned.
  103. .LP
  104. .IP "allreq request" 6
  105. A resource request is sent to all connected resource monitors.
  106. The number of streams acted upon is returned.
  107. .LP
  108. .IP "flushreq" 6
  109. All resource requests previously sent to all connected resource monitors
  110. are flushed out to the network. Nothing is returned.
  111. .LP
  112. .IP "activereq" 6
  113. The connection number of the next stream with something to read is returned.
  114. If there is nothing to read from any of the connections, a negative
  115. number is returned.
  116. .LP
  117. .IP "fullresp flag" 6
  118. Evaluates
  119. .I flag
  120. as a boolean value and sets
  121. the response mode used by
  122. .B getreq
  123. to
  124. .B full
  125. if
  126. .I flag
  127. evaluates to "true".
  128. The full return from a resource monitor includes the original request
  129. followed by an equal sign followed by the response. The default
  130. situation is only to return the response following the equal sign.
  131. If a script needs to "see" the entire line, this function may be used.
  132. .LP
  133. .IP "pbsstatserv" 6
  134. The server is sent a status request for information about the server
  135. itself.
  136. If the request succeeds, a list with three elements is returned,
  137. otherwise an empty string is returned.
  138. The first element is the server's name. The second is a list of attributes.
  139. The third is the "text" associated with the server (usually blank).
  140. .LP
  141. .IP "pbsstatjob" 6
  142. The server is sent a status request for information about the all
  143. jobs resident within the server.
  144. If the request succeeds, a list is returned, otherwise an empty string
  145. is returned.
  146. The list contains an entry for each job. Each element is a list
  147. with three elements. The first is the job's jobid. The second
  148. is a list of attributes. The attribute names which specify
  149. resources will have a name of the form "Resource_List:name" where
  150. "name" is the resource name.
  151. The third is the "text" associated with the job (usually blank).
  152. .LP
  153. .IP "pbsstatque" 6
  154. The server is sent a status request for information about all
  155. queues resident within the server.
  156. If the request succeeds, a list is returned, otherwise an empty string
  157. is returned.
  158. The list contains an entry for each queue. Each element is a list
  159. with three elements. This first is the queue's name. The second
  160. is a list of attributes similar to
  161. .B pbsstatjob.
  162. The third is the "text" associated with the queue (usually blank).
  163. .LP
  164. .IP "pbsstatnode" 6
  165. The server is sent a status request for information about all
  166. nodes defined within the server.
  167. If the request succeeds, a list is returned, otherwise an empty string
  168. is returned.
  169. The list contains an entry for each node. Each element is a list
  170. with three elements. This first is the node's name. The second
  171. is a list of attributes similar to
  172. .B pbsstatjob.
  173. The third is the "text" associated with the node (usually blank).
  174. .LP
  175. .IP "pbsselstat" 6
  176. The server is sent a status request for information about the all runnable
  177. jobs resident within the server.
  178. If the request succeeds, a list similar to
  179. .B pbsstatjob
  180. is returned, otherwise an empty string is returned.
  181. .LP
  182. .IP "pbsrunjob jobid ?location?" 6
  183. Run the job given by
  184. .I jobid
  185. at the location given by
  186. .I location.
  187. If
  188. .I location
  189. is not given, the default location is used.
  190. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  191. .LP
  192. .IP "pbsasyrunjob jobid ?location?" 6
  193. Run the job given by
  194. .I jobid
  195. at the location given by
  196. .I location
  197. without waiting for a positive response that the job
  198. has actually started.
  199. If
  200. .I location
  201. is not given, the default location is used.
  202. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  203. .LP
  204. .IP "pbsrerunjob jobid" 6
  205. Re-runs the job given by
  206. .I jobid.
  207. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  208. .LP
  209. .IP "pbsdeljob jobid" 6
  210. Delete the job given by
  211. .I jobid.
  212. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  213. .LP
  214. .IP "pbsholdjob jobid" 6
  215. Place a hold on the job given by
  216. .I jobid.
  217. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  218. .LP
  219. .IP "pbsmovejob jobid ?location?" 6
  220. Move the job given by
  221. .I jobid
  222. to the location given by
  223. .I location.
  224. If
  225. .I location
  226. is not given, the default location is used.
  227. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  228. .LP
  229. .IP "pbsqenable queue" 6
  230. Set the "enabled" attribute for the queue given by
  231. .I queue
  232. to true.
  233. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  234. .LP
  235. .IP "pbsqdisable queue" 6
  236. Set the "enabled" attribute for the queue given by
  237. .I queue
  238. to false.
  239. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  240. .LP
  241. .IP "pbsqstart queue" 6
  242. Set the "started" attribute for the queue given by
  243. .I queue
  244. to true.
  245. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  246. .LP
  247. .IP "pbsqstop queue" 6
  248. Set the "started" attribute for the queue given by
  249. .I queue
  250. to false.
  251. If this is successful, a "0" is returned, otherwise, "-1" is returned.
  252. .LP
  253. .IP "pbsalterjob jobid attribute_list" 6
  254. Alter the attributes for a job specified by
  255. .I jobid.
  256. The parameter
  257. .I attribute_list
  258. is the list of attributes to be altered. There can be more than one.
  259. Each attribute consists of a list of three elements. The first
  260. is the name, the second the resource and the third is the new value.
  261. If the alter is successful, a "0" is returned, otherwise, "-1" is returned.
  262. .LP
  263. .IP "pbsrescquery resource_list" 6
  264. .B Deprecated.
  265. Obtain information about the resources specified by
  266. .I resource_list.
  267. This will be a list of strings. If the request succeeds, a list
  268. with the same number of elements as
  269. .I resource_list
  270. is returned. Each element in this list will be a list with four
  271. numbers. The numbers specify
  272. .I available,
  273. .I allocated,
  274. .I reserved,
  275. and
  276. .I down
  277. in that order.
  278. .LP
  279. .IP "pbsrescreserve resource_id resource_list" 6
  280. .B Deprecated.
  281. Make (or extend) a reservation for the resources specified by
  282. .I resource_list
  283. which will be given as a list of strings. The parameter
  284. .I resource_id
  285. is a number which provides a unique identifier for a reservation
  286. being tracked by the server. If
  287. .I resource_id
  288. is given as "0", a new reservation is created. In this case,
  289. a new identifier is generated and returned by the function.
  290. If an old identifier is used, that same number will be returned.
  291. The Tcl variable "pbs_errno" will be set to indicate the success
  292. or failure of the reservation.
  293. .LP
  294. .IP "pbsrescrelease resource_id" 6
  295. .B Deprecated.
  296. The reservation specified by
  297. .I resource_id
  298. is released.
  299. .LP
  300. The two following commands are not normally used by the scheduler.
  301. They are included here because there could be a need for a scheduler
  302. to contact a server other than the one which it normally communicates
  303. with. Also, these commands are used by the Tcl tools.
  304. .LP
  305. .IP "pbsconnect ?server?" 6
  306. Make a connection to the named server or the default server if
  307. a parameter is not given.
  308. Only one connection to a server is allowed at any one time.
  309. .LP
  310. .IP pbsdisconnect 6
  311. Disconnect from the currently connected server.
  312. .LP
  313. The above Tcl functions use PBS interface library calls for communication
  314. with the server and the PBS resource monitor library to communicate
  315. with pbs_mom.
  316. .LP
  317. .IP "datetime ?day? ?time?" 6
  318. The number of arguments used determine the type of
  319. date to be calculated. With no arguments, the current POSIX
  320. date is returned. This is an integer in seconds.
  321. .sp
  322. With one argument there are two possible formats. The first is a 12
  323. (or more) character string specifying a complete date in
  324. the following format:
  325. .br
  326. .I \ \ \ YYMMDDhhmmss
  327. .br
  328. All characters must be digits. The year (YY) is given by the first
  329. two (or more) characters and is the number of years since 1900.
  330. The month (MM) is the number of the month [01-12].
  331. The day (DD) is the day of the month [01-32]. The hour (hh) is the hour
  332. of the day [00-23]. The minute (mm) is minutes after the hour [00-59].
  333. The second (ss) is seconds after the minute [00-59]. The POSIX date
  334. for the given date/time is returned.
  335. .sp
  336. The second option with one argument is a relative time. The format
  337. for this is
  338. .br
  339. .I \ \ \ HH:MM:SS
  340. .br
  341. With hours (HH), minutes (MM) and seconds (SS) being separated by
  342. colons ":". The number returned in this case will be the number of seconds
  343. in the interval specified, not an absolute POSIX date.
  344. .sp
  345. With two arguments a relative date is calculated. The first argument
  346. specifies a day of the week and must be one of the following strings:
  347. "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", or "Sat". The second
  348. argument is a relative time as given above. The POSIX date
  349. calculated will be the day of the week given which follows the
  350. current day, and the time given in the second argument. For example,
  351. if the current day was Monday, and the two arguments were
  352. "Fri" and "04:30:00", the date calculated would be the POSIX date
  353. for the Friday following the current Monday, at four-thirty in the
  354. morning. If the day specified and the current day are the same,
  355. the current day is used, not the day one week later.
  356. .LP
  357. .IP "strftime format time"
  358. This function calls the POSIX function
  359. .I strftime().
  360. It requires two arguments. The first
  361. is a format string. The format conventions are the same as those
  362. for the POSIX function strftime(). The second argument is POSIX
  363. calendar time in second as returned by
  364. .I datetime.
  365. It returns a string based on the format given. This gives the ability to
  366. extract information about a time, or format it for printing.
  367. .LP
  368. .IP "logmsg tag message" 6
  369. This function calls the internal PBS function
  370. .I log_err().
  371. It will cause a log message to be written to the scheduler's log file. The
  372. .I tag
  373. specifies a function name or other word used to identify the area
  374. where the message is generated. The
  375. .I message
  376. is the string to be logged.
  377. .LP
  378. .SH "SEE ALSO"
  379. pbs_tclsh(8B), pbs_wish(8B), pbs_mom(8B),
  380. pbs_server(8B), pbs_sched(8B)