Submit initial Working Version of RangerMetrics
This commit is contained in:
22
@RangerMetrics/addons/RangerMetrics/config.cpp
Normal file
22
@RangerMetrics/addons/RangerMetrics/config.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
class CfgPatches {
|
||||
class RangerMetrics {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 0.1;
|
||||
requiredAddons[] = {};
|
||||
author[] = {"EagleTrooper and Gary"};
|
||||
authorUrl = "http://example.com";
|
||||
};
|
||||
};
|
||||
|
||||
class CfgFunctions {
|
||||
class RangerMetrics {
|
||||
class Common {
|
||||
file = "\RangerMetrics\functions";
|
||||
class postInit { postInit = 1;};
|
||||
class log {};
|
||||
class send {};
|
||||
class run {};
|
||||
};
|
||||
};
|
||||
};
|
||||
22
@RangerMetrics/addons/RangerMetrics/functions/fn_log.sqf
Normal file
22
@RangerMetrics/addons/RangerMetrics/functions/fn_log.sqf
Normal file
@@ -0,0 +1,22 @@
|
||||
params [["_text","Log text invalid",[""]], ["_type","INFO",[""]]];
|
||||
private _textFormatted = format ["[RangerMetrics] %1: %2", _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];
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
// function adapted from YAINA by MartinCo at http://yaina.eu
|
||||
|
||||
if !(isServer || !hasInterface) exitWith {};
|
||||
_cba = (isClass(configFile >> "CfgPatches" >> "cba_main"));
|
||||
|
||||
[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;
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
92
@RangerMetrics/addons/RangerMetrics/functions/fn_run.sqf
Normal file
92
@RangerMetrics/addons/RangerMetrics/functions/fn_run.sqf
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
// function adapted from YAINA by MartinCo at http://yaina.eu
|
||||
|
||||
params ["_args"];
|
||||
_args params [["_cba",false,[true]]];
|
||||
|
||||
if(missionNamespace getVariable ["RangerMetrics_run",false]) then {
|
||||
private _startTime = diag_tickTime;
|
||||
|
||||
// Mission Name
|
||||
// private _missionName = missionName;
|
||||
// ["missionName", _missionName] call RangerMetrics_fnc_send;
|
||||
|
||||
// World Name
|
||||
// private _worldName = worldName;
|
||||
// ["worldName", _worldName] call RangerMetrics_fnc_send;
|
||||
|
||||
// Server Name
|
||||
// private _serverName = serverName;
|
||||
// ["serverName", _serverName] call RangerMetrics_fnc_send;
|
||||
|
||||
// Number of local units
|
||||
["count.units", { local _x } count allUnits] call RangerMetrics_fnc_send;
|
||||
["count.groups", { local _x } count allGroups] call RangerMetrics_fnc_send;
|
||||
["count.vehicles", { local _x} count vehicles] call RangerMetrics_fnc_send;
|
||||
|
||||
// Server Stats
|
||||
["stats.fps", round diag_fps] call RangerMetrics_fnc_send;
|
||||
["stats.fpsMin", round diag_fpsMin] call RangerMetrics_fnc_send;
|
||||
["stats.uptime", round diag_tickTime] call RangerMetrics_fnc_send;
|
||||
["stats.missionTime", round time] call RangerMetrics_fnc_send;
|
||||
|
||||
// Scripts
|
||||
private _activeScripts = diag_activeScripts;
|
||||
["scripts.spawn", _activeScripts select 0] call RangerMetrics_fnc_send;
|
||||
["scripts.execVM", _activeScripts select 1] call RangerMetrics_fnc_send;
|
||||
["scripts.exec", _activeScripts select 2] call RangerMetrics_fnc_send;
|
||||
["scripts.execFSM", _activeScripts select 3] call RangerMetrics_fnc_send;
|
||||
|
||||
private _pfhCount = if(_cba) then {count CBA_common_perFrameHandlerArray} else {0};
|
||||
["scripts.pfh", _pfhCount] call RangerMetrics_fnc_send;
|
||||
|
||||
// Globals if server
|
||||
if (isServer) then {
|
||||
// Number of local units
|
||||
["count.units", count allUnits, true] call RangerMetrics_fnc_send;
|
||||
["count.groups", count allGroups, true] call RangerMetrics_fnc_send;
|
||||
["count.vehicles", count vehicles, true] call RangerMetrics_fnc_send;
|
||||
["count.players", count allPlayers, true] call RangerMetrics_fnc_send;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private _headlessClients = entities "HeadlessClient_F";
|
||||
{
|
||||
{
|
||||
private _stats_fps = round diag_fps;
|
||||
["stats.HCfps", _stats_fps] remoteExec ["RangerMetrics_fnc_send", 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_send", 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];
|
||||
};
|
||||
};
|
||||
41
@RangerMetrics/addons/RangerMetrics/functions/fn_send.sqf
Normal file
41
@RangerMetrics/addons/RangerMetrics/functions/fn_send.sqf
Normal file
@@ -0,0 +1,41 @@
|
||||
params ["_metric", "_value", ["_global", false]];
|
||||
|
||||
private _profileName = profileName;
|
||||
private _prefix = "Arma3";
|
||||
|
||||
private _metricPath = [format["%1,%2", _profileName, profileName], format["%1,%2", _profileName, "global"]] select _global;
|
||||
|
||||
// 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 {
|
||||
[format ["Sending a3influx data: %1", _extSend], "DEBUG"] call RangerMetrics_fnc_log;
|
||||
};
|
||||
|
||||
// send the data
|
||||
private _return = "a3influx" callExtension _extSend;
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
// extension error codes
|
||||
if(_return in ["invalid metric value","malformed, could not find separator"] ) exitWith {
|
||||
[format ["%1 (%2)", _return, _extSend], "ERROR"] call RangerMetrics_fnc_log;
|
||||
false
|
||||
};
|
||||
|
||||
// success, only show if debug is set
|
||||
if(missionNamespace getVariable ["RangerMetrics_debug",false]) then {
|
||||
_returnArgs = _return splitString (toString [10,32]);
|
||||
[format ["a3influx return data: %1",_returnArgs], "DEBUG"] call RangerMetrics_fnc_log;
|
||||
};
|
||||
|
||||
true
|
||||
18
@RangerMetrics/mod.cpp
Normal file
18
@RangerMetrics/mod.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
name = "RangerMetrics";
|
||||
picture = "";
|
||||
logoSmall = "";
|
||||
logo = "";
|
||||
logoOver = "";
|
||||
actionName = "";
|
||||
action = "";
|
||||
dlcColor[] =
|
||||
{
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
overview = "Metrics for 17th Ranger Batallion";
|
||||
description = "Version 1.1.0";
|
||||
hideName = 1;
|
||||
hidePicture = 1;
|
||||
Reference in New Issue
Block a user