New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Capture Mac Address for Ping Sensor

Votes:

0

Your Vote:

Up

Down

Would like to know if there is a way to collect the arp entry (mac address) for a PING sensor. If there isn't a way, is this something that you might consider adding in the future? This would be very useful in troubleshooting when devices drop from the network in order to find them on switches.

mac-address network ping prtg

Created on Nov 30, 2011 5:44:55 PM by  Ismael J. Carlo (53) 2 1



11 Replies

Votes:

0

Your Vote:

Up

Down

Dear Ismael,

not possible in the moment. Sorry.

best regards.

Created on Nov 30, 2011 6:16:28 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Ismael,

A ping travels the Network Layer (layer 3) where the MAC address is part of the Data Link Layer (layer 2), making it not possible for a ping to tell you anything about the MAC address of the responding device.

You might want to consider using WMI to get the MAC address.

Regards,

Created on Dec 1, 2011 7:04:57 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,173) 3 4



Votes:

0

Your Vote:

Up

Down

I realized it wasn't a Layer 3 feature, but in many cases, WMI won't be an option such as switches, firewalls, linux, etc... What I was hoping you could do is scrape the ARP tables to store the mac address with the device. The problem is that the arp tables aren't large enough to store all the arp entries so once a device is down we loose visibility to it's mac address.

Created on Dec 1, 2011 7:15:43 PM by  Ismael J. Carlo (53) 2 1



Votes:

0

Your Vote:

Up

Down

Hi Ismael,

So the sensor should return the mac address and if the device is down (mac cannot be resolved) return the value from the previous scan.

I think this can be done with a Custom Sensor.

If you contact me directly, I can drop you a link to do some testing. My email address can be found at http://code.google.com/p/prtg-addons/wiki/PTF_Custom_Sensors in the left pane under "feedback"

Regards,

Created on Dec 2, 2011 12:32:11 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,173) 3 4



Votes:

0

Your Vote:

Up

Down

Gerard, thanks for your offer, you're always such a great help. What I was hoping for was something a little more native to PRTG. For example, when a device is first discovered PRTG captures the mac-address for the device and stores it somewhere. As a reference, the PowerShell script below will return the mac address for a specified device. I could write something to update the device description in PRTG, but I have no external trigger aside from an alarm.

function Get-MacAddress {
	param( [string]$device= $( throw "Please specify device" ) )
	

	if ( $device | ? { $_ -match "[0-9].[0-9].[0-9].[0-9]" } )
	{
		#"Searching by IP Address"
		$ip = $ip
	} else {
		#"Searching by Host Name"
		$ip = [System.Net.Dns]::GetHostByName($device).AddressList[0].IpAddressToString
	}

	arp -d; # purge arp cache
	$ping = ( new-object System.Net.NetworkInformation.Ping ).Send($ip);
	$mac = arp -a;

	if($ping){
		( $mac | ? { $_ -match $ip } ) -match "([0-9A-F]{2}([:-][0-9A-F]{2}){5})" | out-null;
		if ( $matches ) {
			$matches[0];
		} else {
			"Not Found"
		}
	} 
}

Created on Dec 5, 2011 10:17:42 PM by  Ismael J. Carlo (53) 2 1

Last change on Dec 6, 2011 2:26:15 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Ismael,

Why do you need a trigger? Simply update the device description in PRTG every time the PowerShell script runs.

Regards,

Created on Dec 6, 2011 2:33:20 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,173) 3 4



Votes:

0

Your Vote:

Up

Down

I was trying to get the MAC-address from a device, and used your script to add it as a Custom Sensor EXE. I created GetMAC.ps1 and added the following:

$device = $Args[0]

if ( $device | ? { $_ -match "[0-9].[0-9].[0-9].[0-9]" } )
{
	#"Searching by IP Address"
	$ip = $device
} else {
	#"Searching by Host Name"
	$ip = [System.Net.Dns]::GetHostByName($device).AddressList[0].IpAddressToString
}

arp -d; # purge arp cache
$ping = ( new-object System.Net.NetworkInformation.Ping ).Send($ip);
$mac = arp -a;

if($ping){
	( $mac | ? { $_ -match $ip } ) -match "([0-9A-F]{2}([:-][0-9A-F]{2}){5})" | out-null;
	if ( $matches ) {
		"0:"+$matches[0];
	} else {
		"Not Found:error"
	}
} 

I added %host as the parameter and now it returns the MAC-address.

Then I read your reply to update the device description... but I have no idea how to do that... any thoughts to create a better sensor for getting the MAC-address?

Created on Dec 1, 2016 12:01:16 AM by  nikagl (0) 1

Last change on Dec 1, 2016 10:11:38 AM by  nikagl (0) 1



Votes:

0

Your Vote:

Up

Down

Hi there,

Please clarify what you don't understand about the device description so we can help you further. :)

Created on Dec 1, 2016 12:51:49 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I was referring to the comment "Why do you need a trigger? Simply update the device description in PRTG every time the PowerShell script runs.". When the script runs, it returns the MAC address into the Data of the Custom Sensor, and I was wondering how to update the description using the powershell script...

Created on Dec 1, 2016 1:11:30 PM by  nikagl (0) 1



Votes:

0

Your Vote:

Up

Down

Hi there,

You can transmit the "%deviceid" placeholder to the PowerShell script (Parameter field) and use the following API-Call to edit the device's name: http(s)://<YOURPRTG>/api/setobjectproperty.htm?id=<DEVICEID>&name=name&value=<$MACADDRESS>

Please note that this will set the device name to only the MAC address, perhaps you can use another API-Call to call first the name of the device and append afterwards the MAC-Address. But you will have to build this into the script by yourself.

Created on Dec 1, 2016 9:32:27 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Thanks!

Created on Dec 1, 2016 10:07:49 PM by  nikagl (0) 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.