system_monitor

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

system monitor

system_monitor #

A Flutter package to monitor system CPU and RAM usage using a WebSocket connection to a Python backend. This package works in conjunction with the system_monitor_cli package, which provides a command-line interface for managing the Python server.
Using system_monitor_cli #
This package can be used in conjunction with the system_monitor_cli package, which provides a command-line interface for managing the Python server. For more details on how to use the CLI tool, please refer to the system_monitor_cli README.
Getting Started #
Prerequisites #
Before using this package, make sure you have Python installed on your computer. You can download Python from the official website: https://www.python.org/
You also need to install the following Python libraries:

psutil: A cross-platform library for accessing system details and process utilities.
websockets: A library for building WebSocket servers and clients in Python.

Installing Python Libraries #
Using pip
pip install psutil
pip install websockets
copied to clipboard
Using pip3 (for Python 3)
pip3 install psutil
pip3 install websockets
copied to clipboard
Installation #
To use this package, add system_monitor as a dependency in your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
system_monitor: ^1.0.6
copied to clipboard
Usage #
Import the package
import 'package:system_monitor/system_monitor.dart';
copied to clipboard
Initialize the monitor
Before using the package, you need to initialize the monitor by creating an instance of SystemMonitor and calling its init() method:
SystemMonitor monitor = SystemMonitor.instance;
await monitor.init();
copied to clipboard
Get RAM Usage #
To get the current RAM usage in GB, you can call the getRamUsage() method:
SystemMonitor monitor = SystemMonitor.instance;
double ramUsage = await monitor.getRamUsage();
print('RAM Usage: $ramUsage GB');
copied to clipboard
Get CPU Usage #
To get the current CPU usage in percentage, you can call the getCpuUsage() method:
SystemMonitor monitor = SystemMonitor.instance;
double cpuUsage = await monitor.getCpuUsage();
print('CPU Usage: $cpuUsage%');
copied to clipboard
Realtime Monitoring #
You can also start realtime monitoring of CPU and RAM usage using the startRealtimeMonitoring() method:
SystemMonitor monitor = SystemMonitor.instance;
StreamSubscription<Map<String, double>> subscription = monitor.startRealtimeMonitoring().listen((data) {
double ramUsage = data['ram'];
double cpuUsage = data['cpu'];
print('Realtime RAM Usage: $ramUsage GB, CPU Usage: $cpuUsage%');
});
copied to clipboard
Don't forget to cancel the subscription when you no longer need realtime monitoring:
subscription.cancel();
copied to clipboard
Closing the Connection #
When you are done using the monitor, make sure to close the connection to the Python backend:
SystemMonitor monitor = SystemMonitor.instance;
monitor.close();
copied to clipboard
Example #
For a complete example, check out the example folder in this repository.
License #
This package is licensed under the MIT License - see the LICENSE file for details.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.