
One of my colleagues still has not learned that if she goes for a vacation, she should not give me the exact name of the cruise ship she's going to. What do I do? Of course, I monitor the cruise ship location with Zabbix.
Tracking a cruise ship? WHY?
Because I can. This all started when she sent me a link to one of the ship tracking sites, like FlightRadar, but for maritime vessels. My response back was "I need to add this to my Zabbix", and here we are.
The challenge
Originally, she sent me to visit Vessel Finder, but it quickly became clear that scraping the geo-coordinates from that site would not be fun at all.
Next, I tried to find a site that would offer an API for tracking these vessels -- yes, quickly found multiple, but they all wanted my money, and I didn't want to pay anything for this fun little experiment.
Finally, I found out myshiptracking.com, which might not have an API, but the page content is easy enough to scrape with the traditional Zabbix HTTP agent item type and some item preprocessing.

There are so many ships out there! Anyway, if I click on any of them, I get this. Here's just some random vessel from that flock of ships.

On source code, those details are good old HTML.

Scraping the details
How to track a ship by using Zabbix, then? First, I created a new host, and added a new HTTP agent item to it. The item acts as the master data.

Next, I created few dependent items ...

... and parsed any details with some not-pretty-but-working regular expressions. Here's longitude as an example.


.. and the regexp as plain text:
.*Longitude.*<\/th>\r\n\s+<td>(.*)°<\/td>
Of course, on item tab, I also made sure that the longitude populates the Longitude inventory field automatically, and same for latitude.

Creating a dashboard
Finally, I just added a simple dashboard with a geomap, a new honeycomb widget (admittedly not the best option in this case, as would look ugly with full-length coordinates and speed/course with five decimals....), and a graph.

And I'm done! Not creating triggers for this one, as that would be too much. I really don't need any "Ship has stopped moving" or "Ship is turning" stylish notifications. Not that I would need to track any of this, but such is monitoring nerds life, having some fun in the middle of serious work.
Comments
Hi,
Great post as Always!
I made the same tracking as you described. But i cannot get the value of speed. What regex did you use for this value?
thx!
Yep getting the speed was painful as the table format data there would show there anchor icon and the content would change if vessel was stationary... so I used the longer description text that's available about each ships status (still on same page), and used this regexp
.*<strong>([0-9\.]+) Knots</strong>.*
Cheers,
Janne
I tried getting the course from simular regex as longitude, but no luck.Tried feeding the html through regexr to see if I found a working regex, but still no luck. Would you share the coarse regex? Perhaps also the "Status" one would be possible as well. I tried thisone, with no luck.
Latitude.*\n*\t*.*\n*\t*.*\n*\t*\n*\t*Status<\/th>\n\t+(.*)<
speed of ship