p4 heartbeat

Monitor the responsiveness of a target server, such as a standby server monitoring its master server, to help the administrator determine if a failover might be needed.

Syntax

p4 [g-opts] heartbeat [-i interval] [-w wait] [-m missingInterval] [-r missingWait] [-c count]
p4 [g-opts] heartbeat -t target [-i interval] [-w wait] [-m missingInterval] [-r missingWait] [-c count]

Syntax conventions

Description

The p4 heartbeat command can be used to monitor a server. Both the server running p4 heartbeat and the server being monitored must be at 20.1 or later.

A typical use case is that a standby server uses the heartbeat to monitor the responsiveness of its master server, which can help the administrator determine if a failover might be needed (see p4 failover).

Heartbeat sends requests to a target server at regular intervals and monitors the responses. The server that is monitoring the target server can be set up to alert administrators about a change in the target server's status.

If the target server ... the monitoring server can fire a trigger or extension of type ...
misses a response heartbeat-missing
resumes its response heartbeat-resumed
misses consecutive responses that reach the maximum count heartbeat-dead

See Triggering on heartbeat in the Helix Core Server Administrator Guide.

Note
  • If you want the standby server to monitor the master server: on the standby server, configure the heartbeat thread as a startup background thread by setting the startup.N configurable as follows: p4 configure standby#startup.4=heartbeat

  • This command was designed for a standby server to monitor a master server for a possible failover scenario (see Failover in the Helix Core Server Administrator Guide), but we recommend a human being, rather than a script, make any decision to perform a failover operation.
  • The monitoring server can monitor any target server except itself. In other words, the target specified with the -t target or by the value of P4TARGET must not use the P4PORT value for the server where the p4 heartbeat command is being run.
  • Logging:

    • If the heartbeat command is started with -t target, the timestamp is logged in commands.csv and all.csv
    • Both first missing heartbeat and the maximum count of missing heartbeats exceeded are logged in errors.csv
    • To get verbose logging that includes every missing heartbeat, start Helix Core Server with the following option: -vheartbeat=3
  • This command increases network traffic between the target server and the monitoring server.
  • The heartbeat thread runs until any of the following occur:

    • the heartbeat thread detects that the target server has died
    • the heartbeat thread is terminated explicitly
    • the heartbeat thread is terminated at server shutdown

    This is true whether the heartbeat thread runs as a startup process, like the startup processes for p4 pull, or you run p4 heartbeat in the foreground.

For an overview of Helix Core replication, see Replication in the Helix Core Server Administrator Guide.

Options

-t

Specifies the target server to be monitored. If not specified, the command uses the value of P4TARGET. If neither P4TARGET nor the -t option is set, the command will fail.

-i

Specifies the time in milliseconds to wait before sending another heartbeat request.

If not specified, this interval defaults to the net.heartbeat.interval configurable.

-w

Specifies the time in milliseconds to wait before the response is timed out.

If not specified, this defaults to the net.heartbeat.wait configurable.

-m

Specifies the time in milliseconds to wait before sending another heartbeat request after the previous response was missing.

If not specified, this defaults to the net.heartbeat.missing.interval configurable.

-r

Specifies the time in milliseconds to wait before the response times out after the previous response was missing.

If not specified, this defaults to the net.heartbeat.missing.wait configurable.

-c

Specifies the maximum number of consecutive missed heartbeats before the heartbeat is is considered non-responsive or dead..

If not specified, this defaults to the net.heartbeat.missing.count configurable.

g-opts

See Global options.

Usage notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required

N/A

N/A

super

available to an operator user

Related commands

Fail over to a standby server.

p4 failover