void printRun (ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -15, ! wide_display); if (javaMode) { ppSetColumn(ATTR_JAVA_VENDOR, -11, ! wide_display); ppSetColumn(ATTR_JAVA_VERSION, Lbl("Ver"), -6, ! wide_display); } else if (vmMode) { ppSetColumn(ATTR_VM_TYPE, Lbl("VMType"), -6, ! wide_display); ppSetColumn(ATTR_VM_NETWORKING_TYPES, Lbl("Network"), -11, ! wide_display); } else { ppSetColumn(ATTR_OPSYS, -11, true); ppSetColumn(ATTR_ARCH, -6, true); } ppSetColumn(ATTR_LOAD_AVG, Lbl("LoadAv"), formatLoadAvg, NULL, 6, true); ppSetColumn(ATTR_REMOTE_USER, -20, ! wide_display); ppSetColumn(ATTR_CLIENT_MACHINE, -16, ! wide_display); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printQuillNormal (ClassAd *ad) { static bool first = true; static AttrListPrintMask alpm; if (ad) { // print header if necessary if (first) { printf ("\n%-20.20s %-10.10s %-16.16s %-18.18s\n\n", ATTR_NAME, ATTR_MACHINE, ATTR_QUILL_SQL_TOTAL, ATTR_QUILL_SQL_LAST_BATCH); alpm.registerFormat("%-20.20s ", ATTR_NAME, "[??????????????????] "); alpm.registerFormat("%-10.10s ", ATTR_MACHINE, "[????????] "); alpm.registerFormat("%16d ",ATTR_QUILL_SQL_TOTAL, "[??????????????] "); alpm.registerFormat("%18d\n",ATTR_QUILL_SQL_LAST_BATCH, "[???????????]\n"); first = false; } alpm.display (stdout, ad); } }
void printMasterNormal(ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, -20, false); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printNegotiatorNormal(ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -32 : -20, ! wide_display); ppSetColumn(ATTR_MACHINE, wide_display ? -32 : -20, ! wide_display); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printStorageNormal(ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -30, ! wide_display); ppSetColumn(ATTR_DISK, Lbl("AvailDisk"), "%9d", true); ppSetColumn(ATTR_SUBNET, "%-11s", !wide_display); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printAnyNormal(ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_MY_TYPE, formatAdType, -18, true, CallInvalidField); ppSetColumn(ATTR_TARGET_TYPE, formatAdType, -18, true, CallInvalidField); ppSetColumn(ATTR_NAME, wide_display ? "%-41s" : "%-41.41s", ! wide_display, ShortInvalidField /*"[???]"*/); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
static void ppDisplayHeadings(FILE* file, ClassAd *ad, const char * pszExtra) { if (ad) { // render the first ad to a string so the column widths update std::string tmp; pm.display(tmp, ad, NULL); } if (pm.has_headings()) { pm.display_Headings(file); } else { pm.display_Headings(file, pm_head); } if (pszExtra) printf("%s", pszExtra); }
void printScheddSubmittors (ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -28, ! wide_display); ppSetColumn(ATTR_MACHINE, wide_display ? -34 : -18, ! wide_display); ppSetColumn(ATTR_RUNNING_JOBS, "%11d", true); ppSetColumn(ATTR_IDLE_JOBS, "%8d", true); ppSetColumn(ATTR_HELD_JOBS, "%8d", true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printCollectorNormal(ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -28, ! wide_display); ppSetColumn(ATTR_MACHINE, wide_display ? -34 : -18, ! wide_display); ppSetColumn(ATTR_RUNNING_JOBS, "%11d", true); ppSetColumn(ATTR_IDLE_JOBS, "%8d", true); ppSetColumn(ATTR_NUM_HOSTS_TOTAL, "%10d", true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printScheddNormal (ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -20, ! wide_display); ppSetColumn(ATTR_MACHINE, wide_display ? -34 : -10, ! wide_display); ppSetColumn(ATTR_TOTAL_RUNNING_JOBS, "%16d", true); ppSetColumn(ATTR_TOTAL_IDLE_JOBS, "%13d", true); ppSetColumn(ATTR_TOTAL_HELD_JOBS, "%14d", true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
// print a single job ad // static void printJob(ClassAd & ad) { if (longformat) { if (use_xml) { fPrintAdAsXML(stdout, ad); } else { fPrintAd(stdout, ad); } printf("\n"); } else { if (customFormat) { mask.display(stdout, &ad); } else { displayJobShort(&ad); } } }
void printStartdAbsent (ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, -34, ! wide_display); ppSetColumn(ATTR_OPSYS, -10, true); ppSetColumn(ATTR_ARCH, -8, true); ppSetColumn(ATTR_LAST_HEARD_FROM, Lbl("Went Absent"), formatRealDate, -11, true); ppSetColumn(ATTR_CLASSAD_LIFETIME, Lbl("Will Forget"), formatDueDate, -11, true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); return; }
void printGridNormal(ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, -34, ! wide_display); ppSetColumn("NumJobs", "%7d", true); ppSetColumn("SubmitsAllowed", Lbl("Allowed"), "%7d", true); ppSetColumn("SubmitsWanted", Lbl(" Wanted"), "%7d", true); ppSetColumn(ATTR_RUNNING_JOBS, "%11d", true); ppSetColumn(ATTR_IDLE_JOBS, "%8d", true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printServer (ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -13, ! wide_display); ppSetColumn(ATTR_OPSYS, -11, true); ppSetColumn(ATTR_ARCH, -6, true); ppSetColumn(ATTR_LOAD_AVG, Lbl("LoadAv"), formatLoadAvg, NULL, 6, true); ppSetColumn(ATTR_MEMORY, "%8d", true); ppSetColumn(ATTR_DISK, "%9d", true); ppSetColumn(ATTR_MIPS, "%7d", true); ppSetColumn(ATTR_KFLOPS, "%9d", true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printStartdOffline( ClassAd *ad, bool first ) { if( first ) { ppInit(); ppSetColumn( ATTR_NAME, -34, ! wide_display ); // A custom printer for filtering out the ints would be handy. ppSetColumn( "OfflineUniverses", Lbl( "Offline Universes" ), formatOfflineUniverses, -42, ! wide_display ); // How should I print out the offline reasons and timestamps? ppDisplayHeadings(stdout, ad, "\n"); } if( ad ) { pm.display( stdout, ad ); } return; }
void printStartdNormal (ClassAd *ad, bool first) { if (first) { ppInit(); ppSetColumn(ATTR_NAME, wide_display ? -34 : -18, ! wide_display); if (javaMode) { ppSetColumn(ATTR_JAVA_VENDOR, -10, ! wide_display); ppSetColumn(ATTR_JAVA_VERSION, Lbl("Ver"), -6, ! wide_display); } else if (vmMode) { ppSetColumn(ATTR_VM_TYPE, Lbl("VmType"), -6, true); ppSetColumn(ATTR_VM_NETWORKING_TYPES, Lbl("Network"), -9, true); }else { ppSetColumn(ATTR_OPSYS, -10, true); ppSetColumn(ATTR_ARCH, -6, true); } ppSetColumn(ATTR_STATE, -9, true); ppSetColumn(ATTR_ACTIVITY, -8, true); //ppSetColumn(0, ATTR_LOAD_AVG, "%.3f ", false, invalid_fields_empty ? "" : "[???] "); //pm_head.Append(ATTR_LOAD_AVG); //pm_head.Append(wide_display ? ATTR_LOAD_AVG : "LoadAv"); //pm.registerFormat("%.3f ", wide_display ? 7 : 6, FormatOptionAutoWidth, ATTR_LOAD_AVG, invalid_fields_empty ? "" : "[???] "); ppSetColumn(ATTR_LOAD_AVG, Lbl("LoadAv"), formatLoadAvg, NULL, 6, true); if (vmMode) { ppSetColumn(ATTR_VM_MEMORY, Lbl("VMMem"), "%4d", false); } else { ppSetColumn(ATTR_MEMORY, Lbl("Mem"), "%4d", false); } pm_head.Append(wide_display ? "ActivityTime" : " ActvtyTime"); pm.registerFormat(NULL, 12, FormatOptionAutoWidth | (wide_display ? 0 : FormatOptionNoPrefix) | AltFixMe, formatActivityTime, ATTR_ENTERED_CURRENT_ACTIVITY /* " [Unknown]"*/); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
void printState (ClassAd *ad, bool first) { if (first) { ppInit(); int timewid = wide_display ? 12 : 11; ppSetColumn(ATTR_NAME, wide_display ? -34 : -12, ! wide_display); ppSetColumn(ATTR_CPUS, Lbl("Cpu"), 3, true); ppSetColumn(ATTR_MEMORY, Lbl(" Mem"), 5, true); //ppSetColumn(ATTR_LOAD_AVG, Lbl("Load "), "%.3f", true); ppSetColumn(ATTR_LOAD_AVG, Lbl("LoadAv"), formatLoadAvg, NULL, 6, true); ppSetColumn(ATTR_KEYBOARD_IDLE, Lbl(" KbdIdle"), formatRealTime, timewid, true); ppSetColumn(ATTR_STATE, -7, true); ppSetColumn(ATTR_ENTERED_CURRENT_STATE, Lbl(" StateTime"), formatElapsedTime, timewid, true); ppSetColumn(ATTR_ACTIVITY, Lbl("Activ"), -5, true); ppSetColumn(ATTR_ENTERED_CURRENT_ACTIVITY, Lbl(" ActvtyTime"), formatElapsedTime, timewid, true); ppDisplayHeadings(stdout, ad, "\n"); } if (ad) pm.display (stdout, ad); }
// Read the history from a single file and print it out. static void readHistoryFromFile(char *JobHistoryFileName, char* constraint, ExprTree *constraintExpr) { int EndFlag = 0; int ErrorFlag = 0; int EmptyFlag = 0; AttrList *ad = NULL; long offset = 0; bool BOF = false; // Beginning Of File MyString buf; FILE* LogFile=safe_fopen_wrapper(JobHistoryFileName,"r"); if (!LogFile) { fprintf(stderr,"History file (%s) not found or empty.\n", JobHistoryFileName); exit(1); } // In case of rotated history files, check if we have already reached the number of // matches specified by the user before reading the next file if (specifiedMatch != 0) { if (matchCount == specifiedMatch) { // Already found n number of matches, cleanup fclose(LogFile); return; } } if (backwards) { offset = findLastDelimiter(LogFile, JobHistoryFileName); } while(!EndFlag) { if (backwards) { // Read history file backwards if (BOF) { // If reached beginning of file break; } offset = findPrevDelimiter(LogFile, JobHistoryFileName, offset); if (offset == -1) { // Unable to match constraint break; } else if (offset != 0) { fseek(LogFile, offset, SEEK_SET); buf.readLine(LogFile); // Read one line to skip delimiter and adjust to actual offset of ad } else { // Offset set to 0 BOF = true; fseek(LogFile, offset, SEEK_SET); } } if( !( ad=new AttrList(LogFile,"***", EndFlag, ErrorFlag, EmptyFlag) ) ){ fprintf( stderr, "Error: Out of memory\n" ); exit( 1 ); } if( ErrorFlag ) { printf( "\t*** Warning: Bad history file; skipping malformed ad(s)\n" ); ErrorFlag=0; if(ad) { delete ad; ad = NULL; } continue; } if( EmptyFlag ) { EmptyFlag=0; if(ad) { delete ad; ad = NULL; } continue; } if (!constraint || EvalBool(ad, constraintExpr)) { if (longformat) { ad->fPrint(stdout); printf("\n"); } else { if (customFormat) { mask.display(stdout, ad); } else { displayJobShort(ad); } } matchCount++; // if control reached here, match has occured if (specifiedMatch != 0) { // User specified a match number if (matchCount == specifiedMatch) { // Found n number of matches, cleanup if (ad) { delete ad; ad = NULL; } fclose(LogFile); return; } } } if(ad) { delete ad; ad = NULL; } } fclose(LogFile); return; }
// Read the history from a single file and print it out. static void readHistoryFromFileOld(const char *JobHistoryFileName, const char* constraint, ExprTree *constraintExpr) { int EndFlag = 0; int ErrorFlag = 0; int EmptyFlag = 0; ClassAd *ad = NULL; long offset = 0; bool BOF = false; // Beginning Of File MyString buf; int flags = 0; if( !backwards ) { // Currently, the file position manipulations used in -backwards // do not work with files > 2GB on platforms with 32-bit file // offsets. flags = O_LARGEFILE; } int LogFd = safe_open_wrapper_follow(JobHistoryFileName,flags,0); if (LogFd < 0) { fprintf(stderr,"Error opening history file %s: %s\n", JobHistoryFileName,strerror(errno)); #ifdef EFBIG if( (errno == EFBIG) && backwards ) { fprintf(stderr,"The -backwards option does not support files this large.\n"); } #endif exit(1); } FILE *LogFile = fdopen(LogFd,"r"); if (!LogFile) { fprintf(stderr,"Error opening history file %s: %s\n", JobHistoryFileName,strerror(errno)); exit(1); } // In case of rotated history files, check if we have already reached the number of // matches specified by the user before reading the next file if (specifiedMatch != 0) { if (matchCount == specifiedMatch) { // Already found n number of matches, cleanup fclose(LogFile); return; } } if (backwards) { offset = findLastDelimiter(LogFile, JobHistoryFileName); } if(longformat && use_xml) { std::string out; AddClassAdXMLFileHeader(out); printf("%s\n", out.c_str()); } while(!EndFlag) { if (backwards) { // Read history file backwards if (BOF) { // If reached beginning of file break; } offset = findPrevDelimiter(LogFile, JobHistoryFileName, offset); if (offset == -1) { // Unable to match constraint break; } else if (offset != 0) { fseek(LogFile, offset, SEEK_SET); buf.readLine(LogFile); // Read one line to skip delimiter and adjust to actual offset of ad } else { // Offset set to 0 BOF = true; fseek(LogFile, offset, SEEK_SET); } } if( !( ad=new ClassAd(LogFile,"***", EndFlag, ErrorFlag, EmptyFlag) ) ){ fprintf( stderr, "Error: Out of memory\n" ); exit( 1 ); } if( ErrorFlag ) { printf( "\t*** Warning: Bad history file; skipping malformed ad(s)\n" ); ErrorFlag=0; if(ad) { delete ad; ad = NULL; } continue; } if( EmptyFlag ) { EmptyFlag=0; if(ad) { delete ad; ad = NULL; } continue; } if (!constraint || constraint[0]=='\0' || EvalBool(ad, constraintExpr)) { if (longformat) { if( use_xml ) { fPrintAdAsXML(stdout, *ad); } else { fPrintAd(stdout, *ad); } printf("\n"); } else { if (customFormat) { mask.display(stdout, ad); } else { displayJobShort(ad); } } matchCount++; // if control reached here, match has occured if (specifiedMatch != 0) { // User specified a match number if (matchCount == specifiedMatch) { // Found n number of matches, cleanup if (ad) { delete ad; ad = NULL; } fclose(LogFile); return; } } } if(ad) { delete ad; ad = NULL; } } if(longformat && use_xml) { std::string out; AddClassAdXMLFileFooter(out); printf("%s\n", out.c_str()); } fclose(LogFile); return; }
void printCustom (ClassAd *ad) { (void) pm.display (stdout, ad, targetAd); }
void prettyPrint (ClassAdList &adList, TrackTotals *totals) { ppOption pps = using_print_format ? PP_CUSTOM : ppStyle; ClassAd *ad; int classad_index; int last_classad_index; bool fPrintHeadings = pm.has_headings() || (pm_head.Length() > 0); classad_index = 0; last_classad_index = adList.Length() - 1; adList.Open(); while ((ad = adList.Next())) { if (!wantOnlyTotals) { switch (pps) { case PP_STARTD_NORMAL: if (absentMode) { printStartdAbsent (ad, (classad_index == 0)); } else if( offlineMode ) { printStartdOffline( ad, (classad_index == 0)); } else { printStartdNormal (ad, (classad_index == 0)); } break; case PP_STARTD_SERVER: printServer (ad, (classad_index == 0)); break; case PP_STARTD_RUN: printRun (ad, (classad_index == 0)); break; case PP_STARTD_COD: printCOD (ad); break; case PP_STARTD_STATE: printState(ad, (classad_index == 0)); break; #ifdef HAVE_EXT_POSTGRESQL case PP_QUILL_NORMAL: printQuillNormal (ad); break; #endif /* HAVE_EXT_POSTGRESQL */ case PP_SCHEDD_NORMAL: printScheddNormal (ad, (classad_index == 0)); break; case PP_NEGOTIATOR_NORMAL: printNegotiatorNormal (ad, (classad_index == 0)); break; case PP_SCHEDD_SUBMITTORS: printScheddSubmittors (ad, (classad_index == 0)); break; case PP_VERBOSE: printVerbose (ad); break; case PP_XML: printXML (ad, (classad_index == 0), (classad_index == last_classad_index)); break; case PP_MASTER_NORMAL: printMasterNormal(ad, (classad_index == 0)); break; case PP_COLLECTOR_NORMAL: printCollectorNormal(ad, (classad_index == 0)); break; case PP_CKPT_SRVR_NORMAL: printCkptSrvrNormal(ad, (classad_index == 0)); break; case PP_STORAGE_NORMAL: printStorageNormal(ad, (classad_index == 0)); break; case PP_GRID_NORMAL: printGridNormal(ad, (classad_index == 0)); break; case PP_GENERIC_NORMAL: case PP_GENERIC: case PP_ANY_NORMAL: printAnyNormal(ad, (classad_index == 0)); break; case PP_CUSTOM: // hack: print a single item to a string, then discard the string // this makes sure that the headings line up correctly over the first // line of data. if (fPrintHeadings) { std::string tmp; pm.display(tmp, ad, targetAd); if (pm.has_headings()) { if ( ! (pmHeadFoot & HF_NOHEADER)) pm.display_Headings(stdout); } else { pm.display_Headings(stdout, pm_head); } fPrintHeadings = false; } printCustom (ad); break; case PP_NOTSET: fprintf (stderr, "Error: pretty printing set to PP_NOTSET.\n"); exit (1); default: fprintf (stderr, "Error: Unknown pretty print option.\n"); exit (1); } } classad_index++; totals->update(ad); } adList.Close(); // if there are no ads to print, but the user wanted XML output, // then print out the XML header and footer, so that naive XML // parsers won't get confused. if ( PP_XML == pps && 0 == classad_index ) { printXML (NULL, true, true); } // if totals are required, display totals if (adList.MyLength() > 0 && totals) totals->displayTotals(stdout, 20); }