int totpool(int con, int update) { if (update) if (pbs_rescquery(con, &resc_nodes, 1, &nodes_avail, &nodes_alloc, &nodes_resrv, &nodes_down) != 0) { return (-1); } return (nodes_avail + nodes_alloc + nodes_resrv + nodes_down); }
int totpool(int con, int update) { struct pbs_client_thread_context *ptr; struct node_pool *np; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return -1; ptr = (struct pbs_client_thread_context *) pbs_client_thread_get_context_data(); if (!ptr) { pbs_errno = PBSE_INTERNAL; return -1; } if (!ptr->th_node_pool) { np = (struct node_pool *) malloc(sizeof(struct node_pool)); if (!np) { pbs_errno = PBSE_INTERNAL; return -1; } ptr->th_node_pool = (void *) np; if ((np->resc_nodes = strdup("nodes")) == NULL) { free(np); np = NULL; pbs_errno = PBSE_SYSTEM; return -1; } } else np = (struct node_pool *) ptr->th_node_pool; if (update) { if (pbs_rescquery(con, &np->resc_nodes, 1, &np->nodes_avail, &np->nodes_alloc, &np->nodes_resrv, &np->nodes_down) != 0) { return (-1); } } return (np->nodes_avail + np->nodes_alloc + np->nodes_resrv + np->nodes_down); }
char * avail(int con, char *resc) { int av; int al; int res; int dwn; if (pbs_rescquery(con, &resc, 1, &av, &al, &res, &dwn) != 0) return ("?"); else if (av > 0) return ("yes"); else if (av == 0) return ("no"); else return ("never"); }