Before launching into the application itself, let's plan ahead for how we will store and retrieve the data in the database. There are two levels of information that we are going to collect and store.
First, in this application we will check the general status of the given host. So the hostname or IP address will be our main document ID or key. Then the host is check for it's availability or status - is it responsive at all or not? Then the timestamp for the last time it was checked is also collected. The status, timestamp and hostname are the high level of data stored.
Second, a detailed list of ports is scanned and the responses of what protocols are available and what ports are open is returned. This detailed information is stored using a key combining host, protocol, port, and timestamp.
With the above planned approach, it is possible to quickly grab the current status for a host. It is also possible to retrieve the detailed information about a particular port at a specific point in time. More advanced features using views and design documents will be considered elsewhere, but by using this plan, querying for view-level data will be much easier and provide a quick way to roll-up stats across a network.