title: Check MongoDB status in node js
body: <p>I need to be able to run '<code>/etc/init.d/mongod status</code>' or '<code>service mongod status</code>' from wihtin a node js file, in order to store the response in the database. </p>
  
  <p>When I run the above commands in the command line, I get the following response:</p>
  
  <pre><code>● mongod.service - SYSV: Mongo is a scalable, document-oriented database.
     Loaded: loaded (/etc/rc.d/init.d/mongod)
     Active: active (running) since Thu 2017-02-02 08:07:42 UTC; 3h 27min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 793 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=0/SUCCESS)
   Main PID: 1027 (mongod)
     CGroup: /system.slice/mongod.service
             └─1027 /usr/bin/mongod -f /etc/mongod.conf
  </code></pre>
  
  <p>However, I want to include this status in an API response that I write. Therefore, when a user request my API, I want it to return the mongoDB status check as seen above.</p>
  
  <p>I have tried the following ways:</p>
  
  <p>router.get('/status', function(req, res) {</p>
  
  <pre><code>var databaseCheck = service mongod status // not sure how to do this
  res.json({
      mongoResponse: '//to have the above status check response here'
  });
  </code></pre>
  
  <p>});</p>
  
  <p>I am new to all this, so any help would be appreciated. I may understand that my thinking is wrong - do let me know if there is a different way of doing this please</p>