AAC::Clean OldActions
Log In or Register to download the BES file, and more.

0 Votes

Description

This Fixlet prompts for a password that will be required to access the REST API used to run a query and delete expired actions

The password is the password of current operator.

You can exclude actions from deletion defining a regular expression that matches (case insensitive) the titles you would like to exclude (like ".*do not delete.*|.*keep this.*") 

Server name can be used to bypass certificate check (will block the login action)

The list of deleted actions will be retained in directory "<Client folder>\HCL\" in a file named "<ExecutionTimestamp>_OldActions.xml"
 


Written by Andrea.Capasso@hcl.com using documentation from BigFix Wiki for parametrized fixlets 

NOTE:Currently tested on Windows Server only - prepared for Linux


Property Details

ID26853
StatusAlpha - Code that was just developed
TitleAAC::Clean OldActions
DomainBESC
CategoryUtility
Sourceandrea.capasso@hcl.com
Source Release Date8/17/2017 12:00:00 AM
KeywordsBigFix Maintenance
Is TaskTrue
Added by on 3/29/2021 4:56:35 PM
Last Modified by on 3/29/2021 4:56:35 PM
Counters 138 Views / 2 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

Used in 95 fixlets and 5 analyses   * Results in a true/false
Show indented relevance
exists main gather service

Actions

Action 1 (default)

Action Link Click here to Delete the actions expired or closed older than the given days.
Script Type BigFix Action Script
action parameter query "User" with description "Leave empty for your operator ID, use '*' for all operators" with default "*"
action parameter query "Days" with description "Enter the number of days to retain expired/stopped actions: " with default "3650"
action parameter query "Exclude" with description "Enter a regex expression that appear in the title to exclude actions from deletion: " with default ".*do not delete.*|.*Policy.*"
action parameter query "Server" with description "BigFix server (empty to use current): " with default ""

action log all
if {parameter "User" = "" }
parameter "UserFilter"="{"and name of issuer of it = %25%2522" & (concatenation "" of values of headers "action-issuer-name" of action) & "%25%2522"}"
elseif {parameter "User" = "*" }
parameter "UserFilter"=""
else
parameter "UserFilter"="{"and name of issuer of it = %25%2522" & (parameter "User") & "%25%2522"}"
endif

if {parameter "Server" = "" }
parameter "BFServer"="{host name of root server}"
else
parameter "BFServer"="{parameter "Server"}"
endif

if {windows of operating system}
parameter "sep"="\"
parameter "ServerFolder"="{value "EnterpriseServerFolder" of key "HKLM\SOFTWARE\BigFix\Enterprise Server" of registry}"
parameter "BFAPIEXE"="{parameter "ServerFolder" & "IEM CLI\iem.exe"}"
else
parameter "sep"="/"
parameter "ServerFolder"="{"/opt/BESServer/"}"
parameter "BFAPIEXE"="{parameter "ServerFolder" & "IEM CLI/iem"}"
endif

folder create "{pathname of storage folder of client & parameter "sep" & "HCL"}"
parameter "TargetFolder"="{pathname of folder "HCL" of storage folder of client & parameter "sep"}"
parameter "ExecutionTimestamp"="{(((year of it as string & month of it as two digits & day_of_month of it as two digits) of Current Date ) & "T" &((two digit hour of it & two digit minute of it) of current time_of_day))}"

action log commands
appendfile "{parameter "BFAPIEXE"}" login -q --server={parameter "BFServer"} --user={concatenation "" of values of headers "action-issuer-name" of action} --password="{parameter "RDPW"}"
action log all
appendfile "{parameter "BFAPIEXE"}" get query --relevance "(id of it, state of it, name of it, name of issuer of it, now-Time Issued of it) of BES Actions whose ( exists State of it and (now - (Time Issued of it) > {parameter "Days"} * day) and state of it != %%22Open%%22 and name of it != case insensitive regex %%22.*{parameter "Exclude"}.*%%22 {parameter "UserFilter"})" --outFile "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "OldActions.xml"}"
delete "run.cmd"
move __appendfile run.cmd
if {windows of operating system}
    wait run.cmd
else
    wait sh run.cmd
