Server Management - Systems Insight Manager
1753267 Members
5214 Online
108792 Solutions
New Discussion юеВ

Re: IP addresses showing instead of names

 
Michael Sole_3
Occasional Advisor

IP addresses showing instead of names

I am running a host file discovery on a list of non-computer network devices.

Rather than the host name the IP address appears as the machine name in the list.

Please help
10 REPLIES 10
rcseattle
Frequent Advisor

Re: IP addresses showing instead of names

It would be nice to know what methods and what order the CMS uses to discover names of devices.

I know it used to do a reverse DNS lookup of names (in 4.2 I think) which caused problems in our environment since we do not use our SUN DNS hostnames for our Wintel servers here. But that seems to have been fixed in 5.0.

At that time I wrote a vbs script and ran it ever night that would get the SNMP name and if that failed I'd try a WMI get and rewrote the names in the database so they would show up with our servernames instead of the location-based alphanumeric hostnames.
Michael Sole_3
Occasional Advisor

Re: IP addresses showing instead of names

You are correct I believe the problem has to do with reverse lookup.

These devices, as I stated, are not computers. They are control units that allow people to use a "debit card" to pay for copiers. They run a unix based OS. I have to manually create the DNS records but unfortunately the reverse records were not all created properly.

I am trying to figure out a way to script the process. Otherwise I have to do it manually. Eck :P
rcseattle
Frequent Advisor

Re: IP addresses showing instead of names

If they have SNMP on, maybe this will help:

Option Explicit

Dim Conn, oRs, strComputer

Set Conn = CreateObject("ADODB.Connection")
Conn.Open "DSN=InsightDB;UID=USERIDHERE;PWD=PASSWORDHERE;DATABASE=Insight_v42_0_153223624"
Set oRs = CreateObject("ADODB.Recordset")
oRs.Open "Select Name, fullDNSName from dbo.devices", Conn

Do While Not oRs.EOF
strComputer = Trim(oRs.Fields("fullDNSName"))
' Attempt to get system name from SNMP
Call GetSNMPSystemName(strComputer)
' IF SNMP call fails to return name, attempt WMI call
If strComputer = "" then
strComputer = Trim(oRs.Fields("fullDNSName"))
Call GetWMISystemName(strComputer)
End If
If strComputer = "" Then
' SNMP & WMI calls failed, do nothing
'Debug.Print Trim(oRs.Fields("Name")), Trim(oRs.Fields("fullDNSName"))
Else
Conn.Execute ("UPDATE dbo.devices SET dbo.devices.Name = '" & strComputer & _
"' WHERE (((dbo.devices.fullDNSName)='" & Trim(oRs.Fields("fullDNSName")) & "'));")
'Debug.Print strComputer, Trim(oRs.Fields("fullDNSName"))
End If
oRs.MoveNext
Loop
oRs.Close

WSCript.Quit


Sub GetSNMPSystemName(ByRef strComputer)
Dim strTargetSnmpDevice, objWmiLocator, objWmiServices, objWmiNamedValueSet
Dim colSystem, objInterface, objProp

strTargetSnmpDevice = strComputer
strComputer = ""

On Error Resume Next
Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")

Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"

Set colSystem = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_system", , _
objWmiNamedValueSet)
For Each objInterface In colSystem
For Each objProp In objInterface.Properties_
If objProp.Name = "sysName" Then strComputer = objProp.Value
Next
Next

' If the name is a full DNS name return only the Hostname
If InStr(strComputer, ".") > 0 Then
strComputer = Left(strComputer, InStr(strComputer, ".") - 1)
End If

' If there was an error, then return ""
If Err.Number <> 0 Then
strComputer = ""
Err.Clear
End If
End Sub


Sub GetWMISystemName(ByRef strComputer)
'declare variables
Dim objWMIService, colItems, objItem
On Error Resume Next

'get WMI service
Set objWMIService = GetObject("winmgmts:\\" & _
strComputer & "\root\cimv2")
If Err.Number <> 0 Then
strComputer = ""
Exit Sub
End If

'get item collection
Set colItems = objWMIService.ExecQuery( _
"Select * from Win32_OperatingSystem")

