I am trying to create a monit config file to monitor if mongodb is running.
Here's my config file.
check process mongod with pidfile /var/run/mongodb/mongod.pid
group mongodb
start program = "/sbin/start mongod"
stop program = "/sbin/stop mongod"
if failed host 127.0.0.1 port 27017 protocol http
and request "/" with timeout 10 seconds then restart
I always get the following error and it restarts mongodb.
port response time FAILED to [localhost]:27017 type TCP/IP protocol HTTP
I checked and verified mongodb running. I event tried connecting to mongodb using curl. Here's the command I executed to verify http connection to the mongo is working.
curl -v localhost:27017
Here's the output I am getting.
* Rebuilt URL to: localhost:27017/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 27017 (#0)
> GET / HTTP/1.1
> Host: localhost:27017
> User-Agent: curl/7.58.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Connection: close
< Content-Type: text/plain
< Content-Length: 85
<
It looks like you are trying to access MongoDB over HTTP on the native driver port.
* Closing connection 0
Not sure what I am doing wrong.
The same config file is working on ubuntu 14.4, but it does not working ubuntu 18.4.