replicator/lib/ruby/pg-wal-plugin.rb
def plugin_status
    # See if we have a file to which we can write.  
    if @out_params_file
      out = File.new(@out_params_file, "w")
    else
      out = STDOUT
    end
    
    # Write the values. 
    if is_master()
      out.puts("role=master")
      #out.puts("errmsg=")
      out.puts("pendingError=")
      #out.puts("last-sent=" + read_status_file(@wal_archived))
      if is_streaming_replication
        save_progress_timestamp
        out.puts("appliedLastSeqno=" + pg_current_xlog_location())
        out.puts("appliedLastEventId=" + pg_current_xlog_location())
        out.puts("currentEventId=" + pg_current_xlog_location())
      else
        out.puts("appliedLastSeqno=" + read_status_file(@wal_archived))
        out.puts("appliedLastEventId=" + read_status_file(@wal_archived))
        out.puts("currentEventId=" + read_status_file(@wal_archived))
      end
      #out.puts("last-applied=") 
      #out.puts("last-received=")
      out.puts("minimumStoredSeqNo=") # TODO: oldest stored WAL file.
      out.puts("maximumStoredSeqNo=")
      #out.puts("applied-latency=0.0")
      out.puts("appliedLatency=0.0")
    else
      out.puts("role=slave")
      #out.puts("errmsg=")
      out.puts("pendingError=")
      #out.puts("last-sent=")
      #out.puts("last-applied=" + read_status_file(@wal_restored))
      if is_streaming_replication
        out.puts("appliedLastSeqno=" + pg_last_xlog_replay_location())
        out.puts("appliedLastEventId=" + pg_last_xlog_replay_location())
        out.puts("minimumStoredSeqNo=") # TODO: oldest stored WAL file.
        out.puts("maximumStoredSeqNo=" + pg_last_xlog_receive_location())
        out.puts("currentEventId=" + pg_last_xlog_replay_location())
        out.puts("appliedLatency=" + get_streaming_replication_latency())
      else
        out.puts("appliedLastSeqno=" + read_status_file(@wal_restored))
        out.puts("appliedLastEventId=" + read_status_file(@wal_restored))
        #out.puts("last-received=" + read_status_file(@wal_archived))
        out.puts("minimumStoredSeqNo=") # TODO: oldest stored WAL file.
        out.puts("maximumStoredSeqNo=" + read_status_file(@wal_archived))
        out.puts("currentEventId=" + read_status_file(@wal_restored))
        out.puts("appliedLatency=" + get_wal_shipping_latency().to_s)
      end
    end
    
    # Close file only if we are using output params. 
    if @out_params_file
      out.close
    end
  end
# Emits current WAL replication status. 
Emits current WAL replication status.
Emits current WAL replication status .
def plugin_status
    if @out_params_file
      out = File.new(@out_params_file, "w")
    else
      out = STDOUT
    end
    if is_master()
      out.puts("role=master")
      out.puts("pendingError=")
      if is_streaming_replication
        save_progress_timestamp
        out.puts("appliedLastSeqno=" + pg_current_xlog_location())
        out.puts("appliedLastEventId=" + pg_current_xlog_location())
        out.puts("currentEventId=" + pg_current_xlog_location())
      else
        out.puts("appliedLastSeqno=" + read_status_file(@wal_archived))
        out.puts("appliedLastEventId=" + read_status_file(@wal_archived))
        out.puts("currentEventId=" + read_status_file(@wal_archived))
      end
      out.puts("minimumStoredSeqNo=") 
      out.puts("maximumStoredSeqNo=")
      out.puts("appliedLatency=0.0")
    else
      out.puts("role=slave")
      out.puts("pendingError=")
      if is_streaming_replication
        out.puts("appliedLastSeqno=" + pg_last_xlog_replay_location())
        out.puts("appliedLastEventId=" + pg_last_xlog_replay_location())
        out.puts("minimumStoredSeqNo=") 
        out.puts("maximumStoredSeqNo=" + pg_last_xlog_receive_location())
        out.puts("currentEventId=" + pg_last_xlog_replay_location())
        out.puts("appliedLatency=" + get_streaming_replication_latency())
      else
        out.puts("appliedLastSeqno=" + read_status_file(@wal_restored))
        out.puts("appliedLastEventId=" + read_status_file(@wal_restored))
        out.puts("minimumStoredSeqNo=") 
        out.puts("maximumStoredSeqNo=" + read_status_file(@wal_archived))
        out.puts("currentEventId=" + read_status_file(@wal_restored))
        out.puts("appliedLatency=" + get_wal_shipping_latency().to_s)
      end
    end
    if @out_params_file
      out.close
    end
  end
def plugin_status if @out_params_file out = File . new ( @out_params_file , "w" ) else out = STDOUT end if is_master ( ) out . puts ( "role=master" ) out . puts ( "pendingError=" ) if is_streaming_replication save_progress_timestamp out . puts ( "appliedLastSeqno=" + pg_current_xlog_location ( ) ) out . puts ( "appliedLastEventId=" + pg_current_xlog_location ( ) ) out . puts ( "currentEventId=" + pg_current_xlog_location ( ) ) else out . puts ( "appliedLastSeqno=" + read_status_file ( @wal_archived ) ) out . puts ( "appliedLastEventId=" + read_status_file ( @wal_archived ) ) out . puts ( "currentEventId=" + read_status_file ( @wal_archived ) ) end out . puts ( "minimumStoredSeqNo=" ) out . puts ( "maximumStoredSeqNo=" ) out . puts ( "appliedLatency=0.0" ) else out . puts ( "role=slave" ) out . puts ( "pendingError=" ) if is_streaming_replication out . puts ( "appliedLastSeqno=" + pg_last_xlog_replay_location ( ) ) out . puts ( "appliedLastEventId=" + pg_last_xlog_replay_location ( ) ) out . puts ( "minimumStoredSeqNo=" ) out . puts ( "maximumStoredSeqNo=" + pg_last_xlog_receive_location ( ) ) out . puts ( "currentEventId=" + pg_last_xlog_replay_location ( ) ) out . puts ( "appliedLatency=" + get_streaming_replication_latency ( ) ) else out . puts ( "appliedLastSeqno=" + read_status_file ( @wal_restored ) ) out . puts ( "appliedLastEventId=" + read_status_file ( @wal_restored ) ) out . puts ( "minimumStoredSeqNo=" ) out . puts ( "maximumStoredSeqNo=" + read_status_file ( @wal_archived ) ) out . puts ( "currentEventId=" + read_status_file ( @wal_restored ) ) out . puts ( "appliedLatency=" + get_wal_shipping_latency ( ) . to_s ) end end if @out_params_file out . close end end
Emits current WAL replication status.
Emits current WAL replication status .
# See if we have a file to which we can write.   # Write the values.  #out.puts("errmsg=") #out.puts("last-sent=" + read_status_file(@wal_archived)) #out.puts("last-applied=")  #out.puts("last-received=") # TODO: oldest stored WAL file. #out.puts("applied-latency=0.0") #out.puts("errmsg=") #out.puts("last-sent=") #out.puts("last-applied=" + read_status_file(@wal_restored)) # TODO: oldest stored WAL file. #out.puts("last-received=" + read_status_file(@wal_archived)) # TODO: oldest stored WAL file. # Close file only if we are using output params. 