<commit_before><?php
/**
 * Orwell Status Monitor
 *
 * A simple status monitor that parses through today's log files and determines
 * whether Orwell executed, how many e-mails it sent, and whether it finished
 * "on time" or not.
 *
 * Meant to be used as a passive service report to Nagios, via NSCA, in order
 * to allow for Nagios monitoring of Orwell execution runs.
 **/
include_once(dirname(__FILE__) . '/lib/Log/RubyLog.class.php');
include_once(dirname(__FILE__) . '/lib/LogSet.class.php');

if ($_SERVER)
{
	header("Content-type: text/plain");
	set_time_limit(600);
}

// Debug-mode: output extra information about the log handlers being used and
// the log files that are being opened/read/closed. 
if (! defined('DEBUG'))
{
	if ($_GET['debug'] || getenv('debug'))
	{
		define('DEBUG', true);
	}
	else
	{
		define('DEBUG', false);
	}
}

/**
 * Trivial utility function to setup the counters for an orwell "chunk" in the
 * $orwell_chunks array.
 **/
function ensure_orwell_chunk($i)
{
	global $orwell_chunks;
	
	if (! isset($orwell_chunks[$i]))
	{
		$orwell_chunks[$i] = array
		(
			'start' => array(),
			'stop' => array()
		);
	}
}

/**
 * Trivial utility function to output the information from this script in the
 * format that Nagios/NSCA expects (tab-delimited fields).
 **/
function nagios_service_report($return_code, $message)
{
	global $environment;
	
	$fields = array();
	$fields[] = "logmaster";                               // Hostname.
	$fields[] = "Orwell: " . ucfirst(lower($environment)); // Service description.
	$fields[] = $return_code;                              // Check result (0 = OK, 1 = WARNING, 2 = CRITICAL).
	$fields[] = $message;                                  // Plugin output (verbose description/message).

	echo join("\t", $fields) . "\n";
	exit;
}

$environment = 'live'; // beta, live, or stage
$orwell_chunks = array();
$orwell_end_timestamp = null;
$orwell_start_timestamp = null;
<commit_msg>Oops -- bugfix lower -> strtolower<commit_after><?php
/**
 * Orwell Status Monitor
 *
 * A simple status monitor that parses through today's log files and determines
 * whether Orwell executed, how many e-mails it sent, and whether it finished
 * "on time" or not.
 *
 * Meant to be used as a passive service report to Nagios, via NSCA, in order
 * to allow for Nagios monitoring of Orwell execution runs.
 **/
include_once(dirname(__FILE__) . '/lib/Log/RubyLog.class.php');
include_once(dirname(__FILE__) . '/lib/LogSet.class.php');

if ($_SERVER)
{
	header("Content-type: text/plain");
	set_time_limit(600);
}

// Debug-mode: output extra information about the log handlers being used and
// the log files that are being opened/read/closed. 
if (! defined('DEBUG'))
{
	if ($_GET['debug'] || getenv('debug'))
	{
		define('DEBUG', true);
	}
	else
	{
		define('DEBUG', false);
	}
}

/**
 * Trivial utility function to setup the counters for an orwell "chunk" in the
 * $orwell_chunks array.
 **/
function ensure_orwell_chunk($i)
{
	global $orwell_chunks;
	
	if (! isset($orwell_chunks[$i]))
	{
		$orwell_chunks[$i] = array
		(
			'start' => array(),
			'stop' => array()
		);
	}
}

/**
 * Trivial utility function to output the information from this script in the
 * format that Nagios/NSCA expects (tab-delimited fields).
 **/
function nagios_service_report($return_code, $message)
{
	global $environment;
	
	$fields = array();
	$fields[] = "logmaster";                                    // Hostname.
	$fields[] = "Orwell: " . ucfirst(strtolower($environment)); // Service description.
	$fields[] = $return_code;                                   // Check result (0 = OK, 1 = WARNING, 2 = CRITICAL).
	$fields[] = $message;                                       // Plugin output (verbose description/message).

	echo join("\t", $fields) . "\n";
	exit;
}

$environment = 'live'; // beta, live, or stage
$orwell_chunks = array();
$orwell_end_timestamp = null;
$orwell_start_timestamp = null;

{'fraction_non_alphanumeric': 0.1447067783701447, 'fraction_numerical': 0.0030464584920030465, 'mean_word_length': 3.2004264392324093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1698328', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1245, 'n_words': 375}