# External check with c program

**URL:** <https://discourse.haproxy.org/t/external-check-with-c-program/5927>\
**Category:** Help!\
**Created:** [November 16, 2020, 10:58am UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927 "2020-11-16T10:58:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nhamza](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@Nhamza](https://discourse.haproxy.org/u/Nhamza)\
**Post date:** [November 16, 2020, 10:58am UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/1 "2020-11-16T10:58:22Z")

</div>

Please help guys , how can i use external check for an c program ?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [November 17, 2020, 12:21am UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/2 "2020-11-17T00:21:52Z")

</div>

You can use whatever you like, as long as whatever application you are calling returns zero on success and non-zero on failure:

> **[HAProxy version 2.2.5 - Configuration Manual](https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4.2-external-check%20command)**

---

<div class="post-metadata">

**Author:** ![Nhamza](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@Nhamza](https://discourse.haproxy.org/u/Nhamza)\
**Post date:** [November 18, 2020, 10:04am UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/3 "2020-11-18T10:04:37Z")

</div>

Thaank’s luka for your answers,  
it’s what i had did the program return either 1 or 0 , and when i restart the haproxy service i don’t get error , but when i execute i don’t get anything

 ![Capture d’écran 2020-11-16 à 12.39.39](https://us1.discourse-cdn.com/flex016/uploads/haproxy/original/2X/d/d6674179edfd8dff2a9ba03d0458142ad3f405c6.png)

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [November 18, 2020, 11:21pm UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/4 "2020-11-18T23:21:55Z")

</div>

Run your application manually in the shell and check the return code yourself (`echo $?`) after your program returns.

---

<div class="post-metadata">

**Author:** ![Nhamza](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@Nhamza](https://discourse.haproxy.org/u/Nhamza)\
**Post date:** [November 19, 2020, 6:27pm UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/5 "2020-11-19T18:27:35Z")

</div>

a lot of thank’s again to answer me,  
i checked the program with echo hi returned 0 or 1 i tested it but i feel like there some bad configuration in haproxy.cfg it’s why i share the configuration with you, you find that’s it correct ?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [November 19, 2020, 7:13pm UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/6 "2020-11-19T19:13:39Z")

</div>

Yes, I too think that there is something wrong, with the configuration and otherwise.

`external-check path` does not appear to point to an actual path. A path means a directory.  
`external-check command` it is unclear if the configuration is really what you want.

Can you provide the output of the following commands, because I really struggle to understand what this configuration is supposed to do:

```auto
file /root/2script.c
file /root/2script.c/0
file /root/2script.c/1
/root/2script.c/0
echo $?
/root/2script.c/1
echo $?

```

---

<div class="post-metadata">

**Author:** ![Nhamza](https://avatars.discourse-cdn.com/v4/letter/n/df788c/32.png) [@Nhamza](https://discourse.haproxy.org/u/Nhamza)\
**Post date:** [November 19, 2020, 7:17pm UTC](https://discourse.haproxy.org/t/external-check-with-c-program/5927/7 "2020-11-19T19:17:37Z")

</div>

ahh there is the first problem it is the same file 2script.c who give us either 0 or 1 the return of 2script.c is 0 or 1, in test i execute  
/root/2script.c  
i get 0 or 1 in return
