Santa Barbar Air Quality DS


Recommended Posts

  • Administrators

If anyone's interested, I threw together a simple DS to pull air quality indices from ourair.org. The data's all around Santa Barbara, which is where our headquarters are. I did it more for an example and for our internal folks who live in that area.

PRMARN - SB_AirQuality

Either add ourair.org into your LM portal with display name of "Air Pollution Control District of Santa Barbara" or change the AppliesTo to apply to an existing device (a collector or some other device). The device it appliesto is irrelevant as the URL is hard coded into the script.

Link to post
Share on other sites

Nice!  I was trying to build out a DS for weather API checks some time back, but I run into the same issue I do with Cisco PSIRT API checks -- no way to cache results short of local files to avoid excessive usage due to duplicate calls.  I guess I will just have to see what I can do with local files.  Not sure if a SQLite binding is included with the provided Groovy libraries.  If not, that could help.

Link to post
Share on other sites
  • LogicMonitor Staff

@mnagel there's no SQLite JAR in there, unfortunately, but EA collectors do have a new script cache feature: https://www.logicmonitor.com/support/collectors/collector-configurations/collector-script-caching

The cache is scoped to a device, and entries will survive collection intervals.

Link to post
Share on other sites

Exactly, I just stopped since I did not want to sign up for a much larger account than needed.  I think there are other attributes I wanted to track, like precipitation, but pretty much that was put off since I could not restrict calls to once per zip code for each hour or so.  We used to get that information (using caching) with Nagios from the Wunderground API and insert detail into alerts via our notification templating system. My philosophy has always been to include as much relevant information in alerts as possible to support Lazy Admin mode.  A bit harder to do here without conditional templating, but I rebuilt that system into our ticketing system via an inbound transform.  The main thing we lose is the ability to run callbacks to get stuff like top 5 process details, etc. Still, we only use that in some cases and most clients get alerts from LM, so still wishing for real templating one day :).

Link to post
Share on other sites
  • Administrators
5 minutes ago, mnagel said:

I think there are other attributes I wanted to track, like precipitation

Yeah, precipitation was something I couldn't get for free.

FWIW, this is the json that my weather ds fetches:

{
  "base": "stations",
  "clouds": {
    "all": 75
  },
  "cod": 200,
  "coord": {
    "lat": 30.58,
    "lon": -97.86
  },
  "dt": 1600371953,
  "id": 0,
  "main": {
    "feels_like": 301.38,
    "humidity": 58,
    "pressure": 1016,
    "temp": 301.86,
    "temp_max": 303.15,
    "temp_min": 300.37
  },
  "name": "Leander",
  "sys": {
    "country": "US",
    "id": 5739,
    "sunrise": 1600345037,
    "sunset": 1600389261,
    "type": 1
  },
  "timezone": -18000,
  "visibility": 10000,
  "weather": [
    {
      "description": "broken clouds",
      "icon": "04d",
      "id": 803,
      "main": "Clouds"
    }
  ],
  "wind": {
    "deg": 360,
    "gust": 8.2,
    "speed": 5.7
  }
}

 

Link to post
Share on other sites
5 minutes ago, Stuart Weenig said:

Yeah, precipitation was something I couldn't get for free.

FWIW, this is the json that my weather ds fetches:


{
  "base": "stations",
  "clouds": {
    "all": 75
  },
  "cod": 200,
  "coord": {
    "lat": 30.58,
    "lon": -97.86
  },
  "dt": 1600371953,
  "id": 0,
  "main": {
    "feels_like": 301.38,
    "humidity": 58,
    "pressure": 1016,
    "temp": 301.86,
    "temp_max": 303.15,
    "temp_min": 300.37
  },
  "name": "Leander",
  "sys": {
    "country": "US",
    "id": 5739,
    "sunrise": 1600345037,
    "sunset": 1600389261,
    "type": 1
  },
  "timezone": -18000,
  "visibility": 10000,
  "weather": [
    {
      "description": "broken clouds",
      "icon": "04d",
      "id": 803,
      "main": "Clouds"
    }
  ],
  "wind": {
    "deg": 360,
    "gust": 8.2,
    "speed": 5.7
  }
}

 

weather is in there, which would be fine.  My recollection was that OWM was free for basic access with a query limit, and the query limit could be kept to with the new caching feature so I will definitely revisit it now. Found it:

60 calls/minute
1,000,000 calls/month

It sounds like a lot, but without caching....  yeah :).

Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.