Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Introduction to Custom Inventory in Notification Server 7.0

Created: 20 Oct 2008 | 2 comments
Language Translations
dougj's picture
+1 1 Vote
Login to vote

Notification Server 7.0 introduces major enhancements and changes to the custom inventory process. This article provides a preview of the process, as of the date of this article.

NOTE: The purpose of this article is to give a sneak peak. UI elements, help or label text, may be changed in the interim between now and the release. This article provides no guarantees or promises and what will be delivered in the final release.

Introduction

Custom Inventory in Notification Server 7.0 is cross-platform and script-based. In NS7, the same console screens are used to create and configure custom inventory across all platforms - Windows, Unix, Linux and Macintosh. Depending on the platform and installed components, scripts can be written in any of the following scripting languages:

  • Applescript
  • Command script
  • JavaScript
  • Perl
  • PowerShell
  • Python
  • Unix Shell script
  • VBScript

Prior to NS7, the custom inventory dataclass and table could be created by the first incoming custom inventory NSE containing the schema and data for a given dataclass. Now, in NS7, custom Inventory requires that the data class be created on the Notification Server prior to deploying the custom inventory task to clients. These data classes are referred to as 'custom data classes'.

The basic process of creating a custom inventory task is:

  1. Create the data class in the NS console
  2. Create the task with scripting logic in the Notification Server console.
  3. Create a report to view the results of custom inventory. (This document will not discuss report creation.)
Note: Custom Inventory source xml/cit files from Inventory for Windows 6.x can still be used in Inventory for Windows 7.0. This will be documented and previewed in a separate article.
Note: The syntax for Unix shell scripts in 7.0 is identical to the syntax in 6.x, with the addition of an inclusion of a helper shell script.

Further documentation is available by browsing on an NS7 server to <installdrive>:\Program Files\Altiris\Documentation\Web\en\Inventory\help\index.html. The documentation now features a very nice search utility. Searching for 'custom inventory' will return several related pages.

Create a Custom Data Class

  1. In the NS7 Console, click Settings, All Settings, . Then, expand Discovery and Inventory, Inventory Solution, Manage Custom Dataclasses.
  2. Click on '* New Dataclass' and enter a Name and Description. In this example, I will be selecting data from the Win32_UserAccount class and creating attributes for the following three fields: Name, Disabled and SID.
  3. Highlight the new dataclass and click 'Add attribute'. Enter a name and select or enter the appropriate Data Type, Maximum size, Key option and Data required option.
  4. Repeat this for each attribute/column you wish to collect data for.
  5. A completed custom dataclass would appear as shown here.
  6. Note the option to 'Allow multiple rows from a single computer resource'. This is helpful, and necessary, as is the case with a User report, for example, where multiple users can be reported on each computer.
  7. When you are done adding attributes, click 'Save changes' at the bottom of the screen.
  8. 8. The GUID for this dataclass will be required to be entered in the script. To find the guid, click on a dataclass name, then click the 'Details' button, which is the little hand between the 'New dataclass' button and the red 'X' button. Make a note of the guid value and save it for later use. (Note: this is a Windows-only requirement. Unix, Linux and Macintosh scripting do not have this requirement.)

Create a Custom Task and Script for Windows

The easiest way to create a new custom inventory task is to clone a sample. The sample already contains the required code for a WMI query. You will only need to add your own logic to gather the data you require and to populate the attribute variables in the script.

