Alerting

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:

  • projectName
  • locationName

Email Setup

/**
 * @param {Config} config
 * @param {Context} context
 * Do not edit this comment or parameter types. Required for code suggestions
*/
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");
  }
};

/*
   [  1] SMTP-Server         : 64 chars from  #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
   [  2] SMTP-Port           : 5 chars from 1234567890
   [ 12] SMTP-use-TLS        : Yes (1), No (0), Preferred (2), Required (3)
   [ 13] SMTP-Authentication : None (0), Plain-Text-Preferred (1), Encrypted (2), Preferred-Encrypted (3)
   [  3] POP3-Server         : 64 chars from  #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
   [  4] POP3-Port           : 5 chars from 1234567890
   [ 11] Loopback-Addr.      : 16 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789
   [  5] User-Name           : 63 chars from  #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
   [  6] Password            : 31 chars from  #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
   [  7] E-Mail-Sender       : 63 chars from  #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
   [  8] Send-Again-(min.)   : 3 chars from 1234567890
   [  9] Hold-Time-(hrs.)    : 3 chars from 1234567890
   [ 10] Buffers             : 3 chars from 1234567890
*/

Alert all connections

/**
 * @param {Config} config
 * @param {Context} context
 * Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {

    if (context.device.isGateway && !context.network.isCentralGateway) {

        for (var pos in context.network.vpnconnections);

        // /Setup/WAN/Action-Table
        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
            // setup subject (translate to your desired language)
            + "?subject=VPN-Verbindung im Projekt " + context.vars.projectName
            + " am Standort " + context.vars.locationName + " abgebrochen um %t"
            // setup body (translate to your desired language)
            + "?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
            // setup subject (translate to your desired language)
            + "?subject=VPN-Verbindung im Projekt " + context.vars.projectName
            + " am Standort " + context.vars.locationName + " aufgebaut um %t"
            // setup body (translate to your desired language)
            + "?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);

        /*
           [  1] Index       : 5 chars from 1234567890
           [  8] Active      : Yes (0), No (1)
           [  2] Host-Name   : 64 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789
           [  3] Peer        : 16 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789
           [  4] Lock-Time   : 9 chars from 1234567890
           [  5] Condition   : Establish (0), Disconnect (1), End (2), Failure (3), Establish-Failure (4), Budget-Exhausted (5), Budget-Released (6)
           [  6] Action      : 250 chars from #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!"$%&'()*+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz `
           [  7] Check-For   : 50 chars from #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()*+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz `
           [  9] Owner       : 16 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
           [ 10] Routing-Tag : 5 chars from 1234567890
       */
    }
};

Alert specific Connection

/**
 * @param {Config} config
 * @param {Context} context
 * Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {

    if (context.device.isGateway) {

        // /Setup/WAN/Action-Table
        var actionTable = config.getTableByOid("1.2.2.25");

        // setup disconnect alert
        var row1 = actionTable.createNewRow();
        row1.setByOid("1", "5");
        row1.setByOid("8", "0");
        row1.setByOid("2", "VOIP-VPN-DOWN");
        row1.setByOid("3", "VOIP-VPN");
        row1.setByOid("10", "4094");
        row1.setByOid("4", "0");
        row1.setByOid("5", "3");
        row1.setByOid("6", "mailto:" + context.vars.MAIL_TO
            // setup subject (translate to your desired language)
            + "?subject=VOIP-VPN Verbindung im Projekt " + context.vars.projectName
            + ", am Standort " + context.vars.locationName + " abgebrochen um %t"
            // setup body (translate to your desired language)
            + "?body=Im Projekt " + context.vars.projectName
            + " wurde die VPN-Verbindung VOIP-VPN am Standort " + context.vars.locationName + " unerwartet abgebaut");
        row1.setByOid("7", "");
        row1.setByOid("9", "root");
        actionTable.addOrMerge(row1);

        // setup re-connect alert
        var row2 = actionTable.createNewRow();
        row2.setByOid("1", "6");
        row2.setByOid("8", "0");
        row2.setByOid("2", "VOIP-VPN-UP");
        row2.setByOid("3", "VOIP-VPN");
        row2.setByOid("10", "4094");
        row2.setByOid("4", "0");
        row2.setByOid("5", "0");
        row2.setByOid("6", "mailto:" + context.vars.MAIL_TO
            // setup subject (translate to your desired language)
            + "?subject=VOIP-VPN Verbindung im Projekt " + context.vars.projectName
            + ", am Standort " + context.vars.locationName + " aufgebaut um %t"
            // setup body (translate to your desired language)
            + "?body=Im Projekt " + context.vars.projectName
            + " wurde die VPN-Verbindung VOIP-VPN am Standort " + context.location.locationName + " aufgebaut");
        row2.setByOid("7", "");
        row2.setByOid("9", "root");
        actionTable.addOrMerge(row2);

        // table details
        /*
           [  1] Index       : 5 chars from 1234567890
           [  8] Active      : Yes (0), No (1)
           [  2] Host-Name   : 64 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789
           [  3] Peer        : 16 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789
           [  4] Lock-Time   : 9 chars from 1234567890
           [  5] Condition   : Establish (0), Disconnect (1), End (2), Failure (3), Establish-Failure (4), Budget-Exhausted (5), Budget-Released (6)
           [  6] Action      : 250 chars from #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!"$%&'()*+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz `
           [  7] Check-For   : 50 chars from #ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()*+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz `
           [  9] Owner       : 16 chars from ABCDEFGHIJKLMNOPQRSTUVWXYZ@{|}~!$%&'()+-,/:;<=>?[\]^_.0123456789abcdefghijklmnopqrstuvwxyz`
           [ 10] Routing-Tag : 5 chars from 1234567890
       */

    }
};

results matching ""

    No results matching ""