Check network status. 
Supported in QuikCode versions 2.36 and later.  Not the free DOS version.      


 
    ****************************************************************************
    * Program: netping.q v1.2                                                  *
    * Written: 06/26/2007                                                      *
    * Purpose: Pings a server at a specified time interval and sounds an alarm *
    *          when connection errors are detected. Network errors are written *
    *          to a log file.                                                  *
    * Syntax.: quikcode.exe netping.q [Enter Key]                              *
    *                                                                          *
    * Equates: SERVER ---------> IP Address of server to ping.                 *
    *          LOG-FILE -------> Log file to record network errors.            *
    *          PING-TIME ------> Default time interval to ping server.         *
    *          ALERT-TIME -----> Time interval to ping server during an alert. *
    *          ALERT-MUTE -----> Mute after contiguous number of alerts.       *
    *          ALERT-MINIMIZE -> Minimize after contiguous number of alerts.   *
    *          UP-WAV ---------> Connection up wav sound file.                 *
    *          DOWN-WAV -------> Connection down wav sound file.               *
    *          TIMEOUT-WAV ----> Connection Timeout Wav sound file.            *
    *                                                                          *
    * Notes..: - Replace SERVER equate value with domain name or IP address.   *
    *          - Server must be pingable, otherwise NetPing will NOT work.     *
    *          - Kill using Windows task manager when window is hidden.        *
    *          - To turn logging off, set LOG-FILE equate to '' or spaces.     *   
    ****************************************************************************
 
    * These options reduce program memory requirements
    option equmax          = 50                   * Max number of pgm equates 
    option labmax          = 15                   * Max number of pgm labels
    option stmtmax         = 225                  * Max number of pgm statements
    option strmax          = 60                   * Max number of pgm strings 
    option wstsize         = 200                  * Working Storage record size
    option ifasize         = 200                  * Input File A record size 
    option ofasize         = 70                   * Output File A record size
   
    * User configurable equates  
    equate SERVER            to 'NNN.NNN.NNN.NNN' * <- DOMAIN NAME OR IP ADDRESS HERE
    equate LOG-FILE          to 'netping.log'     * Append errors to log file
    equate PING-TIME         to 60000             * 1 Minute default ping interval 
    equate ALERT-TIME        to 15000             * 15 Second alert ping interval
    equate ALERT-MUTE        to 5                 * Mute after contiguous alerts
    equate ALERT-MINIMIZE    to 10                * Minimize after contiguous alerts
    equate UP-WAV            to 'net_up.wav'      * Wav file -> Network up 
    equate DOWN-WAV          to 'net_dn.wav'      * Wav file -> Network down
    equate TIMEOUT-WAV       to 'net_to.wav'      * Wav file -> Network timeout
 
    * Leave these equates intact
    equate VERSION           to 'v1.2'            * NetPing version number
    equate BELL              to x'07'             * Ring the PC bell
    equate RED-ON-BLACK      to 12                * Red text on black background
    equate YELLOW-ON-BLACK   to 14                * Yellow text on black background
    equate GREEN-ON-BLACK    to 10                * Green text on black background
    equate DKRED-ON-BLACK    to 4                 * Red text on black background
    equate DKYELLOW-ON-BLACK to 6                 * Yellow text on black background
    equate DKGREEN-ON-BLACK  to 2                 * Green text on black background
    equate WHITE-ON-BLACK    to 7                 * White text on black background
    equate UP                to 'U'               * Connection is Up
    equate DOWN              to 'D'               * Connection is Down
    equate TIMEOUT           to 'T'               * Connection Timed out
    equate HIDE              to 0                 * Hide window
    equate SHOW              to 8                 * Show window
    equate MINIMIZE          to 6                 * Minimize window
    equate MAXIMIZE          to 10                * Maximize window
 
    * Working Storage equates
    equate idx               to wst1-2-i          * General purpose index 
    equate sleep-millis      to wst3-6-L          * Sleep delay in milliseconds
    equate error-cnt         to wst7-8            * Counter of contiguous errors
    equate net-status-cd     to wst9              * (D)own, (U)p, (T)imeout 
    equate net-timeouts      to wst10-16          * Total Network Timeouts Detected
    equate net-timeout-dt    to wst17-26          * Last Network Timeout Date
    equate net-timeout-tm    to wst27-37          * Last Network Timeout Time
    equate net-disconnects   to wst38-44          * Total Network Disconnects Detected
    equate net-disconnect-dt to wst45-54          * Last Network Disconnect Date
    equate net-disconnect-tm to wst55-65          * Last Network Disconnect Time
    equate net-connects      to wst66-72          * Total Network Connects Detected 
    equate net-connect-dt    to wst73-82          * Last Network Connect Date
    equate net-connect-tm    to wst83-93          * Last Network Connect Time
    equate start-dt          to wst94-103         * NetPing Start Date
    equate start-tm          to wst104-114        * NetPing Start Time 
    equate logging-sw        to wst115            * Log to file switch (Y/N) 
 
    cls                                           * Clear the screen
    cursor off                                    * Cursor is invisible
    set windowtitle          to 'NetPing ' VERSION '  -  Server: ' SERVER  * Set Window Title
    set windowsize           to 6 53              * Set Window Size
    move PING-TIME           to sleep-millis
    move 0                   to error-cnt
    move 0                   to net-timeouts
    move 0                   to net-disconnects
    move 0                   to net-connects
    move date                to start-dt
    move time                to start-tm     
    move start-dt            to ofa1-10
    move start-tm            to ofa12-22
    move '- NetPing ' VERSION ' started.  Server: ' SERVER to ofa24
    if LOG-FILE = ''
      or LOG-FILE = spaces
      move 'N'               to logging-sw
    else
      move 'Y'               to logging-sw 
      open ofa LOG-FILE textappend       
      if ofa is open
        write ofa             * Write netping started to log file 
        close ofa.
 
 
    * Main Loop
