Monitoring, Management & Location Tracking

Send Daily Emails for a Specific MAC Address Using_AMP's Client Report Page

Aruba Employee

AT the end of this article is a Perl script you can run from your AMP command line that will email you the contents of AMP's Client Report page for a specified MAC address. To run the command, copy it to your AMP (WinSCP is a good program to use when copying file from WIndows platforms, you can get WinSCP at http://winscp.net/eng/index.php), then run the following command to make the script executable:

chmod 755 email_client_report

Once this is done, you can test the command:

email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

This will send a copy of the client history page for the specified MAC address to your email client. Note that some email clients may report a scripting error when they attempt to open the email; this is harmless and occurs because email clients generally do not support scripting languages in the same way as web browsers do.

To make the script run automatically, edit the crontab file from your AMP root account:

crontab -e

Using the default vi text editor, arrow down in the crontab file and use 'O' to add line beneath the current line. You should then be able to paste the script in, like this:

00 05 * * * /root/email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

Type <Esc>, then a colon to exit vi's insert mode, then use 'wq <Enter>' to save the crontab file. The portion at the beginning of the crontab command, i.e. '00 05 * * *', tells AMP when to run the script; in this case at 5:00 a.m. every morning. If you type 'man crontab' at the AMP's command line, you can get additional help on setting up AMP to run the script at other times, such as a certain day of the week, or hourly, etc.

The script file contents are listed below. To create this file in Windows, cut and paste it from your browser, then save the file as 'email_client_report' using WordPad. Since Windows text file formats are different from Linux file formats, use should run the 'dos2unix' command on this file after copying it to your AMP and before attempting to run it. Otherwise, the file script file will not work.


#Email Client Report#

#!/usr/bin/perl -W

eval 'exec /usr/bin/perl -W -S $0 ${1+"$@"}'
if 0; # not running under some shell
use lib '../blib/lib';

use HTML::Mail;
use strict;

#Sends an email of the AMP Client webpage, takes a client MAC address as its first arguement, then an email address as the second arguement.

if ( $#ARGV != 1 ) {
print <<EOF;
Usage sendpage url email

sendpage http://www.cpan.org receipient\@domain.org

EOF
exit 0;
}

my $mac = shift;
my $email = shift;
my $url = 'https://localhost/nf/client_monitoring?mac=' . $mac;

### initialisation
my $html_mail = new HTML::Mail(
HTML => $url,
From => $email,
To => $email,
Subject => "AMP Report",
);

#$html_mail->send();
$html_mail->build(Text=>undef);
$html_mail->send;
AT the end of this article is a Perl script you can run from your AMP command line that will email you the contents of AMP's Client Report page for a specified MAC address. To run the command, copy it to your AMP (WinSCP is a good program to use when copying file from WIndows platforms, you can get WinSCP at http://winscp.net/eng/index.php), then run the following command to make the script executable:

chmod 755 email_client_report

Once this is done, you can test the command:

email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

This will send a copy of the client history page for the specified MAC address to your email client. Note that some email clients may report a scripting error when they attempt to open the email; this is harmless and occurs because email clients generally do not support scripting languages in the same way as web browsers do.

To make the script run automatically, edit the crontab file from your AMP root account:

crontab -e

Using the default vi text editor, arrow down in the crontab file and use 'O' to add line beneath the current line. You should then be able to paste the script in, like this:

00 05 * * * /root/email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

Type <Esc>, then a colon to exit vi's insert mode, then use 'wq <Enter>' to save the crontab file. The portion at the beginning of the crontab command, i.e. '00 05 * * *', tells AMP when to run the script; in this case at 5:00 a.m. every morning. If you type 'man crontab' at the AMP's command line, you can get additional help on setting up AMP to run the script at other times, such as a certain day of the week, or hourly, etc.

The script file contents are listed below. To create this file in Windows, cut and paste it from your browser, then save the file as 'email_client_report' using WordPad. Since Windows text file formats are different from Linux file formats, use should run the 'dos2unix' command on this file after copying it to your AMP and before attempting to run it. Otherwise, the file script file will not work.


#Email Client Report#

#!/usr/bin/perl -W

eval 'exec /usr/bin/perl -W -S $0 ${1+"$@"}'
if 0; # not running under some shell
use lib '../blib/lib';

use HTML::Mail;
use strict;

#Sends an email of the AMP Client webpage, takes a client MAC address as its first arguement, then an email address as the second arguement.

if ( $#ARGV != 1 ) {
print <<EOF;
Usage sendpage url email

sendpage http://www.cpan.org receipient\@domain.org

EOF
exit 0;
}

my $mac = shift;
my $email = shift;
my $url = 'https://localhost/nf/client_monitoring?mac=' . $mac;

### initialisation
my $html_mail = new HTML::Mail(
HTML => $url,
From => $email,
To => $email,
Subject => "AMP Report",
);

