# Trend the gateway thread count

**URL:** <https://forum.inductiveautomation.com/t/trend-the-gateway-thread-count/98939>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 21, 2024, 2:52pm UTC](https://forum.inductiveautomation.com/t/trend-the-gateway-thread-count/98939 "2024-11-21T14:52:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [November 21, 2024, 2:52pm UTC](https://forum.inductiveautomation.com/t/trend-the-gateway-thread-count/98939/1 "2024-11-21T14:52:54Z")

</div>

I want to create a ignition tag that historizes the gateway thread count.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cb4ad5a3e4367cf25a52a7afdeb66960583f90be.png)  
Is there a way of doing this without doing thread dumps, something lighter.

I am trying to find a bug that causes the thread count of the gateway to exponentially increase which leads to a crash.

The issue is it happens randomly. Gateway will be stable for a few days and then this issue will occur.

I have logging on all my scripts but need to find the exact time the thread count increases massively.

Thanks,

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 21, 2024, 3:05pm UTC](https://forum.inductiveautomation.com/t/trend-the-gateway-thread-count/98939/2 "2024-11-21T15:05:03Z")

</div>

Call this function and get it into a tag however you want:

```python
def getThreadCount():
	from java.lang.management import ManagementFactory

	threadMxBean = ManagementFactory.getThreadMXBean()
	return threadMxBean.getThreadCount()

```