100 perform 200               * Ping the SERVER
    sleep sleep-millis        * Sleep between pings
    go to 100
 
 
    * Ping the SERVER
200 open ifa 'ping ' SERVER ' -n 1 -l 1' pipe    * Ping server using Pipe I/O
    if ifa is not open        * This should never happen!
      color YELLOW-ON-BLACK
      display ' Unable to execute PING command!  Program netping.q will stop.' BELL
      sleep 10000 
      end.
210 read ifa at eof 220
    move 1                   to idx
    findi 'Request timed out' in ifa by idx
    if idx > 0                * Server didn't respond soon enough 
      perform 300             * Connection Timeout Alert
      go to 230.
    move 1                   to idx
    findi 'Reply from' in ifa by idx
    if idx = 0
      go to 210.
    findi 'time=' in ifa by idx
    if idx > 1                * Server responded
      perform 500             * Connection is up.
      go to 230.
220 perform 400               * Connection Down Alert
230 close ifa                 * Close Pipe
299 exit
 
 
    * Connection Timeout Alert
300 if error-cnt = ALERT-MINIMIZE  
     set windowstate        to MINIMIZE. * Minimize Window 
 
    if net-status-cd <> TIMEOUT 
      move TIMEOUT           to net-status-cd
      move ALERT-TIME        to sleep-millis
      set windowstate        to MAXIMIZE  * Maximize the window
      set windowstate        to SHOW      * Show the window
      move date              to ofa
      move time1-11          to ofa12-22
      move '- Timed out'     to ofa24
      if logging-sw = 'Y'
        open ofa LOG-FILE textappend      * Write errors to log file  
        if ofa is open
          write ofa
          close ofa.
 
    if error-cnt <= ALERT-MUTE
      playsound TIMEOUT-WAV nowait.
 
    add 1                    to error-cnt
    add 1                    to net-timeouts 
    move date                to net-timeout-dt
    move time                to net-timeout-tm
    perform 600               * Display NetPing Statistics
