The task. There is Nagios system running on some host in LAN. It checketh for some things and if something is bad, it sendeth out notifications to people who should fix it. The problem is that there is no Internet access from the LAN, so it is impossible to send out notifications using Internet e-mail, only locally. There is, however, an SMTP server in the LAN, which provideth access to Internet e-mail, but the host where Nagios is running is not allowed to send e-mail. The task is to solve this problem somehow.
Now there is true Unix solution: take some host in the LAN which is authorized to send mail and make Nagios remotely call something on it to send mail, like this:
echo “Notification” | ssh allowed-host nail -s “Subject” firstname.lastname@example.org
Where nail on allowed-host is configured to send mail using msmtp(1).
However, on all authorized hosts there are only Windows and ancient HP-UX systems. HP-UX is a problem because everything so ancient there so it is virtually impossible to install msmtp(1) and nail(1) there. But who said that the Unix way solution cannot be applied to Windows? Nobody. So…
Final design of the solution looketh like this:
echo “Notification” | nail -A “Inet” -s “Subject”
Where “Inet” nail account is configured to use something like this instead of sendmail:
ssh allowed-host msmtp “$@”
Now the only problem is to install msmtp on the Windows machine and set up ssh access to it. msmtp was not a problem at all–binary distribution for Windows is available. As for ssh, Cygwin did its job. OpenSSH Cygwin package containeth very nice command ssh-config-host-or-something which configureth ssh to run as NT service. The funny part was that Cygwin must be downloaded from Internet using setup.exe, which is Windows application. But, as I said, there is no Internet access there and I have no Windows at home. So I had to run setup.exe using wine, and it worked nice except for that I had to switch wine to virtual desktop mode.
Now everything is set up and working just fine. Everything took about two or three hours, mostly because I never did anything like this before. I can not imagine more elegant solution.