<commit_before>#!/bin/bash

CATALINA_PID=/var/run/tomcat7.pid

if ! service tomcat7 status > /dev/null 2>&1 ; then
	# Ensure we keep timestamps
	cp="cp --preserve=timestamps"
	tar="tar --atime-preserve"

	# Create directory to store dump
	DUMPDIR=/var/log/tomcat_watchdog/$(date +"%Y-%m-%d.%H.%M")
	mkdir -p $DUMPDIR

	# Notify that we are dumping
	now=$(date); echo "$now >> Tomcat7 is not running, dumping to $DUMPDIR"

	# Store the PID file, if we have one
	if [ -f "$CATALINA_PID" ]; then
		$cp $CATALINA_PID $DUMPDIR/tomcat7.pid > /dev/null
	fi
	# Save a copy of the tomcat logs
	$tar -czf $DUMPDIR/tomcat7_logs.tar.gz /var/log/tomcat7/* > /dev/null 2>&1
	# Save a copy of the tomcat files
	$tar -czf $DUMPDIR/tomcat7_files.tar.gz /usr/share/tomcat7/* > /dev/null 2>&1
	# Save a copy of the syslog
	$tar -czf $DUMPDIR/syslog.tar.gz /var/log/syslog > /dev/null 2>&1

	# Try to restart tomcat
	if service tomcat7 restart; then
		now=$(date); echo "$now >> Tomcat7 has been restarted."
	else
		now=$(date); echo "$now >> Tomcat7 could not be restarted."
	fi
fi

<commit_msg>Smarter collection of logfiles, cut back on the dump size. Also now properly tested.<commit_after>#!/bin/bash

CATALINA_PID=/var/run/tomcat7.pid

if ! service tomcat7 status > /dev/null 2>&1 ; then
	# Ensure we keep timestamps
	cp="cp --preserve=timestamps"
	tar="tar --atime-preserve"

	# Create directory to store dump
	DUMPDIR=/var/log/tomcat_watchdog/$(date +"%Y-%m-%d.%H.%M")
	mkdir -p $DUMPDIR

	# Notify that we are dumping
	now=$(date); echo "$now >> Tomcat7 is not running, dumping to $DUMPDIR"

	# Store the PID file, if we have one
	if [ -f "$CATALINA_PID" ]; then
		$cp $CATALINA_PID $DUMPDIR/tomcat7.pid > /dev/null
	fi
	# Save a copy of the tomcat logs
	$tar -czf $DUMPDIR/tomcat7_logs.tar.gz /var/log/tomcat7/* > /dev/null 2>&1
	# Save any tomcat module logs, if any can be found
	MODULE_LOGS=$(find -L /usr/share/tomcat7 -name *.log)
	if [ -n "$MODULE_LOGS" ]; then
		$tar -czhf $DUMPDIR/tomcat7_module_logs.tar.gz $MODULE_LOGS \
			> /dev/null 2>&1
	fi
	# Save a copy of the system logs
	$tar -czf $DUMPDIR/system_logs.tar.gz /var/log/syslog /var/log/*.log \
		/var/log/dmesg /var/log/messages > /dev/null 2>&1

	# Try to restart tomcat
	if service tomcat7 restart; then
		now=$(date); echo "$now >> Tomcat7 has been restarted."
	else
		now=$(date); echo "$now >> Tomcat7 could not be restarted."
	fi
fi


{'fraction_non_alphanumeric': 0.14470391993327772, 'fraction_numerical': 0.0158465387823186, 'mean_word_length': 3.50093808630394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '2142977', 'n_tokens_mistral': 1002, 'n_tokens_neox': 937, 'n_words': 278}