View | Details | Raw Unified | Return to ticket 1384
Collapse All | Expand All

(-)a/contribs/perlapi/common/msg.h (+14 lines)
Lines 220-225 inline static int hv_store_int(HV* hv, const char *key, int val) Link Here
220
}
220
}
221
221
222
/*
222
/*
223
 * store a double
224
 */
225
inline static int hv_store_double(HV* hv, const char *key, double val)
226
{
227
	SV* sv = newSVnv(val);
228
229
	if (!key || hv_store(hv, key, (I32)strlen(key), sv, 0) == NULL) {
230
		SvREFCNT_dec(sv);
231
		return -1;
232
	}
233
	return 0;
234
}
235
236
/*
223
 * store a signed 32b int into HV
237
 * store a signed 32b int into HV
224
 */
238
 */
225
inline static int hv_store_int32_t(HV* hv, const char *key, int32_t val)
239
inline static int hv_store_int32_t(HV* hv, const char *key, int32_t val)
(-)a/contribs/perlapi/libslurmdb/perl/Slurmdb.xs (+37 lines)
Lines 189-191 slurmdb_report_user_top_usage(db_conn, user_condition, group_accounts) Link Here
189
	slurmdb_destroy_user_cond(user_cond);
189
	slurmdb_destroy_user_cond(user_cond);
190
    OUTPUT:
190
    OUTPUT:
191
        RETVAL
191
        RETVAL
192
193
SV*
194
slurmdb_jobs_get(db_conn, conditions)
195
	void* db_conn
196
	HV*   conditions
197
    INIT:
198
	AV*   results;
199
	HV*   rh;
200
	List  list = NULL;
201
	ListIterator itr;
202
	slurmdb_job_cond_t *job_cond = (slurmdb_job_cond_t*)
203
		slurm_xmalloc(sizeof(slurmdb_job_cond_t), __FILE__,
204
		__LINE__, "slurmdb_jobs_get");
205
	slurmdb_job_rec_t *rec = NULL;
206
207
	if (hv_to_job_cond(conditions, job_cond) < 0) {
208
		XSRETURN_UNDEF;
209
	}
210
	results = (AV*)sv_2mortal((SV*)newAV());
211
    CODE:
212
	list = slurmdb_jobs_get(db_conn, job_cond);
213
	if (list) {
214
	    itr = slurm_list_iterator_create(list);
215
216
	    while ((rec = slurm_list_next(itr))) {
217
		rh = (HV *)sv_2mortal((SV*)newHV());
218
		if (job_rec_to_hv(rec, rh) < 0) {
219
		    XSRETURN_UNDEF;
220
		}
221
		av_push(results, newRV((SV*)rh));
222
	    }
223
	    slurm_list_destroy(list);
224
	}
225
	RETVAL = newRV((SV*)results);
226
	slurmdb_destroy_job_cond(job_cond);
227
    OUTPUT:
228
        RETVAL
(-)a/contribs/perlapi/libslurmdb/perl/cluster.c (+144 lines)
Lines 484-486 report_user_rec_to_hv(slurmdb_report_user_rec_t* rec, HV* hv) Link Here
484
484
485
    return 0;
485
    return 0;
