Planning your next vacation with Paid Monitor
The power of Paid Monitor and Paid Monitor Monitor Manager M3
Paid Monitor can monitor everything – and anything.
In the last article I’ve demonstrated some of Paid Monitor Monitor Manager (M3) framework capabilities with parameter extraction from web pages.
M3 support parameter extraction via XML xpath, JSON path and also a simple regular expression.
In the following article I’ll demonstrate another handful of solid examples. The last ones will help you decide when to take your next vacation.
I suggest reading this previous article in the series before proceeding with reading.
Follow me, follow you
First and foremost – I must admit – I’m not a Twitter user.
It is very common today for businesses to have a Twitter account, twitting their latest news for the hungry followers with their latest advancements.
Stakeholders would usually follow the Twitter account in order to find out how much interest there is in their business. Yet again, Paid Monitoring & M3 come for the rescue.
Graphing results in Paid Monitor combined with the brilliant JSON API Twitter provides enables us to easily graph the number of followers on a Twitter account:
This link provides the following JSON output (filtered and beautified):
{ ... "default_profile": false, "profile_sidebar_border_color": "BDDCAD", "time_zone": "Pacific Time (US & Canada)", "default_profile_image": false, "statuses_count": 931, "profile_use_background_image": true, "created_at": "Sun Nov 16 11:20:23 +0000 2008", "lang": "en", "verified": false, "favourites_count": 16, "friends_count": 1985, "profile_background_color": "36a5e5", "id": 17421289, "is_translator": false, "profile_background_image_url": "https://a3.twimg.com/profile_background_images/312142083/Twitter_Background_3.jpg", "followers_count": 1950, ... }
The M3 configuration for extracting that could have never been simpler, here is a snippet:
<url>https://api.twitter.com/1/users/show.json?screen_name=paid-monitor</url> <metric name="Followers"> <type>integer</type> <uom>nr</uom> <json>{'followers_count'}</json> </metric>
We simply specify the URL and the JSON path to the element we’re interested in.
Doing business with Yahoo!
It is only recently that I was exposed to the vast financial API Yahoo! provides.
In addition to impressive graphing capabilities Yahoo! also exports all financial data in a CSV (comma separated, spreadsheet like format).
SNP 500 can be graphed via the following link.
The Yahoo! API for obtaining the last closeout would be:
# wget -q -O - "https://finance.yahoo.com/d/quotes.csv?s=^GSPC&f=p" 1204.42
Graphing that is simple as well with M3:
<url>https://finance.yahoo.com/d/quotes.csv?s=^GSPC&f=p</url> <metric name="SNP 500 previous close"> <type>float</type> <uom>Points</uom> <regex>(.*)</regex> </metric>
Yes, there is a bit of a learning curve dealing with Yahoo! Finance, however this page will help you extract the information you want.
Planning your next vacation
HotWire provides as well a very comprehensive API for obtaining hotel and flight prices. Monitoring the cheapest hotel you can book via Paid Monitor and M3 is simple as any other parameter extraction.
I want to fly to Paris. I’ve been twice to France, but never to Paris.
# wget -q -O - "https://api.hotwire.com/v1/deal/hotel?dest=paris&apikey=XXXXX&limit=1" <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Hotwire> <Result> <HotelDeal> ... <City>Courbevoie</City> <CountryCode>FR</CountryCode> <FoundDate>2011-09-07T15:20:04-07:00</FoundDate> <CurrencyCode>USD</CurrencyCode> <Price>57.0</Price> ... </HotelDeal> </Result> </Hotwire>
Please note you’ll have to register with HotWire if you want an API key. I concealed mine here for obvious reasons. To be honest $57 for a night in a hotel is pretty cheap, however, lets look for something cheaper by monitoring this price in Paid Monitor. The configuration for graphing it is available in hotwire_sample.xml.
The xpath we’re interested in is:
{Result}[0]->{HotelDeal}[0]->{Price}[0]
When will my money buy more?
I’ve shown already how to extract stock data from Yahoo! Finance. But if SNP 500 or NASDAQ are on a peak, it doesn’t necessarily mean it’s a good time for a vacation in Paris.
Say your money in the bank is in USD and you want to spend some time in Paris, graphing the USD to EUR exchange rate can provide you with a good idea when it’s time to visit the Eiffel Tower:
The code is for this example is here.
Paid Monitoring can monitor anything! Follow us also on Twitter and GitHub.
Read more about Paid Monitor Monitor Manager (M3) Framework:
- HTTP extraction with Paid Monitor
- Nagios to Paid Monitor converter: Making life easier for sysadmins
- Using M3 to take System Monitors to the Next Level
Leave a Reply