2 # Copyright (C) 2002 Stanislav Sinyagin
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 # $Id: action_printemail.in,v 1.1 2010-12-27 00:04:03 ivan Exp $
19 # Stanislav Sinyagin <ssinyagin@yahoo.com>
21 # We need this for $Torrus::Global::templateDirs
22 BEGIN { require '@torrus_config_pl@'; }
28 require '@email_siteconfig_pl@';
30 if( not $ENV{'TORRUS_TREE'} )
32 print STDERR ("Torrus environment variables missing. This program ",
33 "must be run from Torrus Monitor\n");
38 my $ok = GetOptions( 'url=s' => \$Torrus::Email::url,
39 'template=s' => \$Torrus::Email::template );
43 print STDERR ("Error parsing options\n");
47 my $tt = new Template(INCLUDE_PATH => $Torrus::Global::templateDirs);
51 'tree' => $ENV{'TORRUS_TREE'},
52 'token' => $ENV{'TORRUS_TOKEN'},
53 'path' => $ENV{'TORRUS_NODEPATH'},
54 'nickname' => $ENV{'TORRUS_NICKNAME'},
55 'url' => $Torrus::Email::url . '/' .
56 $ENV{'TORRUS_TREE'} . '?token='.$ENV{'TORRUS_TOKEN'},
57 'ncomment' => $ENV{'TORRUS_NCOMMENT'},
58 'npcomment' => $ENV{'TORRUS_NPCOMMENT'},
59 'event' => $ENV{'TORRUS_EVENT'},
60 'monitor' => $ENV{'TORRUS_MONITOR'},
61 'mcomment' => $ENV{'TORRUS_MCOMMENT'},
62 'severity' => $ENV{'TORRUS_SEVERITY'},
63 'timestamp' => scalar(localtime($ENV{'TORRUS_TSTAMP'})),
64 'value' => $ENV{'TORRUS_VALUE'},
65 'dispvalue' => $ENV{'TORRUS_DISPLAY_VALUE'},
66 'env' => sub { return $ENV{$_[0]} }
69 my $result = $tt->process($Torrus::Email::template, $vars);
73 print STDERR "Error while processing template: ".$tt->error()."\n";
76 exit( $result ? 0:1 );
81 # indent-tabs-mode: nil
82 # perl-indent-level: 4