Linux Tactic

Keep Your Hardware Healthy: Command Line Tools for Sensor Monitoring

Looking for ways to monitor the health of your computer hardware? Look no further! In this article, we will explore some command line apps and tools that can help you keep an eye on the performance of your hardware sensors, including fan speed, voltage, and temperature.

1. Command Line Apps for Monitoring Hardware Sensors

Lm-sensors

Lm-sensors is a command line app that is used to monitor hardware sensors on Linux systems. It can provide information related to fan speed, voltage, and temperature.

To install

Lm-sensors, simply run the command “sudo apt install lm-sensors” in your terminal.

Once

Lm-sensors is installed, you can then run the command “sensors-detect” which will prompt you to configure your hardware settings.

Simply follow the prompts to complete the hardware configuration wizard.

After the configuration wizard is complete, you can check the temperature and sensor information by running the command “sensors”.

Alternatively, you can use the command “watch -n 1 sensors” to view the temperature and sensor information in real-time.

Psutil

Psutil is a Python module that can be used to monitor hardware information such as active processes, system utilization data, and sensors_temperatures(). The module has two scripts available for use: temperatures.py and sensors.py.

Temperatures.py provides a simple overview of the temperature data, while sensors.py provides more detailed information. To use

Psutil, you can install the module using pip by running “pip install psutil”.

HardInfo

HardInfo is a graphical app that provides system information and benchmarks. It also has a command line interface that can be used to display temperature values and sensor information.

To install

HardInfo, run the command “sudo apt install hardinfo”.

To check temperature and sensor information in the command line interface, run the command “

hardinfo -r sensor”.

This will display the temperature values for your hardware sensors.

Glances

Glances is a top-like tool that provides real-time hardware utilization data. It is made with the Python language and uses the

Psutil library to collect data.

You can install

Glances via pip by running “pip install glances”.

Glances also has a lightweight server mode that can provide access to a RESTful JSON API. This can be used to display hardware sensor data on a web interface.

Additionally,

Glances can export data in CSV format.

2.

Installation and Usage of

Lm-sensors

To install

Lm-sensors, simply run the command “sudo apt install lm-sensors” in your terminal. This will download and install the necessary packages.

After installation, run the command “sensors-detect” to configure your hardware sensors. The wizard will prompt you to detect various sensors and identify their corresponding drivers.

After the configuration is complete, you can then check the temperature and sensor information by running the command “sensors”. This will display a list of temperature information for your sensors.

You can also use the command “watch -n 1 sensors” to view real-time updates of the temperature information.

Keep in mind that the temperature values may be displayed in Celsius by default.

If you prefer Fahrenheit, you can change this by modifying the configuration file.

Conclusion

In this article, we discussed command line apps and tools that can help you monitor the performance of your computer hardware sensors. By using these tools, you can detect potential hardware issues and maintain the overall health of your system.

Whether you choose

Lm-sensors,

Psutil,

HardInfo, or

Glances, these tools can help you gain a better understanding of how your hardware is performing. 3.

Psutil for Retrieving Hardware Information

Psutil is a powerful Python module that provides an easy-to-use API for getting hardware information and system utilization data. It can be installed via pip by using the command “python3-pip install psutil”.

Retrieving CPU and GPU Temperature Values

One of the most useful functions in

Psutil is sensors_temperatures(), which retrieves information about the temperature sensors on your system. To use this feature, simply import the psutil module and call the function sensors_temperatures().

For example, the following code can be used to print the temperature values of the CPU and GPU sensors:

“`python

import psutil

while True:

temp = psutil.sensors_temperatures()

print(f”CPU Temperature: {temp[‘coretemp’][0].current}C”)

print(f”GPU Temperature: {temp[‘amdgpu’][0].current}C”)

“`

This code continuously prints the temperature values of the CPU and GPU sensors every second (“-n 1”) using the while loop. You can change the time interval by modifying the value of “-n”.

Using

Psutil Scripts

Psutil also includes two useful scripts, “temperatures.py” and “sensors.py”. These scripts provide detailed information about the hardware sensors on your system and battery level data.

To use the “temperatures.py” script, simply run it using the following command:

