var secrets = require('./config/secrets');
var getDropletStats = require('./droplet_stats');
var User = require('./models/User');

var mongoose = require('mongoose');
mongoose.connect(secrets.db);

var DigitalOceanAPI = require('digitalocean-api');
var api = new DigitalOceanAPI(secrets.digitalocean.client_id, secrets.digitalocean.api_key);

var _ = require('underscore');

var checkServers = function () {
  console.log( '| Doing Server Check' );
  User.find( '', function(err,users) {
    if (err) return err;
    var starbound_servers = [];
    _.each(users, function(user,i) {
      // console.log(user);
      if( user.servers[0] != undefined ) {
        starbound_servers.push( user.servers[0] );
      }
      return false;
    });
    console.log( '| Servers' );

    api.dropletGetAll(function(err,droplets){
      if (err) return err;
      _.each(droplets, function(droplet,i) {
        if( _.contains( starbound_servers, droplet.id ) ) {          
          console.log( droplet.name, droplet.id );
          // starbound.today Droplets
          getDropletStats( droplet );
        }
      });
    });

  });
}

setInterval( checkServers(), 15 * 60 * 1000 );

@@ -332,24 +332,48 @@
 .api_key);%0A%0A
+var fs = require('fs');%0A
 var _ = requ
@@ -1076,16 +1076,27 @@
         
+ var data =
  getDrop
@@ -1112,24 +1112,258 @@
  droplet );%0A
+          data.name = droplet.name;%0A          data.id = droplet.id;%0A          data.time = new Date();%0A          fs.appendFile('./server-monitor.log', data, function (err) %7B%0A            console.log( 'Ran 15 min check' );%0A          %7D);%0A
         %7D%0A  

monitor logging