예제 #1
0
extern void jobacctinfo_pack(jobacctinfo_t *jobacct,
			     uint16_t rpc_version, uint16_t protocol_type,
			     Buf buffer)
{
	bool no_pack;

	no_pack = (!plugin_polling && (protocol_type != PROTOCOL_TYPE_DBD));

	if (rpc_version >= SLURM_MIN_PROTOCOL_VERSION) {
		if (!jobacct || no_pack) {
			pack8((uint8_t) 0, buffer);
			return;
		}
		pack8((uint8_t) 1, buffer);

		pack32((uint32_t)jobacct->user_cpu_sec, buffer);
		pack32((uint32_t)jobacct->user_cpu_usec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_sec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_usec, buffer);
		pack64(jobacct->max_vsize, buffer);
		pack64(jobacct->tot_vsize, buffer);
		pack64(jobacct->max_rss, buffer);
		pack64(jobacct->tot_rss, buffer);
		pack64(jobacct->max_pages, buffer);
		pack64(jobacct->tot_pages, buffer);
		pack32((uint32_t)jobacct->min_cpu, buffer);
		packdouble(jobacct->tot_cpu, buffer);
		pack32((uint32_t)jobacct->act_cpufreq, buffer);
		pack64((uint64_t)jobacct->energy.consumed_energy, buffer);

		packdouble((double)jobacct->max_disk_read, buffer);
		packdouble((double)jobacct->tot_disk_read, buffer);
		packdouble((double)jobacct->max_disk_write, buffer);
		packdouble((double)jobacct->tot_disk_write, buffer);

		_pack_jobacct_id(&jobacct->max_vsize_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_rss_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_pages_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->min_cpu_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_disk_read_id, rpc_version,
			buffer);
		_pack_jobacct_id(&jobacct->max_disk_write_id, rpc_version,
			buffer);
	} else {
		info("jobacctinfo_pack version %u not supported", rpc_version);
		return;
	}
}
예제 #2
0
extern void jobacctinfo_pack(jobacctinfo_t *jobacct,
			     uint16_t rpc_version, uint16_t protocol_type,
			     Buf buffer)
{
	int i = 0;

	if (!plugin_polling && (protocol_type != PROTOCOL_TYPE_DBD))
		return;

	/* The function can take calls from both DBD and from regular
	 * SLURM functions.  We choose to standardize on using the
	 * SLURM_PROTOCOL_VERSION here so if PROTOCOL_TYPE_DBD comes
	 * in we need to translate the DBD rpc_version to use the
	 * SLURM protocol_version.
	 *
	 * If this function ever changes make sure the
	 * slurmdbd_translate_rpc function has been updated with the
	 * new protocol version.
	 */
	if (protocol_type == PROTOCOL_TYPE_DBD)
		rpc_version = slurmdbd_translate_rpc(rpc_version);

	if (rpc_version >= SLURM_2_6_PROTOCOL_VERSION) {
		if (!jobacct) {
			for (i = 0; i < 14; i++)
				pack32((uint32_t) 0, buffer);
			for (i = 0; i < 4; i++)
				packdouble((double) 0, buffer);
			for (i = 0; i < 6; i++)
				_pack_jobacct_id(NULL, rpc_version, buffer);
			return;
		}

		pack32((uint32_t)jobacct->user_cpu_sec, buffer);
		pack32((uint32_t)jobacct->user_cpu_usec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_sec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_usec, buffer);
		pack32((uint32_t)jobacct->max_vsize, buffer);
		pack32((uint32_t)jobacct->tot_vsize, buffer);
		pack32((uint32_t)jobacct->max_rss, buffer);
		pack32((uint32_t)jobacct->tot_rss, buffer);
		pack32((uint32_t)jobacct->max_pages, buffer);
		pack32((uint32_t)jobacct->tot_pages, buffer);
		pack32((uint32_t)jobacct->min_cpu, buffer);
		pack32((uint32_t)jobacct->tot_cpu, buffer);
		pack32((uint32_t)jobacct->act_cpufreq, buffer);
		pack32((uint32_t)jobacct->energy.consumed_energy, buffer);

		packdouble((double)jobacct->max_disk_read, buffer);
		packdouble((double)jobacct->tot_disk_read, buffer);
		packdouble((double)jobacct->max_disk_write, buffer);
		packdouble((double)jobacct->tot_disk_write, buffer);

		_pack_jobacct_id(&jobacct->max_vsize_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_rss_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_pages_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->min_cpu_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_disk_read_id, rpc_version,
			buffer);
		_pack_jobacct_id(&jobacct->max_disk_write_id, rpc_version,
			buffer);
	} else if (rpc_version >= SLURM_2_5_PROTOCOL_VERSION) {
		if (!jobacct) {
			for (i = 0; i < 14; i++)
				pack32((uint32_t) 0, buffer);
			for (i = 0; i < 4; i++)
				_pack_jobacct_id(NULL, rpc_version, buffer);
			return;
		}

		pack32((uint32_t)jobacct->user_cpu_sec, buffer);
		pack32((uint32_t)jobacct->user_cpu_usec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_sec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_usec, buffer);
		pack32((uint32_t)jobacct->max_vsize, buffer);
		pack32((uint32_t)jobacct->tot_vsize, buffer);
		pack32((uint32_t)jobacct->max_rss, buffer);
		pack32((uint32_t)jobacct->tot_rss, buffer);
		pack32((uint32_t)jobacct->max_pages, buffer);
		pack32((uint32_t)jobacct->tot_pages, buffer);
		pack32((uint32_t)jobacct->min_cpu, buffer);
		pack32((uint32_t)jobacct->tot_cpu, buffer);
		pack32((uint32_t)jobacct->act_cpufreq, buffer);
		pack32((uint32_t)jobacct->energy.consumed_energy, buffer);

		_pack_jobacct_id(&jobacct->max_vsize_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_rss_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_pages_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->min_cpu_id, rpc_version, buffer);
	} else {
		if (!jobacct) {
			for (i = 0; i < 12; i++)
				pack32((uint32_t) 0, buffer);
			for (i = 0; i < 4; i++)
				_pack_jobacct_id(NULL, rpc_version, buffer);
			return;
		}

		pack32((uint32_t)jobacct->user_cpu_sec, buffer);
		pack32((uint32_t)jobacct->user_cpu_usec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_sec, buffer);
		pack32((uint32_t)jobacct->sys_cpu_usec, buffer);
		pack32((uint32_t)jobacct->max_vsize, buffer);
		pack32((uint32_t)jobacct->tot_vsize, buffer);
		pack32((uint32_t)jobacct->max_rss, buffer);
		pack32((uint32_t)jobacct->tot_rss, buffer);
		pack32((uint32_t)jobacct->max_pages, buffer);
		pack32((uint32_t)jobacct->tot_pages, buffer);
		pack32((uint32_t)jobacct->min_cpu, buffer);
		pack32((uint32_t)jobacct->tot_cpu, buffer);

		_pack_jobacct_id(&jobacct->max_vsize_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_rss_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->max_pages_id, rpc_version, buffer);
		_pack_jobacct_id(&jobacct->min_cpu_id, rpc_version, buffer);

	}
}