Skip to content

SMS Process

SMS Process in SMS.

7 min read Updated SS RS

SMS Process#

SMS stands for "Short Message Service" , it is a mode of notifying the users on their mobiles about anomalies. This helps quickly and efficiently to address the issue.

SMS Alerts Flow
SMS Alerts Flow

Validate the SMS gateway config details from the control center:

  1. Data Receiver: To view the logs in the data receiver.

    1. Navigate to installation path, by executing below command:

      /opt/Heal/centralized_logs/<respective server IP>_data receiver
      

      In the output, look for the violation data, or any connection error.

  2. RabbitMQ Inspection in UI: Check RabbitMQ to see if the queue is piled up, in the below path:

    https:// <RabbitMQ_IP>:<RabbitMQ_Webport>/
    

    RabbitMQ UI — Queues
    RabbitMQ UI — Queues

  3. RabbitMQ Inspection in Server: If RabbitMQ UI access is not available, then follow the below steps:

    1. List the RabbitMQ container ID's.

      • RHEL 7.X: Docker
      docker ps | grep rabbitmq
      
      • RHEL 8.x: Podman
      podman ps | grep rabbitmq
      
    2. Collect the container ID and execute the below command:

      • RHEL 7.X: Docker
      docker exec -it <container ID> bash
      
      • RHEL 8.X: Podman
      podman exec -it <container ID> bash
      

      For Example:

      podman exec -it f05bedeffb67 bash
      

      Expected Output:

      [root@localhost ~]# podman exec -it f05bedeffb67 bash
      root@localhost:/data#
      
    3. To view the queues list, execute the below command inside the container:

      rabbitmqctl list_queues
      

      Expected Output:

      Timeout: 60.0 seconds ...
      Listing queues for vhost / ...
      name messages
      nor-thresholds 0
      anomaly-event-signal-messages 0
      violated-events 0
      anomaly-event-action-messages 11
      static-aggregated-kpi 0
      signal-messages 0
      

      This command's output will show the queue size. In order to check the functioning of the service, the values in the output should vary proportionally to time.

  4. Event Detector: If the event detector is not generated, then check the logs of the event detector for any errors, by navigating to the below path:

    /opt/Heal/centralized_logs/<respective server IP>_EVENT DETECTOR_1
    
  5. Signal detector: Anomalies are generated but failed to generate signals, then check the logs of the signal detector for any errors, by navigating to the below path:

    /opt/Heal/centralized_logs/<respective server IP>_SIGNAL DETECTOR_1
    
  6. Notification Processor Log: If signal messages Que is not consumed, then check the logs for any error messages.

    1. Navigate to the notification processor folder, by executing the below command:

      cd /opt/Heal/centralized_logs/<service name>
      

      For Example:

      cd /opt/Heal/centralized_logs/192.0.2.2_NOTIFICATIONPROCESSOR_1
      
    2. Inspect this log in the above directory for any potential issues.

    3. Check A1eventHandler: The A1event Handler processes events. Search for the violation in the event handler based on the anomaly ID. If the violation is not found, it might indicate an issue with the event handling process.
    4. Navigate to the notification processor folder, by executing the below command:

      cd /opt/Heal/centralized_logs/<service name>
      

      For Example:

      cd /opt/Heal/centralized_logs/192.0.2.2_A1EVENTHANDLER_1
      
  7. Redis Notification Settings: Verify if the notification is enabled and if the config details are updated correctly in Redis.

    1. List the Redis container ID's.

      • RHEL 7.X: Docker
      docker ps | grep redis
      
      • RHEL 8.X: Podman
      podman ps | grep redis
      
    2. Collect the container ID and login to the Redis container.

      • RHEL 7.X: Docker
      docker exec -it <container ID> bash
      
      • RHEL 8.X: Podman
      podman exec -it <container ID> bash
      
    3. Login to the Redis cli.

      redis-cli -c --tls --cert /etc/redis.crt --key /etc/redis.key --cacert /etc/appnomic-
      rootca.crt -h 192.0.2.2 -p 8448
      

      In order to check the config details is present in redis, execute the below key:

      hegtall          /accounts/<account_identifier>/sms/configuration
      
  8. Check IMB logs

    • Go to the IMB centralized logs.
    /opt/Heal/centralized_logs/incident-management-broker
    
  9. SMS gateway: To verify the SMS gateway is reachable and accepting requests, execute the below curl command (replace the placeholders with your gateway details):

    curl -v -H 'auth_key:<sms-gateway-api-key>' \
      -X POST 'http://<gateway-host>:<port>/<send-path>' \
      --data "send=SENDERID&encrypt=0&dest=<mobile-number>"
    

    Expected Output (key lines):

    * Connected to 203.0.113.34 (203.0.113.34) port 8448 (#0)
    > POST /ConnectOneMwUrl/sendencsms/sendencsms HTTP/1.1
    > auth_key:<sms-gateway-api-key>
    < HTTP/1.1 200 OK
    < Content-Type: text/plain
    

    A 200 OK response confirms the gateway accepted the request. If the request fails, verify the gateway URL, credentials and network path with the SMS provider; if it succeeds, investigate the HEAL side.

Not able to send SMS alerts#

Case 1: IMB Port Issue#

Issues observed are as follows:

  1. Container process was not coming up due to xms and xmx values are not updated in java command available in entrypoint.sh file.

    So execute the below java command manually:

    IMB was not configured, so started IMB but inside

    java -XX:+UseOpenJSSE -XX:+UseConcMarkSweepGC -Xms128M -Xmx512M -
    XX:OnOutOfMemoryError='kill -9 %p' -Dcom.sun.management.jmxremote -
    Dcom.sun.management.jmxremote.ssl=false -
    Dcom.sun.management.jmxremote.authenticate=false -
    Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.rmi.port=9010 -
    Dcom.sun.management.jmxremote.local.only=false -
    Djava.rmi.server.hostname=192.0.2.42 -
    jar /opt/incident-management-broker/lib/incident-management-broker-*.jar &
    
  2. Post started IMB, logs were not updated, since the consul key provided is not matched with the existing key due to spelling mistake.

    Create the below consul key to start the logs writing.

    consul kv put service/incident-manamgent-broker/log/mode TRACE
    
  3. Updated the SMS based on consul keys,

    consul kv put service/incident-management-broker/sms_gateway_url
    https://bulksmsapi.example.co.in:9445/bmg/sms/corpapp
    consul kv put service/incident-management-broker/sms_gateway_headers
    "Authorization@@Basic <base64-credentials>##Content-
    Type@@application/x-www-form-urlencoded##Accept@@application/x-www-form-urlencoded"
    consul kv put service/incident-management-broker/incident_enable 0
    
  4. Execute the below command to process and formatting SMS-related data:

    • Updated the below content in sms-post-data.template to take the values dynamically.
    content_type=text&sender_id=SENDERID&mobile=${binding.variables['MobileNumber']}&message=
    ${binding.variables['MessageContent'].trim()}&Intflag=0&charging=0
    
    • Update the below content in sms-preprocessing.groovy .
    Map<String, String> preProcessing(Map<String, String> bind) {
    Map<String, String> map = [:]
    map.putAll(bind)
    map.put("MobileNumber", bind.getOrDefault("MobileNumber", "").replace("'", ""))
    String msg = bind.getOrDefault("MessageContent", "")
    map.put("MessageContent", msg)
    map
    }
    
  5. IMB port was unable to telnet, since the port mapping was not done in the nomad file, so add the below port details:

    port_map {
    imb_port=8989
    jmx_port = 11112
    }
    port "imb_port"
    {
    static = "8989"
    }
    
  6. Config Issue:

    • The logs are getting as TEMPLATE VERIFY FAILED message due to some extra spaces in the template.

    Note: If still the TEMPLATE VERIFY FAILED exception persists, then the user has hardcoded the AVAILABILITY, so if any alerts triggered for core KPIs, then template have {KPI_Type}.

    • Also observed certificate was not imported, so getting PKIX exception. Generate certificate for SMS gateway IP, PORT and imported in IMB cacerts.
    • Post that issue solved.
    echo -n | openssl s_client -connect 'haproxy.example:9998' | sed -ne '/-BEGIN
    CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/haproxy_3.crt
    keytool -import -trustcacerts -keystore /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-
    1.el8_5.x86_64/jre/lib/security/cacerts -storepass changeit -noprompt -alias haproxy_3
    -file /tmp/haproxy_3.crt
    
  7. Enable the required Mobile Numbers for the alerts.

  8. The IMB port was not configured, post the reconfiguration, IMB came up and enabled the IMB logs consul key.
  9. Template has been updated as per user requirements (as earlier we were not able to receive the text messages due the max character size limit of 160 in old template).

Case 2: Groovy File Issue#

The error is as below:

2023-03-28 09:58:55 - DEBUG c.a.a.i.broker.sink.WebserviceSink - SMS posted data on
server, recieved response code: 200 and body:
error_code=10008&error_desc=MESSAGE_TEMPLATE_VERIFY_FAILED&umid=3123032815285536631036
607 7862023-03-28 09:58:55 - INFO c.a.a.i.broker.sink.WebserviceSink - SMS is sent
successfully. 7872023-03-28 09:58:55 - TRACE c.a.a.i.broker.sink.WebserviceSink - Map
data: [MessageContent: Heal\(APM\) Alert, Default Instance_Name:WebApp-01
KPI_Name:Used Size PercentagI Threshold:Lower:75.0,Upper:0.0 KPI_Value:92.0 -Example.,
MobileNumber:<mobile-number>, Notification-Proxy:1, itsm.name:"", itsm.server:"",
itsm.username:"", itsm.password:5B , itsm.oauth:0, itsm.clientid:"",
itsm.clientsecret:5B , itsm.requiredfields:"", itsm.poxyhost:"", itsm.poxyport:"",
itsm.poxypusername:"", itsm.poxypassword:"", cc.cache.update:5,
utp.event.name:UTPNotification, utp.event.eventkey:Latest_Events,
utp.event.appkey:App_Names, utp.default.suppressioninterval:60, itsm.customerid:"",
itsm.integrationkey:"", itsm.eventaction:"", itsm.severity:"", itsm.webservicename:,
itsm.routingId:"", itsm.routingIdType:"", access_key:null, access_expiry:null,
out:java.io.PrintWriter@72f0d08a,
TemplateStr:content_type=text&sender_id=SENDERID&mobile=<mobile-number>&message=Heal\(APM\)
Alert, Default Instance_Name:WebApp-01 KPI_Name:Used Size PercentagI
Threshold:Lower:75.0,Upper:0.0 KPI_Value:92.0 -Example.&Intflag=0&charging=0 788

Solution:

  1. There was only 160 characters whitelisted and the sms-preprocessing groovy file

    cat sms-preprocessing.groovy

    Map<String, String> preProcessing(Map<String, String> bind) {
      Map<String, String> map = [:]
      map.putAll(bind)
      map.put("MobileNumber", bind.getOrDefault("MobileNumber", "").replace("'", ""))
      String msg = bind.getOrDefault("MessageContent", "").replace("Lower threshold:",
    "Lower:").replace("Upper Threshold:", "Upper:")
      msg = getExtractedMessage(msg, "KPI_Name:", "Threshold:", 20)
      msg = getExtractedMessage(msg, "Instance_Name:", "KPI_Name:", 20)
      map.put("MessageContent", msg)
      map
    }
    String getExtractedMessage(def msg, def propertyName, def nextProperty, def maxLength)
    {
      def start = msg.indexOf(propertyName)
      def end = msg.indexOf(nextProperty)
      def currentValue = msg.substring(start+propertyName.length(), end-2)
      def newValue = (currentValue.length() > maxLength) ?currentValue.substring(0,
    maxLength-1):currentValue
      def updatedMsg = msg.replace(currentValue, newValue)
      updatedMsg
    }
    
  2. In the sms-preprocessing , the groovy file had set the limit of message content size as 20. The template verification failed due to the KPI name exceeded the mentioned limit.

  3. Since, the KPI_Name message content limit exceeded 20 , the msg character limit in sms-preprocessing groovy file updated from 20 to 30 . Then the SMS alerts for disk space is received.
Incident Management Broker / SMS log output (Case 2 — Groovy File Issue)
Incident Management Broker / SMS log output (Case 2 — Groovy File Issue)
cat sms-preprocessing.groovy (Case 2 — Groovy File Issue)
cat sms-preprocessing.groovy (Case 2 — Groovy File Issue)

Case 3: KPI Attribute dropped in SMS Alert#

Issue:

Some characters of KPI Attribute are not shown in SMS alert. This has occurred only for Attribute /databackup of Used Size Percentage KPI.

RCA:

  1. In SMS alert, attribute is shown as /databacp (this case is observed only for this specific attribute).
  2. The correct attribute name is /databackup.
  3. The attribute name is correct in the Email Alert and incident management broker log.

SMS Template:

Heal\(APM\)Alert, .{1,30} Instance_Name:.{1,30} KPI_Name:.{1,30}-.{1,30} Threshold:.
{1,30} KPI_Value:.{1,30}-SMS

Solution:

The complete attribute name is received after changing the value from 30 to 32 in sms-preprocessing.groovy file.