Description:
To setup LCOS based e-mail alerts you need to configure an SMTP mail server, as well as actions that trigger the respective behavior.
You will need to setup the following variables:
Mandatory variables:
- SMTP_SERVER
- SMTP_USER
- SMTP_PASSWORT
- MAIL_SENDER
- MAIL_TO
Optional variables:
List of used variables:
Add-in codes:
exports.main = function (config, context) {
if (context.device.isGateway) {
config.setScalarByOid("1.2.27.1", context.vars.SMTP_SERVER);
config.setScalarByOid("1.2.27.2", "587");
config.setScalarByOid("1.2.27.12", "2");
config.setScalarByOid("1.2.27.13", "3");
config.setScalarByOid("1.2.27.3", "");
config.setScalarByOid("1.2.27.4", "110");
config.setScalarByOid("1.2.27.11", "");
config.setScalarByOid("1.2.27.5", context.vars.SMTP_USER);
config.setScalarByOid("1.2.27.6", context.vars.SMTP_PASSWORT);
config.setScalarByOid("1.2.27.7", context.vars.MAIL_SENDER);
config.setScalarByOid("1.2.27.8", "30");
config.setScalarByOid("1.2.27.9", "72");
config.setScalarByOid("1.2.27.10", "100");
}
};
|
---|
Add-in as JSON file:
email.json
Alerts for all connections:
exports.main = function (config, context) {
if (context.device.isGateway && !context.network.isCentralGateway) {
for (var pos in context.network.vpnconnections);
var actionTable = config.getTableByOid("1.2.2.25");
var row1 = actionTable.createNewRow();
row1.setByOid("1", "7");
row1.setByOid("8", "0");
row1.setByOid("2", context.network.vpnconnections[pos] + "-DOWN");
row1.setByOid("3", context.network.vpnconnections[pos]);
row1.setByOid("10", "4094");
row1.setByOid("4", "0");
row1.setByOid("5", "3");
row1.setByOid("6", "mailto:" + context.vars.MAIL_TO
+ "?subject=VPN-Verbindung im Projekt " + context.vars.projectName
+ " am Standort " + context.vars.locationName + " abgebrochen um %t"
+ "?body=Im Projekt " + context.vars.projectName
+ " wurde die VPN-Gegenstelle " + context.network.vpnconnections[pos]
+ " am Standort " + context.vars.locationName + " unerwartet abgebaut");
row1.setByOid("7", "");
row1.setByOid("9", "root");
actionTable.addOrMerge(row1);
var row2 = actionTable.createNewRow();
row2.setByOid("1", "8");
row2.setByOid("8", "0");
row2.setByOid("2", context.network.vpnconnections[pos] + "-UP");
row2.setByOid("3", context.network.vpnconnections[pos]);
row2.setByOid("10", "4094");
row2.setByOid("4", "0");
row2.setByOid("5", "0");
row2.setByOid("6", "mailto:" + context.vars.MAIL_TO
+ "?subject=VPN-Verbindung im Projekt " + context.vars.projectName
+ " am Standort " + context.vars.locationName + " aufgebaut um %t"
+ "?body=Im Projekt " + context.vars.projectName
+ " wurde die VPN-Gegenstelle " + context.network.vpnconnections[pos]
+ " am Standort " + context.vars.locationName
+ " aufgebaut");
row2.setByOid("7", "");
row2.setByOid("9", "root");
actionTable.addOrMerge(row2);
}
};
|
---|
Add-in as JSON file:
alert_all_connections.json
Alerts for specific connections:
exports.main = function (config, context) {
if (context.device.isGateway) {
config.setScalarByOid("1.2.27.1", context.vars.SMTP_SERVER);
config.setScalarByOid("1.2.27.2", "587");
config.setScalarByOid("1.2.27.12", "2");
config.setScalarByOid("1.2.27.13", "3");
config.setScalarByOid("1.2.27.3", "");
config.setScalarByOid("1.2.27.4", "110");
config.setScalarByOid("1.2.27.11", "");
config.setScalarByOid("1.2.27.5", context.vars.SMTP_USER);
config.setScalarByOid("1.2.27.6", context.vars.SMTP_PASSWORT);
config.setScalarByOid("1.2.27.7", context.vars.MAIL_SENDER);
config.setScalarByOid("1.2.27.8", "30");
config.setScalarByOid("1.2.27.9", "72");
config.setScalarByOid("1.2.27.10", "100");
}
};
|
---|
Add-in as JSON file:
alert_specific_connection.json