// This method sucks. As soon as we have a real solution for storing // all 4 of these values in the job classad, it should be removed. void Email::writeBytes( float run_sent, float run_recv, float tot_sent, float tot_recv ) { // if we're not currently open w/ a message, we're done if( ! fp ) { return; } fprintf( fp, "\nNetwork:\n" ); fprintf( fp, "%10s Run Bytes Received By Job\n", metric_units(run_recv) ); fprintf( fp, "%10s Run Bytes Sent By Job\n", metric_units(run_sent) ); fprintf( fp, "%10s Total Bytes Received By Job\n", metric_units(tot_recv) ); fprintf( fp, "%10s Total Bytes Sent By Job\n", metric_units(tot_sent) ); }
static const char * format_readable_kb(const classad::Value &val, AttrList *, Formatter &) { long long kbi; double kb; if (val.IsIntegerValue(kbi)) { kb = kbi*1024.0; } else if (val.IsRealValue(kb)) { kb *= 1024.0; } else { return " "; } return metric_units(kb); }
void publishNotifyEmail( FILE* mailer, char* buf, PROC* proc ) { double rutime, rstime, lutime, lstime; /* remote/local user/sys times */ double trtime, tltime; /* Total remote/local time */ double real_time; float run_time = 0.0; time_t arch_time=0; /* time_t is 8 bytes some archs and 4 bytes on other archs, and this means that doing a (time_t*) cast on & of a 4 byte int makes my life hell. So we fix it by assigning the time we want to a real time_t variable, then using ctime() to convert it to a string */ fprintf(mailer, "Your condor job " ); #if defined(NEW_PROC) if ( proc->args_v1or2[0] ) { ArgList args; MyString args_string; args.AppendArgsV1or2Raw(proc->args_v1or2[0],NULL); args.GetArgsStringForDisplay(&args_string); fprintf(mailer, "%s %s ", proc->cmd[0], args_string.Value() ); } else fprintf(mailer, "%s ", proc->cmd[0] ); #else ArgList args; MyString args_string; args.AppendArgsV1or2(proc->args_v1or2,NULL); args.GetArgsStringForDisplay(&args_string); fprintf(mailer, "%s %s ", proc->cmd, args_string.Value() ); #endif fprintf(mailer, "%s\n\n", buf ); job_report_display_errors( mailer ); char* user = NULL; char* full_user = NULL; if( ! JobAd->LookupString(ATTR_USER, &user) ) { JobAd->LookupString(ATTR_OWNER, &user); } if( user ) { full_user = email_check_domain( user, JobAd ); fprintf( mailer, "\nSubmitted by: %s\n", full_user ); free( full_user ); full_user = NULL; free( user ); user = NULL; } arch_time = proc->q_date; fprintf(mailer, "\nTime:\n"); fprintf(mailer, "\tSubmitted at: %s", ctime(&arch_time)); if( proc->completion_date ) { real_time = proc->completion_date - proc->q_date; arch_time = proc->completion_date; fprintf(mailer, "\tCompleted at: %s\n", ctime(&arch_time)); fprintf(mailer, "\tReal Time: %s\n", d_format_time(real_time)); if (JobAd) { JobAd->LookupFloat(ATTR_JOB_REMOTE_WALL_CLOCK, run_time); } run_time += proc->completion_date - ShadowBDate; fprintf(mailer, "\tRun Time: %s\n", d_format_time(run_time)); if (CommittedTime > 0) { fprintf(mailer, "\tCommitted Time: %s\n", d_format_time(CommittedTime)); } } fprintf( mailer, "\n" ); #if defined(NEW_PROC) rutime = proc->remote_usage[0].ru_utime.tv_sec; rstime = proc->remote_usage[0].ru_stime.tv_sec; trtime = rutime + rstime; #else rutime = proc->remote_usage.ru_utime.tv_sec; rstime = proc->remote_usage.ru_stime.tv_sec; trtime = rutime + rstime; #endif lutime = proc->local_usage.ru_utime.tv_sec; lstime = proc->local_usage.ru_stime.tv_sec; tltime = lutime + lstime; fprintf(mailer, "\tRemote User Time: %s\n", d_format_time(rutime) ); fprintf(mailer, "\tRemote System Time: %s\n", d_format_time(rstime) ); fprintf(mailer, "\tTotal Remote Time: %s\n\n", d_format_time(trtime)); fprintf(mailer, "\tLocal User Time: %s\n", d_format_time(lutime) ); fprintf(mailer, "\tLocal System Time: %s\n", d_format_time(lstime) ); fprintf(mailer, "\tTotal Local Time: %s\n\n", d_format_time(tltime)); if( tltime >= 1.0 ) { fprintf(mailer, "\tLeveraging Factor: %2.1f\n", trtime / tltime); } fprintf(mailer, "\tVirtual Image Size: %d Kilobytes\n", proc->image_size); if (NumCkpts > 0) { fprintf(mailer, "\nCheckpoints written: %d\n", NumCkpts); fprintf(mailer, "Checkpoint restarts: %d\n", NumRestarts); } // TotalBytesSent and TotalBytesRecvd are from the shadow's // perspective, and we want to display the stats from the job's // perspective. Note also that TotalBytesSent and TotalBytesRecvd // don't include our current run, so we need to include the // stats from our syscall_sock (if we have one) and the BytesSent // and BytesRecvd variables. This is ugly and confusing, which // explains why I keep getting it wrong. :-( float network_bytes = TotalBytesSent + BytesSent; if (syscall_sock) { network_bytes += syscall_sock->get_bytes_sent(); } if (network_bytes > 0.0) { fprintf(mailer,"\nNetwork:\n"); fprintf(mailer,"\t%s read\n",metric_units(network_bytes)); network_bytes = TotalBytesRecvd + BytesRecvd; if (syscall_sock) { network_bytes += syscall_sock->get_bytes_recvd(); } fprintf(mailer,"\t%s written\n",metric_units(network_bytes)); } if (JobIsStandard()) { job_report_display_file_info( mailer, (int) run_time ); job_report_display_calls( mailer ); } email_custom_attributes( mailer, JobAd ); }