Video Screencast Help

Custom Inventory on Mac with Python

Created: 13 Sep 2011 • Updated: 13 Sep 2011
Language Translations
Dishwishy's picture
0 0 Votes
Login to vote

This article is a high-level introduction to using custom inventory with the Mac agent for Altiris, taking you from data class creation to script execution. I will also attach the sample python script as well for reference.

1)      First, we are going to need to define our data classes on the NS (Settings>All Settings>Discovery and Inventory>Inventory Solution>”Manage Custom Data Classes”). Before you Add your attributes, you’ll need to know what you want to name the columns (fields) that our script is going to return. In this example I know my script is going to output two fields, the application name (Name), and the application version (version). Also make sure you enable the “Allow Multiple Rows from a single computer resource” option as it’s difficult to enable this after.

2)      Next we need to create the script that is going to generate output for the Unix custom inventory binary to consume and forward on to the NS. For this we are going to use python, why, because it’s awesome and happens to have a library that supports plists to make getting the data much easier. First go to “Manage>Jobs and Tasks, right click a folder and select the “New>Task” option (feel free to place this in a custom folder if you like as well, just to keep things organized).

Select the Run Script Task and name it something like “Mac custom app inventory” and choose “Python Script” as the script type. Then paste in the contents of this script file and click “Ok” to save.

3)      Now that we have the task, let’s take it a step further and “embed” this into a policy so we can have it execute autonomously on the client side. To do this we are actually going to need to create a “Managed Software Delivery”, so go to “Manage>Policies>Software>Managed Software Delivery”. Right click the Managed Software Delivery folder and select “New>Managed Software Delivery”. From there, give it an identifiable name and then click the “Add” button and select “Task” from the drop down menu. You should be presented with a list of tasks, select the task that matches the Name of the task we created earlier (Mac Custom App Inventory, in this example).

4)       Once that is set, expand the “Applied to” section and select which machines you want this policy to run on. Then set a schedule, and since this is a task with no actual software being installed we will use the “Compliance” section of the schedule to determine how often we want to send this inventory up (in this example 5am every Wednesday). Then for the “remediation” section leave it as “Immediate” from the dropdown. Finally, save the policy, enable it, and wait for that table to populate. NOTE: On the database side it should be stored under Inv_<name of the data class you created>, so in the case the table is “Inv_Mac_App_List”.

 

The python script is attached to this article as a plist_final.zip file.