netty-js
v1.1.0
Published
Netty - A website monitoring and tracking service for uptime, response time, and SSL checks.
Maintainers
Readme
Netty - Node.js URL Monitoring Library
Description: Monitor uptime, response time, SSL certificates, DNS, and more. Supports multiple URLs, retries, intervals, slow response alerts, and event-driven notifications.
Installation: npm install monitor
Usage Example:
const Monitor = require('./monitor');
const monitor = new Monitor({ url: ['https://example.com', 'https://google.com'], interval: 30000, // check every 30 seconds timeout: 10000, // request timeout retries: 2, // retry failed requests twice retryDelay: 2000, // wait 2s between retries slowThreshold: 1500 // emit 'slow' if response > 1.5s });
monitor.on('check', (res) => console.log('Checked:', res)); monitor.on('up', (res) => console.log('UP:', res.url)); monitor.on('down', (res) => console.log('DOWN:', res.url)); monitor.on('slow', (res) => console.log('SLOW response:', res.url, res.responseTime)); monitor.on('error', (err) => console.log('Error:', err));
monitor.start();
// Access last result for a specific URL setTimeout(() => { console.log('Last result for example.com:', monitor.getLast('https://example.com')); }, 35000);
Features:
- Monitor multiple URLs
- Interval-based checks
- DNS lookup verification
- HTTP/HTTPS requests with retries
- SSL certificate validation
- SSL expiration warnings (7 days before expiry)
- Response time tracking
- Slow response alerts
- Event-driven (check, up, down, slow, error)
- Keeps last 100 checks per URL
Events: check - Emitted after every check up - Emitted if URL is up down - Emitted if URL is down slow - Emitted if response time exceeds threshold error - Emitted on network/DNS/SSL error
Result Object Structure: url: URL being monitored up: true/false statusCode: HTTP status code responseTime: response time in ms dns: DNS lookup info { address, family } ssl: SSL certificate info { subject, issuer, validFrom, validTo } sslExpired: true/false sslWarning: true if SSL expires within 7 days checkedAt: ISO timestamp
Methods: start() - Start monitoring all URLs stop() - Stop monitoring checkAll() - Perform a single check for all URLs getLast(url) - Get the last check result for a URL getHistory(url) - Get the last 100 results for a URL
License: MIT
