[pskmail] Re: pskmail-monitor

  • From: Thomas DJ4WL <dj4wl@xxxxxxxxxxxxxx>
  • To: pskmail@xxxxxxxxxxxxx
  • Date: Fri, 18 Apr 2008 19:30:38 +0200

Hi Roberto,

pskmail-monitor13tar.gz
it is Release v.1.3 of 02/03/2008
thanks for your quick Answer

vy 73 tom
dj4wl

Roberto IS0GRB schrieb:
Hi Tomas, i have see the problem.
After the last version of pskmail-monitor i have changed some parts of it.
I will prepare a new version and send you as soon as possible.
What version are you using now?
73 Roberto IS0GRB
    ----- Original Message -----
    *From:* Thomas Andreas <mailto:dj4wl@xxxxxxxxxxxxxx>
    *To:* freelists.org <mailto:pskmail@xxxxxxxxxxxxx>
    *Sent:* Friday, April 18, 2008 3:50 PM
    *Subject:* [pskmail] pskmail-monitor

    Hi Roberto,

    mni tnx for your help.
    you can see it on www.dj4wl.dyndns.org/dj4wl
    <http://www.dj4wl.dyndns.org/dj4wl>
    i checked a couple times, but couldnt find whats wrong.
    it seem that "cat" and "mv" are doing well.
    but i guess there is a bug on Stations heard, because there are wrong
    callsigns, caracter errors.
    the serverlist do not print the correct findu online status. its
    allways
    redbutton status.

    iam just a couple weeks on linux and http-server would be also vy
    pleased to get some hints to keep it secure.

    vy 73 tom
    dj4wl


    pskmail-monitor and serverlist are placed at home/tom
    *.shtml, *.htm, *.php, *.jpg are located at /var/www/dj4wl


    pskmail-monitor:

    #!/bin/sh
    # *    Script for PSKMmail Server Monitor
    # *
    # *    This program is published under the GPL license.
    # *    Copyright (C) 2008 Roberto Abis, IS0GRB (is0grb@xxxxxxxxx
    <mailto:is0grb@xxxxxxxxx>)
    # *    Release v.1.3 of 02/03/2008
    # *
    # *    This is free software; you can redistribute it and/or modify
    # *    it under the terms of the GNU General Public License as
    published
    by
    # *    the Free Software Foundation; either version 2 of the
    License, or
    # *    (at your option) any later version.
    # *
    # *    This is distributed in the hope that it will be useful,
    # *    but WITHOUT ANY WARRANTY; without even the implied warranty of
    # *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # *    GNU General Public License for more details.
    # *
    # *    You should have received a copy of the GNU General Public
    License
    # *    along with this program; if not, write to the Free Software
    # *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307  USA

    # Change paths to reflect your installation
    path="/home/tom"
    fldigilog="/home/tom/.fldigi/fldigi.log"

    cd $path

    cat /dev/null > pskmailheard.htm
    cat /dev/null > serverstatus.htm
    todaydate=`date +%Y-%m-%d`
    todaydate2=`date +%d/%m/%y`
    timecheck=`date +%H:%M`

    echo "$todaydate2<br>" >> pskmailheard.htm
    echo "LastCheck<br>$timecheck UTC<br><br>" >> pskmailheard.htm

    #---------
    # Analyze fldigi.log and extract packets of all stations
    # Stations received directly: qsl from me
    cat $fldigilog | grep $todaydate | grep "TX (" | grep QSL | awk
    '{print
    $5}' | sort | uniq > heardtmp
    # Stations received directly: qsl from other
    cat $fldigilog | grep $todaydate | grep QSL | awk -FQSL '{print $2}' |
    grep "<EOT>" | awk -FEOT '{print $1}' | awk -Fde '{print $2}' | awk
    '{print $1}' | awk -F\< '{print $1}' | sort | uniq  >> heardtmp
    cat $fldigilog | grep $todaydate | grep QSL | awk -FQSL '{print $2}' |
    awk -Fde '{print $1}' | awk '{print $1}' | sort | uniq  >> heardtmp
    cat $fldigilog | grep $todaydate | grep QSL | awk -FQSL '{print $2}' |
    awk '{print $1}' | sort | uniq  >> heardtmp
    cat $fldigilog | grep $todaydate | grep ":1024" | awk -F:1024 '{print
    $1}' | awk -F00u '{print $2}' | awk '{print $1}' | sort | uniq >>
    heardtmp
    cat $fldigilog | grep $todaydate | grep "00u" | awk -F00u '{print
    $2}' |
    awk -F: '{print $1}' | awk '{print $1}' | sort | uniq >> heardtmp
    cat $fldigilog | grep $todaydate | grep ":1024" | awk -F:1024 '{print
    $1}' | awk -F00c '{print $2}' | awk '{print $1}' | sort | uniq >>
    heardtmp
    cat $fldigilog | grep $todaydate | grep ":24" | awk -F:24 '{print
    $2}' |
    awk -F:1024 '{print $1}' | awk '{print $1}' | sort | uniq >> heardtmp
    cat $fldigilog | grep $todaydate | awk -F: '{print $3}' | awk -F0c
    '{print $2}' | awk '{print $1}' | sort | uniq >> heardtmp
    # Stations received directly: beacons
    cat $fldigilog | grep $todaydate | grep ":26" | awk -F:26 '{print
    $1}' |
    awk -F00u '{print $2}' | sort | uniq >> heardtmp
    cat $fldigilog | grep $todaydate | grep ":72" | awk -F:72 '{print
    $1}' |
    awk -F00u '{print $2}' | sort | uniq >> heardtmp
    # Stations that have sent CQ
    cat $fldigilog | grep $todaydate | grep "CQ de" | awk -F"CQ de"
    '{print
    $2}' | awk '{print $1}' | sort | uniq >> heardtmp
    #
    cat heardtmp | grep -v "'" | grep -v "," | grep -v "_" | grep -v ":" |
    awk '{print $1}' | tr [a-z] " " | tr "<" " " | tr ">" " " | awk
    '{print
    $1}' | sort | uniq > heardtmp
    #---------

    #---------
    # Check every stations captured on findu to verify if the station is
    valid or if is it a station with caracters errors
    for callsign in `cat heardtmp`
    do
    lenght=`echo $callsign | wc -L`
    if [ "$lenght" -gt "3" ] ; then
    callsignfiltered=`echo $callsign | awk -F- '{print $1}'`
    if [ "$callsignfiltered" != "" ] ; then
    # Search in findu if the callsign is real to avoid partial callsign
    corrupted from rf disturbs
    findu=`lynx -dump
    http://www.findu.com/cgi-bin/find.cgi?call=$callsign |
    grep "Sorry, no position known"`
    if [ "$findu" != "" ] ; then
    finducheck="0"
    else
    finducheck="1"
    fi
    if [ "$finducheck" != "0" ] ; then
    vericall="Verified"
    echo "$callsign ($vericall)"
    echo "<img src=freccetta.jpg><a
    href=http://www.findu.com/cgi-bin/find.cgi?call=$callsign
    target=blank><b>$callsign</b></a><br>" >> pskmailheard.htm
    else
    vericall="Not Verified"
    fi
    fi
    fi
    done
    # Move the page of the station heard in /var/www/html
    mv pskmailheard.htm /var/www/dj4wl/pskmailheard.htm
    #---------

    echo "---------------"

    #---------
    # Update servers info
    # Check the last aprs beacon sent
    for server in `cat serverlist`
    do
    times=`lynx -dump -delay=5 http://www.findu.com/cgi-bin/find.cgi?call=
    $server | grep received | awk -Freceived '{print $2}' | awk
    '{print $1,
    $2}' | tr " " "*"`
    times1=`echo $times | awk -F* '{print $1}'`
    times2=`echo $times | awk -F* '{print $2}'`
    if [ "$times2" = "" ] ; then
    echo "Server $server down"
    echo "<img src=redbutton.jpg><b>$server</b>&nbsp;<br>" >>
    serverstatus.htm
    else
    if [ "$times2" = "days" ] ; then
    echo "Server $server down"
    echo "<img src=redbutton.jpg><b>$server</b>&nbsp;<br>" >>
    serverstatus.htm
    fi
    if [ "$times2" = "hours" ] ; then
    echo "Server $server down"
    echo "<img src=redbutton.jpg><b>$server</b>&nbsp;<br>" >>
    serverstatus.htm
    fi
    if [ "$times2" = "minutes" ] ; then
    lasttime=`lynx -dump -delay=5
    http://www.findu.com/cgi-bin/find.cgi?call=$server | grep received
    | awk
    -Freceived '{print $2}' | awk '{print $1}'`
    # Check if the last aprs beacon was sent 30min ago
    if [ "$times1" -lt "30" ] ; then
    echo "Server $server ok"
    echo "<img src=greenbutton.jpg><b>$server</b>&nbsp;<br>" >>
    serverstatus.htm
    else
    echo "Server $server down"
    echo "<img src=redbutton.jpg><b>$server</b>&nbsp;<br>" >>
    serverstatus.htm
    fi
    fi
    if [ "$times2" = "seconds" ] ; then
    echo "Server $server ok"
    echo "<img src=greenbutton.jpg><b>$server</b>&nbsp;<br>" >>
    serverstatus.htm
    fi
    fi
    done
    # Move the page of the servers status in /var/www/html
    mv serverstatus.htm /var/www/dj4wl/serverstatus.htm
    #---------

    # Erase temporary files
    rm -f heard.tmp

    exit



    gmfskwl.php:

    <?php
    /*
    # This program is published under the GPL license.
    #   Copyright (C) 2006 Pär Crusefalk SM0RWO (per@xxxxxxxxxxx
    <mailto:per@xxxxxxxxxxx>)
    #
    # *    This is free software; you can redistribute it and/or modify
    # *    it under the terms of the GNU General Public License as
    published
    by
    # *    the Free Software Foundation; either version 2 of the
    License, or
    # *    (at your option) any later version.
    # *
    # *    This is distributed in the hope that it will be useful,
    # *    but WITHOUT ANY WARRANTY; without even the implied warranty of
    # *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # *    GNU General Public License for more details.
    # *
    # *    You should have received a copy of the GNU General Public
    License
    # *    along with this program; if not, write to the Free Software
    # *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307  USA
    */
            /* Open gmfsk.log and read the last x lines */
            function readlastlinesoffile($file,$linestoread)
            {
                    /* open the file and get text to array */
                    $fd = fopen($file, "r") or die("Cant open file
    $file.");
                    $fstring = fread($fd,filesize($file));
                    $line_array = explode("\n", $fstring);
                    fclose($fd);
                    /* Parse array according to size */
                    $size = sizeof($line_array);
                    $newarray = $line_array;
                    if ($size > $linestoread)
                            $newarray =
    array_slice($line_array,1-$linestoread); /*
     return only the last lines */
                    /* output it right away */
                    $current = reset($newarray);
                    if ($current) print("$current<br>");
                    while($current = next($newarray))
                    {
                            if (strpos($current,"TX (")===FALSE)
                            print("<font face=tahoma size=2
    color=\"#000000
    \">$current</font><br>\n");
                            else
    print("<font face=tahoma color=\"#FF0000\"
    size=2>$current</font><br>\n");
                    }
            }
    ?>
    <?php
$myrefresh = $_GET['refresh']; if ($myrefresh>0)
    {
      print("<meta http-equiv=\"refresh\" content=\"$myrefresh\">");
    }
    ?>
    <br>
    <font face=tahoma size=4> DJ4WL-3 PSKMail Server RF log<br>Freq.
    10.147,25 MHz (30m)<br>e-mail: dj4wl@xxxxxxxxxxxxxx</font><br><br
    <mailto:dj4wl@xxxxxxxxxxxxxx%3C/font%3E%3Cbr%3E%3Cbr>>
    <font face=tahoma size=2>
    <?php
            $filename = "/home/tom/.fldigi/fldigi.log";
            $mylines = $_GET['lines'];
            if ($mylines > 0)
            {
                readlastlinesoffile($filename,$mylines);
            }
            else{
            readlastlinesoffile($filename,15);
            }
    ?>
    </font>




    /etc/apache2/sites-available:

    <VirtualHost 192.168.0.8:80>
    ServerName dj4wl.dyndns.org
    ServerAdmin webmaster@xxxxxxxxxxxxxxxx
    <mailto:webmaster@xxxxxxxxxxxxxxxx>
    DocumentRoot /var/www/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews +Includes
    AllowOverride None
    Order allow,deny
    allow from all
    # This directive allows us to have apache2's default start page
                    # in /apache2-default/, but still have / go to the
    right
    place
                    #RedirectMatch ^/$ /apache2-default/
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>

    </VirtualHost>


    /etc/crontab:

    # /etc/crontab: system-wide crontab
    # Unlike any other crontab you don't have to run the `crontab'
    # command to install the new version when you edit this file
    # and files in /etc/cron.d. These files also have username fields,
    # that none of the other crontabs do.

    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

    # m h dom mon dow user command
    17 * * * * root    cd / && run-parts --report /etc/cron.hourly
    25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts
    --report /etc/cron.daily )
    47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts
    --report /etc/cron.weekly )
    52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts
    --report /etc/cron.monthly )
    #
    # PSKMail monitor
    */2 * * * * dj4wl-3 /home/tom/pskmail-monitor
    15 8,10,12,14,16,18,20,22 * * * ~/getstuff_pskmail 2>errors.txt




-- No virus found in this incoming message.
    Checked by AVG.
    Version: 7.5.524 / Virus Database: 269.23.1/1384 - Release Date:
    17/04/2008 15.47


Other related posts: