<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Good script, thanks Niels<br>
    73<br>
    Libor<br>
    <br>
    <div class="moz-cite-prefix">On 3/26/23 10:50, Niels PD9Q via
      Dxspider-support wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:740fcba2-29c0-9666-f4ce-870ab54e93aa@packet-radio.net">#!/bin/bash
      <br>
      ts=$(date +%s%N)
      <br>
      # Path to the log dir
      <br>
      path=/spider/local_data/log
      <br>
      # Get Month and Year.
      <br>
      month=$(date +%m)
      <br>
      year=$(date +%Y)
      <br>
      # Get the log file.
      <br>
      file="$path"/"$year"/"$month".dat
      <br>
      if [ -f "$file" ]; then
      <br>
          a="$path"/"$year"/"$month".dat
      <br>
      else
      <br>
          echo "$file does not exist. Error, check the path."
      <br>
      fi
      <br>
      # Get some info about the log file
      <br>
      size=$(du -sh "$path"/"$year"/"$month".dat | awk '{ print $1 }')
      <br>
      line=$(wc -l "$a")
      <br>
      # Get the connected from.
      <br>
      b=$(sed -n '/connected from/p' "$a")
      <br>
      # Remove some mess.
      <br>
      c=$(echo "$b" | sed -e '/\>^DXProt^\<<i
        class="moz-txt-slash"><span class="moz-txt-tag">/</span>d' -e 's<span
          class="moz-txt-tag">/</span></i>\>^DXCommand^\</ /g')
      <br>
      # Remove connecteds from localhost (Nobody have to see that i`m
      connecting 1000 times a day) Remove sk1/sk0.
      <br>
      d=$(echo "$c" | sed -e '/127.0.0.1/d' -e '/SK0MMR/d' -e
      '/SK1MMR/d' -e '/PD9Q/d')
      <br>
      # First connect from call... uniq on the second column.
      <br>
      e=$(echo "$d" | awk -F '[ .]' '!uniq[$2]++')
      <br>
      # Last connect from call sort bottom to top / uniq on the second
      column.
      <br>
      f=$(echo "$d" | sort -t: -k 1nr,1 | awk -F '[ .]' '!uniq[$2]++')
      <br>
      # Change the epoch time to reable text (can find any good option
      in bash so perl it is).
      <br>
      g=$(echo "$e" | perl -pe 's/(\d+)/localtime($1)/e')
      <br>
      h=$(echo "$f" | perl -pe 's/(\d+)/localtime($1)/e')
      <br>
      # Echo to a file, need it to compare.
      <br>
      echo "$g" > first
      <br>
      echo "$h" > last
      <br>
      grep -vxFf first last >last.tmp && mv last.tmp last
      <br>
      i=$(cat first)
      <br>
      j=$(cat last )
      <br>
      # ** Count times connected
      <br>
      # Get only the calls
      <br>
      m=$(echo "$d" | awk -F' ' '{ print $2}')
      <br>
      #
      <br>
      count_total=$(echo "$m" | wc -l)
      <br>
      # Count the uniq calls, add the times off connection and sort
      <br>
      n=$(echo "$m" | awk -- '{for (i = 1; i <= NF; i++) wc[$i] +=1};
      END {for (w in wc) print w, wc[w]}' | sort)
      <br>
      count_call=$(echo "$n" | wc -l)
      <br>
      # Add line number
      <br>
      o=$(echo "$n" |awk -v ln=1 '{print ln++  " "  $0 }')
      <br>
      # Add tab between numbers and words
      <br>
      p=$(echo "$o" | awk -v OFS='\t\t' '{ print $1, $2, $3 }')
      <br>
      <br>
div================================================================
      <br>
      div=$div$div
      <br>
      <br>
      width=85
      <br>
      <br>
      printf "\n** Output Generated on %(%m-%d-%Y %H:%M:%S)T\n" $(date
      +%s)
      <br>
      printf "** Log file : "$a"\n"
      <br>
      printf "** Files size : "$size"\n"
      <br>
      printf "** Lines in the log file : "$line""
      <br>
      printf "\n** Total of inbound connects : "$count_total""
      <br>
      printf "\n** Total users : "$count_call"\n"
      <br>
      printf "** Connected Stations over a month\n"
      <br>
      printf "%$width.${width}s\n" "$div"
      <br>
      printf "$i\n" | column -t
      <br>
      printf "%$width.${width}s\n" "$div"
      <br>
      printf "** End Connected Stations\n\n"
      <br>
      <br>
      printf "** Last Connected Stations - Return Connects\n"
      <br>
      printf "%$width.${width}s\n" "$div"
      <br>
      printf "$j\n" | column -t
      <br>
      printf "%$width.${width}s\n" "$div"
      <br>
      printf "** End last Connected Stations\n"
      <br>
      <br>
      <br>
      header="\n%-0s %5s %11s\n"
      <br>
      width=38
      <br>
      printf "$header" "Nr" "Call" "Times"
      <br>
      printf "$p\n" | column -t
      <br>
      echo "Script Runtime $((($(date +%s%N) - $ts)/1000000))ms"
      <br>
      <br>
       73 Niels PD9Q / PI1LAP-1
      <br>
      <br>
      Op 26-3-2023 om 05:32 schreef Tim Tuck via Dxspider-support:
      <br>
      <blockquote type="cite" style="color: #007cff;">Hi all,
        <br>
        <br>
        I want to turn on registration on my node but I'd like to
        pre-register my top users in the process to minimise any pain.
        <br>
        <br>
        The question then is... who are my top users ?
        <br>
        <br>
        I couldn't find a command to show me any form of database of who
        has connected to and used my node over the past month other than
        parsing the log files for the connected statements.
        <br>
        <br>
        So before I go do some scripting around the log files I thought
        I'd ask if anyone has done this and can share  😄
        <br>
        <br>
        Of course I could be missing something obvious so I stand by for
        a face palm moment!
        <br>
        <br>
        thanks
        <br>
        <br>
        Tim
        <br>
        <br>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>