Submit initial Working Version of RangerMetrics

This commit is contained in:
2023-04-02 12:29:41 -05:00
parent 670355169d
commit e72e58f2a4
9 changed files with 289 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.pbo
*.bak

68
7cavChat.txt Normal file
View File

@@ -0,0 +1,68 @@
Jarvis — Today at 8:23 PM
@EagleTrooper let's use this instead
to save blowing up the recruiters notifications
on recruitment
EagleTrooper — Today at 8:23 PM
Yeah keep the recruitment clean. I understand Im a recruiter / NCO / admin for the community in involved in.
Alright,
I am working on developing a dashboard that gives historical stats with our server as well as our missions that run Performance / FPS / Memory Usage / etc. During my research i came across your groups Repo and it appears that you are doing something very similar to what I wanted to do. I did read through just to get an idea unfortunately there was some gaps in the implementation and i was hoping to speak to someone about how it was done with your group as well as if they would be so kind as to provide pointers and insight so that I may implement something very similar.
Jarvis — Today at 8:26 PM
Do you know how to setup a Grafana/InfluxDB stack?
EagleTrooper — Today at 8:27 PM
Already have it setup (Background in IT and Cloud Network Engineering).
Sweetwater.I — Today at 8:27 PM
u can see our dashboard here if u wanna see what cavmetrics extension is outputting.
https://metrics.7cav.us/d/NED-gV3Mz/arma3?orgId=1&refresh=10s
Jarvis — Today at 8:28 PM
It's basically just arma -> influx -> grafana
Sweetwater.I — Today at 8:28 PM
but yeah, influxdb+grafana is what we do
Jarvis — Today at 8:28 PM
The cavmetrics addon you see is the arma extension
EagleTrooper — Today at 8:28 PM
Yep understood the workflow and that was very clear. I believe the piece im missing or dont understand is the dll creation / implementation
Jarvis — Today at 8:28 PM
If you know influx/grafana, you're 2/3rds of the way there
Just git clone the cavmetrics repo
EagleTrooper — Today at 8:29 PM
I believe it was the Arma-Influx?
That was the piece that i was not clear on. Unless i was misunderstanding it still required a compiled DLL
Jarvis — Today at 8:29 PM
the a3_influx dll is inside of the git repo
so == a DLL but linux
we run our servers on linux
EagleTrooper — Today at 8:30 PM
Unfortuantly it looks like its a .so
Sweetwater.I — Today at 8:30 PM
use the arma-influx repo to build the extension
EagleTrooper — Today at 8:30 PM
Yeah we have windows :/
Sweetwater.I — Today at 8:30 PM
cavmetrics is what we called the packaged extension.
on the repo
Jarvis — Today at 8:30 PM
https://github.com/7Cav/Arma-Influx
GitHub
GitHub - 7Cav/Arma-Influx: Arma Extension for sending metrics to In...
Arma Extension for sending metrics to InfluxDB. Contribute to 7Cav/Arma-Influx development by creating an account on GitHub.
Just compile that for dll
it's an arma ext written in go
Liber.N — Today at 8:31 PM
Cavmetrics is an arma addon thats calls to arma influx extension
Jarvis — Today at 8:31 PM
you'll need to change the makefile on that repo tho
EagleTrooper — Today at 8:32 PM
does it need to be labeld armago? or a3influx?
If that is what your referring to then it appears i do have an understanding of it and something else is missing outside of my imediate understanding and may not have anything you can provide input on. I will review the implementation again and see if I can get any further.
I do appreciate the input and help.
Jarvis — Today at 8:35 PM
no probs, it's a long road but found it worth it in the end
https://metrics.7cav.us/
Specifically - https://metrics.7cav.us/d/NED-gV3Mz/arma3?orgId=1&refresh=10s
EagleTrooper — Today at 8:36 PM
I will take a look! Keep on Keeping on and again I appreciate the friendly response!
Jarvis — Today at 8:36 PM
You'll need to update these for your influx db host - https://github.com/7Cav/cav_metrics/blob/dev/%40CavMetrics/addons/CavMetrics/functions/fn_send.sqf#L9-L12

View 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 {};
};
};
};

View 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];
};
};
};

View File

@@ -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;
};
};
};

View 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];
};
};

View 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
View 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;

View File

@@ -0,0 +1 @@
# RangerMetrics based off of CAV-Metrics