What format is the RabbitMQ uptime?

193 views Asked by At

I have a query which I am running:

python rabbitmqadmin -H xxxxxxxxxx -P 443 -u xxxxxxxxxx -p xxxxxxxxxxx -s list nodes name type running uptime

and I am getting back:

+------------------+------+---------+----------+
|       name       | type | running |  uptime  |
+------------------+------+---------+----------+
| rabbit@localhost | disc | True    | 69193749 |
+------------------+------+---------+----------+

What format is the field uptime in? How long is 69193749? Is that in milliseconds?

2

There are 2 answers

0
Matthias On

It is in milliseconds.

You can use one of the methods here to get the time in seconds and then you can compare to your command, e.g.

sudo rabbitmqctl eval "{Total_Wallclock_Time, _} = erlang:statistics(wall_clock),Total_Wallclock_Time div 1000."

I also tried restarting the server and run the command a few times in succession, and that confirmed it is in milliseconds.

~$ sudo systemctl restart rabbitmq-server
~$ rabbitmqadmin list nodes name type running uptime
+----------------------+------+---------+--------+
|         name         | type | running | uptime |
+----------------------+------+---------+--------+
| rabbit@comp          | disc | True    | 7510   |
+----------------------+------+---------+--------+
~$ rabbitmqadmin list nodes name type running uptime
+----------------------+------+---------+--------+
|         name         | type | running | uptime |
+----------------------+------+---------+--------+
| rabbit@comp          | disc | True    | 12512  |
+----------------------+------+---------+--------+
~$ rabbitmqadmin list nodes name type running uptime
+----------------------+------+---------+--------+
|         name         | type | running | uptime |
+----------------------+------+---------+--------+
| rabbit@comp          | disc | True    | 22519  |
+----------------------+------+---------+--------+

Then running the previously suggested command

sudo rabbitmqctl eval "{Total_Wallclock_Time, _} = erlang:statistics(wall_clock),Total_Wallclock_Time div 1000."

now gave me

38

seconds.

It is interesting I also tried rabbitmqadmin --help but I could not find information about the format there, nor when I googled the problem, so a very valid question.

0
Luke Bakken On

The rabbitmqadmin utility works by making REST calls to the RabbitMQ API. This is the equivalent curl statement to get the uptime:

lbakken@shostakovich ~
$ curl -4su 'guest:guest' localhost:15672/api/nodes | jq '.[0].uptime'
998893

lbakken@shostakovich ~
$ curl -4su 'guest:guest' localhost:15672/api/nodes | jq '.[0].uptime'
1003897

As @matthias points out, there is no documentation of what units are used. I can add that to our docs, but I'm not exactly sure of the best place to do it.

If you run rabbitmqctl status, you can see the uptime in seconds:

$ ./sbin/rabbitmqctl status
Status of node rabbit@shostakovich ...
Runtime

OS PID: 172928
OS: Linux
Uptime (seconds): 1113
...
...
...

...and, as shown in the linked blog post, the following will show uptime in seconds:

$ curl -4su 'guest:guest' localhost:15672/api/nodes | jq '.[0].uptime / 1000 | floor'
1194

The value increases about every 5 seconds due to how management statistics are updated.