Subject: How to determine which Mac s are connected?

From: Brandon Warren <[email-masked]>
Date: Wed, 22 Mar 2000 15:53:18 -0800 (PST)

Hi,

How can I determine which Macs are connected?

"ps aux" will tell me which users are connected, but I want to
know which machines are connected.

"netstat" will tell me the IP address of each Mac that is connected. This
would work if our Macs were not using DHCP.

"nbplkup" will tell me the Mac name for a given Mac address
(e.g. 11637.212:252), so if I knew what Mac address were connected,
I could determine the machine name.

Is there a way of finding the hardware network address (MAC) for a
given IP?  That could also help, if I had a list of all our MAC
address.

Thanks in advance for any help,

Brandon

---

From: Patrik Schindler <[email-masked]>
Date: Thu, 23 Mar 2000 08:33:08 +0100

>given IP?  That could also help, if I had a list of all our MAC

Yes, take a look on the output of "arp -a".

Indeed, a little goodie to keep track which users were connected from which machines would be nice, but I have no idea to keep track of AppleTalk users.

Only afpd knows which childs he forks. Perhaps this is one point: Register some kind of file in /proc/sys (what about the /proc structure within Solaris?)...

:wq! PoC

---

From: Ove Ruben R Olsen <[email-masked]>
Date: Sun, 26 Mar 2000 17:33:43 +0200

At 09:33 +0200 on 23.03.00, Patrik Schindler wrote:

> Indeed, a little goodie to keep track which users were connected from
>which machines would be nice, but I have no idea to keep track of
>AppleTalk users.

If you only need the  IP-/host-address Anders Brownworth little "nu" script
will do
the trick. Found on http://thehamptons.com/anders/netatalk/utils.html. I have
done some enchanements to the script so that it also shows the
IP-/host-address.

I have sumitted the script to Anders so that if he wish he may put the new
version
out on the web.

The script is also pasted into this message. I have just thrown it togehter to
run on RedHat ;-) - tweaking must probably be applied.

\Ruben.

#!/usr/bin/perl

# nu - by Anders Brownworth   [email-masked]
#      modified by Ambrose Li <[email-masked]>
#      modified by Ove Ruben R Olsen <[email-masked]>
#
# shows netatalk users logged on and their remote address
# this assumes the netstat -p and ps uax of linux usage
#
# usage: nu

open (NS, "/bin/netstat -p 2>&1|");
while (<NS>) {
  last if (/^Active UNIX domain/);
  ($junk, $remote, $morejunk, $pid) = unpack("A44 A23 A13 A10", $_);

  if ( ($junk =~ /afpovertcp/) && ($morejunk != /ESTABLISHED/) ) {
    ($pid) = split(/\//,$pid,2);
    $PID{$pid} = $remote;
  }
}
close(NS);

print pack("A10 A6 A24 A20 A20", "USER", "SINCE", "FROM", "NAME"), "\n
";

open(USERS, "/bin/ps -uax|") ;

while (<USERS>) {
  ($uid, $pid, $junk, $since) = unpack("A8 A6 a36 A5", $_);

  $pid =~ tr/ //d;
  if ($PID{$pid} ne "") {
    ($name,$office) = split(/,/,(getpwnam($uid))[6], 3);
    print pack("A10 A6 A24 A40", $uid, $since, $PID{$pid},  $name,
$office), "\n
";
  }

}