Client Management Suite

 View Only
Expand all | Collapse all

Custom Inventory Troubleshooting

Migration User

Migration UserMay 02, 2012 09:03 AM

  • 1.  Custom Inventory Troubleshooting

    Posted Apr 16, 2012 05:56 PM

    I have a custom inventory which reads some registry values and reports them. It is nothing terribly fancy and I used the sample inventory to get my vbscript started. M problem is it doesn't submit data from some computers. I had to reinstall the agent on a bunch to get it working but there are still a couple stragglers on which, even though the agent is reinstalled, I am not getting data. The policy which kicks off the inventory task "says" it ran successfully and if I create a new vbscript on the machine itself and paste the contents of the custom inventory script in it it will run successfully and submit data. It seems to me like an agent issue but NSI files no longer get created so I cannot really troubleshoot the script to see if it is running or not. Any ideas how to troubleshoot this?



  • 2.  RE: Custom Inventory Troubleshooting

    Posted Apr 16, 2012 10:42 PM

    Sounds like an account or privileges issue.  What account is used by your script?  Are you using that account to run the script when you do your manual test on a problem machine?



  • 3.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 07:13 AM

    It runs under the system account. The registry keys in question are in HKLM so permissions shouldn't be an issue as it runs on other computers fine. I suppose it could be just on these couple computers though.



  • 4.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 08:46 AM
    Is it using wmi? We have seen problems where wmi is broken. Can you post the script here?


  • 5.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 09:14 AM

    It does not use WMI and here is the script:

     

    Option Explicit 
    On Error Resume Next

    Const HKEY_LOCAL_MACHINE  = &H80000002

    Dim nse
    Dim objDCInstance
    Dim objDataClass
    Dim objDataRow
    Dim strKeyPath, strValue, oReg, WshShell

    strKeyPath = "SOFTWARE\Campbell\Server Info"

    'open registry provider
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

    'Try reading the key
    oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"function",strValue

    'Catch the error
    Select Case IsNull(strValue)
       'Error Code 0 = 'success'
       Case 0:
      'Create instance of Altiris NSE component
      set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
      
      ' Set the header data of the NSE
      ' Please don't modify this GUID
      nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
      nse.Priority = 1
      
      'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
      set objDCInstance = nse.AddDataClass ("{acf84c3b-bacd-46ac-b221-5a5de074f441}")
      set objDataClass = nse.AddDataBlock(objDCInstance)
      
      'Add a new row
      set objDataRow = objDataClass.AddRow
      
      'Set columns
      'Get function
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"function",strValue
      objDataRow.SetField 0, strValue
      
      'Get primary business owner
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"primary business owner",strValue
      objDataRow.SetField 1, strValue
      
      'Get primary it owner
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"primary it owner",strValue
      objDataRow.SetField 2, strValue
      
      'Get backup itowner
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"backup it owner",strValue
      objDataRow.SetField 3, strValue
      
      'Get backup business owner
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"backup business owner",strValue
      objDataRow.SetField 4, strValue
      
      'Get post-reboot procedure
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"post-reboot procedures",strValue
      objDataRow.SetField 5, strValue
      
      'Get pre-reboot procedure
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"pre-reboot procedures",strValue
      objDataRow.SetField 6, strValue
      
      'Get upinxhours
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"upinxhours",strValue
      if (isNumeric(strValue)) then
         objDataRow.SetField 7, strValue
      else
         objDataRow.SetField 7, "0"
      End If
      
                      'Get notes
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"notes",strValue
      if (isnull(strValue)) then
       objDataRow.SetField 8, ""
      else
       objDataRow.SetField 8, strValue
      end if

      'Get phase
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"phase",strValue
      if (isnull(strValue)) then
       objDataRow.SetField 9, ""
      else
       objDataRow.SetField 9, strValue
      end if

      nse.SendQueued
     Case Else:
      'do nothing
    End Select



  • 6.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 10:28 AM

    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

    That line is connecting to WMI.  You can still read reg values without WMI using Wscript.Shell.  I never use WMI, because you simply can't count on it ever working.



  • 7.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 10:37 AM

    Yes it does use WMI; I was thinking scripting language...am tired today...LOL

    I will look into wscript.shell and let you know what happens. Thanks for the tip. It shouldn't take long to change.



  • 8.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 11:29 AM

    OK I changed the script to use wscript.shell rather than WMI. I also added a bunch of wscript.echo commands to print the registry values during the script run so I can see what is going on. I can see it is retrieving the values I want as it outputs them to a command window and pauses (I put a sleep in there). So if I can see that the data I want is being returned we can rule out permissions and point the finger at the Altiris agent I think. Any other thoughts?



  • 9.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 12:01 PM

    I haven't done much with Custom Inventory in 7.x yet (working now to get our legacy 6.x working, and having results finally), but I know a risk you always took with using VBScript to build inventory .xml files directly was due to invalid characters in the input string, specifically: &, <, >, ", ' (maybe some others).  Not sure if the ObjDataRow.SetField method is "cleaning" the string to escape any XML-special characters or not.  Is the .nsi and/or .bak file being created on the "problem" clients?  Will IE parse the file if you rename it to .xml, or do you get a parsing error?

    In my 6.x custom inventory scripts, I added a "writeXML" function to clean the string before writing it to XML.  It doesn't get everything, but it gets the most common illegal characters:

    ' Function WriteXml replaces &, ', ", <, and > in a string with properly escaped XML-compliant Escape
    ' codes and returns the "fixed" string.
    Function WriteXml(sInput)
      sInput = Replace(sInput, "&", "&amp;")
      sInput = Replace(sInput, "'", "&apos;")
      sInput = Replace(sInput, """", "&quot;")
      sInput = Replace(sInput, "<", "&lt;")
      sInput = Replace(sInput, ">", "&gt;")
      WriteXml = sInput
    End Function


  • 10.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 01:02 PM

    I would like to think that the Altiris.AeXNSEvent object would parse the input to make sure its valid XML, but who knows.  Good point.

    I've never seen a clear understanding of the timing of custom inventories.  I know when the NSE gets created.  But when its actually sent, and then when its finally processed, I'm not sure of.  I can say that I was playing with this a while back.  I ran all the obvious client stuff and resource membership updates and whatever.  Nothing showed up.  Until magically then next day.  Since your pre and post WMI scripts posts in this thread were about an hour apart, I'd make sure you've got the timing right (whatever that is).



  • 11.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 03:11 PM

    No file gets created to the best of my knowledge; the script creates a COM object which stores the data rows and submits the object to the SMP. If files were created that would make this easier to troubleshoot since I would have something at which to look. I have run the script as different users at this point and am getting no results so the issue has been made worse on this server now. I am thinking this might be a DCOM issue but I don't know where to go with it from here. I figured out which DLL houses Altiris.AeXNSEvent and reregistered it to no avail.



  • 12.  RE: Custom Inventory Troubleshooting

    Posted Apr 17, 2012 03:20 PM

    I found an article with the object model and it does produce XML but not a file. You can use nse.getxmlbody before the nse.sendqueued call to see the XML. Mine looks correct but I don't see the GUID of the server which might explain why the data is not being pulled into the database. I have some more poking around to do but here is the link to the object model: http://www.symantec.com/business/support/index?page=content&id=HOWTO31200.



  • 13.  RE: Custom Inventory Troubleshooting

    Posted Apr 18, 2012 12:13 PM

    If you run the script locally as the account used as the default credentials by the task, it should fail.

    If you run the script via Altiris as the script you were using to test manually, it should succeed.

    Is this what you see?



  • 14.  RE: Custom Inventory Troubleshooting

    Posted Apr 18, 2012 02:55 PM

    At this point it fails regardless of the account and method used which is why I think DCOM issue. The XML looks fine as best I can tell. I can post the XML and a screenshot of the custom inventory if that would be helpful.



  • 15.  RE: Custom Inventory Troubleshooting

    Posted May 02, 2012 09:03 AM

    Check that, use nse.xml to see the entire message.



  • 16.  RE: Custom Inventory Troubleshooting

    Posted May 02, 2012 10:54 AM

    Have you tried updating the script so that rather than commenting out an Else condition, it actually fails with an error code?  This could help you see if your problem is in data gathering and NSE submission, or if the script is somehow ending up outside of the case logic you were expecting.



  • 17.  RE: Custom Inventory Troubleshooting

    Posted May 02, 2012 02:00 PM

    As a test I deleted one of the computers having the issue from the SMP. I let the computer record get recreated and let the inventory run. LO! I now have inventory data for that server. So the question is why but I have a case open with support so I will see what they say.



  • 18.  RE: Custom Inventory Troubleshooting
    Best Answer

    Posted May 02, 2012 04:50 PM

    It could be outdated DataHash values.  Try picking a problem computer and instead of deleting it, running this statement:

    DELETE FROM ResourceUpdateSummary
    WHERE ResourceGuid='ResourceGuid of problem computer'
    AND InventoryClassGuid='GUID of problem data class'

    If successful, you could then run a tidier UPDATE statement that sets DataHash to NULL for the entire InventoryClassGuid.



  • 19.  RE: Custom Inventory Troubleshooting

    Posted May 03, 2012 07:49 AM

    I only had one computer left to test this against so I changed your query to a select and the last modified date was from about 2 months ago. I ran the delete statement, kicked off the inventory again and it updated so it looks like you were correct. I will consider doing that for the entire dataclass simply to make sure all the data is up to date as of today. Thanks for the suggestion!



  • 20.  RE: Custom Inventory Troubleshooting

    Posted May 03, 2012 11:42 AM

    Excellent!  Remember, DELETE is a heavy-handed approach, so use UPDATE in any future troubleshooting to simply set DataHash to a NULL value.