Mac Management Group

 View Only

Task Execution and Historical Information for Unix, Linux and Mac Managed Clients 

Apr 13, 2015 11:30 AM

The Unix, Linux and Mac (ULM) Client Task Agent does the following for a Unix Shell Run Script task:

1.     Create a temporary file containing the text of the script at path: /opt/altiris/notification/basetasks/var/script.xxxxxxx/script. 

2.     Change file permissions: chmod 0500 <file>

3.     Change file owner: chown user <file> (only if it should run under a specific user account)

4.     Set the proper environment variables (not sure if this is from aex-env or something specific to task management)

5.     Run the script. In the case of applescript, the command is: /usr/bin/osascript "<file>". 

6.     Remove the temporary ‘script’ file and ‘script.xxxxxx’ directory. 

7.     Update history and information files. 

Note that the '.../basetasks/var' directory will be created by this task execution process, if needed.

The following shows the directory and file listings and the actual contents of the temporary ’script’ file. In this case, the script contained a 30 second sleep command to allow for viewing the this file listing and its contents. 

======

pwd
/opt/altiris/notification/basetasks/var
 

ls -al
total 0
drwxr-xr-x  3 root  admin   102B Apr  9 23:22 script.6Krcp4  


cd script.6Krcp4/


ls -al
total 8
-r-x------  1 root  admin    49B Apr  9 23:22 script  

cat script 
#!/bin/sh
echo 'Starting'
sleep 30
echo 'Ending'

================

Task history and Information Files on the Client: 

Information on the task execution is stored in historical files on the client. Files containing task information are: Taskinfo.ini and instance_<InstanceGuid>.ini. The path for this information is: 

/opt/altiris/notification/ctagent/var/history/{TASKGUID.EN_US}/

The ‘Taskinfo.ini’ file contains the task name, date of last update, etc., as shown here:

[Task]
last_update=1428643399
name=Mac - Find Task Files on Client
handler=Altiris.ScriptTaskAgent
max_run_time=01:00:00

Each time a task runs, an ‘instance’ of that task’s execution is created. Each instance will have it’s own ‘instance_<InstanceGuid>.ini’ file. The most valuable information in these files is the task execution date and the ‘success’ code. 

Sample instance* file for a successful task:

[TaskInstance]
status=Complete
last_change_utc=2015-04-10 05:23:19.112662
parent={5C1D99B0-A9AA-4808-817E-4E4DDB579320}
job={00000000-0000-0000-0000-000000000000}
queue_time_utc=2015-04-10 05:22:49.069684
type=ts
run_time_utc=2015-04-10 05:22:49.071636
complete_time_utc=2015-04-10 05:23:19.112996
success=true
return=0
ex_type=
ex_text=

Sample instance* file for a task that failed: 

ex_type=Altiris.ClientTaks.ExecutionException
ex_text=Script failed by existing with a non-zero return code

Related Client Commands

Following are ULM client task agent commands that may be helpful: 

aex-cta ts:

Shows if the client task agent is registered to a task server

aex-cta register 

Forces registration of the ctagent to a task server

aex-cta refresh 

Checks the task server for new tasks to run

aex-cta list 

Lists task history in its most basic format

aex-cta list –show-task-id

Lists task history with task guid, which should match the task history directory guid, from above. 

aex-cta list <task guid>

Shows task instances for the specified task

aex-cta list <task guid> <instance guid>

Shows summary information for the specified task instace. This should match the corresponding ‘instance_<instanceguid>.ini file contents. 

A script is attached the performs various ‘aex-cta’ commands and outputs specific data. (It’s a bit rough and could be improved by someone with more knowledge of unix shell scripting. If you do improve it, please post it on connect.symantec.com so everyone can benefit. Thanks. )

ULM Task Information in the Symantec_CMDB

Following are a few relationships among the various task-related tables: 

Item.Guid                           -> ItemVersions.ItemGuid
Item.Guid                           -> ItemClass.Guid
ItemClass.Guid                      -> Class.Guid
ItemVersions.VersionGuid            -> TaskInstances.TaskVersionGuid
TaskInstances.ResourceGuid          -> vcomputer.Guid
TaskInstances.ResourceGuid          -> inv_aex_ac_identification._ResourceGuid
TaskInstances.TaskInstanceGuid      -> TaskInstanceStatus.TaskInstanceGuid 
TaskInstances.TaskInstanceGuid      -> TaskInstanceResults.TaskInstanceGuid

 

The following SQL query will gather information from the Symantec_CMDB on the NS/SMP server. It also shows the relationships among the related tables in the database.

 

 

-- Find tasks by class type; show instances, versions, end times and statuses

Declare @TaskName varchar(255)

Declare @ComputerName varchar(255)

Set @TaskName = '%'

Set @ComputerName = '%'

select        vc,guid 'Client GuUID'

            , vc.name 'Client Name'

            , c.type 'Class Type'

            , i.guid 'Task Guid'

            , i.name 'Task name'

            , ti.TaskInstanceGuid 'Instance Guid'

            , iv.Version 'Instance Version'

            , tir.endtime 'Instance EndTime'

            , case tis.instancestatus

                  when 0 then 'Not started'

                  when 1 then 'Started'

                  when 2 then 'Completed'

                  when 3 then 'Failed'

                  when 4 then 'Stop Requested'

                  else 'unknown'

              end 'Instance Status'

  from ItemClass ic

  join class c in ic.guid = c.guid 

  join item i on i.guid = ic.guid

  join itemversions iv on iv.itemguid = i.guid

  join taskinstances ti on ti.taskversionguid = iv.versionguid

  join vcomputer vc on ti.resourceguid = vc.guid

  left join taskinstancestatus tis        on tis.taskinstanceguid = ti.taskinstanceguid

  left join taskinstanceresults tir on tir.taskinstanceguid = ti.taskinstanceguid

  where [classGuid] in 

      ('3CB6424C-6B59-4C19-8ACE-1E12D265CEC3', -- Altiris.Inventory.InventoryTask

      '4F1B9B32-B5C6-4D83-8992-F73582217AAC')  -- Altiris.TaskServerTasks.ScriptTask.ScriptTask

    and i.name like @TaskName

    and vc.name like @ComputerName

  order by i.name, vc.name, iv.version, tir.endtime

  ************************************************************

Class types, if desired for the above query, can be found using the following SQL query:

 

 ************************************************************

-- Find task class type

DECLARE @TaskName varchar(255)

SET @TaskName = '%custinv samplens7%' 

select i.name 'TaskName', c.guid 'ClassGuid', c.type 'ClassType'

      from item i

      join itemclass ic on ic.guid = i.guid

      join class c on c.guid = ic.classguid

      where name like @TaskName

  ************************************************************

 

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
txt file
gettaskinfo.txt   2 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.