test.js

/** This file has been compiled from /home/alex/github/node-scripter/var/local/script/test.coffee */

(function() {
  var Exec, async, checkDf, string;

  async = require('alinex-async');

  Exec = require('alinex-exec');

  string = require('alinex-util').string;

  exports.description = 'General testing of server';

  exports.options = {
    server: {
      alias: 's',
      type: 'string',
      describe: 'server to check'
    }
  };

  exports.handler = function(args, cb) {
    var debug, report;
    debug = exports.debug;
    report = exports.report;
    debug("get data from remote server...");
    console.log(args.server);
    return async.mapOf({
      df: {
        remote: args.server,
        cmd: 'df',
        args: ['-t', 'ext4', '-t', 'vfat'],
        priority: 'immediately'
      },
      conntrack: {
        remote: args.server,
        cmd: 'grep',
        args: ['conntrack', '/var/log/syslog'],
        priority: 'immediately'
      }
    }, function(setup, name, cb) {
      return Exec.run(setup, function(err, proc) {
        return cb(null, proc);
      });
    }, function(err, data) {
      if (err) {
        return cb(err);
      }
      checkDf(data.df, report);
      return cb();
    });
  };

  checkDf = function(proc, report) {
    var data;
    report.h2("Disk Usage");
    if (proc.result.error) {
      report.alert(proc.result.error);
    }
    if (proc.stdout()) {
      data = string.toList(proc.stdout(), /\n/, /\s+/);
      return report.table(data.slice(1), data[0]);
    }
  };

  exports.email = {
    base: 'default'
  };

}).call(this);