endif
delete run.cmd

action log commands
appendfile {concatenation "%0d%0a" of (parameter "BFAPIEXE" & " delete action/" & concatenation "" of node values of first child of it) of child nodes whose (node name of it = "Answer" and node value of attribute 0 of it = "integer") of child nodes whose (node name of it = "Tuple") of child nodes whose (node name of it = "Result") of child node 0 of child node 1 of xml document of file (parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "OldActions.xml" )}
action log all
delete "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.cmd"}"
move __appendfile "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.cmd"}"

if {windows of operating system}
    wait "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.cmd"}"
else
    wait sh "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.cmd"}"
endif

delete "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.cmd"}"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.

Action 2

Action Link Click here to Create a list of action IDs to delete in file "<Client folder>\HCL\<ExecutionTimestamp>_actionIDList.txt"
Script Type BigFix Action Script
action parameter query "User" with description "Leave empty for your operator ID, use '*' for all operators" with default "*"
action parameter query "Days" with description "Enter the number of days to retain expired/stopped actions: " with default "3650"
action parameter query "Exclude" with description "Enter a regex expression that appear in the title to exclude actions from deletion: " with default ".*do not delete.*|.*Policy.*"
action parameter query "Server" with description "BigFix server (empty to use current): " with default ""

action log all
if {parameter "User" = "" }
parameter "UserFilter"="{"and name of issuer of it = %25%2522" & (concatenation "" of values of headers "action-issuer-name" of action) & "%25%2522"}"
elseif {parameter "User" = "*" }
parameter "UserFilter"=""
else
parameter "UserFilter"="{"and name of issuer of it = %25%2522" & (parameter "User") & "%25%2522"}"
endif

if {parameter "Server" = "" }
parameter "BFServer"="{host name of root server}"
else
parameter "BFServer"="{parameter "Server"}"
endif

if {windows of operating system}
parameter "sep"="\"
parameter "ServerFolder"="{value "EnterpriseServerFolder" of key "HKLM\SOFTWARE\BigFix\Enterprise Server" of registry}"
parameter "BFAPIEXE"="{parameter "ServerFolder" & "IEM CLI\iem.exe"}"
else
parameter "sep"="/"
parameter "ServerFolder"="{"/opt/BESServer/"}"
parameter "BFAPIEXE"="{parameter "ServerFolder" & "IEM CLI/iem"}"
endif

folder create "{pathname of storage folder of client & parameter "sep" & "HCL"}"
parameter "TargetFolder"="{pathname of folder "HCL" of storage folder of client & parameter "sep"}"
parameter "ExecutionTimestamp"="{(((year of it as string & month of it as two digits & day_of_month of it as two digits) of Current Date ) & "T" &((two digit hour of it & two digit minute of it) of current time_of_day))}"

action log commands
appendfile "{parameter "BFAPIEXE"}" login -q --server={parameter "BFServer"} --user={concatenation "" of values of headers "action-issuer-name" of action} --password="{parameter "RDPW"}"
action log all
appendfile "{parameter "BFAPIEXE"}" get query --relevance "(id of it, state of it, name of it, name of issuer of it, now-Time Issued of it) of BES Actions whose ( exists State of it and (now - (Time Issued of it) > {parameter "Days"} * day) and state of it != %%22Open%%22 and name of it != case insensitive regex %%22.*{parameter "Exclude"}.*%%22 {parameter "UserFilter"})" --outFile "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "OldActions.xml"}"
delete "run.cmd"
move __appendfile run.cmd
if {windows of operating system}
    wait run.cmd
else
    wait sh run.cmd
endif
delete run.cmd

action log command
appendfile {concatenation "%0d%0a" of (concatenation "" of node values of first child of it) of child nodes whose (node name of it = "Answer" and node value of attribute 0 of it = "integer") of child nodes whose (node name of it = "Tuple") of child nodes whose (node name of it = "Result") of child node 0 of child node 1 of xml document of file (parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "OldActions.xml" )}
delete "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.lst"}"
move __appendfile "{parameter "TargetFolder" & (parameter "ExecutionTimestamp") & "_" & "actionIDList.lst"}"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!