# How to write the Gateway Alarm Active and Ack count to PLC

**URL:** <https://forum.inductiveautomation.com/t/how-to-write-the-gateway-alarm-active-and-ack-count-to-plc/59932>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [May 23, 2022, 10:46pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-gateway-alarm-active-and-ack-count-to-plc/59932 "2022-05-23T22:46:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven.gyllich](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@steven.gyllich](https://forum.inductiveautomation.com/u/steven.gyllich)\
**Post date:** [May 23, 2022, 10:46pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-gateway-alarm-active-and-ack-count-to-plc/59932/1 "2022-05-23T22:46:51Z")

</div>

I need to get the Gateway Alarm Active and Acknowledge count to the PLC. What would be the best way to get this value to my PLC? Does anyone have a sample script that could do this?

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [May 24, 2022, 12:29am UTC](https://forum.inductiveautomation.com/t/how-to-write-the-gateway-alarm-active-and-ack-count-to-plc/59932/2 "2022-05-24T00:29:54Z")

</div>

Something like this in a timer script should do it, adjust the filters to your liking:

```auto
paths = ['[default]AlarmsActive', '[default]AlarmsAcked']
activeCount = len(system.alarm.queryStatus(state = [2]))
ackCount = len(system.alarm.queryStatus(state = [0,1,3]))
system.tag.writeBlocking(paths, [activeCount, ackCount])

```

There are other places you could run this, like in an expression tag, though i don’t know if that would impact performance.

---

<div class="post-metadata">

**Author:** ![steven.gyllich](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@steven.gyllich](https://forum.inductiveautomation.com/u/steven.gyllich)\
**Post date:** [May 26, 2022, 2:39pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-gateway-alarm-active-and-ack-count-to-plc/59932/3 "2022-05-26T14:39:27Z")

</div>

This is exactly what I was looking for, Thanks!
