agentless_monitor 1.0.0 copy "agentless_monitor: ^1.0.0" to clipboard
agentless_monitor: ^1.0.0 copied to clipboard

Monitor 1000+ servers without installing any agent. Uses SSH, SNMP, and REST API protocols to collect CPU, RAM, Disk, Network, Process and Service metrics. Auto-discovers new hosts in CIDR subnets. Ze [...]

example/lib/main.dart

// example/lib/main.dart — Minimal Flutter UI example
//
// Add agentless_monitor as a dependency, then drop this into a Flutter app.
// This shows a live-updating list of monitored hosts using standard widgets.

// NOTE: This file requires Flutter SDK. If you are using pure Dart,
// see example/bin/cli_example.dart instead.

// ignore_for_file: avoid_print

import 'dart:async';

import 'package:agentless_monitor/agentless_monitor.dart';
// import 'package:flutter/material.dart';  ← uncomment in a real Flutter project

/// Entry point for the Flutter example.
/// In a real app, replace the `void main()` below with the Flutter
/// runApp() call and use the [MonitorDashboard] widget.
void main() async {
  // Pure-Dart usage — identical to the CLI example.
  final monitor = AgentlessMonitor();
  monitor.useDefaultAlertRules();

  monitor.addTarget(
    '10.0.0.0/24',
    TargetConfig.linux(
      ssh: SshAuthConfig.password(username: 'admin', password: 'secret'),
      interval: const Duration(seconds: 30),
    ),
  );

  monitor.metricsStream.listen((r) {
    print('[${r.host}] CPU=${r.cpu?.usagePercent.toStringAsFixed(1)}% '
        'RAM=${r.ram?.usagePercent.toStringAsFixed(1)}% '
        'status=${r.status.name}');
  });

  monitor.alertsStream.listen((a) {
    print('[ALERT][${a.severity.name}] ${a.host} — ${a.message}');
  });

  await monitor.start();
  await Future<void>.delayed(const Duration(minutes: 5));
  await monitor.stop();
  monitor.dispose();
}

// ═══════════════════════════════════════════════════════════════════════════
//  Flutter Widget (requires flutter SDK — see imports above)
// ═══════════════════════════════════════════════════════════════════════════

/// A simple stateful widget that displays a live table of monitored hosts.
///
/// Usage:
/// ```dart
/// runApp(MaterialApp(home: MonitorDashboard(monitor: AgentlessMonitor())));
/// ```
/*
class MonitorDashboard extends StatefulWidget {
  final AgentlessMonitor monitor;
  const MonitorDashboard({super.key, required this.monitor});

  @override
  State<MonitorDashboard> createState() => _MonitorDashboardState();
}

class _MonitorDashboardState extends State<MonitorDashboard> {
  final List<MonitorResult> _results = [];
  late final StreamSubscription<MonitorResult> _sub;

  @override
  void initState() {
    super.initState();
    _sub = widget.monitor.metricsStream.listen((r) {
      setState(() {
        _results.removeWhere((e) => e.host == r.host);
        _results.add(r);
        _results.sort((a, b) => a.host.compareTo(b.host));
      });
    });
    widget.monitor.start();
  }

  @override
  void dispose() {
    _sub.cancel();
    widget.monitor.stop();
    widget.monitor.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('agentless_monitor')),
      body: ListView.builder(
        itemCount: _results.length,
        itemBuilder: (_, i) {
          final r = _results[i];
          final color = switch (r.status) {
            TargetStatus.up       => Colors.green,
            TargetStatus.down     => Colors.red,
            TargetStatus.warning  => Colors.orange,
            TargetStatus.critical => Colors.red.shade900,
            _                     => Colors.grey,
          };
          return ListTile(
            leading: CircleAvatar(backgroundColor: color, radius: 6),
            title: Text(r.host),
            subtitle: Text(
              'CPU: ${r.cpu?.usageLabel ?? "?"} | '
              'RAM: ${r.ram?.usageLabel ?? "?"} | '
              'Disk: ${r.disk?.overallUsagePercent.toStringAsFixed(1) ?? "?"}%',
            ),
            trailing: Text('${r.responseTimeMs}ms'),
          );
        },
      ),
    );
  }
}
*/
0
likes
130
points
80
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Monitor 1000+ servers without installing any agent. Uses SSH, SNMP, and REST API protocols to collect CPU, RAM, Disk, Network, Process and Service metrics. Auto-discovers new hosts in CIDR subnets. Zero setup. Production-ready, pub.dev-ready, MIT licensed.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

async, collection, cron, equatable, freezed_annotation, hive, json_annotation, retry, stream_transform

More

Packages that depend on agentless_monitor