move credentials to settings.json, use RVExtensionArgs call
adds value type definitions for float/int, adds mission, server name, world name to sent metrics
This commit is contained in:
@@ -1,23 +1,47 @@
|
|||||||
|
|
||||||
// function adapted from YAINA by MartinCo at http://yaina.eu
|
// function adapted from YAINA by MartinCo at http://yaina.eu
|
||||||
|
|
||||||
if !(isServer || !hasInterface) exitWith {};
|
// if (!isServer) exitWith {};
|
||||||
_cba = (isClass(configFile >> "CfgPatches" >> "cba_main"));
|
_cba = (isClass(configFile >> "CfgPatches" >> "cba_main"));
|
||||||
|
|
||||||
|
RangerMetrics_debug = true;
|
||||||
|
|
||||||
[format ["Instance name: %1", profileName]] call RangerMetrics_fnc_log;
|
[format ["Instance name: %1", profileName]] call RangerMetrics_fnc_log;
|
||||||
[format ["CBA detected: %1", _cba]] call RangerMetrics_fnc_log;
|
[format ["CBA detected: %1", _cba]] call RangerMetrics_fnc_log;
|
||||||
["Initializing v1.1"] call RangerMetrics_fnc_log;
|
["Initializing v1.1"] call RangerMetrics_fnc_log;
|
||||||
|
|
||||||
RangerMetrics_run = true;
|
// _extData = "RangerMetrics" callExtension "loadSettings";
|
||||||
|
// if (_extData == "0") exitWith {
|
||||||
|
// ["Extension not found, disabling"] call RangerMetrics_fnc_log;
|
||||||
|
// RangerMetrics_run = false;
|
||||||
|
// };
|
||||||
|
|
||||||
if(_cba) then { // CBA is running, use PFH
|
// _extData = parseSimpleArray _extData;
|
||||||
[RangerMetrics_fnc_run, 10, [_cba]] call CBA_fnc_addPerFrameHandler;
|
// RangerMetrics_settingsDir = _extData select 0;
|
||||||
} else { // CBA isn't running, use sleep
|
// RangerMetrics_settingsLoaded = _extData select 1;
|
||||||
[_cba] spawn {
|
// RangerMetrics_influxURL = _extData select 2;
|
||||||
params ["_cba"];
|
|
||||||
while{true} do {
|
// [format["InfluxDB URL: %1", RangerMetrics_influxURL]] call RangerMetrics_fnc_log;
|
||||||
[[_cba]] call RangerMetrics_fnc_run; // nested to match CBA PFH signature
|
// _extVersion = "RangerMetrics" callExtension "version";
|
||||||
sleep 10;
|
// ["Extension version: " + _extVersion] call RangerMetrics_fnc_log;
|
||||||
};
|
|
||||||
|
addMissionEventHandler ["ExtensionCallback", {
|
||||||
|
params ["_name", "_function", "_data"];
|
||||||
|
if (_name == "RangerMetrics") then {
|
||||||
|
[parseSimpleArray _data] call RangerMetrics_fnc_log;
|
||||||
};
|
};
|
||||||
};
|
}];
|
||||||
|
|
||||||
|
// RangerMetrics_run = true;
|
||||||
|
|
||||||
|
// if(_cba) then { // CBA is running, use PFH
|
||||||
|
// [RangerMetrics_fnc_run, 10, [_cba]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
// } else { // CBA isn't running, use sleep
|
||||||
|
// [_cba] spawn {
|
||||||
|
// params ["_cba"];
|
||||||
|
// while{true} do {
|
||||||
|
// [[_cba]] call RangerMetrics_fnc_run; // nested to match CBA PFH signature
|
||||||
|
// sleep 10;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ if(missionNamespace getVariable ["RangerMetrics_run",false]) then {
|
|||||||
private _headlessClients = entities "HeadlessClient_F";
|
private _headlessClients = entities "HeadlessClient_F";
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
private _stats_fps = round diag_fps;
|
private _stats_fps = diag_fps;
|
||||||
["stats.HCfps", "float", _stats_fps] remoteExec ["RangerMetrics_fnc_send", 2];
|
["stats.HCfps", "float", _stats_fps] remoteExec ["RangerMetrics_fnc_send", 2];
|
||||||
|
|
||||||
} remoteExecCall ["bis_fnc_call", owner _x];
|
} remoteExecCall ["bis_fnc_call", owner _x];
|
||||||
|
|||||||
@@ -1,38 +1,37 @@
|
|||||||
params ["_metric", "_value", ["_global", false]];
|
params ["_metric", "_valueType", "_value", ["_global", false]];
|
||||||
|
|
||||||
private _profileName = profileName;
|
private _profileName = profileName;
|
||||||
private _prefix = "Arma3";
|
private _prefix = "Arma3";
|
||||||
|
private _locality = [profileName, "global"] select _global;
|
||||||
|
|
||||||
|
// InfluxDB settings
|
||||||
|
// private _connection = "http://indifox.info:8086";
|
||||||
|
// private _token = "BwOzapPBLZ-lhtrcs3PC2Jk2p7plCC0UckHKxe8AxulYkk9St1q2aloXMW2rDD4X2ufIkx3fwSbEe6ZeJo8ljg==";
|
||||||
|
// private _org = "ranger-metrics";
|
||||||
|
// private _bucket = "ranger-metrics";
|
||||||
|
|
||||||
private _environmentMeta = [missionName, worldName, serverName];
|
// private _extSend = format["%1,%2", format["%1,%2,%3,%4,%5,%6", _connection, _token, _org, _bucket, _metricPath, _metric], _value];
|
||||||
|
private _extSend = [
|
||||||
private _metricPath = [
|
// _connection,
|
||||||
format["%1,%2,%3,%4,%5",
|
// _token,
|
||||||
_profileName,
|
// _org,
|
||||||
profileName,
|
// _bucket,
|
||||||
missionName, worldName, serverName
|
_profileName,
|
||||||
],
|
_locality,
|
||||||
format["%1,%2,%3,%4,%5",
|
missionName,
|
||||||
_profileName,
|
worldName,
|
||||||
"global",
|
serverName,
|
||||||
missionName, worldName, serverName
|
_metric,
|
||||||
]
|
_valueType,
|
||||||
] select _global;
|
_value
|
||||||
|
];
|
||||||
// InfluDB settings
|
|
||||||
private _connection = "http://INFLUX_URL:8086";
|
|
||||||
private _token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX_AUTH_TOKEN_XXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
|
||||||
private _org = "XXX_INFLUX_ORG_XXXXXX";
|
|
||||||
private _bucket = "XXX_BUCKET_NAME";
|
|
||||||
|
|
||||||
private _extSend = format["%1,%2", format["%1,%2,%3,%4,%5,%6", _connection, _token, _org, _bucket, _metricPath, _metric], _value];
|
|
||||||
|
|
||||||
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
|
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
|
||||||
[format ["Sending a3influx data: %1", _extSend], "DEBUG"] call RangerMetrics_fnc_log;
|
[format ["Sending a3influx data: %1", _extSend], "DEBUG"] call RangerMetrics_fnc_log;
|
||||||
};
|
};
|
||||||
|
|
||||||
// send the data
|
// send the data
|
||||||
private _return = "RangerMetrics" callExtension _extSend;
|
private _return = "RangerMetrics" callExtension ["sendToInflux", _extSend];
|
||||||
|
|
||||||
// shouldn't be possible, the extension should always return even if error
|
// shouldn't be possible, the extension should always return even if error
|
||||||
if(isNil "_return") exitWith {
|
if(isNil "_return") exitWith {
|
||||||
@@ -41,14 +40,15 @@ if(isNil "_return") exitWith {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// extension error codes
|
// extension error codes
|
||||||
if(_return in ["invalid metric value","malformed, could not find separator"] ) exitWith {
|
// if(_return in ["invalid metric value","malformed, could not find separator"] ) exitWith {
|
||||||
[format ["%1 (%2)", _return, _extSend], "ERROR"] call RangerMetrics_fnc_log;
|
// [format ["%1 (%2)", _return, _extSend], "ERROR"] call RangerMetrics_fnc_log;
|
||||||
false
|
// false
|
||||||
};
|
// };
|
||||||
|
|
||||||
// success, only show if debug is set
|
// success, only show if debug is set
|
||||||
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
|
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
|
||||||
_returnArgs = _return splitString (toString [10,32]);
|
// _returnArgs = _return splitString (toString [10,32]);
|
||||||
|
_returnArgs = parseSimpleArray _return;
|
||||||
[format ["a3influx return data: %1",_returnArgs], "DEBUG"] call RangerMetrics_fnc_log;
|
[format ["a3influx return data: %1",_returnArgs], "DEBUG"] call RangerMetrics_fnc_log;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user