“`bash

python3 /usr/share/doc/python3-psutil/examples/temperatures.py -c

“`

This command will print the temperature information in a well-formatted output. You can also use the “-n” option to continuously view the temperature information.

Similarly, to use the “sensors.py” script, run it using the following command:

“`bash

python3 /usr/share/doc/python3-psutil/examples/sensors.py –battery

“`

This command will print the battery level information and other sensor information. You can modify the options to filter the information you require.

4.

HardInfo for Viewing Hardware Components Information

HardInfo is a graphical app that provides detailed information about various hardware components and benchmarks your system’s performance. It can be installed using the command “sudo apt install hardinfo”.

Hardware Information and Benchmarks

Once installed,

HardInfo provides a simple and intuitive graphical interface that displays hardware component information and performance benchmark data. You can navigate the various tabs to view information about your CPU, GPU, memory, and storage devices.

HardInfo also provides the ability to generate text and HTML reports that can be saved for future reference. These reports include detailed information about hardware components, drivers, and other system information.

Command Line Interface

In addition to the graphical interface,

HardInfo also provides a command line interface that can be used to view information about hardware sensors and temperature values.

To view the temperature values of your hardware sensors, simply run the following command in your terminal:

“`bash

hardinfo -r sensor

“`

This command will display the temperature values of your sensors, including your CPU and GPU temperatures. You can use this information to monitor the health of your hardware and detect potential issues.

Conclusion

By using

Psutil and

HardInfo, you can gain valuable insights into the performance of your hardware components. Whether you need to monitor the temperature of your CPU and GPU or generate detailed system reports and benchmarks, these tools provide everything you need to maintain the health of your system and keep it running smoothly.

5.

Glances for Real-Time Hardware Utilization Data

Overview of

Glances

Glances is a top-like tool that provides real-time hardware utilization data in an easy-to-read format. It is written in the Python language and uses the

Psutil library to collect data about various hardware components and system performance.

Glances can be installed via pip by using the command “pip install glances”. Once installed, you can launch

Glances by running the “glances” command in your terminal.

Usage of

Glances

Glances provides a wealth of information about your system’s performance in real-time. It provides detailed information about CPU usage, network activity, disk usage, memory usage, and even processes running on your system.

By default,

Glances refreshes information every second. This provides real-time updates about the performance of your system and ensures that you have access to the most up-to-date data possible.

To change the update interval, you can use the “-t” option. For example, to update

Glances every 5 seconds, you can use the following command:

“`bash

glances -t 5

“`

This command instructs

Glances to update the data every 5 seconds, providing a less frequent but still relevant update to the data. One of the standout features of

Glances is its lightweight server mode.

This mode allows

Glances to run as a server, serving data to multiple clients simultaneously. This can be useful in a variety of scenarios, such as monitoring multiple machines from a centralized location or providing real-time performance data to a team of developers.

To run

Glances in server mode, you can use the following command:

“`bash

glances -w

“`

This command instructs

Glances to run in server mode, providing a RESTful JSON API that can be used to access real-time hardware utilization data. Once the server is running, you can access the API by navigating to “http://localhost:61208/api/3” in your web browser.

In addition to the server mode,

Glances also provides a web UI that can be accessed via a web browser. This UI provides a graphical interface for viewing real-time hardware utilization data.

To access the web UI, simply navigate to “http://localhost:61208” in your web browser.

Conclusion

Glances is a powerful tool that provides real-time hardware utilization data for a variety of hardware components and system performance metrics. By using

Glances, you can monitor the health of your system, detect potential issues, and identify areas for improvement.

Whether you need to monitor a single machine or provide real-time data to a team of developers,

Glances provides everything you need to get the job done. In conclusion, monitoring the hardware sensors of your computer is crucial for maintaining the overall health of your system.

This article covered various command line tools, including

Lm-sensors,

Psutil,

HardInfo, and

Glances, that can help you keep track of fan speed, voltage, and temperature. By using these tools, you can detect potential hardware issues, monitor the performance of your system, and detect areas for improvement.

Whether you are monitoring a single machine or providing real-time data to a team of developers, these tools provide everything you need to keep your system running smoothly and efficiently.

Popular Posts