For Each objItem In colItems
strComputer = objItem.CSName
Next

If Err.Number <> 0 Then
strComputer = ""
Exit Sub
End If

End Sub


Michael Sole_3
Occasional Advisor

Re: IP addresses showing instead of names

That is a handy little script but as it stands now there is no SNMP implemented in these little buggers.

How about a script that can read all the A records from the DNS server and then write the associate PTR records?

That would fix everything!
rcseattle
Frequent Advisor

Re: IP addresses showing instead of names

Well I made some scripts that would do similar stuff to that as add-in formulas to Excel for my own use here, but here is the disclaimer:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ├В┬й1996-2001 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

So all I believe I can do is point you to MVPS.org and vbnet.
http://vbnet.mvps.org/index.html?code/network/hostnamefromip.htm

It takes a little work to make it want you want, but the examples are very helpful to get you started.

I use mine by putting values into Excel and using a formula to return hostname from IP or vice-versa. It's come in very handy here.
Michael Sole_3
Occasional Advisor

Re: IP addresses showing instead of names

I got this script:
'on error resume next
' This VBScript code shows how to add an A record and PTR record using
' the DNS WMI Provider

' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00466-4
' Book web site: http://rallenhome.com/books/adcookbook/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strForwardDomain = "xerox.local"
set objDNS = GetObject("winMgmts:root\MicrosoftDNS")
set objRR = objDNS.Get("MicrosoftDNS_ResourceRecord")
set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""")
' ------ END CONFIGURATION ---------

Const ForReading = 1

strCurrentDir = Left(WScript.ScriptFullName,InstrRev(WScript.ScriptFullName,"\"))

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("om.txt", ForReading)

strServers = objTextFile.ReadAll
objTextFile.Close

arrComputers = Split(strServers, vbCrLf)

for each strComputer in arrComputers
arrPTRInfo = Split(strComputer, ",")

strHostName = strComputer
arrrevIP = Split(arrPTRInfo(1), ".")
strReverseRRAdd = arrRevIP (3) & "." & arrrevIP(2) & "." & arrRevIP(1) & "." & arrRevIP(0) & ".in-addr.arpa IN PTR " & strHostName & "." & strForwardDomain
strReverseDomain = arrrevIP(2) & "." & arrRevIP(1) & "." & arrRevIP(0) & ".in-addr.arpa"

strNull = objRR.CreateInstanceFromTextRepresentation( _
objDNSServer.Name, _
strReverseDomain, _
strReverseRRAdd, _
objOutParam)
set objRR2 = objDNS.Get(objOutParam)
WScript.Echo "Created Record: " & objRR2.TextRepresentation

next

It pulls from a text file that I exported from the DNS server but I do not now how to create the PTR record now that I have it correctly formated.
rcseattle
Frequent Advisor

Re: IP addresses showing instead of names

Hmm looks like MS DNS. Which we don't have here, so I haven't coded against it. MVPS might have help on that.

Do you know that those reverse names are not in your DNS now?

Back to an earlier point: It would be nice to know what protocols and what order the CMS uses when doing discovery to name the devices. Once they are there does nightly discovery change them as it used to in 4.2? I don't seem to have those problems in 5.0 anymore, but don't know what changes HP implemented.

My earlier solution was to rewrite the info in the SQL database (scheduled task after the nightly discovery) that our CMS uses so that our MS server names would show rather than our location based SUN alpha-numeric DNS hostnames would display.

That angle (rewriting names in the database) might provide the results you want, albeit from a slightly different direction than you were looking for.

You may have to just run it once; the names may stick. But an answer from someone on the discovery process of the CMS would be nice first.
Michael Sole_3
Occasional Advisor

Re: IP addresses showing instead of names

Yeah I am positive those names are not in the reverse look up. Some are but others are not and that is how the discovery is reflected.
David Claypool
Honored Contributor

Re: IP addresses showing instead of names

When HP SIM gets a response to an IP address ping, the only method it uses for name resolution is DNS. That can be a local hosts file or a DNS service. No other process is used (Insight Manager 7 would use WINS if it was present).

I think the easiest workaround for Michael would be to create a local hosts file rather than trying to create the PTR records...