399 exit                  
 
 
    * Connection Down Alert
400 if error-cnt = ALERT-MINIMIZE  
     set windowstate        to MINIMIZE. * Minimize Window 
 
    if net-status-cd <> DOWN 
      move DOWN              to net-status-cd
      move ALERT-TIME        to sleep-millis
      set windowstate        to MAXIMIZE  * Maximize the window
      set windowstate        to SHOW      * Show the window
      move date              to ofa
      move time              to ofa12-22
      move '- Disconnected'  to ofa24
      if logging-sw = 'Y'
        open ofa LOG-FILE textappend      * Write errors to log file 
        if ofa is open
          write ofa
          close ofa.
 
    if error-cnt <= ALERT-MUTE
      playsound DOWN-WAV nowait.
 
    add 1                    to error-cnt
    add 1                    to net-disconnects 
    move date                to net-disconnect-dt
    move time                to net-disconnect-tm
    perform 600               * Display NetPing Statistics 
499 exit                 
 
 
    * Connection Up Notification
500 if net-status-cd <> UP
      move UP                to net-status-cd
      move PING-TIME         to sleep-millis
      set windowstate        to MAXIMIZE  * Maximize the window
      set windowstate        to SHOW      * Show the window
      move date              to net-connect-dt
      move time              to net-connect-tm
      move 0                 to error-cnt
      add 1                  to net-connects 
      perform 600             * Display NetPing Statistics 
      playsound UP-WAV nowait
      move date              to ofa
      move time1-11          to ofa12-22
      move '- Connected'     to ofa24
      sleep 10000
      set windowstate        to MINIMIZE  * Minimize Window
      set windowstate        to HIDE      * Hide Window
      if logging-sw = 'Y'
        open ofa LOG-FILE textappend      * Write errors to log file 
        if ofa is open
          write ofa
          close ofa.
599 exit
 
 
    * Display NetPing Statistics
600 cursor 1 2
    color DKGREEN-ON-BLACK
    display x'F0F0' noskip
    color DKYELLOW-ON-BLACK
    display x'F0F0' noskip
    color DKRED-ON-BLACK
    display x'F0F0' '  ' noskip
    color WHITE-ON-BLACK
    display 'N e t P i n g   S t a t i s t i c s' noskip
    color DKRED-ON-BLACK
    display '  ' x'F0F0' noskip
    color DKYELLOW-ON-BLACK
    display x'F0F0' noskip
    color DKGREEN-ON-BLACK
    display x'F0F0' noskip
 
    cursor 2 1  
    color WHITE-ON-BLACK
    display ' Status.....:'
    display ' Disconnects:           Last:'
    display ' Timeouts...:           Last:'
    display ' Connects...:           Last:'
 
    if net-status-cd = DOWN
      color RED-ON-BLACK
      cursor 2 15
      display 'Disconnected' noskip
    else 
      color WHITE-ON-BLACK. 
 
    cursor 3 15
    display net-disconnects noskip
    cursor 3 31
    display net-disconnect-dt ' ' net-disconnect-tm noskip
 
    if net-status-cd = TIMEOUT
      color YELLOW-ON-BLACK
      cursor 2 15
      display 'Timed out   ' noskip
    else
      color WHITE-ON-BLACK.
 
    cursor 4 15
    display net-timeouts  noskip
    cursor 4 31 
    display net-timeout-dt ' ' net-timeout-tm noskip
 
    if net-status-cd = UP
      color GREEN-ON-BLACK
      cursor 2 15
      display 'Connected   ' noskip
    else
      color WHITE-ON-BLACK.
 
    cursor 5 15     
    display net-connects noskip
    cursor 5 31
    display net-connect-dt ' ' net-connect-tm noskip
699 exit
 

Back to homeBack to home