<commit_before>#!/bin/bash

# ------------------------------------------------------- #
#
# chinachu-check-status.sh
#
# Copyright (c) 2015 tag
#
# ------------------------------------------------------- #

# environment
PATH=${PATH}
DATE_FORMAT="%Y-%m-%d %T"

# variables
CHINACHU_URL="http://localhost:10772"
MARGIN_UPTIME=600
MARGIN_SLEEP=1800


# check the uptime
NOW=`date +%s`
UPTIME=`uptime -s`
BORDER=`date -d "${UPTIME} ${MARGIN_UPTIME} seconds" +%s`
#echo now: `date -d @${NOW} +"${DATE_FORMAT}"`
#echo uptime: `date -d "${UPTIME}" +"${DATE_FORMAT}"`
#echo border: `date -d @${BORDER} +"${DATE_FORMAT}"`
if [ ${NOW} -lt ${BORDER} ]; then
	echo "[`date +"${DATE_FORMAT}"`] ${0}: It has not elapsed only a few minutes from a boot. (uptime: `date -d "${UPTIME}" +"${DATE_FORMAT}"`)" 1>&2
	exit 1
fi


# check the status of Chinachu: Is Chinachu recording
if `chinachu-is-recording ${CHINACHU_URL}`; then
	echo "[`date +"${DATE_FORMAT}"`] ${0}: Chinachu is recording now." 1>&2
	exit 1
fi


# check the status of Chinachu: Is Chinachu waiting for the next recording
NEXT=`chinachu-get-next-time ${CHINACHU_URL}`
BORDER=`expr ${NEXT} - ${MARGIN_SLEEP}`
if [ ${NOW} -gt ${BORDER} ]; then
	echo "[`date +"${DATE_FORMAT}"`] ${0}: Chinachu is waiting for the next recording. (next: `date -d @${NEXT} +"${DATE_FORMAT}"`)" 1>&2
	exit 1
fi


# check whether someone is logging in to this server
USERS=`who -u | wc -l`
if [ ${USERS} -gt 0 ]; then<commit_msg>Update chinachu-check-status.sh<commit_after>#!/bin/bash

# ------------------------------------------------------- #
#
# chinachu-check-status.sh
#
# Copyright (c) 2015 tag
#
# ------------------------------------------------------- #

# environment
PATH=${PATH}
DATE_FORMAT="%Y-%m-%d %T"

# variables
CHINACHU_URL="http://localhost:10772"
MARGIN_UPTIME=600
MARGIN_SLEEP=1800


# check the uptime
NOW=`date +%s`
#UPTIME=date -d "`uptime -s`" +%s
UPTIME=`cat /proc/driver/rtc | ALARM_DATE="echo $(sed -e "s/^alrm_time.*\([0-9]*-[0-9]*-[0-9]\)$/\1/") $(sed -e "s/^alrm_date.*\([0-9]*:[0-9]*:[0-9]\)$/\1/")" ; date -d "${ALARM_DATE}" +%s`
BORDER=$((${UPTIME} + ${MARGIN_UPTIME}))
if [ ${NOW} -lt ${BORDER} ]; then
        echo "[`date +"${DATE_FORMAT}"`] ${0}: It has not elapsed only a few minutes from a boot. (uptime: `date -d @${UPTIME} +"${DATE_FORMAT}"`)" 1>&2
        exit 1
fi

# check the status of Chinachu: Is Chinachu recording
if `chinachu-is-recording ${CHINACHU_URL}`; then
	echo "[`date +"${DATE_FORMAT}"`] ${0}: Chinachu is recording now." 1>&2
	exit 1
fi


# check the status of Chinachu: Is Chinachu waiting for the next recording
NEXT=`chinachu-get-next-time ${CHINACHU_URL}`
BORDER=$((${NEXT} - ${MARGIN_SLEEP}))
if [ ${NOW} -gt ${BORDER} ]; then
	echo "[`date +"${DATE_FORMAT}"`] ${0}: Chinachu is waiting for the next recording. (next: `date -d @${NEXT} +"${DATE_FORMAT}"`)" 1>&2
	exit 1
fi


# check whether someone is logging in to this server
USERS=`who -u | wc -l`
if [ ${USERS} -gt 0 ]; then
{'fraction_non_alphanumeric': 0.2708613728129206, 'fraction_numerical': 0.024226110363391656, 'mean_word_length': 3.1464435146443517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1969145', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1127, 'n_words': 309}