Check if master is up from slave server(replication) postgresql
I wanted to write this as comment but I don't have enough reputation.
Did you tried, pg_stat_wal_receiver? It came with PostgreSQL-9.6.

dbs=# select * from pg_stat_wal_receiver ;
-[ RECORD 1 ]---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pid                   | 12345
status                | streaming
receive_start_lsn     | B0/F0000000
receive_start_tli     | 1
received_lsn          | CE/13C7B18
received_tli          | 1
last_msg_send_time    | 2018-09-26 16:15:25
last_msg_receipt_time | 2018-09-26 16:15:25
latest_end_lsn        | CE/13C7B18
latest_end_time       | 2018-09-26 16:15:25
slot_name             | 
conninfo              | connection info


https://www.postgresql.org/docs/9.6/static/monitoring-stats.html#PG-STAT-WAL-RECEIVER-VIEW