AFP548 Changing the world one server at a time.

Associate user, ip address, timestamp?

Home › Forums › OS X Server and Client Discussion › Questions and Answers › Associate user, ip address, timestamp?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #372675
    pzingg
    Participant

    Has anyone written a utility that either runs as a login/logout hook, or trolls the /Library/Logs/AppleFileService/AppleFileServiceAccess.log to associate a username with an ip address?

    I would like to gain information about when users log in, how long they remain logged in, and how they are connected (especially for my wireless laptop cart users).

    The AppleFileServiceAccess.log on my file server(s) can show me when they connect to their home directories or other shares:

    IP 10.4.80.214 – – [06/May/2008:14:21:53 -0800] “Login jarmans” 0 0 0

    And a login script and/or cron job installed on every school computer could do something like this:

    #!/usr/bin/perl -w
    # login_log.pl
    # sudo defaults write com.apple.loginwindow LoginHook /path/to/login_log.pl

    use POSIX;

    my $login;
    if (defined($ARGV[0])) {
    $login = ‘login: ‘.$ARGV[0].”\n”;
    } else {
    $login = ‘login: ‘.`/usr/bin/users`;
    }
    my $mytime = POSIX::strftime(“%Y%m%d-%H%M%S”, localtime(time));
    my $filename = “/tmp/login-$mytime.txt”;
    my $timestamp = ‘time: ‘.$mytime.”\n”;
    my $hostname = ‘hostname: ‘.`/bin/hostname`;
    my $machine_id = ‘machine_id: ‘.
    `/sbin/ifconfig en0 | /usr/bin/grep ether | /usr/bin/awk ‘{ print \$2; }’`;
    my $ip_address = ‘ip_addresses: ‘.
    `/sbin/ifconfig | /usr/bin/grep ‘inet ‘ | /usr/bin/awk ‘{ print \$2; }’ | /usr/bin/tr ‘[:space:]’ ‘ ‘`.”\n”;
    my $base_station = ‘airport_name: ‘.
    `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | /usr/bin/grep ‘ BSSID:’ | /usr/bin/awk ‘{ print \$2; }’`;
    my $network_name = ‘network_name: ‘.
    `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | /usr/bin/grep ‘ SSID:’ | /usr/bin/awk ‘{ print \$2; }’`;

    # create the login file
    open TMPFILE, “>$filename” or die “tmpfile”;
    print TMPFILE $timestamp;
    print TMPFILE $login;
    print TMPFILE $hostname;
    print TMPFILE $machine_id;
    print TMPFILE $ip_address;
    print TMPFILE $base_station;
    print TMPFILE $network_name;
    close TMPFILE;

    # PUT the file to an http server
    system(“/usr/bin/curl -T $filename http://localhost:3000”);

    Just wondering whether someone has the front and back end tied together already?

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.