<commit_before>open Listext
open Threadext
open Rrdd_shared
open Rrd
open Ds

module D = Debug.Make(struct let name = "rrdd_monitor" end)
open D

let create_rras use_min_max =
	(* Create archives of type min, max and average and last *)
	Array.of_list (List.flatten
		(List.map (fun (n,ns) ->
			if ns > 1 && use_min_max then [
				Rrd.rra_create Rrd.CF_Average n ns 1.0;
				Rrd.rra_create Rrd.CF_Min n ns 1.0;
				Rrd.rra_create Rrd.CF_Max n ns 1.0;
			] else [Rrd.rra_create Rrd.CF_Average n ns 0.5]
		) timescales)
	)

let step = 5

(** Create a rrd *)
let create_fresh_rrd use_min_max dss =
	let rras = create_rras use_min_max in
	let dss = Array.of_list (List.filter_map (fun ds ->
		if ds.ds_default then
			Some (Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 ~max:ds.ds_max ~min:ds.ds_min Rrd.VT_Unknown)
		else None) dss)
	in
	let rrd = Rrd.rrd_create dss rras (Int64.of_int step) (Unix.gettimeofday()) in
	rrd

(* Updates all of the hosts rrds. We are passed a list of uuids that
 * is used as the primary source for which VMs are resident on us.
 * When a new uuid turns up that we haven't got an RRD for in our
 * hashtbl, we create a new one. When a uuid for which we have an RRD
 * for doesn't appear to have any stats this update, we assume that the
 * domain has gone and we stream the RRD to the master. We also have a
 * list of the currently rebooting VMs to ensure we don't accidentally<commit_msg>rrdd_monitor: Use Int64 literal instead of Int64.of_int<commit_after>open Listext
open Threadext
open Rrdd_shared
open Rrd
open Ds

module D = Debug.Make(struct let name = "rrdd_monitor" end)
open D

let create_rras use_min_max =
	(* Create archives of type min, max and average and last *)
	Array.of_list (List.flatten
		(List.map (fun (n,ns) ->
			if ns > 1 && use_min_max then [
				Rrd.rra_create Rrd.CF_Average n ns 1.0;
				Rrd.rra_create Rrd.CF_Min n ns 1.0;
				Rrd.rra_create Rrd.CF_Max n ns 1.0;
			] else [Rrd.rra_create Rrd.CF_Average n ns 0.5]
		) timescales)
	)

let step = 5L

(** Create a rrd *)
let create_fresh_rrd use_min_max dss =
	let rras = create_rras use_min_max in
	let dss = Array.of_list (List.filter_map (fun ds ->
		if ds.ds_default then
			Some (Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 ~max:ds.ds_max ~min:ds.ds_min Rrd.VT_Unknown)
		else None) dss)
	in
	let rrd = Rrd.rrd_create dss rras step (Unix.gettimeofday()) in
	rrd

(* Updates all of the hosts rrds. We are passed a list of uuids that
 * is used as the primary source for which VMs are resident on us.
 * When a new uuid turns up that we haven't got an RRD for in our
 * hashtbl, we create a new one. When a uuid for which we have an RRD
 * for doesn't appear to have any stats this update, we assume that the
 * domain has gone and we stream the RRD to the master. We also have a
 * list of the currently rebooting VMs to ensure we don't accidentally
{'fraction_non_alphanumeric': 0.07775453277545327, 'fraction_numerical': 0.011854951185495118, 'mean_word_length': 3.511006289308176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5963023', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1075, 'n_words': 416}