Forum Discussion

Anonymous's avatar
Anonymous
5 years ago

Santa Barbar Air Quality DS

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.

  • 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.

  • Anonymous's avatar
    Anonymous
    1 hour ago, Michael Rodrigues said:

    new script cache feature

    That could be handy for some of the zoom DSs (ZoomOverallDailyStats, which is unpublished). Hm......will have to look into this. @Stefan W

  • 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 :).

  • Anonymous's avatar
    Anonymous
    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
      }
    }

     

  • 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 :).