For this example, we will walk through the steps required to create a new task and manually enter the custom inventory code. This code can be copied from a sample, or previously existing, custom inventory task prior to creating this new task.

  1. In the NS7 Console, click on 'Manage' > 'Jobs and Tasks' and click on the 'Jobs and Tasks' menu entry in the left-hand pane.
  2. Click on 'Create a new job or task' in the right-hand pane. A new window will open.
  3. Scroll to the bottom of the left-hand pane in the new window and click on 'Run Script' to select the appropriate type of task.
  4. Enter an appropriate name for this task in top text field.
  5. Select the desired script type. Again, Custom Inventory in NS7 can run AppleScript, Command Script, JavaScript, Perl, Powershell, Python, Unix shell scripts or VBScript.
  6. Enter the following code. Similar code will already exist if you cloned the task. This task performs the following:
    1. Creates a wmi object, executes a wmi query and stores the result set.
    2. Creates an Altiris NSE object.
    3. Creates an Altiris 'Inventory data block' and associates it with a specific custom data class.
    4. Loops through each row in the result set and populates each row of the result set into a row in the datablock.
    5. Processes and sends the NSE to the Notification Server.
      On Error Resume Next
      
      'Create instance of Wbem service object, connect to namespace and run wmi query
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set objCIMObj = objWMIService.ExecQuery("select * from win32_useraccount")
      
      'Create instance of Altiris NSE component and set the header data of the NSE
      dim nse
      set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
      
      ' Please don't modify this GUID. This is the 'Inventory Capture Item'. 
      nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
      nse.Priority = 1
      
      'Create Inventory data block. 
      'Change the following guid. This is the guid of associated custom inventory dataclass.
      dim objDCInstance
      set objDCInstance = nse.AddDataClass ("{3ce8a021-ffaa-4467-a01a-872e0fcabbdf}")
      dim objDataClass
      set objDataClass = nse.AddDataBlock (objDCInstance)
      
      ' objCIMObj contains the resultset from the wmi query
      For each objInfo in objCIMObj
      
      'Add a new row and set column values
      dim objDataRow
      set objDataRow = objDataClass.AddRow
      
      objDataRow.SetField 0, objInfo.Name
      objDataRow.SetField 1, objInfo.Disabled
      objDataRow.SetField 2, objInfo.SID
      
      Next
      
      nse.SendQueued
      
      
  7. Note that custom inventory in NS7 includes the ability to add 'tokens', or pre-defined variables, to scripts. The available tokens are shown below. It is possible to create new,
  8. It is also possible to create new tokens. The values can be selected from the Symantec_cmdb database, as shown below. '%COMPUTERID% is a predefined token that contains the client's guid value.
  9. The advanced tab contains settings for authentication, windowing of the client task, and task control.
  10. Click 'Save Changes' to save the script and associated settings. At this point, the task is ready to run.
  11. The 'Task Status' section of this screen contains scheduling and other options. Scheduling is partly controlled by core NS functionality and partly by Inventory Solution functionality.
    1. Quick Run - When this option is selected, a combo list box is presented. The desired client computer name can be entered. Also, a drop-down list of available resources will be populated and the desired resource can be chosen from the list. Selecting a resource and clicking 'run' will initiate the task on the selected client immediately, depending on maintenance windows, etc.
    2. New Schedule - This is a standard scheduling window. A new schedule will be associated with the current task, allow for selection of specific resources, and can be ran 'Now' or on a specified schedule that has the option to repeat at a specified frequency. There is also an option to override maintenance windows.
  12. Other features in the 'Task Status' section are the task details screen, delete task entries, task history view, grouping and search options and the refresh button.
    1. Details - This is the little hand icon. It shows details of when the highlighted task ran, if it succeeded, etc.
    2. Delete - The red 'X' allows you to delete highlighted entries in the task status section.
    3. View - Allows for seeing current or archived entries.
    4. Group By - Provides a drop-down list for grouping entries to see a higher-level view.
    5. Search - Allows for searching for specific entries.
    6. Refresh - Reloads entries and status of entries. The down-arrow allows for setting an automatic refresh interval.

Create a Custom Task and Script for Unix, Linux or Macintosh

Creating a Unix or Linux custom inventory task is exactly the same as creating a custom inventory task for Windows except for the scripting language and the actual code, or logic, used in the script. The Unix and Linux custom inventory in NS7 was built to facilitate the re-use of custom inventory logic from an NS6 environment.

  1. Follow the same steps for creating a new task or simply browse to Jobs and Tasks -> Samples -> Custom ->Custom Inventory - PS List
  2. Right-click on the above task and select clone.
  3. Modify the code as required for your specific requirements.
  4. After saving the task, it may be helpful to move it to a more appropriate folder in the menu tree. Simply open the desired location in the menu tree and drag the task to that location.
  5. The task can be ran and scheduled the same as for any other task in the NS console.

    Following is a sample of the shell script code required for a Unix or Linux custom inventory.

    		
    . `aex-helper info path -s INVENTORY`/lib/helpers/custominv_inc.sh
    #
    # Sample script for custom inventory
    # The first line of code should be always included at the begin of the script
    # Actual script for collecting inventory data begins after the following label:
    # SCRIPT_BEGINS_HERE
    #!/bin/sh
    echo UNIX_PS_List
    echo "Delimiters=\" \" "
    echo string20 string20 string20 string256
    echo PID Terminal Time Command
    if [ "`uname -s`" = "Darwin" ] ; then
    	ps -ax | sed -e "1d" | awk '{print $1 " " $2 " " $4 " " $5 " " }'
    else
    	ps -e | sed -e "1d" | awk '{print $1 " " $2 " " $3 " " $4 " " }'
    fi
    
    

This code does the following:

  1. Include a file required to format the data.
  2. Specify the data class.
  3. Specify delimeters for use in parsing the data returned from the command to be executed.
  4. Specify the datatypes and lengths of each column.
  5. Specify the column names. Note: this is only required when the command to be executed does NOT already include column headings.
  6. Run the desired command. In this case, we check for and run appropriate platform-specific commands.

Comments 2 CommentsJump to latest comment

SandyF's picture

Does the client have to already have the ability to run the script or does the server send down the exe/dll that it will need to use to run the script?

Sandy Fletcher
IT Asset Management Consultant
http://www.velocegroup.com

0
Login to vote
dougj's picture

The aexnsevent.dll file must exist and be properly registered on the client in order for custom inventory 7.x to work. This dll is installed as part of the agent/solution installation. Without it, the vbscript will fail as it wont be able to create the nse-related objects and use the object's methods, etc.   Also, if the agent isn't installed, no data will be sent to the NS.

cscript/wscript already exist on windows machines, so the ability to kick off a vbscript already exists on windows machines. 

Is that what you're asking? 

0
Login to vote