UK CA Unified Infrastructure Management User Group

 View Only

LUA script to log value from alarm

  • 1.  LUA script to log value from alarm

    Posted Mar 29, 2016 08:22 AM

    Hi all,

     

    I have the following LUA script to take a value from an alarm and send it to QoS:

     

    local qos_name   = "QOS_LOGMON_VARIABLE"

    local qos_source = "o2bjobl1"

    local qos_target = "O2BJOBL1 - ActiveMQ - Messages Dequeued"

     

     

    local pattern = " dequeueCount=(%d+) "

     

     

    local a = alarm.get("TP60381977-54232")

     

     

    local vdequeueCount = string.match(a.message, pattern)

     

     

    local sum = vdequeueCount

     

     

    print = (vdequeueCount)

     

     

    nimbus.qos(qos_name, qos_source, qos_target, sum, QOS_ASYNCH)

     

    My issue is that the value I'm looking for, in this case it's the value after is the dequeueCount...dequeueCount="206" isn't been sent to the QoS DB.

     

    I've noticed that my script is looking for dequeueCount=(%d+) whereas the alarm text states dequeueCount="(%d+)".

     

    Can anyone point me towards the correct syntax for pick up the speech marks around the (%d+), or do I need a whole new script?

     

    The alarm that my AO rule is tied to is below:

     

    <queues>  <queue name="workQueue">    <stats size="7053"          consumerCount="28"          enqueueCount="1080"          dequeueCount="0"/>     <feed>     <atom>queueBrowse/workQueue;jsessionid=wt119703mqcz13mx2fs8od7b8?view=rss&amp;feedType=atom_1.0</atom>     <rss>queueBrowse/workQueue;jsessionid=wt119703mqcz13mx2fs8od7b8?view=rss&amp;feedType=rss_2.0</rss>   </feed> </queue>  <queue name="fsmRequestQueue">    <stats size="0"          consumerCount="4"          enqueueCount="206"          dequeueCount="206"/>     <feed>     <atom>queueBrowse/fsmRequestQueue;jsessionid=wt119703mqcz13mx2fs8od7b8?view=rss&amp;feedType=atom_1.0</atom>     <rss>queueBrowse/fsmRequestQueue;jsessionid=wt119703mqcz13mx2fs8od7b8?view=rss&amp;feedType=rss_2.0</rss>   </feed> </queue>  <queue name="fsmResponseQueue">    <stats size="0"          consumerCount="62"          enqueueCount="206"          dequeueCount="206"/>     <feed>     <atom>queueBrowse/fsmResponseQueue;jsessionid=wt119703mqcz13mx2fs8od7b8?view=rss&amp;feedType=atom_1.0</atom>     <rss>queueBrowse/fsmResponseQueue;jsessionid=wt119703mqcz13mx2fs8od7b8?view=rss&amp;feedType=rss_2.0</rss>   </feed> </queue>  </queues

     

    Hope this makes sense,

     

    Thanks,

    Sam