way too many changes to list, i have commit-ment issues <>

This commit is contained in:
2023-04-12 22:45:37 -07:00
parent 12ef61e067
commit 67541f46f9
56 changed files with 1091 additions and 1506 deletions

View File

@@ -15,11 +15,13 @@ class CfgFunctions {
file = "\RangerMetrics\functions\capture\EHOnly";
class ace_unconscious {};
class EntityKilled {};
class Explosion {};
class FiredMan {};
class HandleChatMessage {};
class MarkerCreated {};
class MarkerDeleted {};
class MarkerUpdated {};
class milsim_serverEfficiency {};
};
}
class RangerMetrics_cDefinitions {
@@ -30,6 +32,7 @@ class CfgFunctions {
class client_poll {};
// class clientEvent {};
class server_CBA {};
class unit_handlers {};
};
};
class RangerMetrics_capture {
@@ -63,7 +66,6 @@ class CfgFunctions {
class sendClientPoll {};
class startServerPoll {};
class classHandlers {};
class initUnit {};
};
class helpers {
file = "\RangerMetrics\functions\helpers";

View File

@@ -1,6 +1,8 @@
if (!RangerMetrics_run) exitWith {};
params ["_killed", "_killer", "_instigator"];
if (!isPlayer _killed) exitWith {}; // only track player deaths
// check in case ACE is active and lastDamageSource has been broadcast via addLocalSoldierEH
_instigator = _unit getVariable [
"ace_medical_lastDamageSource",
@@ -13,7 +15,7 @@ if (isNull _instigator) then { _instigator = _killer }; // player driven vehicle
if (isNull _instigator) then { _instigator = _killed };
// hint format ["Killed By %1", name _instigator];
if (!isPlayer _killed && !isPlayer _instigator) exitWith {}; // only track player kills
private _tags = [];
private _fields = [];
@@ -37,5 +39,5 @@ if (name _killed != "") then {
"EntityKilled",
_tags,
_fields,
nil
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -0,0 +1,33 @@
params ["_vehicle", "_damage", "_source"];
if (isNull _vehicle) exitWith {};
private _sourceClass = "";
private _sourceDisplayName = "";
private _sourcePlayerUID = "";
if !(isNull _source) then {
private _sourceClass = typeOf _source;
private _sourceDisplayName = [configOf _source] call BIS_fnc_displayName;
if (isPlayer _source) then {
private _sourcePlayerId = getPlayerId _source;
private _sourceUserInfo = getUserInfo _sourcePlayerId;
private _sourcePlayerUID = _sourceUserInfo select 2;
} else {
private _sourcePlayerUID = "";
};
};
private _unitPlayerId = getPlayerId _vehicle;
private _userInfo = getUserInfo _unitPlayerId;
private _unitPlayerUID = _userInfo select 2;
[
"player_events",
"Explosion",
[["string", "playerUID", _unitPlayerUID]],
[
["string", "sourceClass", _sourceClass],
["string", "sourceDisplayName", _sourceDisplayName],
["string", "sourcePlayerUID", _sourcePlayerUID],
["float", "damage", _damage]
],
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -1,4 +1,9 @@
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
params [
["_unit", objNull],
"_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"
];
if (isNull _unit) exitWith {};
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
@@ -17,5 +22,6 @@ private _userInfo = getUserInfo _unitPlayerId;
// ["object", "projectile", _projectile],
["string", "vehicle", [configOf _vehicle] call displayName],
["string", "vehicleClass", typeOf _vehicle]
]
],
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -2,6 +2,8 @@ if (!RangerMetrics_run) exitWith {};
params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"];
// if (!_isPlayerMessage) exitWith {};
private _fields = [
["int", "channel", _channel],
["int", "owner", _owner],
@@ -17,24 +19,22 @@ private _fields = [
];
// we need special processing to ensure the object is valid and we have a playerUid. Line protocol doesn't support empty string
private "_playerUid";
if (isNil "_person") then {
_playerUid = "";
private "_playerUID";
if (parseNumber _strID > 1) then {
_playerUID = (getUserInfo _strID)#2;
} else {
if !(objNull isEqualType _person) then {
_playerUid = getPlayerUID _person;
} else {
_playerUid = "";
};
_playerUID = "";
};
if (_playerUid isNotEqualTo "") then {
_fields pushBack ["string", "playerUid", _playerUid];
if (_playerUID isNotEqualTo "") then {
_fields pushBack ["string", "playerUID", _playerUid];
};
[
"server_events",
"HandleChatMessage",
nil,
_fields
_fields,
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -9,12 +9,11 @@ if (_owner isEqualTo "") exitWith {};
// Get marker
private _markerData = _marker call BIS_fnc_markerToString;
if (_markerData isEqualTo "") exitWith {};
// Get owner playerUID
private _ownerUID = getPlayerUID _owner;
if (_ownerUID isEqualTo "") then {
_ownerUID = "-1";
};
if (_ownerUID isEqualTo "") exitWith {};
[
"server_events",
@@ -26,5 +25,6 @@ if (_ownerUID isEqualTo "") then {
["string", "marker", _markerData],
["number", "channelNumber", _channelNumber],
["string", "owner", _ownerUID]
]
],
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -26,5 +26,6 @@ if (_ownerUID isEqualTo "") then {
["string", "marker", _markerData],
["number", "channelNumber", _channelNumber],
["string", "owner", _ownerUID]
]
],
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -1,31 +1,20 @@
if (!RangerMetrics_run) exitWith {};
params ["_marker", "_channelNumber", "_owner", "_local"];
params ["_marker", "_local"];
// Log marker
if (_marker isEqualTo "") exitWith {};
if (_channelNumber isEqualTo "") exitWith {};
if (_owner isEqualTo "") exitWith {};
// Get marker
private _markerData = _marker call BIS_fnc_markerToString;
// Get owner playerUID
private _ownerUID = getPlayerUID _owner;
if (_ownerUID isEqualTo "") then {
_ownerUID = "-1";
};
[
"server_events",
"MarkerUpdated",
nil,
[
["string", "actorPlayerUID", _ownerUID]
["string", "marker", _markerData]
],
[
["string", "marker", _markerData],
["number", "channelNumber", _channelNumber],
["string", "owner", _ownerUID]
]
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -2,10 +2,10 @@ if (!RangerMetrics_run) exitWith {};
params [["_unit", objNull], "_unconscious"];
if (isNull _unit) exitWith {};
if (!isPlayer _unit) exitWith {};
// Get owner playerUID
private _unitUID = getPlayerUID _unitUID;
if (_unitUID isEqualTo "") exitWith {};
if (_unitUID isEqualTo "") exitWith {false};
[
"player_state",
@@ -14,7 +14,9 @@ if (_unitUID isEqualTo "") exitWith {};
["string", "playerUID", _unitUID]
],
[
["int", "health", damage _unit],
["float", "health", 1 - (damage _unit)],
["bool", "state", _unconscious]
]
] call RangerMetrics_fnc_queue;
] call RangerMetrics_fnc_queue;
true;

View File

@@ -0,0 +1,15 @@
params ["_fields", []];
// Example:
// [
// ["float", "milsim_raw_cps", "3207.98"],
// ["float", "milsim_cps", "1"]
// ]
[
"server_state",
"server_efficiency",
nil,
_fields,
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -1,40 +0,0 @@
params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"];
private _fields = [
["int", "channel", _channel],
["int", "owner", _owner],
["string", "from", _from],
["string", "text", _text],
// ["object", "person", _person],
["string", "name", _name],
["string", "strID", _strID],
["bool", "forcedDisplay", _forcedDisplay],
["bool", "isPlayerMessage", _isPlayerMessage],
["int", "sentenceType", _sentenceType],
["int", "chatMessageType", _chatMessageType]
];
// we need special processing to ensure the object is valid and we have a playerUid. Line protocol doesn't support empty string
private "_playerUid";
if (isNil "_person") then {
_playerUid = "";
} else {
if !(objNull isEqualType _person) then {
_playerUid = getPlayerUID _person;
} else {
_playerUid = "";
};
};
if (_playerUid isNotEqualTo "") then {
_fields pushBack ["string", "playerUid", _playerUid];
};
[
"server_events",
"HandleChatMessage",
nil,
_fields
] call RangerMetrics_fnc_queue;

View File

@@ -1,7 +0,0 @@
// Number of global units
["server_state", "entities_global", nil, [
["int", "units_alive", count allUnits ],
["int", "units_dead", count allDeadMen],
["int", "groups_total", count allGroups],
["int", "vehicles_total", count vehicles]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,7 +0,0 @@
// Number of local units
["server_state", "entities_local", nil, [
["int", "units_alive", { local _x} count allUnits ],
["int", "units_dead", { local _x } count allDeadMen],
["int", "groups_total", { local _x } count allGroups],
["int", "vehicles_total", { local _x } count vehicles]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,25 +1,100 @@
if (!RangerMetrics_run) exitWith {};
// Number of remote units
["server_state", "entities_remote", nil, [
["int", "units_alive", { not (local _x)} count allUnits ],
["int", "units_dead", { not (local _x) } count allDeadMen],
["int", "groups_total", { not (local _x) } count allGroups],
["int", "vehicles_total", { not (local _x) } count vehicles]
]] call RangerMetrics_fnc_queue;
private _allUnits = allUnits;
private _allDeadMen = allDeadMen;
private _allGroups = allGroups;
private _vehicles = vehicles;
private _allPlayers = call BIS_fnc_listPlayers;
{
private _thisSide = _x;
private _thisSideStr = _thisSide call BIS_fnc_sideNameUnlocalized;
// Number of remote units
["server_state", "entities_remote", [
["string", "side", _thisSideStr]
], [
["int", "units_alive", {
side _x isEqualTo _thisSide &&
not (local _x)
} count _allUnits],
["int", "units_dead", {
side _x isEqualTo _thisSide &&
not (local _x)
} count _allDeadMen],
["int", "groups_total", {
side _x isEqualTo _thisSide &&
not (local _x)
} count _allGroups],
["int", "vehicles_total", {
side _x isEqualTo _thisSide &&
not (local _x) &&
!(_x isKindOf "WeaponHolderSimulated")
} count _vehicles],
["int", "vehicles_weaponholder", {
side _x isEqualTo _thisSide &&
not (local _x) &&
(_x isKindOf "WeaponHolderSimulated")
} count _vehicles]
]] call RangerMetrics_fnc_queue;
// Number of local units
["server_state", "entities_local", nil, [
["int", "units_alive", { local _x} count allUnits ],
["int", "units_dead", { local _x } count allDeadMen],
["int", "groups_total", { local _x } count allGroups],
["int", "vehicles_total", { local _x } count vehicles]
]] call RangerMetrics_fnc_queue;
// Number of local units
["server_state", "entities_local", [
["string", "side", _thisSideStr]
], [
["int", "units_alive", {
side _x isEqualTo _thisSide &&
local _x
} count _allUnits],
["int", "units_dead", {
side _x isEqualTo _thisSide &&
local _x
} count _allDeadMen],
["int", "groups_total", {
side _x isEqualTo _thisSide &&
local _x
} count _allGroups],
["int", "vehicles_total", {
side _x isEqualTo _thisSide &&
local _x &&
!(_x isKindOf "WeaponHolderSimulated")
} count _vehicles],
["int", "vehicles_weaponholder", {
side _x isEqualTo _thisSide &&
local _x &&
(_x isKindOf "WeaponHolderSimulated")
} count _vehicles]
]] call RangerMetrics_fnc_queue;
// Number of global units
["server_state", "entities_global", nil, [
["int", "units_alive", count allUnits ],
["int", "units_dead", count allDeadMen],
["int", "groups_total", count allGroups],
["int", "vehicles_total", count vehicles]
]] call RangerMetrics_fnc_queue;
// Number of global units - only track on server
if (isServer) then {
["server_state", "entities_global", [
["string", "side", _thisSideStr]
], [
["int", "units_alive", {
side _x isEqualTo _thisSide
} count _allUnits],
["int", "units_dead", {
side _x isEqualTo _thisSide
} count _allDeadMen],
["int", "groups_total", {
side _x isEqualTo _thisSide
} count _allGroups],
["int", "vehicles_total", {
side _x isEqualTo _thisSide &&
!(_x isKindOf "WeaponHolderSimulated")
} count _vehicles],
["int", "vehicles_weaponholder", {
side _x isEqualTo _thisSide &&
(_x isKindOf "WeaponHolderSimulated")
} count _vehicles],
["int", "players_alive", {
side _x isEqualTo _thisSide &&
alive _x
} count _allPlayers],
["int", "players_dead", {
side _x isEqualTo _thisSide &&
!alive _x
} count _allPlayers]
]] call RangerMetrics_fnc_queue;
};
} forEach [east, west, independent, civilian];

View File

@@ -14,12 +14,18 @@ private _fields = [
["bool", "isJip", _jip]
];
// Role description
private _roleDescription = roleDescription _unit;
if (_roleDescription isNotEqualTo "") then {
_fields pushBack ["string", "roleDescription", _roleDescription];
};
[
"player_state",
"player_identity",
[
["string", "playerUID", getPlayerUID player]
["string", "playerUID", _playerUID]
],
_fields,
nil
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -1,44 +0,0 @@
// loadout data, captured clientside
if (isNull player) exitWith {};
params ["_handleName"];
private _lastLoadout = player getVariable "RangerMetrics_myLoadout";
if (isNil "_lastLoadout") then {
_lastLoadout = [];
};
private _currentLoadout = [
["string", "currentWeapon", currentWeapon player],
["string", "uniform", uniform player],
["string", "vest", vest player],
["string", "backpack", backpack player],
["string", "headgear", headgear player],
["string", "goggles", goggles player],
["string", "hmd", hmd player],
["string", "primaryWeapon", primaryWeapon player],
["string", "primaryWeaponMagazine", primaryWeaponMagazine player],
["string", "secondaryWeapon", secondaryWeapon player],
["string", "secondaryWeaponMagazine", secondaryWeaponMagazine player],
["string", "handgunWeapon", handgunWeapon player],
["string", "handgunMagazine", handgunMagazine player]
];
// exit if loadout hasn't changed
if (_lastLoadout isEqualTo _currentLoadout) exitWith {};
// continue if loadout has changed
// store loadout data locally
player setVariable ["RangerMetrics_myLoadout", _currentLoadout];
// send loadout data to server
[
"player_state", // bucket to store the data
"player_loadout", // measurement classifier inside of bucket
[ // tags
["string", "playerUID", getPlayerUID player]
],
_currentLoadout, // fields
nil
] remoteExec ["RangerMetrics_fnc_queue", 2];

View File

@@ -7,7 +7,8 @@ params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "
[["string", "playerUID", _playerUID]],
[
["int", "clientStateNumber", _clientState],
["int", "adminState", _adminState]
["int", "adminState", _adminState],
["string", "profileName", _profileName]
],
nil
["server"]
] call RangerMetrics_fnc_queue;

View File

@@ -1,6 +1,6 @@
if (!RangerMetrics_run) exitWith {};
["server_state", "server_performance", nil, [
["float", "avg", diag_fps toFixed 2],
["float", "min", diag_fpsMin toFixed 2]
["float", "fps_avg", diag_fps toFixed 2],
["float", "fps_min", diag_fpsMin toFixed 2]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,48 +1,201 @@
if (!RangerMetrics_run) exitWith {};
params [
["_unit", objNull, [objNull]]
];
if (isNull _unit) exitWith {};
if (isNull _unit) exitWith {false};
// if (!isPlayer _unit) exitWith {};
private _lastLoadout = _unit getVariable "RangerMetrics_myLoadout";
// do not check more than once every 15 seconds
_checkDelay = 15;
_lastCheck = _unit getVariable [
"RangerMetrics_lastInventoryCheck",
0
];
if (
(_lastCheck + _checkDelay) > diag_tickTime
) exitWith {false};
_unit setVariable ["RangerMetrics_lastInventoryCheck", diag_tickTime];
private _lastLoadout = _unit getVariable "RangerMetrics_unitLoadout";
if (isNil "_lastLoadout") then {
_lastLoadout = [];
};
};
private _currentLoadout = [
["string", "currentWeapon", currentWeapon _unit],
["string", "uniform", uniform _unit],
["string", "vest", vest _unit],
["string", "backpack", backpack _unit],
["string", "headgear", headgear _unit],
["string", "goggles", goggles _unit],
["string", "hmd", hmd _unit],
["string", "primaryWeapon", primaryWeapon _unit],
["string", "primaryWeaponMagazine", primaryWeaponMagazine _unit],
["string", "secondaryWeapon", secondaryWeapon _unit],
["string", "secondaryWeaponMagazine", secondaryWeaponMagazine _unit],
["string", "handgunWeapon", handgunWeapon _unit],
["string", "handgunMagazine", handgunMagazine _unit]
];
private _uniqueUnitItems = uniqueUnitItems [_unit, 2, 2, 2, 2, true];
// if (_lastLoadout isEqualTo _uniqueUnitItems) exitWith {false};
// _unit setVariable ["RangerMetrics_unitLoadout", _uniqueUnitItems];
private _uniqueUnitItems = _uniqueUnitItems toArray false;
_classItemCounts = [];
{
_x params ["_item", "_count"];
if (_item isEqualTo "") exitWith {};
_classItemCounts pushBack ["int", _item, _count];
} forEach _uniqueUnitItems;
_playerUID = getPlayerUID _unit;
_unitId = _unit getVariable ["RangerMetrics_Id", -1];
if (_unitId isEqualTo -1) exitWith {false};
// this section uses uniqueUnitItems to get a list of all items and their counts
[
"player_state",
"unit_loadout",
[
["string", "playerUID", _playerUID],
["string", "unitId", str _unitId],
["string", "format", "className"]
],
_classItemCounts,
["server"]
] call RangerMetrics_fnc_queue;
// prep displayName by fetching from configs
_displayItemCounts = [];
{
_x params ["_valueType", "_item", "_count"];
// exit if loadout hasn't changed
if (_lastLoadout isEqualTo _currentLoadout) exitWith {};
// from CBA_fnc_getItemConfig, author: commy2
private "_itemConfig";
{
private _config = configFile >> _x >> _item;
// continue if loadout has changed
if (isClass _config) exitWith {
_itemConfig = _config;
};
} forEach ["CfgWeapons", "CfgMagazines", "CfgGlasses"];
// store loadout data locally
_unit setVariable ["RangerMetrics_myLoadout", _currentLoadout];
if (isNil "_itemConfig") then {
private _config = configFile >> "CfgVehicles" >> _item;
_playerUID = getPlayerUID _unit;
if (getNumber (_config >> "isBackpack") isEqualTo 1) then {
_itemConfig = _config;
};
};
_itemDisplayName = getText(_itemConfig >> "displayName");
_displayItemCounts pushBack ["int", _itemDisplayName, _count];
} forEach _classItemCounts;
[
"player_state",
"unit_loadout",
[
["string", "playerUID", _playerUID],
["string", "unitId", str _unitId],
["string", "format", "displayName"]
],
_displayItemCounts,
["server"]
] call RangerMetrics_fnc_queue;
true;
// get current loadout
// ! this section breaks everything down individually, see above for uniqueUnitItems implementation
// private _primaryWeapon = primaryWeapon _unit;
// (primaryWeaponItems _unit) params [
// "_primaryWeaponSilencer",
// "_primaryWeaponLaser",
// "_primaryWeaponOptics",
// "_primaryWeaponBipod"
// ];
// _primaryWeapon = [
// ["string", "weapon", _primaryWeapon],
// ["string", "silencer", _primaryWeaponSilencer],
// ["string", "laser", _primaryWeaponLaser],
// ["string", "optic", _primaryWeaponOptics],
// ["string", "bipod", _primaryWeaponBipod]
// ];
// private _secondaryWeapon = secondaryWeapon _unit;
// (secondaryWeaponItems _unit) params [
// "_secondaryWeaponSilencer",
// "_secondaryWeaponLaser",
// "_secondaryWeaponOptics",
// "_secondaryWeaponBipod"
// ];
// _secondaryWeapon = [
// ["string", "weapon", _secondaryWeapon],
// ["string", "silencer", _secondaryWeaponSilencer],
// ["string", "laser", _secondaryWeaponLaser],
// ["string", "optic", _secondaryWeaponOptics],
// ["string", "bipod", _secondaryWeaponBipod]
// ];
// private _handgun = handgunWeapon _unit;
// (handgunItems _unit) params [
// "_handgunSilencer",
// "_handgunLaser",
// "_handgunOptics",
// "_handgunBipod"
// ];
// _handgun = [
// ["string", "weapon", _handgun],
// ["string", "silencer", _handgunSilencer],
// ["string", "laser", _handgunLaser],
// ["string", "optic", _handgunOptics],
// ["string", "bipod", _handgunBipod]
// ];
// private _magazinesFields = [];
// private _magazines = (magazines _unit) call BIS_fnc_consolidateArray;
// _magazines = _magazines apply {
// _x params ["_magazine", "_count"];
// _magazinesFields pushBack ["int", _magazine, _count];
// _magazinesFields pushBack ["int", getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), _count];
// };
// private _itemsFields = [];
// private _items = (items _unit) call BIS_fnc_consolidateArray;
// _items = _items apply {
// _x params ["_item", "_count"];
// _itemsFields pushBack ["int", _item, _count];
// _itemsFields pushBack ["int", getText(configFile >> "CfgWeapons" >> _item >> "displayName"), _count];
// };
// private _slotItems = [
// ["string", "goggles", goggles _unit],
// ["string", "gogglesClass", getText(configFile >> "CfgWeapons" >> (goggles _unit) >> "displayName")],
// ["string", "headgear", headgear _unit],
// ["string", "headgearClass", getText(configFile >> "CfgWeapons" >> (headgear _unit) >> "displayName")],
// ["string", "binocular", binocular _unit],
// ["string", "binocularClass", getText(configFile >> "CfgWeapons" >> (binocular _unit) >> "displayName")],
// ["string", "uniform", uniform _unit],
// ["string", "uniformClass", getText(configFile >> "CfgWeapons" >> (uniform _unit) >> "displayName")],
// ["string", "vest", vest _unit],
// ["string", "vestClass", getText(configFile >> "CfgWeapons" >> (vest _unit) >> "displayName")],
// ["string", "backpack", backpack _unit],
// ["string", "backpackClass", getText(configFile >> "CfgWeapons" >> (backpack _unit) >> "displayName")]
// ];
// send loadout data
[
"player_state",
"unit_loadout",
[
["string", "playerUID", _playerUID]
],
_currentLoadout,
["server"]
] call RangerMetrics_fnc_queue;
// {
// [
// "player_state",
// "unit_loadout",
// [
// ["string", "playerUID", _playerUID]
// ],
// _x,
// ["server"]
// ] call RangerMetrics_fnc_queue;
// } forEach [
// _primaryWeapon,
// _secondaryWeapon,
// _handgun,
// _magazinesFields,
// _itemsFields,
// _slotItems
// ];
// true;

View File

@@ -1,10 +1,24 @@
if (!RangerMetrics_run) exitWith {};
params ["_unit"];
params [[
"_unit", objNull, [objNull]
]];
if (isNull _unit || !(isPlayer _unit)) exitWith {};
// Used in Dammaged EH, so add a 1s delay to prevent spamming
_checkDelay = 1;
_lastCheck = _unit getVariable [
"RangerMetrics_lastUnitStateCheck",
diag_tickTime
];
if (
(_lastCheck + _checkDelay) > diag_tickTime
) exitWith {};
_unit setVariable ["RangerMetrics_lastUnitStateCheck", diag_tickTime];
// Get owner playerUID
private _unitUID = getPlayerUID _unitUID;
private _unitUID = getPlayerUID _unit;
if (_unitUID isEqualTo "") exitWith {};
// Medical info
@@ -18,7 +32,8 @@ if (RangerMetrics_aceMedicalPresent) then {
};
// Vehicle info
if (!isNull (objectParent _unit)) then {
private _inVehicle = !isNull (objectParent _unit);
if (_inVehicle) then {
_crew = fullCrew (objectParent _unit);
_pos = _crew find {(_x select 0) isEqualTo _unit};
_vehicleRole = toLower _crew select _pos select 1;
@@ -32,19 +47,13 @@ private _fields = [
["bool", "is_unconscious", _isUnconscious],
["bool", "is_cardiac_arrest", _isInCardiacArrest],
["bool", "is_captive", captive _unit],
["bool", "in_vehicle", !isNull (objectParent _unit)],
["bool", "in_vehicle", _inVehicle],
["string", "vehicle_role", _vehicleRole],
["float", "speed_kmh", speed _unit]
];
// Role description
private _roleDescription = roleDescription _unit;
if (_roleDescription isNotEqualTo "") then {
_fields pushBack ["string", "roleDescription", _roleDescription];
};
// Traits
private _playerTraits = getAllUnitTraits player;
private _playerTraits = getAllUnitTraits _unit;
{
private _valueType = typeNAME (_x select 1);
switch (_valueType) do {

View File

@@ -1,3 +1,5 @@
if (!RangerMetrics_run) exitWith {};
[
"server_state",
"view_distance",

View File

@@ -1,5 +1,4 @@
[
["ace_unconscious", {
call RangerMetrics_event_fnc_aceUnconscious
}]
["ace_unconscious", RangerMetrics_event_fnc_ace_unconscious],
["milsim_serverEfficiency", RangerMetrics_event_fnc_milsim_serverEfficiency]
]

View File

@@ -4,13 +4,14 @@
private _userInfo = (getUserInfo _networkId);
_userInfo call RangerMetrics_capture_fnc_player_identity;
_userInfo call RangerMetrics_capture_fnc_player_status;
["server_events", "UserConnected", [
["server_events", "OnUserConnected", [
["string", "playerUID", _userInfo#2]
], [
["string", "networkId", _networkId],
["int", "clientStateNumber", _clientStateNumber],
["string", "clientState", _clientState]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) OnUserConnected fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["OnUserDisconnected", {
params ["_networkId", "_clientStateNumber", "_clientState"];
@@ -24,12 +25,14 @@
["int", "clientStateNumber", _clientStateNumber],
["string", "clientState", _clientState]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) OnUserDisconnected fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
private _userInfo = (getUserInfo _networkId);
_userInfo call RangerMetrics_capture_fnc_player_identity;
_userInfo call RangerMetrics_capture_fnc_player_status;
[_entity] call RangerMetrics_capture_fnc_unit_inventory;
["server_events", "PlayerConnected", [
["string", "playerUID", _userInfo#2]
], [
@@ -40,6 +43,7 @@
["int", "owner", _owner],
["string", "idstr", _idstr]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) PlayerConnected fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["PlayerDisconnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
@@ -56,6 +60,7 @@
["int", "owner", _owner],
["string", "idstr", _idstr]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) PlayerDisconnected fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["OnUserClientStateChanged", {
params ["_networkId", "_clientStateNumber", "_clientState"];
@@ -68,6 +73,7 @@
["int", "clientStateNumber", _clientStateNumber],
["string", "clientState", _clientState]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) OnUserClientStateChanged fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["OnUserAdminStateChanged", {
params ["_networkId", "_loggedIn", "_votedIn"];
@@ -80,6 +86,7 @@
["bool", "loggedIn", _loggedIn],
["bool", "votedIn", _votedIn]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) OnUserAdminStateChanged fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["OnUserKicked", {
params ["_networkId", "_kickTypeNumber", "_kickType", "_kickReason", "_kickMessageIncReason"];
@@ -95,6 +102,7 @@
["string", "kickReason", _kickReason],
["string", "kickMessageIncReason", _kickMessageIncReason]
]] call RangerMetrics_fnc_queue;
[format ["(EventHandler) OnUserKicked fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["HandleChatMessage", {
_this call RangerMetrics_event_fnc_HandleChatMessage;
@@ -110,34 +118,63 @@
["string", "reason", _reason]
]] call RangerMetrics_fnc_queue;
call RangerMetrics_capture_fnc_running_mission;
[format ["(EventHandler) MPEnded fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["EntityCreated", {
params ["_entity"];
if (
!(_entity isKindOf "AllVehicles")
) exitWith {};
call RangerMetrics_capture_fnc_entity_count;
[format["(EventHandler) EntityCreated fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["EntityKilled", {
params ["_entity"];
if (
!(_entity isKindOf "AllVehicles")
) exitWith {};
_this call RangerMetrics_event_fnc_EntityKilled;
call RangerMetrics_capture_fnc_entity_count;
[_entity] call RangerMetrics_capture_fnc_unit_inventory;
[_entity] call RangerMetrics_capture_fnc_unit_state;
[format["(EventHandler) EntityKilled fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["EntityRespawned", {
params ["_newEntity", "_oldEntity"];
call RangerMetrics_capture_fnc_entity_count;
[_entity] call RangerMetrics_capture_fnc_unit_inventory;
[_entity] call RangerMetrics_capture_fnc_unit_state;
[format["(EventHandler) EntityRespawned fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["GroupCreated", {
params ["_group"];
call RangerMetrics_capture_fnc_entity_count;
[format["(EventHandler) GroupCreated fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["GroupDeleted", {
params ["_group"];
call RangerMetrics_capture_fnc_entity_count;
[format["(EventHandler) GroupDeleted fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["MarkerCreated", {
params ["_marker", "_channelNumber", "_owner", "_local"];
if (markerType _marker isEqualTo "") exitWith {};
_this call RangerMetrics_event_fnc_MarkerCreated;
[format["(EventHandler) MarkerCreated fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["MarkerDeleted", {
params ["_marker", "_channelNumber", "_owner", "_local"];
if (markerType _marker isEqualTo "") exitWith {};
_this call RangerMetrics_event_fnc_MarkerDeleted;
[format["(EventHandler) MarkerDeleted fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}],
["MarkerUpdated", {
params ["_marker", "_channelNumber", "_owner", "_local"];
_this call RangerMetrics_event_fnc_MarkerUpdated;
}],
// ["MarkerUpdated", {
// params ["_marker", "_local"];
// if (markerType _marker isEqualTo "") exitWith {};
// _this call RangerMetrics_event_fnc_MarkerUpdated;
// }],
["Service", {
params ["_serviceVehicle", "_servicedVehicle", "_serviceType", "_needsService", "_autoSupply"];
[
@@ -152,5 +189,6 @@
],
nil
] call RangerMetrics_fnc_queue;
[format["(EventHandler) Service fired: %1", _this], "DEBUG"] call RangerMetrics_fnc_log;
}]
]

View File

@@ -2,19 +2,66 @@
[
1, // interval
[ // functions to run
RangerMetrics_capture_fnc_server_performance,
RangerMetrics_capture_fnc_running_scripts,
RangerMetrics_capture_fnc_server_time,
RangerMetrics_capture_fnc_entity_count,
RangerMetrics_capture_fnc_player_performance
[
["server", "hc"],
RangerMetrics_capture_fnc_server_performance
]
]
],
[
60,
3,
[
RangerMetrics_capture_fnc_weather,
RangerMetrics_capture_fnc_view_distance,
RangerMetrics_capture_fnc_running_mission
[
["server", "hc"],
RangerMetrics_capture_fnc_running_scripts
],
[
["server", "hc"],
RangerMetrics_capture_fnc_player_performance
]
]
],
[
15,
[
[
["server", "hc"],
RangerMetrics_capture_fnc_server_time
],
[
["hc"],
RangerMetrics_capture_fnc_entity_count
]
]
],
[
120,
[
[
["server"],
{
{
[_x] call RangerMetrics_capture_fnc_unit_inventory;
} count (call BIS_fnc_listPlayers);
}
]
]
],
[
300,
[
[
["server"],
RangerMetrics_capture_fnc_weather
],
[
["server"],
RangerMetrics_capture_fnc_view_distance
],
[
["server"],
RangerMetrics_capture_fnc_running_mission
]
]
]
]

View File

@@ -0,0 +1,205 @@
params [
["_unit", objNull, [objNull]]
];
if (isNull _unit) exitWith {};
if (!isPlayer _unit) exitWith {};
// if ACE medical is running, remoteExec a Dammaged EH for the player's machine to send lastDamageSource from ACE to the server. this is used for EntityKilled EH and others.
if (RangerMetrics_aceMedicalPresent) then {
[_unit, {
params ["_unit"];
private _handle = _unit addEventHandler ["Dammaged", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _aceLastDamage = _unit getVariable "ace_medical_lastDamageSource";
if (!isNil "_aceLastDamage") then {
_unit setVariable ["ace_medical_lastDamageSource", _aceLastDamage, 2];
};
}];
_unit setVariable [
"RangerMetrics_UNITEH_Dammaged",
_handle
];
}] remoteExec ["call", owner _unit];
};
// explosion damage handler
[_unit, {
params ["_unit"];
private _handle = _unit addEventHandler ["Explosion", {
// params ["_vehicle", "_damage", "_source"];
_this remoteExec [
"RangerMetrics_event_fnc_Explosion", 2
];
}];
_unit setVariable [
"RangerMetrics_UNITEH_Explosion",
_handle
];
}] remoteExec ["call", 0, _unit];
// TODO
// server HitPart EH
// https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HitPart
// _handle = _unit addEventHandler ["HitPart", {
// (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
// private _unitPlayerId = getPlayerId _unit;
// private _userInfo = getUserInfo _unitPlayerId;
// // workaround from wiki to get shooter playerUID
// if (isNull _projectile) exitWith {};
// private _shooterPlayerId = (getPlayerId (getShotParents _projectile select 1));
// private _shooterInfo = getUserInfo _shooterPlayerId;
// [
// "player_events",
// "HandleDamage",
// [
// ["string", "playerUID", _userInfo select 2]
// ],
// [
// ["string", "selection", _selection],
// ["number", "damage", _damage],
// ["number", "hitIndex", _hitIndex],
// ["string", "hitPoint", _hitPoint],
// ["string", "shooter", _shooterInfo select 2],
// ["string", "projectile", _projectile]
// ],
// ["server"]
// ] call RangerMetrics_fnc_queue;
// [_unit] call RangerMetrics_capture_fnc_unit_state;
// }];
_handle = _unit addEventHandler [
"FiredMan", RangerMetrics_event_fnc_FiredMan
];
_unit setVariable [
"RangerMetrics_UNITEH_FiredMan",
_handle
];
_handle = _unit addEventHandler ["GetInMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
private _playerUID = "-1";
if (!isNil "_userInfo") then {
_playerUID = _userInfo select 2;
};
[
"player_events",
"GetInMan",
[
["string", "playerUID", _playerUID]
],
[
["string", "role", _role],
["string", "vehicle", _vehicle],
["string", "turret", _turret]
],
["server"]
] call RangerMetrics_fnc_queue;
[_unit] call RangerMetrics_capture_fnc_unit_state;
}];
_unit setVariable [
"RangerMetrics_UNITEH_GetInMan",
_handle
];
_handle = _unit addEventHandler ["GetOutMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
private _playerUID = "-1";
if (!isNil "_userInfo") then {
_playerUID = _userInfo select 2;
};
[
"player_events",
"GetOutMan",
[
["string", "playerUID", _playerUID]
],
[
["string", "role", _role],
["string", "vehicle", _vehicle],
["string", "turret", _turret]
],
["server"]
] call RangerMetrics_fnc_queue;
[_unit] call RangerMetrics_capture_fnc_unit_state;
}];
_unit setVariable [
"RangerMetrics_UNITEH_GetOutMan",
_handle
];
_handle = _unit addEventHandler ["HandleScore", {
params ["_unit", "_object", "_score"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
private _playerUID = "-1";
if (!isNil "_userInfo") then {
_playerUID = _userInfo select 2;
};
[
"player_events",
"HandleScore",
[
["string", "playerUID", _playerUID]
],
[
["int", "score", _score],
["string", "objectClass", typeOf _object],
["string", "object", [configOf _object] call BIS_fnc_displayName]
],
["server"]
] call RangerMetrics_fnc_queue;
nil;
}];
_unit setVariable [
"RangerMetrics_UNITEH_HandleScore",
_handle
];
_handle = _unit addEventHandler ["InventoryClosed", {
params ["_unit", "_container"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
private _playerUID = "-1";
if (!isNil "_userInfo") then {
_playerUID = _userInfo select 2;
};
[
"player_events",
"InventoryClosed",
[
["string", "playerUID", _playerUID]
],
[
["string", "container", _container]
],
["server"]
] call RangerMetrics_fnc_queue;
[_unit] call RangerMetrics_capture_fnc_unit_inventory;
nil;
}];
_unit setVariable [
"RangerMetrics_UNITEH_InventoryClosed",
_handle
];
true;

View File

@@ -1,23 +1,32 @@
if (!isServer) exitWith {};
if (!RangerMetrics_cbaPresent) exitWith {
[
format["RangerMetrics: CBA not present, aborting class EHs."],
"WARN"
] call RangerMetrics_fnc_log;
false;
// TODO: Add non-CBA compatibility for unit handler & id application
// addMissionEventHandler ["EntityCreated", {
};
///////////////////////////////////////////////////////////////////////
// Initialize all units
///////////////////////////////////////////////////////////////////////
["All", "InitPost", {
private _unit = _this # 0;
["Man", "InitPost", {
params ["_unit"];
[_unit] call RangerMetrics_cDefinitions_fnc_unit_handlers;
if (_unit isKindOf "CAManBase" && isPlayer _unit) then {
[_unit] call RangerMetrics_fnc_initUnit;
};
_unit setVariable [
"RangerMetrics_id",
RangerMetrics_nextID,
true
];
_unit setVariable ["RangerMetrics_id", RangerMetrics_nextID, true];
[_unit] call RangerMetrics_capture_fnc_unit_inventory;
[_unit] call RangerMetrics_capture_fnc_unit_state;
if (RangerMetrics_debug) then {
[

View File

@@ -1,129 +0,0 @@
params [
["_unit", objNull, [objNull]]
];
if (isNull _unit) exitWith {};
if (!isPlayer _unit) exitWith {};
[RangerMetrics_aceMedicalPresent, {
if (not _this) exitWith {};
player addEventHandler ["Dammaged", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _aceLastDamage = _unit getVariable "ace_medical_lastDamageSource";
if (!isNil "_aceLastDamage") then {
_unit setVariable ["ace_medical_lastDamageSource", _aceLastDamage, 2];
};
}];
}] remoteExec ["call", owner _unit, _unit];
_unit addEventHandler ["Dammaged", {
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
private _shooterPlayerId = (getPlayerId (getShotParents _projectile select 1));
private _shooterInfo = getUserInfo _shooterPlayerId;
[_unit] call RangerMetrics_capture_fnc_unit_state;
[
"player_events",
"Dammaged",
[
["string", "playerUID", _userInfo select 2]
],
[
["string", "selection", _selection],
["number", "damage", _damage],
["number", "hitIndex", _hitIndex],
["string", "hitPoint", _hitPoint],
["string", "shooter", _shooterInfo select 2],
["string", "projectile", _projectile]
],
["server"]
] call RangerMetrics_fnc_queue;
}];
_unit addEventHandler ["FiredMan", {
_this call RangerMetrics_event_fnc_FiredMan;
}];
_unit addEventHandler ["GetInMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
[
"player_events",
"GetInMan",
[
["string", "playerUID", _userInfo select 2]
],
[
["string", "role", _role],
["string", "vehicle", _vehicle],
["string", "turret", _turret]
],
["server"]
] call RangerMetrics_fnc_queue;
}];
_unit addEventHandler ["GetOutMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
[
"player_events",
"GetOutMan",
[
["string", "playerUID", _userInfo select 2]
],
[
["string", "role", _role],
["string", "vehicle", _vehicle],
["string", "turret", _turret]
],
["server"]
] call RangerMetrics_fnc_queue;
}];
_unit addEventHandler ["HandleScore", {
params ["_unit", "_object", "_score"];
private _unitPlayerId = getPlayerId _unit;
private _userInfo = getUserInfo _unitPlayerId;
[
"player_events",
"HandleScore",
[
["string", "playerUID", _userInfo select 2]
],
[
["int", "score", _score],
["string", "objectClass", typeOf _object],
["string", "object", [configOf _object] call BIS_fnc_displayName]
],
["server"]
] call RangerMetrics_fnc_queue;
nil;
}];
// _unit addEventHandler ["InventoryClosed", {
// params ["_unit", "_container"];
// private _unitPlayerId = getPlayerId _unit;
// private _userInfo = getUserInfo _unitPlayerId;
// [
// "player_events",
// "InventoryClosed",
// [
// ["string", "playerUID", _userInfo select 2]
// ],
// [
// ["string", "container", _container]
// ],
// ["server"]
// ] call RangerMetrics_fnc_queue;
// }];

View File

@@ -1,6 +1,7 @@
// if (!isServer) exitWith {};
if (is3DEN || !isMultiplayer) exitWith {};
if (!isServer && hasInterface) exitWith {};
RangerMetrics_cbaPresent = isClass(configFile >> "CfgPatches" >> "cba_main");
RangerMetrics_aceMedicalPresent = isClass(configFile >> "CfgPatches" >> "ace_medical_status");
@@ -10,6 +11,8 @@ RangerMetrics_initialized = false;
RangerMetrics_run = false;
RangerMetrics_nextID = 0;
RangerMetrics_messageQueue = createHashMap;
// for debug, view messages in queue
// RangerMetrics_messageQueue apply {[_x, count _y]};
RangerMetrics_sendBatchHandle = scriptNull;
[format ["Instance name: %1", profileName]] call RangerMetrics_fnc_log;
@@ -33,14 +36,13 @@ RangerMetrics_settings set [
"influxDB",
createHashMapFromArray [
["host", _settingsLoaded#1],
["org", _settingsLoaded#2],
["defaultBucket", _settingsLoaded#3]
["org", _settingsLoaded#2]
]
];
RangerMetrics_settings set [
"arma3",
createHashMapFromArray [
["refreshRateMs", _settingsLoaded#4]
["refreshRateMs", _settingsLoaded#3]
]
];
@@ -51,7 +53,9 @@ if (_dbConnection isEqualTo "") exitWith {
["Failed to connect to InfluxDB, disabling"] call RangerMetrics_fnc_log;
};
(parseSimpleArray _dbConnection) call RangerMetrics_fnc_log;
_response = parseSimpleArray _dbConnection;
(_response) call RangerMetrics_fnc_log;
systemChat str _response;
// send server profile name to all clients with JIP, so HC or player reporting knows what server it's connected to
if (isServer) then {
@@ -60,11 +64,6 @@ if (isServer) then {
};
addMissionEventHandler ["ExtensionCallback", {
_this call RangerMetrics_fnc_callbackHandler;
}];
// define the metrics to capture by sideloading definition files
// this keeps the main file clean and easy to read
// the definition files are in the format of a hashmap, where the key is the category and the value is an array of arrays, where each sub-array is a capture definition
@@ -93,14 +92,29 @@ RangerMetrics_captureDefinitions = createHashMapFromArray [
];
// add missionEventHandlers on server
// add missionEventHandlers on server only
{_x params ["_handleName", "_code"];
missionNamespace setVariable [
("RangerMetrics" + "_MEH_" + _handleName),
(addMissionEventHandler [_handleName, _code])
];
if (!isServer) exitWith {};
// try {
_handle = (addMissionEventHandler [_handleName, _code]);
// } catch {
// _handle = nil;
// };
if (isNil "_handle") then {
[format["Failed to add Mission event handler: %1", [_handleName]], "ERROR"] call RangerMetrics_fnc_log;
} else {
missionNamespace setVariable [
("RangerMetrics" + "_MEH_" + _handleName),
_handle
];
true;
};
} forEach ((RangerMetrics_captureDefinitions get "ServerEvent") get "MissionEventHandlers");
// begin server polling
{
_x call RangerMetrics_fnc_startServerPoll;
@@ -120,30 +134,65 @@ RangerMetrics_captureDefinitions = createHashMapFromArray [
// set up CBA event listeners
{_x params ["_handleName", "_code"];
missionNamespace setVariable [
("RangerMetrics" + "_CBAEH_" + _handleName),
([_handleName, _code] call CBA_fnc_addEventHandlerArgs)
];
private "_handle";
// try {
_handle = ([_handleName, _code] call CBA_fnc_addEventHandlerArgs);
// } catch {
// _handle = nil;
// };
if (isNil "_handle") then {
[format["Failed to add CBA event handler: %1", [_handleName, _code]], "ERROR"] call RangerMetrics_fnc_log;
} else {
missionNamespace setVariable [
("RangerMetrics" + "_CBAEH_" + _handleName),
_handle
];
true;
};
} forEach (RangerMetrics_captureDefinitions get "CBAEvent");
// set up CBA class inits if CBA loaded
call RangerMetrics_fnc_classHandlers;
[] spawn {
sleep 1;
isNil {
addMissionEventHandler [
"ExtensionCallback",
RangerMetrics_fnc_callbackHandler
];
RangerMetrics_initialized = true;
RangerMetrics_run = true;
["RangerMetrics_run", true] remoteExecCall ["setVariable", 0, true];
// set up CBA class inits if CBA loaded
call RangerMetrics_fnc_classHandlers;
private _meh = allVariables missionNamespace select {
_x find (toLower "RangerMetrics_MEH_") == 0
};
private _cba = allVariables missionNamespace select {
_x find (toLower "RangerMetrics_CBAEH_") == 0
};
private _serverPoll = allVariables missionNamespace select {
_x find (toLower "RangerMetrics_captureBatchHandle_") == 0
};
[format ["Mission event handlers: %1", _meh]] call RangerMetrics_fnc_log;
[format ["CBA event handlers: %1", _cba]] call RangerMetrics_fnc_log;
[format ["Server poll handles: %1", _serverPoll]] call RangerMetrics_fnc_log;
RangerMetrics_initialized = true;
RangerMetrics_run = true;
["RangerMetrics_run", true] remoteExecCall ["setVariable", 0];
// start sending
[{
params ["_args", "_idPFH"];
if (scriptDone RangerMetrics_sendBatchHandle) then {
RangerMetrics_sendBatchHandle = [] spawn RangerMetrics_fnc_send;
};
// call RangerMetrics_fnc_send;
}, 2, []] call CBA_fnc_addPerFrameHandler;
};
};
// start sending
[{
params ["_args", "_idPFH"];
// if (scriptDone RangerMetrics_sendBatchHandle) then {
// RangerMetrics_sendBatchHandle = [] spawn RangerMetrics_fnc_send;
// };
call RangerMetrics_fnc_send;
}, 3, []] call CBA_fnc_addPerFrameHandler;

View File

@@ -2,29 +2,37 @@
// duplicate the message queue so we can clear it before sending the data
private "_extSend";
isNil {
_extSend = + RangerMetrics_messageQueue;
RangerMetrics_messageQueue = createHashMap;
};
// isNil {
// _extSend = + RangerMetrics_messageQueue;
// RangerMetrics_messageQueue = createHashMap;
// };
// debug
if (
missionNamespace getVariable ["RangerMetrics_debug",false]
) then {
[format ["Sending a3influx data: %1", _extSend], "DEBUG"] call RangerMetrics_fnc_log;
["Sending a3influx data", "DEBUG"] call RangerMetrics_fnc_log;
};
{
private _bucket = _x;
private _records = _y;
// run in direct unscheduled call
// prevents race condition accessing hashmap
isNil {
private _bucket = _x;
private _batchSize = 2000;
while {count _records > 0} do {
// extension calls support a max of 2048 elements in the extension call
// so we need to split the data into chunks of 2000
private "_processing";
_processing = _records select [0, (count _records -1) min 750];
_records = _records select [750, count _records - 1];
// get the records for this bucket
private "_records";
private _records = RangerMetrics_messageQueue get _bucket;
// send the data in chunks
private _processing = _records select [0, (count _records -1) min _batchSize];
RangerMetrics_messageQueue set [
_bucket,
(RangerMetrics_messageQueue get _bucket) - _processing
];
// send the data
if (
@@ -36,7 +44,7 @@ if (
private _measurements = [];
{
_thisMeasurement = _x splitString "," select 0;
_measurements pushBack _thisMeasurement;
_measurements pushBackUnique _thisMeasurement;
} forEach _processing;
// get counts of each measurement
@@ -55,4 +63,4 @@ if (
"RangerMetrics" callExtension ["sendToInflux", flatten [_bucket, _processing]];
};
} forEach _extSend;
} forEach (keys RangerMetrics_messageQueue);

View File

@@ -1,6 +1,6 @@
// format [interval, [[handleName, code], [handleName, code], ...]]
[_this, {
if !(hasInterface || isDedicated) exitWith {};
if (!hasInterface || isDedicated) exitWith {};
params [
["_interval", 5, [5]],
["_pollItems", []]
@@ -13,12 +13,12 @@
private _runningCBA = (isClass(configFile >> "CfgPatches" >> "cba_main"));
if (_runningCBA) then {
localNamespace setVariable [
missionNamespace setVariable [
_handleName,
[_code, _interval, _handleName] call CBA_fnc_addPerFrameHandler
];
} else {
localNamespace setVariable [
missionNamespace setVariable [
_handleName,
[_handleName, _interval] spawn {
params [

View File

@@ -19,7 +19,7 @@ if (RangerMetrics_cbaPresent) then { // CBA is running, use PFH
This system means that capture and sending are occurring in the scheduled environment, not blocking the server, while maintaining the timestamps of when each point was captured. The cycles of each will only occur at most once per 2 seconds, leaving plenty of time, and there will never be more than one call for each at a time.
*/
[{
private _handle = [{
params ["_args", "_idPFH"];
_args params ["_captureHandleName", "_functions"];
@@ -40,9 +40,22 @@ if (RangerMetrics_cbaPresent) then { // CBA is running, use PFH
// call direct
[format["Running %1 functions for %2", count _functions, _captureHandleName], "DEBUG"] call RangerMetrics_fnc_log;
{
call _x;
_x params ["_whereToRun", "_scriptBlock"];
if (
_whereToRun find "server" == -1 &&
!isServer
) exitWith {false};
if (
_whereToRun find "hc" == -1 &&
(!hasInterface && !isDedicated)
) exitWith {false};
[] spawn _scriptBlock;
} forEach _functions;
}, _interval, [_captureHandleName, _functions]] call CBA_fnc_addPerFrameHandler;
missionNamespace setVariable [_captureHandleName, _handle];
} else { // CBA isn't running, use sleep
@@ -51,10 +64,21 @@ if (RangerMetrics_cbaPresent) then { // CBA is running, use PFH
while {true} do {
if (!RangerMetrics_run) exitWith {};
{
call _x;
_x params ["_whereToRun", "_scriptBlock"];
if (
_whereToRun find "server" == -1 &&
!isServer
) exitWith {false};
if (
_whereToRun find "hc" == -1 &&
(!hasInterface && !isDedicated)
) exitWith {false};
[] spawn _scriptBlock;
} forEach _functions;
sleep _interval;
sleep (_interval * 2);
};
};
};

View File

@@ -1,76 +0,0 @@
addMissionEventHandler ["MPEnded", {
}];
addMissionEventHandler ["OnUserConnected", {
params ["_networkId", "_clientStateNumber", "_clientState"];
(getUserInfo _networkId) call RangerMetrics_fnc_player_identity;
(getUserInfo _networkId) call RangerMetrics_fnc_player_status;
["server_events", "UserConnected", nil, [
["string", "networkId", _networkId],
["int", "clientStateNumber", _clientStateNumber],
["string", "clientState", _clientState]
]] call RangerMetrics_fnc_queue;
}];
addMissionEventHandler ["OnUserDisconnected", {
params ["_networkId", "_clientStateNumber", "_clientState"];
(getUserInfo _networkId) call RangerMetrics_fnc_player_identity;
(getUserInfo _networkId) call RangerMetrics_fnc_player_status;
["server_events", "OnUserDisconnected", nil, [
["string", "networkId", _networkId],
["int", "clientStateNumber", _clientStateNumber],
["string", "clientState", _clientState]
]] call RangerMetrics_fnc_queue;
}];
addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
(getUserInfo _idstr) call RangerMetrics_fnc_player_identity;
(getUserInfo _idstr) call RangerMetrics_fnc_player_status;
["server_events", "PlayerConnected", nil, [
["int", "id", _id],
["string", "uid", _uid],
["string", "name", _name],
["bool", "isJip", _jip],
["int", "owner", _owner],
["string", "idstr", _idstr]
]] call RangerMetrics_fnc_queue;
}];
addMissionEventHandler ["PlayerDisconnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
(getUserInfo _idstr) call RangerMetrics_fnc_player_identity;
(getUserInfo _idstr) call RangerMetrics_fnc_player_status;
["server_events", "PlayerDisconnected", nil, [
["int", "id", _id],
["string", "uid", _uid],
["string", "name", _name],
["bool", "isJip", _jip],
["int", "owner", _owner],
["string", "idstr", _idstr]
]] call RangerMetrics_fnc_queue;
}];
addMissionEventHandler ["OnUserClientStateChanged", {
params ["_networkId", "_clientStateNumber", "_clientState"];
(getUserInfo _networkId) call RangerMetrics_fnc_player_status;
["server_events", "OnUserClientStateChanged", nil, [
["string", "networkId", _networkId],
["int", "clientStateNumber", _clientStateNumber],
["string", "clientState", _clientState]
]] call RangerMetrics_fnc_queue;
}];
addMissionEventHandler ["OnUserAdminStateChanged", {
params ["_networkId", "_loggedIn", "_votedIn"];
(getUserInfo _networkId) call RangerMetrics_fnc_player_status;
["server_events", "OnUserAdminStateChanged", nil, [
["string", "networkId", _networkId],
["bool", "loggedIn", _loggedIn],
["bool", "votedIn", _votedIn]
]] call RangerMetrics_fnc_queue;
}];
addMissionEventHandler ["HandleChatMessage", {
_this call RangerMetrics_fnc_chat_message;
// don't interfaere with the chat message
false;
}];

View File

@@ -1,14 +0,0 @@
params ["_name", "_function", "_data"];
if (_name == "RangerMetrics") then {
if (isNil "_data") then {_data = ""};
try {
if (_data isEqualType "") exitWith {
_data = parseSimpleArray _data;
_data call RangerMetrics_fnc_log;
};
diag_log format ["Callback unsupported type: %1: %2", _function, _data];
} catch {
_data = format ["%1", _data];
};
};

View File

@@ -1,4 +0,0 @@
private _visualSettings = [
["objectViewDistance", getObjectViewDistance # 0],
["viewDistance", viewDistance]
];

View File

@@ -1,22 +0,0 @@
{
private _threadId = _x;
private _finished = ["RangerMetrics.influx.has_call_finished", [_threadId]] call py3_fnc_callExtension;
// systemChat str _finished;
if (isNil "_finished") exitWith {
RangerMetrics_activeThreads = RangerMetrics_activeThreads - [_threadId];
[format ["[%1]: Thread %2 not found", RangerMetrics_logPrefix, _threadId], "WARN"] call RangerMetrics_fnc_log;
};
if (_finished isEqualTo []) exitWith {
RangerMetrics_activeThreads = RangerMetrics_activeThreads - [_threadId];
[format ["[%1]: Thread %2 not found", RangerMetrics_logPrefix, _threadId], "WARN"] call RangerMetrics_fnc_log;
};
if (_finished isEqualTo true) then {
RangerMetrics_activeThreads = RangerMetrics_activeThreads - [_threadId];
if (missionNamespace getVariable ["RangerMetrics_debug",false]) then {
private _return = ["RangerMetrics.influx.get_call_value", [_threadId]] call py3_fnc_callExtension;
[format ["%1", _return], "DEBUG"] call RangerMetrics_fnc_log;
};
};
} forEach RangerMetrics_activeThreads;

View File

@@ -1,107 +0,0 @@
/* ----------------------------------------------------------------------------
Function: CBA_fnc_encodeJSON
Description:
Serializes input to a JSON string. Can handle
- ARRAY
- BOOL
- CONTROL
- GROUP
- LOCATION
- NAMESPACE
- NIL (ANY)
- NUMBER
- OBJECT
- STRING
- TASK
- TEAM_MEMBER
- HASHMAP
- Everything else will simply be stringified.
Parameters:
_object - Object to serialize. <ARRAY, ...>
Returns:
_json - JSON string containing serialized object.
Examples:
(begin example)
private _settings = call CBA_fnc_createNamespace;
_settings setVariable ["enabled", true];
private _json = [_settings] call CBA_fnc_encodeJSON;
(end)
Author:
BaerMitUmlaut
---------------------------------------------------------------------------- */
params ["_object"];
if (isNil "_object") exitWith { "null" };
switch (typeName _object) do {
case "SCALAR";
case "BOOL": {
str _object;
};
case "STRING": {
{
_object = [_object, _x#0, _x#1] call CBA_fnc_replace;
} forEach [
["\", "\\"],
["""", "\"""],
[toString [8], "\b"],
[toString [12], "\f"],
[endl, "\n"],
[toString [10], "\n"],
[toString [13], "\r"],
[toString [9], "\t"]
];
// Stringify without escaping inter string quote marks.
"""" + _object + """"
};
case "ARRAY": {
if ([_object] call CBA_fnc_isHash) then {
private _json = (([_object] call CBA_fnc_hashKeys) apply {
private _name = _x;
private _value = [_object, _name] call CBA_fnc_hashGet;
format ["%1: %2", [_name] call CBA_fnc_encodeJSON, [_value] call CBA_fnc_encodeJSON]
}) joinString ", ";
"{" + _json + "}"
} else {
private _json = (_object apply {[_x] call CBA_fnc_encodeJSON}) joinString ", ";
"[" + _json + "]"
};
};
case "HASHMAP": {
private _json = ((_object toArray false) apply {
_x params ["_key", ["_value", objNull]];
if !(_key isEqualType "") then {
_key = str _key;
};
format ["%1: %2", [_key] call CBA_fnc_encodeJSON, [_value] call CBA_fnc_encodeJSON]
}) joinString ", ";
"{" + _json + "}"
};
default {
if !(typeName _object in (supportInfo "u:allVariables*" apply {_x splitString " " select 1})) exitWith {
[str _object] call CBA_fnc_encodeJSON
};
if (isNull _object) exitWith { "null" };
private _json = ((allVariables _object) apply {
private _name = _x;
private _value = _object getVariable [_name, objNull];
format ["%1: %2", [_name] call CBA_fnc_encodeJSON, [_value] call CBA_fnc_encodeJSON]
}) joinString ", ";
"{" + _json + "}"
};
};

View File

@@ -1,83 +0,0 @@
// function adapted from YAINA by MartinCo at http://yaina.eu
params [["_cba",false,[true]]];
if(missionNamespace getVariable ["RangerMetrics_run",false]) then {
private _startTime = diag_tickTime;
// Mission name
["server", "mission_name", [["source", "onLoadName"]], nil, "string", getMissionConfigValue ["onLoadName", ""]] call RangerMetrics_fnc_queue;
["server", "mission_name", [["source", "missionName"]], nil, "string", missionName] call RangerMetrics_fnc_queue;
["server", "mission_name", [["source", "missionNameSource"]], nil, "string", missionNameSource] call RangerMetrics_fnc_queue;
["server", "mission_name", [["source", "briefingName"]], nil, "string", briefingName] call RangerMetrics_fnc_queue;
["server", "server_uptime", nil, nil, "float", diag_tickTime toFixed 2] call RangerMetrics_fnc_queue;
// Number of local units
["simulation", "entity_count", [["entity_type", "unit"], ["only_local", true]], nil, "int", { local _x } count allUnits] call RangerMetrics_fnc_queue;
["simulation", "entity_count", [["entity_type", "group"], ["only_local", true]], nil, "int", { local _x } count allGroups] call RangerMetrics_fnc_queue;
["simulation", "entity_count", [["entity_type", "vehicles"], ["only_local", true]], nil, "int", { local _x} count vehicles] call RangerMetrics_fnc_queue;
// Server Stats
["simulation", "fps", [["metric", "avg"]], nil, "float", diag_fps toFixed 2] call RangerMetrics_fnc_queue;
["simulation", "fps", [["metric", "avg_min"]], nil, "float", diag_fpsMin toFixed 2] call RangerMetrics_fnc_queue;
["simulation", "mission_time", nil, nil, "float", time toFixed 2] call RangerMetrics_fnc_queue;
// Scripts
private _activeScripts = diag_activeScripts;
["simulation", "script_count", [["execution", "spawn"]], nil, "int", _activeScripts select 0] call RangerMetrics_fnc_queue;
["simulation", "script_count", [["execution", "execVM"]], nil, "int", _activeScripts select 1] call RangerMetrics_fnc_queue;
["simulation", "script_count", [["execution", "exec"]], nil, "int", _activeScripts select 2] call RangerMetrics_fnc_queue;
["simulation", "script_count", [["execution", "execFSM"]], nil, "int", _activeScripts select 3] call RangerMetrics_fnc_queue;
private _pfhCount = if(_cba) then {count CBA_common_perFrameHandlerArray} else {0};
["simulation", "script_count", [["execution", "pfh"]], nil, "int", _pfhCount] call RangerMetrics_fnc_queue;
// Globals if server
if (isServer) then {
// Number of global units
["simulation", "entity_count", [["entity_type", "unit"], ["only_local", false]], nil, "int", count allUnits] call RangerMetrics_fnc_queue;
["simulation", "entity_count", [["entity_type", "group"], ["only_local", false]], nil, "int", count allGroups] call RangerMetrics_fnc_queue;
["simulation", "entity_count", [["entity_type", "vehicle"], ["only_local", false]], nil, "int", count vehicles] call RangerMetrics_fnc_queue;
["simulation", "entity_count", [["entity_type", "player"], ["only_local", false]], nil, "int", count allPlayers] call RangerMetrics_fnc_queue;
};
private _headlessClients = entities "HeadlessClient_F";
{
{
private _stats_fps = diag_fps toFixed 2;
private _stats_fps_min = diag_fpsMin toFixed 2;
["simulation", "fps_hc", [["metric", "avg"]], nil, "float", _stats_fps] remoteExec ["RangerMetrics_fnc_queue", 2];
["simulation", "fps_hc", [["metric", "avg_min"]], nil, "float", _stats_fps_min] remoteExec ["RangerMetrics_fnc_queue", 2];
} remoteExecCall ["bis_fnc_call", owner _x];
} foreach _headlessClients;
/** WORKING HEADLESS CODE COMMENTED OUT TO TRY SOMETHING DIFFERNT
// Headless Clients FPS
// Thanks to CPL.Brostrom.A
private _headlessClients = entities "HeadlessClient_F";
{
{
private _stats_fps = round diag_fps;
["stats.HCfps", _stats_fps] remoteExec ["RangerMetrics_fnc_queue", 2];
} remoteExecCall ["bis_fnc_call", owner _x];
} foreach _headlessClients;
*/
// log the runtime and switch off debug so it doesn't flood the log
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
[format ["Run time: %1", diag_tickTime - _startTime], "DEBUG"] call RangerMetrics_fnc_log;
// missionNamespace setVariable ["RangerMetrics_debug",false];
};
};

View File

@@ -1,26 +0,0 @@
params [["_text","Log text invalid",[""]], ["_type","INFO",[""]]];
private _textFormatted = format [
"[%1] %2: %3",
RangerMetrics_logPrefix,
_type,
_text];
if(isServer) then {
diag_log text _textFormatted;
if(isMultiplayer) then {
_playerIds = [];
{
_player = _x;
_ownerId = owner _player;
if(_ownerId > 0) then {
if(getPlayerUID _player in ["76561198013533294"]) then {
_playerIds pushBack _ownerId;
};
};
} foreach allPlayers;
if(count _playerIds > 0) then {
[_textFormatted] remoteExec ["diag_log", _playerIds];
};
};
};

View File

@@ -1,74 +0,0 @@
// if (!isServer) exitWith {};
_cba = (isClass(configFile >> "CfgPatches" >> "cba_main"));
RangerMetrics_logPrefix = "RangerMetrics";
RangerMetrics_debug = true;
RangerMetrics_activeThreads = [];
RangerMetrics_messageQueue = createHashMap;
[format ["Instance name: %1", profileName]] call RangerMetrics_fnc_log;
[format ["CBA detected: %1", _cba]] call RangerMetrics_fnc_log;
["Initializing v1.1"] call RangerMetrics_fnc_log;
private _settingsLoaded = "RangerMetrics" callExtension "loadSettings";
// if (isNil "_settingsLoaded") exitWith {
// ["Extension not found, disabling"] call RangerMetrics_fnc_log;
// RangerMetrics_run = false;
// };
// if (_settingsLoaded isEqualTo []) then {
// if (count _settingsLoaded == 0) exitWith {
// ["Settings not loaded, disabling"] call RangerMetrics_fnc_log;
// RangerMetrics_run = false;
// };
// if (_settingsLoaded#0 isEqualTo 1) exitWith {
// [
// format["Settings not loaded, disabling. %1", _settingsLoaded#1],
// "ERROR"
// ] call RangerMetrics_fnc_log;
// RangerMetrics_run = false;
// };
// };
format["Settings loaded: %1", _settingsLoaded#2] call RangerMetrics_fnc_log;
RangerMetrics_settings = _settingsLoaded#2;
// RangerMetrics_settings = createHashMap;
// private _top = createHashMapFromArray _settingsLoaded#2;
// RangerMetrics_settings set [
// "influxDB",
// createHashMapFromArray (_top get "influxDB")
// ];
// RangerMetrics_settings set [
// "arma3",
// createHashMapFromArray (_top get "refreshRateMs")
// ];
"RangerMetrics" callExtension "connectToInflux";
RangerMetrics_run = true;
// addMissionEventHandler ["ExtensionCallback", {
// params ["_name", "_function", "_data"];
// if (_name == "RangerMetrics") then {
// [parseSimpleArray _data] call RangerMetrics_fnc_log;
// };
// }];
if(_cba) then { // CBA is running, use PFH
[{
params ["_args", "_idPFH"];
_args params [["_cba", false]];
[_cba] call RangerMetrics_fnc_gather;
call RangerMetrics_fnc_checkResults;
call RangerMetrics_fnc_send;
// }, (RangerMetrics_settings get "arma3" get "refreshRateMs"), [_cba]] call CBA_fnc_addPerFrameHandler;
}, 1, [_cba]] call CBA_fnc_addPerFrameHandler;
} else { // CBA isn't running, use sleep
[_cba] spawn {
params ["_cba"];
while {true} do {
[_cba] call RangerMetrics_fnc_gather; // nested to match CBA PFH signature
call RangerMetrics_fnc_checkResults;
call RangerMetrics_fnc_send;
// sleep (RangerMetrics_settings get "arma3" get "refreshRateMs");
sleep 1;
};
};
};

View File

@@ -1,48 +0,0 @@
params [
["_bucket", "default", [""]],
"_measurement",
["_tags", nil, [[], nil]],
["_fields", nil, [[], nil]],
"_valueType",
"_value"
];
private _profileName = profileName;
private _prefix = "Arma3";
private _extSend = [
_measurement, // metric name
_valueType // float or int or bool
];
private _outTags = [ // tags
["profile", _profileName],
["world", toLower worldName]
];
if (!isNil "_tags") then {
{
_outTags pushBack [_x#0, _x#1];
} forEach _tags;
};
_extSend pushBack (_outTags apply {format["tag|%1|%2", _x#0, _x#1]});
_outFields = [ // fields
["server", serverName],
["mission", missionName],
["value", _value]
];
if (!isNil "_fields") then {
{
_outFields pushBack [_x#0, _x#1];
} forEach _fields;
};
_extSend pushBack (_outFields apply {format["field|%1|%2", _x#0, _x#1]});
// add to queue
(RangerMetrics_messageQueue getOrDefault [_bucket, [], true]) pushBack (flatten _extSend);
true

View File

@@ -1,54 +0,0 @@
// send the data
[{
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
[format ["Sending a3influx data: %1", RangerMetrics_messageQueue], "DEBUG"] call RangerMetrics_fnc_log;
};
// duplicate the message queue so we can clear it before sending the data
private _extSend = + RangerMetrics_messageQueue;
RangerMetrics_messageQueue = createHashMap;
{
// for each bucket, send data to extension
private _bucketName = _x;
private _bucketData = _y;
// if (true) exitWith {
// [format ["bucketName: %1", _bucketName], "DEBUG"] call RangerMetrics_fnc_log;
// [format ["bucketData: %1", _bucketData], "DEBUG"] call RangerMetrics_fnc_log;
// };
{
_thisItem = _x;
private _return = "RangerMetrics" callExtension ["sendToInflux", flatten [_bucketName, _thisItem]];
// shouldn't be possible, the extension should always return even if error
if(isNil "_return") exitWith {
[format ["return was nil (%1)", _extSend], "ERROR"] call RangerMetrics_fnc_log;
false
};
if (typeName _return != "ARRAY") exitWith {
[format ["return was not an array (%1)", _extSend], "ERROR"] call RangerMetrics_fnc_log;
false
};
if (count _return == 0) exitWith {
[format ["return was empty (%1)", _extSend], "ERROR"] call RangerMetrics_fnc_log;
false
};
if (count _return == 2) exitWith {
[format ["return was error (%1)", _extSend], "ERROR"] call RangerMetrics_fnc_log;
false
};
// success, add to list of active threads
// RangerMetrics_activeThreads pushBack (_return select 0);
// success, only show if debug is set
if (missionNamespace getVariable ["RangerMetrics_debug",false]) then {
[format ["a3influx threadId: %1", _return], "DEBUG"] call RangerMetrics_fnc_log;
};
} forEach _bucketData;
} forEach _extSend;
}] call CBA_fnc_execNextFrame;

View File

@@ -0,0 +1,12 @@
params [[
"_unit", objNull, [objNull]
]];
if (isNull _unit) exitWith {};
private _playerID = getPlayerID _unit;
private _userInfo = (getUserInfo _playerID);
_userInfo call RangerMetrics_capture_fnc_player_identity;
_userInfo call RangerMetrics_capture_fnc_player_status;
[_unit] call RangerMetrics_capture_fnc_unit_state;
[_unit] call RangerMetrics_capture_fnc_unit_inventory;

View File

@@ -21,13 +21,17 @@ if (_value isEqualType []) then {
_value = [_value, '""', "'"] call RangerMetrics_fnc_stringReplace;
};
_key = [_key, ',', "\,"] call RangerMetrics_fnc_stringReplace;
_key = [_key, '=', "\="] call RangerMetrics_fnc_stringReplace;
_key = [_key, ' ', "\ "] call RangerMetrics_fnc_stringReplace;
if (_section isEqualTo "tag") exitWith {
switch (_valueType) do {
case "string": {
_value = [_value, ',', "\,"] call RangerMetrics_fnc_stringReplace;
_value = [_value, '=', "\="] call RangerMetrics_fnc_stringReplace;
_value = [_value, ' ', "\ "] call RangerMetrics_fnc_stringReplace;
_value = format['%1="%2"', _key, _value];
_value = format['%1=%2', _key, _value];
};
case "int": {
_value = format['%1=%2i', _key, _value];
@@ -46,7 +50,7 @@ if (_section isEqualTo "field") exitWith {
switch (_valueType) do {
case "string": {
_value = [_value, '\', "\\"] call RangerMetrics_fnc_stringReplace;
_value = [_value, '"', '\"'] call RangerMetrics_fnc_stringReplace;
_value = [_value, '"', '\"'] call RangerMetrics_fnc_stringReplace;
_value = format['%1="%2"', _key, _value];
};
case "int": {

View File

@@ -1,40 +0,0 @@
params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"];
private _fields = [
["int", "channel", _channel],
["int", "owner", _owner],
["string", "from", _from],
["string", "text", _text],
// ["object", "person", _person],
["string", "name", _name],
["string", "strID", _strID],
["bool", "forcedDisplay", _forcedDisplay],
["bool", "isPlayerMessage", _isPlayerMessage],
["int", "sentenceType", _sentenceType],
["int", "chatMessageType", _chatMessageType]
];
// we need special processing to ensure the object is valid and we have a playerUid. Line protocol doesn't support empty string
private "_playerUid";
if (isNil "_person") then {
_playerUid = "";
} else {
if !(objNull isEqualType _person) then {
_playerUid = getPlayerUID _person;
} else {
_playerUid = "";
};
};
if (_playerUid isNotEqualTo "") then {
_fields pushBack ["string", "playerUid", _playerUid];
};
[
"server_events",
"HandleChatMessage",
nil,
_fields
] call RangerMetrics_fnc_queue;

View File

@@ -1,7 +0,0 @@
// Number of global units
["server_state", "entities_global", nil, [
["int", "units_alive", count allUnits ],
["int", "units_dead", count allDeadMen],
["int", "groups_total", count allGroups],
["int", "vehicles_total", count vehicles]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,7 +0,0 @@
// Number of local units
["server_state", "entities_local", nil, [
["int", "units_alive", { local _x} count allUnits ],
["int", "units_dead", { local _x } count allDeadMen],
["int", "groups_total", { local _x } count allGroups],
["int", "vehicles_total", { local _x } count vehicles]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,210 +0,0 @@
// get basic config properties
private _properties = [
["mission_info", [
"author",
"onLoadName",
"onLoadMission",
"loadScreen",
// "header",
"gameType",
"minPlayers",
"maxPlayers",
"onLoadIntro",
"onLoadMissionTime",
"onLoadIntroTime",
"briefingName",
"overviewPicture",
"overviewText",
"overviewTextLocked"
]],
["respawn", [
"respawn",
"respawnButton",
"respawnDelay",
"respawnVehicleDelay",
"respawnDialog",
"respawnOnStart",
"respawnTemplates",
"respawnTemplatesWest",
"respawnTemplatesEast",
"respawnTemplatesGuer",
"respawnTemplatesCiv",
"respawnWeapons",
"respawnMagazines",
"reviveMode",
"reviveUnconsciousStateMode",
"reviveRequiredTrait",
"reviveRequiredItems",
"reviveRequiredItemsFakConsumed",
"reviveMedicSpeedMultiplier",
"reviveDelay",
"reviveForceRespawnDelay",
"reviveBleedOutDelay",
"enablePlayerAddRespawn"
]],
["player_ui", [
"overrideFeedback",
"showHUD",
"showCompass",
"showGPS",
"showGroupIndicator",
"showMap",
"showNotePad",
"showPad",
"showWatch",
"showUAVFeed",
"showSquadRadar"
]],
["corpse_and_wreck", [
"corpseManagerMode",
"corpseLimit",
"corpseRemovalMinTime",
"corpseRemovalMaxTime",
"wreckManagerMode",
"wreckLimit",
"wreckRemovalMinTime",
"wreckRemovalMaxTime",
"minPlayerDistance"
]],
["mission_settings", [
"aiKills",
"briefing",
"debriefing",
"disableChannels",
"disabledAI",
"disableRandomization",
"enableDebugConsole",
"enableItemsDropping",
"enableTeamSwitch",
"forceRotorLibSimulation",
"joinUnassigned",
"minScore",
"avgScore",
"maxScore",
"onCheat",
"onPauseScript",
"saving",
"scriptedPlayer",
"skipLobby",
"HostDoesNotSkipLobby",
"missionGroup"
]
]
];
private _propertyValues = createHashMap;
// recursively walk through missionConfigFile and get all properties into a single hashmap
// iterate through list of categories with desired property names
// if the property exists in the extracted missionConfigFile property hash, save it with the category into _propertyValues
{
private _category = _x#0;
private _values = _x#1;
{
private _property = _x;
private _value = (missionConfigFile >> _property) call BIS_fnc_getCfgData;
// hint str [_category, _property, _value];
if (!isNil "_value") then {
if (typeName _value == "ARRAY") then {
_value = _value joinString ",";
};
if (isNil {_propertyValues get _category}) then {
_propertyValues set [_category, createHashMap];
};
_propertyValues get _category set [_property, _value];
};
} forEach _values;
} forEach _properties;
// Take the generated hashmap of custom-categorized configuration properties and queue them for metrics
{
private _measurementCategory = _x;
private _fields = _y;
private _fieldsWithType = [];
// InfluxDB lookup hash
_types = createHashMapFromArray [
["STRING", "string"],
["ARRAY", "string"],
["SCALAR", "float"],
["BOOL", "bool"]
];
// Preprocess the fields to clean the raw data
{
private _fieldName = _x;
private _fieldValue = _y;
private _fieldType = _types get (typeName _fieldValue);
// turn ARRAY into string since Influx can't take them
if (typeName _fieldValue == "ARRAY") then {
_fieldValue = _fieldValue joinString "|";
};
// convert 0 or 1 (from config) to BOOL
if (typeName _fieldValue == "SCALAR" && _fieldValue in [0, 1]) then {
_fieldType = "bool";
if (_fieldValue == 0) then {
_fieldValue = "false";
} else {
_fieldValue = "true";
};
};
_fieldsWithType pushBack [_fieldType, _fieldName, _fieldValue];
} forEach _fields;
// finally, send the data
[
"config_state",
"mission_config_file",
[
["category", _measurementCategory]
],
_fieldsWithType
] call RangerMetrics_fnc_queue;
} forEach _propertyValues;
// get all properties in missionConfigFile (recursive)
// private _nextCfgClasses = "true" configClasses (missionConfigFile);
// private _nextCfgProperties = configProperties [missionConfigFile];
// private _cfgProperties = createHashMap;
// while {count _nextCfgClasses > 0} do {
// {
// private _thisConfig = _x;
// private _thisConfigClasses = "true" configClasses _thisConfig;
// _thisCfgProperties = configProperties [_thisConfig, "!isClass _x"];
// _saveHash = createHashMap;
// {
// _propertyCfg = _x;
// _saveHash set [configName _propertyCfg, (_propertyCfg) call BIS_fnc_getCfgData];
// } forEach _thisCfgProperties;
// _hierarchy = (configHierarchy _thisConfig);
// _hierarchy deleteAt 0;
// _hierarchy = _hierarchy apply {configName _x};
// _hierarchyStr = _hierarchy joinString ".";
// _hierarchyStrParent = (_hierarchy select [0, count _hierarchy - 2]) joinString ".";
// systemChat _hierarchyStrParent;
// // if (_cfgProperties get _hierarchyStrParent == nil) then {
// // _cfgProperties set [_hierarchyStrParent, createHashMap];
// // };
// _cfgProperties set [_hierarchyStr, _saveHash];
// // _cfgProperties set [_hierarchy, _saveHash];
// _nextCfgClasses append _thisConfigClasses;
// } forEach _nextCfgClasses;
// _nextCfgClasses = _nextCfgClasses - _cfgClasses;
// };
// text ([_cfgProperties] call RangerMetrics_fnc_encodeJSON);
// iterate through _cfgProperties hashmap and queue metrics
// {
// } forEach _cfgProperties;

View File

@@ -1,22 +0,0 @@
params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit", ["_jip", false]];
// _networkInfo params ["_avgPing", "_avgBandwidth", "_desync"];
private _fields = [
["string", "playerID", _playerID],
["string", "ownerId", _ownerId],
["string", "playerUID", _playerUID],
["string", "profileName", _profileName],
["string", "displayName", _displayName],
["string", "steamName", _steamName],
["bool", "isHC", _isHC],
["bool", "jip", _jip]
];
if (!isNil "_unit") then {
private _roleDescription = roleDescription _unit;
if (_roleDescription isNotEqualTo "") then {
_fields pushBack ["string", "roleDescription", _roleDescription];
};
};
["player_state", "player_identity", [], _fields] call RangerMetrics_fnc_queue;

View File

@@ -1,8 +0,0 @@
params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
_networkInfo params ["_avgPing", "_avgBandwidth", "_desync"];
["player_state", "player_performance", [], [
["float", "avgPing", _avgPing],
["float", "avgBandwidth", _avgBandwidth],
["float", "desync", _desync]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,7 +0,0 @@
params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
// _networkInfo params ["_avgPing", "_avgBandwidth", "_desync"];
["player_state", "player_status", [], [
["int", "clientStateNumber", _clientState],
["int", "adminState", _adminState]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,20 +0,0 @@
// Mission name
[
"server_state", // bucket to store the data
"mission_name", // measurement classifier inside of bucket
nil, // tags
[ // fields
[
"string",
"onLoadName",
[
getMissionConfigValue ["onLoadName", ""],
" ",
"\ "
] call RangerMetrics_fnc_stringReplace
],
["string","briefingName", briefingName],
["string","missionName", missionName],
["string","missionNameSource", missionNameSource]
]
] call RangerMetrics_fnc_queue;

View File

@@ -1,7 +0,0 @@
["server_state", "running_scripts", nil, [
["int", "spawn", diag_activeScripts select 0],
["int", "execVM", diag_activeScripts select 1],
["int", "exec", diag_activeScripts select 2],
["int", "execFSM", diag_activeScripts select 3],
["int", "pfh", if (RangerMetrics_cbaPresent) then {count CBA_common_perFrameHandlerArray} else {0}]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,4 +0,0 @@
["server_state", "server_performance", nil, [
["float", "avg", diag_fps toFixed 2],
["float", "min", diag_fpsMin toFixed 2]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,6 +0,0 @@
["server_state", "server_time", nil, [
["float", "diag_tickTime", diag_tickTime toFixed 2],
["float", "serverTime", time toFixed 2],
["float", "timeMultiplier", timeMultiplier toFixed 2],
["float", "accTime", accTime toFixed 2]
]] call RangerMetrics_fnc_queue;

View File

@@ -1,164 +0,0 @@
// get basic config properties
private _properties = [
["settings_mission_info", [
"author",
"onLoadName",
"onLoadMission",
"loadScreen",
"header",
"onLoadIntro",
"onLoadMissionTime",
"onLoadIntroTime",
"briefingName",
"overviewPicture",
"overviewText",
"overviewTextLocked",
"onBriefingGear",
"onBriefingGroup",
"onBriefingPlan"
]],
["settings_respawn", [
"respawn",
"respawnButton",
"respawnDelay",
"respawnVehicleDelay",
"respawnDialog",
"respawnOnStart",
"respawnTemplates",
"respawnWeapons",
"respawnMagazines",
"reviveMode",
"reviveUnconsciousStateMode",
"reviveRequiredTrait",
"reviveRequiredItems",
"reviveRequiredItemsFakConsumed",
"reviveMedicSpeedMultiplier",
"reviveDelay",
"reviveForceRespawnDelay",
"reviveBleedOutDelay",
"enablePlayerAddRespawn"
]],
["settings_player_ui", [
"overrideFeedback",
"showHUD",
"showCompass",
"showGPS",
"showGroupIndicator",
"showMap",
"showNotePad",
"showPad",
"showWatch",
"showUAVFeed",
"showSquadRadar"
]],
["settings_corpse_and_wreck", [
"corpseManagerMode",
"corpseLimit",
"corpseRemovalMinTime",
"corpseRemovalMaxTime",
"wreckManagerMode",
"wreckLimit",
"wreckRemovalMinTime",
"wreckRemovalMaxTime",
"minPlayerDistance"
]],
["settings_mission_general", [
"aiKills",
"briefing",
"debriefing",
"disableChannels",
"disabledAI",
"disableRandomization",
"enableDebugConsole",
"enableItemsDropping",
"enableTeamSwitch",
"forceRotorLibSimulation",
"joinUnassigned",
"minScore",
"avgScore",
"maxScore",
"onCheat",
"onPauseScript",
"saving",
"scriptedPlayer",
"skipLobby",
"HostDoesNotSkipLobby",
"missionGroup"
]
]
];
private _propertyValues = createHashMap;
{
private _category = _x#0;
private _values = _x#1;
{
private _property = _x;
private _value = (missionConfigFile >> _property) call BIS_fnc_getCfgData;
hint str [_category, _property, _value];
if (!isNil "_value") then {
if (typeName _value == "ARRAY") then {
_value = _value joinString ",";
};
if (isNil {_propertyValues get _category}) then {
_propertyValues set [_category, createHashMap];
};
_propertyValues get _category set [_property, _value];
};
} forEach _values;
} forEach _properties;
// Take the generated hashmap and queue metrics
{
private _measurementCategory = _x;
private _fields = _y;
["config", _measurementCategory, nil, _fields, "int", 0] call RangerMetrics_fnc_queue;
} forEach _propertyValues;
// get all properties in missionConfigFile (recursive)
// private _nextCfgClasses = "true" configClasses (missionConfigFile);
// private _nextCfgProperties = configProperties [missionConfigFile];
// private _cfgProperties = createHashMap;
// while {count _nextCfgClasses > 0} do {
// {
// private _thisConfig = _x;
// private _thisConfigClasses = "true" configClasses _thisConfig;
// _thisCfgProperties = configProperties [_thisConfig, "!isClass _x"];
// _saveHash = createHashMap;
// {
// _propertyCfg = _x;
// _saveHash set [configName _propertyCfg, (_propertyCfg) call BIS_fnc_getCfgData];
// } forEach _thisCfgProperties;
// _hierarchy = (configHierarchy _thisConfig);
// _hierarchy deleteAt 0;
// _hierarchy = _hierarchy apply {configName _x};
// _hierarchyStr = _hierarchy joinString ".";
// _hierarchyStrParent = (_hierarchy select [0, count _hierarchy - 2]) joinString ".";
// systemChat _hierarchyStrParent;
// // if (_cfgProperties get _hierarchyStrParent == nil) then {
// // _cfgProperties set [_hierarchyStrParent, createHashMap];
// // };
// _cfgProperties set [_hierarchyStr, _saveHash];
// // _cfgProperties set [_hierarchy, _saveHash];
// _nextCfgClasses append _thisConfigClasses;
// } forEach _nextCfgClasses;
// _nextCfgClasses = _nextCfgClasses - _cfgClasses;
// };
// text ([_cfgProperties] call RangerMetrics_fnc_encodeJSON);
// iterate through _cfgProperties hashmap and queue metrics
// {
// } forEach _cfgProperties;

View File

@@ -4,7 +4,6 @@ classDiagram
}
class server_events {
Measurement MPEnded
Measurement OnUserConnected
Measurement OnUserDisconnected
Measurement PlayerConnected
@@ -12,16 +11,34 @@ classDiagram
Measurement OnUserClientStateChanged
Measurement OnUserAdminStateChanged
Meausrement HandleChatMessage
Measurement MPEnded
Measurement EntityCreated
Measurement EntityKilled
Measurement GroupCreated
Measurement GroupDeleted
Measurement MarkerCreated
Measurement MarkerDeleted
Measurement MarkerUpdated
}
server_state --> running_mission
class running_mission {
tag string profileName
tag string connectedServer
field string onLoadName
field string missionName
field string missionNameSource
field string briefingName
capture: ServerPoll, 60s
tag string profileName
tag string connectedServer
field string onLoadName
field string missionName
field string missionNameSource
field string briefingName
}
server_state --> view_distance
class view_distance {
capture: ServerPoll, 60s
tag string profileName
tag string connectedServer
field string viewDistance
field string objectViewDistance
}
server_state --> server_time
@@ -47,48 +64,62 @@ classDiagram
server_state --> entities_local
class entities_local {
tag string profileName
tag string connectedServer
field int units_alive
field int units_dead
field int vehicles_total
field int groups_total
capture: ServerPoll, 1s (customizable)
tag string profileName
tag string connectedServer
field int units_alive
field int units_dead
field int vehicles_total
field int groups_total
}
server_state --> entities_global
class entities_global {
tag string profileName
tag string connectedServer
field int units_alive
field int units_dead
field int vehicles_total
field int groups_total
capture: ServerPoll, 1s (customizable)
tag string profileName
tag string connectedServer
field int units_alive
field int units_dead
field int vehicles_total
field int groups_total
}
server_state --> entities_remote
class entities_remote {
capture: ServerPoll, 1s (customizable)
tag string profileName
tag string connectedServer
field int units_alive
field int units_dead
field int vehicles_total
field int groups_total
}
server_state --> server_performance
class server_performance {
tag string profileName
tag string connectedServer
field string fps_avg
field string fps_min
capture: ServerPoll, 1s (customizable)
tag string profileName
tag string connectedServer
field string fps_avg
field string fps_min
}
server_state --> weather
class weather {
tag string profileName
tag string connectedServer
field string fog
field string overcast
field string rain
field string humidity
field string waves
field string windDir
field string windStr
field string gusts
field string lightnings
field string moonIntensity
field string moonPhase
field string sunOrMoon
capture: ServerPoll, 60s
tag string profileName
tag string connectedServer
field string fog
field string overcast
field string rain
field string humidity
field string waves
field string windDir
field string windStr
field string gusts
field string lightnings
field string moonIntensity
field string moonPhase
field string sunOrMoon
}
class config_state {
@@ -116,23 +147,23 @@ classDiagram
%% ' link fields in each category
mission_config_file --> mission_info
class mission_info {
tag string profileName
tag string connectedServer
field string author
field string onLoadName
field string onLoadMission
field string loadScreen
%% ' field string header
field string gameType
field int minPlayers
field int maxPlayers
field int onLoadIntro
field int onLoadMissionTime
field int onLoadIntroTime
field string briefingName
field string overviewPicture
field string overviewText
field string overviewTextLocked
tag string profileName
tag string connectedServer
field string author
field string onLoadName
field string onLoadMission
field string loadScreen
%% field string header
field string gameType
field int minPlayers
field int maxPlayers
field int onLoadIntro
field int onLoadMissionTime
field int onLoadIntroTime
field string briefingName
field string overviewPicture
field string overviewText
field string overviewTextLocked
}
mission_config_file --> respawn
@@ -232,41 +263,141 @@ classDiagram
field string objectViewDistance
}
class player_state {
}
class player_state
player_state --> player_identity
class player_identity {
tag string profileName
tag string connectedServer
field string playerID
field string ownerId
field string playerUID
field string profileName
field string displayName
field string steamName
field bool isHC
capture: MissionEH, OnUserConnected
capture: MissionEH, OnUserDisconnected
capture: MissionEH, PlayerConnected
capture: MissionEH, PlayerDisconnected
tag string profileName
tag string connectedServer
field string playerID
field string ownerId
field string playerUID
field string profileName
field string displayName
field string steamName
field bool isHC
field bool isJip
field string roleDescription
}
player_state --> player_status
class player_status {
tag string profileName
tag string connectedServer
field int clientStateNumber
field int adminState
capture: MissionEH, OnUserConnected
capture: MissionEH, OnUserDisconnected
capture: MissionEH, PlayerConnected
capture: MissionEH, PlayerDisconnected
capture: MissionEH, OnUserClientStateChanged
capture: MissionEH, OnUserAdminStateChanged
tag string profileName
tag string connectedServer
field string playerUID
field int clientStateNumber
field int adminState
}
player_state --> player_performance
class player_performance {
tag string profileName
tag string connectedServer
field float avgPing
field float avgBandwidth
field float desync
capture: ServerPoll
tag string profileName
tag string connectedServer
field string playerUID
field float avgPing
field float avgBandwidth
field float desync
}
player_state --> unit_loadout
class unit_loadout {
capture: InventoryClosedEH
tag string profileName
tag string connectedServer
field string playerUID
field string uniform
field string vest
field string backpack
field string headgear
field string goggles
field string hmd
field string primaryWeapon
field string primaryWeaponMagazine
field string secondaryWeapon
field string secondaryWeaponMagazine
field string handgunWeapon
field string handgunMagazine
}
player_state --> unit_state
class unit_state {
tag string connectedServer
tag string playerUID
field float health
field bool is_unconscious
field bool is_cardiac_arrest
field bool is_captive
field bool in_vehicle
field string vehicle_role
field float speed_kmh
}
class player_events
player_events --> Dammaged
class Dammaged {
capture: UnitEH, Dammaged
tag string connectedServer
tag string playerUID
field string selection
field string damage
field string hitIndex
field string hitPoint
field string shooter
field string projectile
}
player_events --> FiredMan
class FiredMan {
capture: UnitEH, FiredMan
tag string connectedServer
tag string playerUID
field string weapon
field string muzzle
field string mode
field string ammo
field string magazine
field string vehicle
field string vehicleClass
}
player_events --> GetInMan
class GetInMan {
capture: UnitEH, GetInMan
tag string connectedServer
tag string playerUID
field string role
field string vehicle
field string turret
}
player_events --> GetOutMan
class GetOutMan {
capture: UnitEH, GetOutMan
tag string connectedServer
tag string playerUID
field string role
field string vehicle
field string turret
}
player_events --> HandleScore
class HandleScore {
capture: UnitEH, HandleScore
tag string connectedServer
tag string playerUID
field int score
field string object
field string objectclass
}