486
}
486
}
487
488
int
489
stats_to_hv(slurmdb_stats_t *stats, HV* hv)
490
{
491
    STORE_FIELD(hv, stats, act_cpufreq,           double);
492
    STORE_FIELD(hv, stats, cpu_ave,               double);
493
    STORE_FIELD(hv, stats, consumed_energy,       double);
494
    STORE_FIELD(hv, stats, cpu_min,               uint32_t);
495
    STORE_FIELD(hv, stats, cpu_min_nodeid,        uint32_t);
496
    STORE_FIELD(hv, stats, cpu_min_taskid,        uint32_t);
497
    STORE_FIELD(hv, stats, disk_read_ave,         double);
498
    STORE_FIELD(hv, stats, disk_read_max,         double);
499
    STORE_FIELD(hv, stats, disk_read_max_nodeid,  uint32_t);
500
    STORE_FIELD(hv, stats, disk_read_max_taskid,  uint32_t);
501
    STORE_FIELD(hv, stats, disk_write_ave,        double);
502
    STORE_FIELD(hv, stats, disk_write_max,        double);
503
    STORE_FIELD(hv, stats, disk_write_max_nodeid, uint32_t);
504
    STORE_FIELD(hv, stats, disk_write_max_taskid, uint32_t);
505
    STORE_FIELD(hv, stats, pages_ave,             double);
506
    STORE_FIELD(hv, stats, pages_max,             uint64_t);
507
    STORE_FIELD(hv, stats, pages_max_nodeid,      uint32_t);
508
    STORE_FIELD(hv, stats, pages_max_taskid,      uint32_t);
509
    STORE_FIELD(hv, stats, rss_ave,               double);
510
    STORE_FIELD(hv, stats, rss_max,               uint64_t);
511
    STORE_FIELD(hv, stats, rss_max_nodeid,        uint32_t);
512
    STORE_FIELD(hv, stats, rss_max_taskid,        uint32_t);
513
    STORE_FIELD(hv, stats, vsize_ave,             double);
514
    STORE_FIELD(hv, stats, vsize_max,             uint64_t);
515
    STORE_FIELD(hv, stats, vsize_max_nodeid,      uint32_t);
516
    STORE_FIELD(hv, stats, vsize_max_taskid,      uint32_t);
517
518
    return 0;
519
}
520
521
int
522
step_rec_to_hv(slurmdb_step_rec_t *rec, HV* hv)
523
{
524
    HV* stats_hv = (HV*)sv_2mortal((SV*)newHV());
525
    stats_to_hv(&rec->stats, stats_hv);
526
    hv_store_sv(hv, "stats", newRV((SV*)stats_hv));
527
528
    STORE_FIELD(hv, rec, elapsed,       uint32_t);
529
    STORE_FIELD(hv, rec, end,           time_t);
530
    STORE_FIELD(hv, rec, exitcode,      int32_t);
531
    STORE_FIELD(hv, rec, ncpus,         uint32_t);
532
    STORE_FIELD(hv, rec, nnodes,        uint32_t);
533
    STORE_FIELD(hv, rec, nodes,         charp);
534
    STORE_FIELD(hv, rec, ntasks,        uint32_t);
535
    STORE_FIELD(hv, rec, pid_str,       charp);
536
    STORE_FIELD(hv, rec, req_cpufreq,   uint32_t);
537
    STORE_FIELD(hv, rec, requid,        uint32_t);
538
    STORE_FIELD(hv, rec, start,         time_t);
539
    STORE_FIELD(hv, rec, state,         uint32_t);
540
    STORE_FIELD(hv, rec, stepid,        uint32_t);
541
    STORE_FIELD(hv, rec, stepname,      charp);
542
    STORE_FIELD(hv, rec, suspended,     uint32_t);
543
    STORE_FIELD(hv, rec, sys_cpu_sec,   uint32_t);
544
    STORE_FIELD(hv, rec, sys_cpu_usec,  uint32_t);
545
    STORE_FIELD(hv, rec, task_dist,     uint16_t);
546
    STORE_FIELD(hv, rec, tot_cpu_sec,   uint32_t);
547
    STORE_FIELD(hv, rec, tot_cpu_usec,  uint32_t);
548
    STORE_FIELD(hv, rec, user_cpu_sec,  uint32_t);
549
    STORE_FIELD(hv, rec, user_cpu_usec, uint32_t);
550
551
    return 0;
552
}
553
554
int
555
job_rec_to_hv(slurmdb_job_rec_t* rec, HV* hv)
556
{
557
    slurmdb_step_rec_t *step;
558
    ListIterator itr = NULL;
559
    AV* steps_av = (AV*)sv_2mortal((SV*)newAV());
560
    HV* stats_hv = (HV*)sv_2mortal((SV*)newHV());
561
    HV* step_hv;
562
563
    stats_to_hv(&rec->stats, stats_hv);
564
    hv_store_sv(hv, "stats", newRV((SV*)stats_hv));
565
566
    if (rec->steps) {
567
	itr = slurm_list_iterator_create(rec->steps);
568
	while ((step = slurm_list_next(itr))) {
569
	    step_hv = (HV*)sv_2mortal((SV*)newHV());
570
	    step_rec_to_hv(step, step_hv);
571
	    av_push(steps_av, newRV((SV*)step_hv));
572
	}
573
    }
574
    hv_store_sv(hv, "steps", newRV((SV*)steps_av));
575
576
    STORE_FIELD(hv, rec, account,         charp);
577
    STORE_FIELD(hv, rec, alloc_cpus,      uint32_t);
578
    STORE_FIELD(hv, rec, alloc_gres,      charp);
579
    STORE_FIELD(hv, rec, alloc_nodes,     uint32_t);
580
    STORE_FIELD(hv, rec, array_job_id,    uint32_t);
581
    STORE_FIELD(hv, rec, array_max_tasks, uint32_t);
582
    STORE_FIELD(hv, rec, array_task_id,   uint32_t);
583
    STORE_FIELD(hv, rec, array_task_str,  charp);
584
    STORE_FIELD(hv, rec, associd,         uint32_t);
585
    STORE_FIELD(hv, rec, blockid,         charp);
586
    STORE_FIELD(hv, rec, cluster,         charp);
587
    STORE_FIELD(hv, rec, derived_ec,      uint32_t);
588
    STORE_FIELD(hv, rec, derived_es,      charp);
589
    STORE_FIELD(hv, rec, elapsed,         uint32_t);
590
    STORE_FIELD(hv, rec, eligible,        time_t);
591
    STORE_FIELD(hv, rec, end,             time_t);
592
    STORE_FIELD(hv, rec, exitcode,        uint32_t);
593
    /*STORE_FIELD(hv, rec, first_step_ptr,  void*);*/
594
    STORE_FIELD(hv, rec, gid,             uint32_t);
595
    STORE_FIELD(hv, rec, jobid,           uint32_t);
596
    STORE_FIELD(hv, rec, jobname,         charp);
597
    STORE_FIELD(hv, rec, lft,             uint32_t);
598
    STORE_FIELD(hv, rec, partition,       charp);
599
    STORE_FIELD(hv, rec, nodes,           charp);
600
    STORE_FIELD(hv, rec, priority,        uint32_t);
601
    STORE_FIELD(hv, rec, qosid,           uint32_t);
602
    STORE_FIELD(hv, rec, req_cpus,        uint32_t);
603
    STORE_FIELD(hv, rec, req_gres,        charp);
604
    STORE_FIELD(hv, rec, req_mem,         uint32_t);
605
    STORE_FIELD(hv, rec, requid,          uint32_t);
606
    STORE_FIELD(hv, rec, resvid,          uint32_t);
607
    STORE_FIELD(hv, rec, resv_name,       charp);
608
    STORE_FIELD(hv, rec, show_full,       uint32_t);
609
    STORE_FIELD(hv, rec, start,           time_t);
610
    STORE_FIELD(hv, rec, state,           uint16_t);
611
    STORE_FIELD(hv, rec, submit,          time_t);
612
    STORE_FIELD(hv, rec, suspended,       uint32_t);
613
    STORE_FIELD(hv, rec, sys_cpu_sec,     uint32_t);
614
    STORE_FIELD(hv, rec, sys_cpu_usec,    uint32_t);
615
    STORE_FIELD(hv, rec, timelimit,       uint32_t);
616
    STORE_FIELD(hv, rec, tot_cpu_sec,     uint32_t);
617
    STORE_FIELD(hv, rec, tot_cpu_usec,    uint32_t);
618
    STORE_FIELD(hv, rec, track_steps,     uint16_t);
619
    STORE_FIELD(hv, rec, uid,             uint32_t);
620
    STORE_FIELD(hv, rec, used_gres,       charp);
621
    STORE_FIELD(hv, rec, user,            charp);
622
    STORE_FIELD(hv, rec, user_cpu_sec,    uint32_t);
623
    STORE_FIELD(hv, rec, user_cpu_usec,   uint32_t);
624
    STORE_FIELD(hv, rec, wckey,           charp);
625
    STORE_FIELD(hv, rec, wckeyid,         uint32_t);
626
627
    return 0;
628
}
629
630
(-)a/contribs/perlapi/libslurmdb/perl/slurmdb-perl.h (+1 lines)
Lines 42-47 extern int cluster_grouping_list_to_av(List list, AV* av); Link Here
42
extern int cluster_rec_to_hv(slurmdb_cluster_rec_t *rec, HV* hv);
42
extern int cluster_rec_to_hv(slurmdb_cluster_rec_t *rec, HV* hv);
43
extern int report_cluster_rec_list_to_av(List list, AV* av);
43
extern int report_cluster_rec_list_to_av(List list, AV* av);
44
extern int report_user_rec_to_hv(slurmdb_report_user_rec_t *rec, HV* hv);
44
extern int report_user_rec_to_hv(slurmdb_report_user_rec_t *rec, HV* hv);
45
extern int job_rec_to_hv(slurmdb_job_rec_t *rec, HV* hv);
45
46
46
47
47
#endif /* _SLURMDB_PERL_H */
48
#endif /* _SLURMDB_PERL_H */

Return to ticket 1384