#!/bin/sh

. /etc/PG.conf

FLOWEYE="/usr/ramdisk/bin/floweye"
MSGPUSH="/usr/ramdisk/bin/ipe_msgpush"

ALERT_ENABLE=`${FLOWEYE} malc list | awk '{print $NF}' | grep 1`

[ "${ALERT_ENABLE}" = "" ] && exit 0 

while true
do
    sleep 60

    ${FLOWEYE} malc get logevent=1 | awk \
    '{
        printf "ʱ䣺%s%%0a", $2;

        printf "û%s", $10;
        if($15 != "NULL")
            printf "%%20[%s]%%0a", $15;
        else
            printf "%%0a";

        printf "ӣ%s:%s%%20<->%%20%s:%s%%0a", $4, $5, $6, $7;
        printf "IOC%s%%20[%s]%%0a", $9, $17;
        printf "գ%s%%0a", $8;
        printf "\n";
    }' | while read msg
    do
        ${MSGPUSH} -s msg_title="в鱨澯" msg_ctx="${msg}"
    done
done
