DX NetOps

Expand all | Collapse all

SANM and MSG_TIMESTAMP_FORMAT

Jump to Best Answer
  • 1.  SANM and MSG_TIMESTAMP_FORMAT

    Posted 05-04-2017 06:56 AM

    Hi

    In the Spectrum manual there is a description for a SANM/AlarmNotifier parameter MSG_TIMESTAMP_FORMAT, which lives in the .alarmrc file, as follows

     

    • MSG_TIMESTAMP_FORMAT
      Sets the format for the timestamp on all SANM messages. The maximum length of the output string is 127 characters. Any characters other than the conversion strings are output as text in the timestamp. The default setting is %X %x:. The colon (:) is appended to the end of the timestamp. For example, to output the date/time for the current locale and the time zone name, the string %x %X %Z is entered as the value. If left blank, no timestamp is output on the messages. If an incorrect string is entered, that string displays as text in the output.

     

    My question is where do I see, or how do I access, this timestamp? 

     

    It does not appear to be in the AlarmNotifier output, or at least changing this setting does not appear to make any difference to the AlarmNotifier ouput.

     

    Regards, John



  • 2.  Re: SANM and MSG_TIMESTAMP_FORMAT
    Best Answer

    Broadcom Employee
    Posted 05-05-2017 03:24 AM

    This parameter is setting the date/time format for AlarmNotifier error messages. So it is for date/time format of error message output into the standard error stream (stderr) of AlarmNotifier process.

    I did a test. I changed from MSG_TIMESTAMP_FORMAT=%X %x to MSG_TIMESTAMP_FORMAT=%x %X. I run AlarmNotifier and do Control-c to stop it.

     

    Here is capture before and after:

    Before and after change the MSG_TIMESTAMP_FORMAT parameter value

    This won't affect date/time format of the event message.



  • 3.  Re: SANM and MSG_TIMESTAMP_FORMAT

    Posted 05-05-2017 09:40 AM

    Well that is pretty useless then 

     

    Thanks for the info in any case.

     

    Regards, John



  • 4.  Re: SANM and MSG_TIMESTAMP_FORMAT

    Broadcom Employee
    Posted 05-08-2017 01:30 AM

    I am not sure if this is going to be suitable for you. But we can customize AlarmNotifier scripts to convert date/time format of Event Message. Below I have tested the SetScript in Spectrum 10.2.1 on Windows 2012.

     

    I have added the following lines within the echo_info() function.

    # Convert Event Message Date/Time Format
    # Assumming Event Message starts with the following Date/Time format
    #    Fri 05 May, 2017 - 16:42:09 - Device ...
    EVENTMSG_DATE=`expr "$EVENTMSG" : '^\(.*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*' | tr -d ',' | tr -d '-'`
    if [ "$EVENTMSG_DATE" ]
    then
      EVENTMSG_NEWDATE=`date -d"$EVENTMSG_DATE" +"%x %X"`
      EVENTMSG_NEW=`echo ${EVENTMSG/*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/$EVENTMSG_NEWDATE}`
      echo "EventMessageDate:     $EVENTMSG_DATE"
      echo "EventMessageNewDate:     $EVENTMSG_NEWDATE"
      echo "EventMessageNew:     $EVENTMSG_NEW"
    else
      # This variable has substituted placeholder chars, echo them inside quotes
      echo "EventMessage:     $EVENTMSG"
    fi

    I got the following result.

    You can run

          date --help

    on bash login shell to see what Date/Time format you can use and adjust the format in above Script (line 7).

    I hope this helps.



  • 5.  Re: SANM and MSG_TIMESTAMP_FORMAT

    Posted 05-08-2017 04:58 AM

    Hi Widjaja_Sangtoki

    I had already done something like this in my script but thought if there was something built in I would use it. I guess somebody somewhere must have thought that MSG_TIMESTAMP_FORMAT parameter would be useful but I fail to see how it could be used for anything other than troubleshooting.

     

    For info my solution is as follows ...

     

    # Change date/time format to DD-Mon-YYYY HH:MM:SS TZ

    DATETIME=`date -d "$DATE $TIME" "+%d-%b-%Y %H:%M:%S %Z"`

     

    This gives output in the format 08-May-2017 09:45:08 BST

     

    Regards, John