-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjobs.c
63 lines (52 loc) · 1.64 KB
/
jobs.c
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
/***************************************************************************
* Description:
* List currently running and queued jobs. Job info is queried from
* lpjs_dispatchd.
*
* History:
* Date Name Modification
* 2021-09-27 Jason Bacon Begin
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sysexits.h>
#include "node-list.h"
#include "config.h"
#include "network.h"
#include "lpjs.h"
int main(int argc,char *argv[])
{
int msg_fd;
// Terminates process if malloc() fails, no check required
node_list_t *node_list = node_list_new();
extern FILE *Log_stream;
char outgoing_msg[LPJS_MSG_LEN_MAX + 1];
if (argc != 1)
{
fprintf (stderr, "Usage: %s\n", argv[0]);
return EX_USAGE;
}
// Shared functions may use lpjs_log
Log_stream = stderr;
// Get hostname of head node
lpjs_load_config(node_list, LPJS_CONFIG_HEAD_ONLY, stderr);
if ( (msg_fd = lpjs_connect_to_dispatchd(node_list)) == -1 )
{
perror("lpjs-jobs: Failed to connect to dispatch");
return EX_IOERR;
}
outgoing_msg[0] = LPJS_DISPATCHD_REQUEST_JOB_LIST;
outgoing_msg[1] = '\0';
if ( lpjs_send_munge(msg_fd, outgoing_msg, close) != LPJS_MSG_SENT )
{
perror("lpjs-jobs: Failed to send message to dispatch");
close(msg_fd);
return EX_IOERR;
}
lpjs_print_response(msg_fd, "lpjs-jobs");
puts("\nJ/S = jobs/submission P/J = processors/job\nT/P = threads/process MiB/P = mibibytes/processor\n");
close (msg_fd);
return EX_OK;
}