TROUBLESHOOTING: Upload a Specified File or Folder - Mac/Linux (1.0)
Log In or Register to download the BES file, and more.

0 Votes

Versioning - This is the latest version.

1TROUBLESHOOTING: Upload a Specified File or Folder - Mac/Linux (1.0)11/17/2022 8:26:42 AM
2TROUBLESHOOTING: Upload a Specified File or Folder - Mac/Linux (1.0)11/17/2022 1:39:40 PM

Description

TROUBLESHOOTING:  Upload a Specified File or Folder - Mac/Linux (1.0)

Description

This task will compress the file or folder with the native tar.gz for Mac and Linux machines.  It will then upload the resulting compressed file to the Bigfix server. 

IMPORTANT: To specify a folder, leave a trailing slash on the file name prompt.  To upload the logs from the Bigfix client folder from a Linux machine, for instance, use this:

  • /var/opt/BES Client/__BESData/__Global/Logs/

A single file needs a full path, this sample will upload the realy log file from a Linux-based relay server:

  • /var/log/BESRelay.log

Deployment Notes

  • Run this only when needed.
  • This fixlet will exit with code 413 if the combined file size of the target files is over 100MB and will exist with a code 404 if the file or folder does not exist on the endpoint.  .
  • To locate the compressed files, you must have access to the file system of the Bigfix root server and know the computer ID of the computer that you want to find the files for.  The filename ends in fileupload.cab or fileupload.tar.gz and the path for each computer ID will look like this:

<Bigfix server install folder>\UploadManagerData\BufferDir\sha1\<last two digits of computer ID>\<full computer ID>

  • As an alternative to digging into the UploadManagerData folder structure, there is an accompanying task named "TROUBLESHOOTING: File or Folder Uploads Monitor" which can be used to monitor for file uploads on the root server that are a result of this task and then move them to a specific folder for easier consumption.
  • This fixlet has a hardcoded secure parameter to prevent targeting endpoints by property, this reduces the risk of an unintentional DDoS on your infrastructure.  To disable this behavior, make a copy of this fixlet and remove the script element below this text.

Supported Platforms

All versions of Mac and Linux currently supported by the BigFix client.


Version and Release Info

1.0.0 -- Initial Version


Property Details

ID26977
StatusBeta - Preliminary testing ready for more
TitleTROUBLESHOOTING: Upload a Specified File or Folder - Mac/Linux (1.0)
DomainBESC
CategoryBigFix AVP
SourceInternal
Source Release Date3/10/2019 12:00:00 AM
KeywordsTroubleshooting Uploads
Is TaskTrue
Added by on 11/17/2022 1:39:40 PM
Last Modified by on 11/17/2022 1:39:40 PM
Counters 2618 Views / 11 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 2 fixlets   * Results in a true/false
Show indented relevance
/* MAC OR LINUX */ mac of operating system OR name of operating system as lowercase contains "linux"

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
action log all

//* ====================================================================================================>
//*
//* DESCRIPTION AND NOTES
//*
//* - This task will upload speciifed files or folders to the root server.
//*
//* ====================================================================================================>


//* ====================================================================================================>
//*
//* SET SOME PARAMETERS
//*
//* - These parameters can be used to control the behavior of the action
//*
//* ====================================================================================================>

action parameter query "FilePath" with description "Please enter full path to file or folder. Leave a trailing trailing / for Mac/Linux to indicate folder upload mode."
parameter "Exportfolder" = "{data folder of client as string & ("/FileUploader/")}"
parameter "maximumfilesizeMB" = "100"

//action uses wow64 redirection false

//create working directory
folder create "{parameter "Exportfolder"}"

//enter single or multiple file copy - we don't need different logic for those on mac/linux
//check sizing
if {sum of sizes of files of folder (parameter "FilePath")|0/1024/1024 > parameter "maximumfilesizeMB" as integer}
        exit 413
//check existance
    elseif {if ((character (length of it - 1) of it) of parameter "FilePath" = "/") then (not exists folder (parameter "FilePath")) else (not exists file (parameter "FilePath"))}
        exit 404
endif
//remove old stuff
    folder delete "{parameter "Exportfolder" & "temp"}"
//fresh working folder
    folder create "{parameter "Exportfolder" & "temp"}"
//copy file or folder to BigFix temp folder
    wait cp -R "{parameter "FilePath"}" "{parameter "Exportfolder" & "temp"}"

    parameter "timestamp" = "{(((month of it as two digits & "-" & day_of_month of it as two digits & "-" & year of it as string) of date(local time zone) of it & "_" & (two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now)}"

//compress and remove directory structure - this is just the option I chose since I think it extracts cleaner
    wait tar -zcvf "{parameter "Exportfolder"}{(computer name as lowercase & "_" & parameter "timestamp" & "_fileupload.tar.gz")}" -C "{parameter "Exportfolder" & "temp"}" .

//save existing ArchiveManager settings
parameter "prevOperatingMode" = "{if (exists setting whose (name of it = "_BESClient_ArchiveManager_OperatingMode" and exists value of it) of client) then value of setting "_BESClient_ArchiveManager_OperatingMode" of client else "0"}"
parameter "prevMaxArchiveSize" = "{if (exists setting whose (name of it = "_BESClient_ArchiveManager_MaxArchiveSize" and exists value of it) of client) then value of setting "_BESClient_ArchiveManager_MaxArchiveSize" of client else "52428800"}"

//limit upload results to 100MB and start the upload asap.
setting "_BESClient_ArchiveManager_MaxArchiveSize"="109715200" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_OperatingMode"="2" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_FileSet-AVPFileUpload"="{parameter "Exportfolder"}{(computer name as lowercase & "_" & parameter "timestamp" & "_fileupload.tar.gz")}" on "{parameter "action issue date" of action}" for client
archive now

//restore previous ArchiveManager settings
setting "_BESClient_ArchiveManager_OperatingMode"="{parameter "prevOperatingMode"}" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_MaxArchiveSize"="{parameter "prevMaxArchiveSize"}" on "{parameter "action issue date" of action}" for client

//cleanup after ourselves
folder delete "{parameter "Exportfolder" & "temp"}"
delete "{parameter "Exportfolder"}{(computer name as lowercase & "_" & parameter "timestamp" & "_fileupload.tar.gz")}"
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!