What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Capture Mac Address for Ping Sensor

Votes:

1

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



11 Replies

Votes:

0

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

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



Votes:

0

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



Votes:

0

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



Votes:

0

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

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



Votes:

0

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



Votes:

0

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

Last change on Dec 1, 2016 12:01:16 AM



Votes:

0

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

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



Votes:

0

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

Thanks!

Created on Dec 1, 2016 10:07:49 PM




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.