A script like this set up on ServerA should do the trick.
#!/bin/bash
date=`/bin/date +%Y%m%d%H%M%S`
email_to="unixforum@localhost"
email_subject="Something went wrong"
email_body="Uh-oh"
server="localhost"
if ! /usr/bin/ssh "$server" "/usr/bin/touch /mnt/testfile.$date" >/dev/null 2>/dev/null
then
echo "$email_body" | /usr/bin/mail -s "$email_subject" "$email_to"
exit 1
fi
exit 0
The 'date' variable at the top just creates a string via the 'date' command that consists of the year, month, date, hour, minute and second all run together. I went with this since you didn't specify any particular format, but this should do for most purposes (if the script only runs at most once per second, anyway).
The next three variables define the recipient, subject and body of the e-mail message. You can customise those all you like.
Finally, the variable 'server' defines the remote server that the 'ssh' command will use to connect to. You'll want to change this to the details of whatever ServerB is.
The basic idea of the script is that it connects to the remote server, and if the 'touch' command (or the 'ssh' command itself) returns a non-successful exit value for any reaason, it then proceeds to send the e-mail.
Here's an example session of it running, in a situation where the touch command at the remote end (which is really just 'localhost' in my test case) fails.
$ whoami
unixforum
$ ./script.sh
$ mail
"/var/mail/unixforum": 1 message 1 new
>N 1 unixforum@localhost Mon Feb 20 15:17 15/654 Something went wrong
? 1
<e-mail headers appear here, redacted>
Uh-oh
? d 1
? q
Held 0 messages in /var/mail/unixforum
$
Just a minor addition: i'd call the ssh-facility this way to prevent problems in case keys are changed/deleted. Not allocating a terminal ( -n ) prevents problems when used inside pipelines: