Find Traps
What are the building blocks of a monitoring tool? We check the status of a thing. That might be pinging or checking an endpoint for some pattern. Based on that status, we might want to push a deep link to a device for our shell app, run a webhook from a site, or send an email. Those are the responses to a state of a thing. We typically call them alerts.
We want to commit those checks and logs into a database and sync that. We also might, if we can, check the object for known vulnerabilities. The following 8 projects lay out frameworks to be able to do much of this - they just aren't glued together into a SaaS offering. Lego blocks without the instructions to build a castle can be more inspiring than the castle itself. This page offers up a window into the source code for a few projects that can be used to check a status, trigger an event, send an alert, etc.
Yet some just want the dang castle... So stay tuned for more!
Projects
The Add Device Wizard
Scan Known Vulnerabilities
Sample Microservices
Show links sent via APNs
Microservice to send emails
Check Nest Device Status
Arbitrary REST calls
Sync a DynamoDB
Next Steps
The main piece of this is the Swift Quiver itself. To read more information on that check out https://www.swiftquiver.com. This is a shell to list things and provide a wizard to add more things. The example code involves using a simple ping (icmp) to check that an IP address is available.
Some devices don't respond to a ping. Maybe they're not on the same network, or maybe they have sockets that have been configured not to respond to icmp requests. Most of those will talk to a web back-end somewhere. One of these is the Google Nest devices. For these, check out https://github.com/krypted/NestMonitor. For others, check out https://github.com/krypted/DevModeCuRL - and keep in mind that with a little regex, it's easy to commit the json from the REST calls in that project to a database to run them on a timed interval. That could be a database as a service, like what Amazon offers with dynamo. Given that most people might have multiple devices, we can then keep that in sync with something like https://github.com/krypted/DynamoDBSync. We can even enrich that information with stuff like vulnerability tracking, with sample code for the Mac at https://github.com/krypted/maccvecheck.
Now we have a database with the state of devices and even a little enriched data. The main types of events to trigger would include:
Email: This could be done as a service using one of the many SaaS offerings that do so, or build your own microservice to do it, like at https://github.com/krypted/gomailer/tree/main/gomailer.
Push: Again, there are SaaS offerings like MagicBell, Amazon's SNS, etc. Or here's a sample app to do it yourself: https://github.com/krypted/DisplayPush.
Webhooks: Here, we can trigger other systems, like IFTTT, our own Lambda, or a GCF as shown here https://github.com/krypted/GSuiteMicroservices.
Ultimately, there are better projects out there (maybe even exposed as Swift packages) that can be used. This is an example of one way to build a custom monitoring tool. But just as you can buy individual Lego pieces or even 3d print your own custom pieces - anything is really possible. Monitoring has long been a custom task. Pinging is an effective way to see the network state of a device, but in a modern home or office, there could be dozens of devices that don't respond to a ping properly. Then we might have a few different ways we want to be alerted about a device that isn't reachable for a given period of time, up to but maybe not including a psychic scream. To get to that magical place shouldn't require us to be programmers. For example, maybe we can put a probe on a device in a home that talks to a web service. Or an appliance. Or whatever you can imagine.