#$html_mail->send();
$html_mail->build(Text=>undef);
$html_mail->send;
AT the end of this article is a Perl script you can run from your AMP command line that will email you the contents of AMP's Client Report page for a specified MAC address. To run the command, copy it to your AMP (WinSCP is a good program to use when copying file from WIndows platforms, you can get WinSCP at http://winscp.net/eng/index.php), then run the following command to make the script executable:

chmod 755 email_client_report

Once this is done, you can test the command:

email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

This will send a copy of the client history page for the specified MAC address to your email client. Note that some email clients may report a scripting error when they attempt to open the email; this is harmless and occurs because email clients generally do not support scripting languages in the same way as web browsers do.

To make the script run automatically, edit the crontab file from your AMP root account:

crontab -e

Using the default vi text editor, arrow down in the crontab file and use 'O' to add line beneath the current line. You should then be able to paste the script in, like this:

00 05 * * * /root/email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

Type <Esc>, then a colon to exit vi's insert mode, then use 'wq <Enter>' to save the crontab file. The portion at the beginning of the crontab command, i.e. '00 05 * * *', tells AMP when to run the script; in this case at 5:00 a.m. every morning. If you type 'man crontab' at the AMP's command line, you can get additional help on setting up AMP to run the script at other times, such as a certain day of the week, or hourly, etc.

The script file contents are listed below. To create this file in Windows, cut and paste it from your browser, then save the file as 'email_client_report' using WordPad. Since Windows text file formats are different from Linux file formats, use should run the 'dos2unix' command on this file after copying it to your AMP and before attempting to run it. Otherwise, the file script file will not work.


#Email Client Report#

#!/usr/bin/perl -W

eval 'exec /usr/bin/perl -W -S $0 ${1+"$@"}'
if 0; # not running under some shell
use lib '../blib/lib';

use HTML::Mail;
use strict;

#Sends an email of the AMP Client webpage, takes a client MAC address as its first arguement, then an email address as the second arguement.

if ( $#ARGV != 1 ) {
print <<EOF;
Usage sendpage url email

sendpage http://www.cpan.org receipient\@domain.org

EOF
exit 0;
}

my $mac = shift;
my $email = shift;
my $url = 'https://localhost/nf/client_monitoring?mac=' . $mac;

### initialisation
my $html_mail = new HTML::Mail(
HTML => $url,
From => $email,
To => $email,
Subject => "AMP Report",
);

#$html_mail->send();
$html_mail->build(Text=>undef);
$html_mail->send;
AT the end of this article is a Perl script you can run from your AMP command line that will email you the contents of AMP's Client Report page for a specified MAC address. To run the command, copy it to your AMP (WinSCP is a good program to use when copying file from WIndows platforms, you can get WinSCP at http://winscp.net/eng/index.php), then run the following command to make the script executable:

chmod 755 email_client_report

Once this is done, you can test the command:

email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

This will send a copy of the client history page for the specified MAC address to your email client. Note that some email clients may report a scripting error when they attempt to open the email; this is harmless and occurs because email clients generally do not support scripting languages in the same way as web browsers do.

To make the script run automatically, edit the crontab file from your AMP root account:

crontab -e

Using the default vi text editor, arrow down in the crontab file and use 'O' to add line beneath the current line. You should then be able to paste the script in, like this:

00 05 * * * /root/email_client_report 00:11:22:FF:EE:DD my_email_address@mycompany.com

Type <Esc>, then a colon to exit vi's insert mode, then use 'wq <Enter>' to save the crontab file. The portion at the beginning of the crontab command, i.e. '00 05 * * *', tells AMP when to run the script; in this case at 5:00 a.m. every morning. If you type 'man crontab' at the AMP's command line, you can get additional help on setting up AMP to run the script at other times, such as a certain day of the week, or hourly, etc.

The script file contents are listed below. To create this file in Windows, cut and paste it from your browser, then save the file as 'email_client_report' using WordPad. Since Windows text file formats are different from Linux file formats, use should run the 'dos2unix' command on this file after copying it to your AMP and before attempting to run it. Otherwise, the file script file will not work.


#Email Client Report#

#!/usr/bin/perl -W

eval 'exec /usr/bin/perl -W -S $0 ${1+"$@"}'
if 0; # not running under some shell
use lib '../blib/lib';

use HTML::Mail;
use strict;

#Sends an email of the AMP Client webpage, takes a client MAC address as its first arguement, then an email address as the second arguement.

if ( $#ARGV != 1 ) {
print <<EOF;
Usage sendpage url email

sendpage http://www.cpan.org receipient\@domain.org

EOF
exit 0;
}

my $mac = shift;
my $email = shift;
my $url = 'https://localhost/nf/client_monitoring?mac=' . $mac;

### initialisation
my $html_mail = new HTML::Mail(
HTML => $url,
From => $email,
To => $email,
Subject => "AMP Report",
);

#$html_mail->send();
$html_mail->build(Text=>undef);
$html_mail->send;

Version history
Revision #:
1 of 1
Last update:
‎06-06-2014 02:49 PM
Updated by:
 
Labels (1)
Contributors
Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: 
Is this a frequent problem?

Request an official Aruba knowledge base article to be written by our experts.