forked from JointCloud/pcm-coordinator
77 lines
2.8 KiB
Go
77 lines
2.8 KiB
Go
package tianhe
|
|
|
|
/*
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include<slurm/slurm.h>
|
|
#include<slurm/slurm_errno.h>
|
|
#include <signal.h>
|
|
|
|
stats_info_response_msg_t *getStats(){
|
|
stats_info_response_msg_t *buf;
|
|
stats_info_request_msg_t req;
|
|
|
|
int rc;
|
|
req.command_id = STAT_COMMAND_GET;
|
|
rc = slurm_get_statistics(&buf, (stats_info_request_msg_t *)&req);
|
|
if (rc != SLURM_SUCCESS) {
|
|
slurm_perror("slurm_get_statistics");
|
|
return NULL;
|
|
}
|
|
//slurm_free_stats_info_request_msg(&req);
|
|
return buf;
|
|
}
|
|
*/
|
|
import "C"
|
|
import pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl"
|
|
|
|
func Get_diag() pbslurm.StatsInfoResponseMsg {
|
|
var go_stats_buffer pbslurm.StatsInfoResponseMsg
|
|
c_stats_buffer := C.getStats()
|
|
if c_stats_buffer == nil {
|
|
return go_stats_buffer
|
|
}
|
|
|
|
go_stats_buffer = Stats_convert_c_to_go(c_stats_buffer)
|
|
//C.slurm_free_stats_response_msg(c_stats_buffer)
|
|
return go_stats_buffer
|
|
}
|
|
|
|
func Stats_convert_c_to_go(c_struct *C.stats_info_response_msg_t) pbslurm.StatsInfoResponseMsg {
|
|
var go_struct pbslurm.StatsInfoResponseMsg
|
|
|
|
go_struct.AgentQueueSize = uint32(c_struct.agent_queue_size)
|
|
go_struct.BfActive = uint32(c_struct.bf_active)
|
|
go_struct.BfBackfilledJobs = uint32(c_struct.bf_backfilled_jobs)
|
|
go_struct.BfCycleCounter = uint32(c_struct.bf_cycle_counter)
|
|
go_struct.BfCycleLast = uint32(c_struct.bf_cycle_last)
|
|
go_struct.BfCycleMax = uint32(c_struct.bf_cycle_max)
|
|
go_struct.BfCycleSum = uint32(c_struct.bf_cycle_sum)
|
|
go_struct.BfDepthSum = uint32(c_struct.bf_depth_sum)
|
|
go_struct.BfDepthTrySum = uint32(c_struct.bf_depth_try_sum)
|
|
go_struct.BfLastBackfilledJobs = uint32(c_struct.bf_last_backfilled_jobs)
|
|
go_struct.BfLastDepth = uint32(c_struct.bf_last_depth)
|
|
go_struct.BfLastDepthTry = uint32(c_struct.bf_last_depth_try)
|
|
go_struct.BfQueueLen = uint32(c_struct.bf_queue_len)
|
|
go_struct.BfQueueLenSum = uint32(c_struct.bf_queue_len_sum)
|
|
go_struct.BfWhenLastCycle = int64(c_struct.bf_when_last_cycle)
|
|
go_struct.JobsCompleted = uint32(c_struct.jobs_completed)
|
|
go_struct.JobsCanceled = uint32(c_struct.jobs_canceled)
|
|
go_struct.JobsFailed = uint32(c_struct.jobs_failed)
|
|
go_struct.JobsStarted = uint32(c_struct.jobs_started)
|
|
go_struct.JobsSubmitted = uint32(c_struct.jobs_submitted)
|
|
go_struct.PartsPacked = uint32(c_struct.parts_packed)
|
|
go_struct.ReqTime = int64(c_struct.req_time)
|
|
go_struct.ReqTimeStart = int64(c_struct.req_time_start)
|
|
go_struct.ScheduleCycleDepth = uint32(c_struct.schedule_cycle_depth)
|
|
go_struct.ScheduleCycleCounter = uint32(c_struct.schedule_cycle_counter)
|
|
go_struct.ScheduleCycleLast = uint32(c_struct.schedule_cycle_last)
|
|
go_struct.ScheduleCycleMax = uint32(c_struct.schedule_cycle_max)
|
|
go_struct.ScheduleCycleSum = uint32(c_struct.schedule_cycle_sum)
|
|
go_struct.ScheduleQueueLen = uint32(c_struct.schedule_queue_len)
|
|
go_struct.ServerThreadCount = uint32(c_struct.server_thread_count)
|
|
|
|
return go_struct
|
|
}
|