# Check if port is open with Logstash/Elasticsearch

**URL:** <https://discuss.elastic.co/t/check-if-port-is-open-with-logstash-elasticsearch/56177>\
**Category:** Logstash\
**Created:** [July 22, 2016, 12:07pm UTC](https://discuss.elastic.co/t/check-if-port-is-open-with-logstash-elasticsearch/56177 "2016-07-22T12:07:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![beelastic](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@beelastic](https://discuss.elastic.co/u/beelastic)\
**Post date:** [July 22, 2016, 12:07pm UTC](https://discuss.elastic.co/t/check-if-port-is-open-with-logstash-elasticsearch/56177/1 "2016-07-22T12:07:13Z")

</div>

I want to be alerted (with wather) if a specific port is closed.

To achiev this i want to create a field with logstash (e.g. `port_status`), and fill it with `open` or `close`, whether the port is open or closed.

How can i check this with logstash? Is it possible with the `tcp` or `udp` plugin?  
Maybe with the following configuration?

```
input {  
          tcp {    
            mode => "client"   
            host => "myserver.com"
            port => 1194
       }
    }
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 22, 2016, 5:41pm UTC](https://discuss.elastic.co/t/check-if-port-is-open-with-logstash-elasticsearch/56177/2 "2016-07-22T17:41:59Z")

</div>

I don't think Logstash/Elasticsearch is a terribly good choice for this kind of alerting. Anyway, I don't see how the tcp input can be made useful here. You could however use an exec input that runs something like `nc -z myserver.com 1194 ; echo $?`.

---

<div class="post-metadata">

**Author:** ![beelastic](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@beelastic](https://discuss.elastic.co/u/beelastic)\
**Post date:** [July 24, 2016, 11:24am UTC](https://discuss.elastic.co/t/check-if-port-is-open-with-logstash-elasticsearch/56177/3 "2016-07-24T11:24:56Z")

</div>

Thank you, i will see if it Works 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:46am UTC](https://discuss.elastic.co/t/check-if-port-is-open-with-logstash-elasticsearch/56177/4 "2017-07-06T04:46:39Z")

</div>


