#!/bin/sh

event="${1}"
[ "${event}" = "" ] && exit 1

tmp_dir="/usr/ramdisk/tmp"
notice_file="${tmp_dir}/notice_ui.json"
cur_time=`date +%s`

mkdir -p ${tmp_dir}

if [ -f ${notice_file} ]; then
    rows=`awk 'END{print NR}' ${notice_file}`
    if [ ${rows} -gt 100 ]; then
        echo "{\"time\":${cur_time},\"event\":\"${event}\"}" > ${notice_file}
    else
        echo "{\"time\":${cur_time},\"event\":\"${event}\"}" >> ${notice_file}
    fi
else
    echo "{\"time\":${cur_time},\"event\":\"${event}\"}" > ${notice_file}
fi
