Changeset 34
- Timestamp:
- 10/27/11 15:13:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pbs_drmaa/log_reader.c
r33 r34 25 25 #include <string.h> 26 26 #include <unistd.h> 27 #include <sys/select.h>28 27 #include <sys/stat.h> 29 28 #include <sys/types.h> … … 398 397 fsd_log_info(("WT - No execution host information for job %s. Reading accounting logs...", job->job_id)); 399 398 exec_host = pbsdrmaa_get_exec_host_from_accountig(self, job->job_id); 400 attribs = pbsdrmaa_add_attr(attribs, PBSDRMAA_EXECUTION_HOST, exec_host); 401 fsd_free(exec_host); 399 if (exec_host) 400 { 401 attribs = pbsdrmaa_add_attr(attribs, PBSDRMAA_EXECUTION_HOST, exec_host); 402 fsd_free(exec_host); 403 } 402 404 } 403 405 } … … 575 577 pbsdrmaa_get_exec_host_from_accountig(pbsdrmaa_log_reader_t * log_reader, const char *job_id) 576 578 { 577 /* TODO: implement */ 578 return NULL; 579 pbsdrmaa_session_t *pbssession = (pbsdrmaa_session_t*) log_reader->session; 580 581 struct tm tm; 582 time_t tm_t; 583 char *line = NULL; 584 FILE *fhandle = NULL; 585 char *exec_host = NULL; 586 587 fsd_log_enter(("")); 588 589 tm_t = time(NULL); 590 localtime_r(&time_t, &tm); 591 592 log_path = fsd_asprintf("%s/server_priv/accounting/%04d%02d%02d", pbssession->pbs_home, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 593 594 fsd_log_info(("Opening accounting log file: %s", log_path)); 595 596 if ((fhandle = fopen(log_path, "r")) == NULL) 597 { 598 fsd_log_error("Failed to open accounting log file: %s", log_path); 599 fsd_free(log_path); 600 return NULL; 601 } 602 603 fsd_free(log_path); 604 /* 605 10/27/2011 14:09:32;E;114249.grass1.man.poznan.pl;user=drmaa group=drmaa jobname=none queue=shortq ctime=1319717371 qtime=1319717371 etime=1319717371 start=1319717372 owner=drmaa@grass1.man.poznan.pl exec_host=grass4.man.poznan.pl/0 Resource_List.neednodes=1 Resource_List.nodect=1 Resource_List.nodes=1 Resource_List.walltime=02:00:00 session=28561 end=1319717372 Exit_status=0 resources_used.cput=00:00:00 resources_used.mem=0kb resources_used.vmem=0kb resources_used.walltime=00:00:00 606 */ 607 while ((line = fsd_readline(fhandle)) != NULL) 608 { 609 if (line[20] == 'E' && strncmp(line + 23, job_id, strlen(job_id)) == 0 ) 610 { 611 char *p = NULL; 612 613 fsd_log_debug(("Matched accounting log record = %s", line)); 614 615 if (!(exec_host = strstr(line, "exec_host"))) 616 { 617 fsd_log_error(("Invalid accounting record: %s", exec_host)); 618 break; 619 } 620 621 exec_host += 10; 622 623 p = exec_host; 624 while (p != ' ' && p != '\0') 625 p++; 626 p = '\0'; 627 628 break; 629 } 630 631 fsd_free(line); 632 } 633 634 if (exec_host) 635 { 636 fsd_log_info(("Job %s was executing on hosts %s.", job_id, exec_host)); 637 exec_host = fsd_strdup(exec_host); 638 } 639 else 640 { 641 fsd_log_error(("Could not find executions hosts for %s.", job_id)) 642 } 643 644 if (line) 645 fsd_free(line); 646 647 fclose(fhandle); 648 649 return exec_host; 579 650 } 580 651
Note: See TracChangeset
for help on using the changeset viewer.