<commit_before>var util = require('util');
var Duplex = require('stream').Duplex;

var Memory = module.exports = function Memory(options)
{
    this.warn = options.warn;
    this.critical = options.critical;
    Duplex.call(this, { objectMode: true });
};
util.inherits(Memory, Duplex);

Memory.prototype._write = function(chunk, _, cb)
{
    if (chunk.name !== 'memory') return cb();

    var memoryUsed = (chunk.value * 100).toFixed(2) + ' %';
    var message = 'Memory usage (' + memoryUsed + ' memory used) ' +
      'on host ' + chunk.host;

    if (chunk.value > this.critical)
    {
        this.push(
        {
            name: 'memory',
            host: chunk.host,
            message: message,
            status: 'critical',
            value: memoryUsed
        });
    }
    else if (chunk.value > this.warn)
    {
        this.push(
        {
            name: 'memory',
            host: chunk.host,
            message: message,
            status: 'warning',
            value: memoryUsed
        });
    }

    cb();
};

Memory.prototype._read = function(){};<commit_msg>Expire memory alerts if memory usage is okay<commit_after>var util = require('util');
var Duplex = require('stream').Duplex;

var Memory = module.exports = function Memory(options)
{
    this.warn = options.warn;
    this.critical = options.critical;
    Duplex.call(this, { objectMode: true });
};
util.inherits(Memory, Duplex);

Memory.prototype._write = function(chunk, _, cb)
{
    if (chunk.name !== 'memory') return cb();

    var memoryUsed = (chunk.value * 100).toFixed(2) + ' %';
    var message = 'Memory usage (' + memoryUsed + ' memory used) ' +
      'on host ' + chunk.host;

    if (chunk.value > this.critical)
    {
        this.push(
        {
            name: 'memory',
            host: chunk.host,
            message: message,
            status: 'critical',
            value: memoryUsed
        });
    }
    else if (chunk.value > this.warn)
    {
        this.push(
        {
            name: 'memory',
            host: chunk.host,
            message: message,
            status: 'warning',
            value: memoryUsed
        });
    }
    else
    {
        this.push(
        {
            name: 'memory',
            host: chunk.host,
            status: 'ok'
        });
    }

    cb();
};

Memory.prototype._read = function(){};
{'fraction_non_alphanumeric': 0.1423728813559322, 'fraction_numerical': 0.003389830508474576, 'mean_word_length': 1.8377403846153846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2805442', 'n_tokens_mistral': 721, 'n_tokens_neox': 695, 'n_words': 162}