How do I get the number of times that an action has been applied or failed or both?

I feel like it should be possible to get the number of times an action has been tried and failed as well as how many times it has succeeded. It should also then be possible to get the number of times it has been attempted in total. (successes + failures)

Ideally, I’d like to be able to get this info from both the context of the action running in actionscript, as well as through session relevance.

This appears to be relevant info through session relevance:

(apply count of it, retry count of it) of results of bes actions whose(123 = id of it)

This should be the client relevance using relevance substitution during action execution:

{active count of active action}
{first active count of active action}

These values do seem to correspond to one another, but they don’t seem to actually give the details on number of attempts correctly, particularly when there are multiple successes and failures of the same action over time.

Then there is also this option:

(it as string) of rows of statements "SELECT TotalActiveCount,ActiveCount FROM ACTION_STATE_HISTORY WHERE ActionID=123" of sqlite databases of files "ActionHistory.db" of folders "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\__Global"

This gives multiple results in some cases, seemingly when the action has run multiple times.

Here is another option to get the total number of attempts:

This option requires renaming the current log file to something like 99999999.log because it is open for writing in the client already. This renaming might not be needed if evaluated through the console, but I’m not certain.

number of lines containing "ActionLogMessage: (action:123) ending action" of files whose(12 = length of name of it AND exists lines of it) of folders "Logs" of folders "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\__Global"

This is the only option that seems accurate and sensible, as far as the total number of successes+failures.

None of these options seem to give what I am looking for, but they seem like the closest I’m going to get.

1 Like

I presume in your testing this was a constant __BESData and site folder and that the action never expired or anything in the test? If the action data is removed then the client will not remember much about it so while the DB might remember something different, the client could get disconnected in that way.

As to the numbers, are they off by a lot with the inspectors? Are they off by one always or?

1 Like

I created an action that was set to reapply every 15min while relevant, and retry on failure after 10 minutes. I set both to 8 times. It was set to expire after 1 week.

I created an IF/THEN that would cause it to fail about 1/2 of the time. (run actionscript based upon seconds since subscribe time mod 2)

// FORCE FAILURE ~1/2 of the time:
if{ 0 = (now - minimum of subscribe times of sites) / second mod 2 }
   waithidden echo this shouldn't work on windows

Then I looked at the output of the relevance substitution I was writing to a file using a modified version of this:

The numbers seem to be off by 1, until it fails and then succeeds, then the numbers seem to reset or something kind of like that. It had been attempted 10 times, but it said that it reapplied 6 times, seeming to no longer count the number of failures.

These are the final numbers I got before stopping the action:

active count of active action :  2
first active count of active action :  7

This implies that it ran 8 times (not 9) based upon how the numbers work after just 1 or 2 runs, but the actual attempted count was 11, based upon 11 occurrences of ActionLogMessage: (action:123) ending action in the log file.

I have a few use cases. One if for gathering metrics / usage of bigfix items.

Another is to have a unique ID for the current run of an action made up of the SourceFixletID_ActionID_RunCount where RunCount is Successes+Failures.

I’m currently working on automatically backing up BigFix content by exporting it with the REST API, then committing it to a GIT repo. I want the run count in the commit message because this will be an action that repeats indefinitely.

I believe once it “succeeds” before it “reapplies” it will reset the failures as they no longer matter. I’ll have to check though

Was the number 7 correct (or off by one as its running) for the reapplies?

1 Like

The 7 number does seem to be correct for the number of times it succeeded.