Use MRTG to monitor CPU temperature in Linux

Source: Internet
Author: User
Tags mrtg
Use MRTG to monitor the CPU temperature of a Linux system-Linux Enterprise Application-Linux server application information. The following is a detailed description. In Linux, there is a software named lm_sensors that can help us monitor the motherboard, CPU operating voltage, fan speed, temperature, and other data. We can see this data in the BIOS of the motherboard. When the machine runs, lm_sensors can be used to monitor CPU temperature changes at any time, which can prevent the CPU from being burned due to overheating.

1. Install lm_sensors

Now, each Linux has the lm_sensors package. We can install it. Or we can compile the source file by ourselves.

1) In FC, RH, CENTOS, use rpm:

[Root @ securitycn ~] # Rpm-ivh lm_sensors-2.10.0-3.1.i386.rpm

3) Compile the source file for Installation

We can download the source file through:

Here, we should note that the libsysfs library must be installed first, which is the Sysfsutils and Sysfsutils-devel software.

Tar xzvf lm-sensors-xxx.tar.gz

Make user

Make user_install testing

Next we will use some simple commands to use lm_sensors to obtain CPU data. We need to use the root identity:

Sensors-detect, and then it will automatically search for the chipset on the motherboard and the corresponding driver. We can answer YES all.

[Root @ securitycn ~] # Sensors-detect

# Sensors-detect revision 1.413 (20:28:00)

This program will help you determine which I2C/SMBus modules you need

Load to use lm_sensors most extends tively. You need to have i2c and

Lm_sensors installed before running this program.

Also, you need to be 'root', or at least have access to the/dev/i2c -*

Files, for most things.

If you have patched your kernel and have some drivers built in, you can

Safely answer NO if asked to load some modules. In this case, things may

Seem a bit confusing, but they will still work.

It is generally safe and recommended to accept the default answers to all

Questions, unless you know what you're doing.

We can start with probing for (PCI) I2C or SMBus adapters.

You do not need any special privileges for this.

Do you want to probe now? (YES/no ):

YES by default.

Then we start lm_sensors:

/Etc/init. d/lm_sensors start

Starting lm_sensors: [OK]

We can use lsmod to determine if the driver we need has been loaded.

Lsmod | grep i2c

I2c_isa 9153 2 w83627hf, w81081d

I2c_i80 1 11341 0

I2c_dev 12613 0

I2c_ec 9025 1 sbs

I2c_core 23745 6 w83627hf, w81_1d, i2c_isa, i2c_i801, i2c_dev, i2c_ec

Then we can use the sensors command:

[Root @ securitycn ~] # Sensors

W83627hf-isa-0290

Adapter: ISA adapter

VCore 1: + 3.33 V (min = + 0.00 V, max = + 0.00 V) ALARM

VCore 2: + 3.36 V (min = + 0.00 V, max = + 0.00 V) ALARM

+ 3.3 V: + 0.93 V (min = + 3.14 V, max = + 3.46 V) ALARM

+ 5 V: + 5.11 V (min = + 4.73 V, max = + 5.24 V)

+ 12 V: + 4.56 V (min = + 10.82 V, max = + 13.19 V) ALARM

-12 V:-7.10 V (min =-13.18 V, max =-10.88 V) ALARM

-5 V:-1.93 V (min =-5.25 V, max =-4.75 V) ALARM

V5SB: + 5.51 V (min = + 4.73 V, max = + 5.24 V) ALARM

VBat: + 0.02 V (min = + 2.40 V, max = + 3.60 V) ALARM

Fan1: 0 RPM (min = 2732 RPM, div = 2) ALARM

Fan2: 0 RPM (min = 0 RPM, div = 2)

Fan3: 0 RPM (min = 0 RPM, div = 2)

Temp1: + 38? (High = + 50 ?, Hyst = + 45 ?) Sensor = thermistor

Temp2: + 33.5? (High = + 80 ?, Hyst = + 75 ?) Sensor = thermistor

Temp3: + 33.5? (High = + 80 ?, Hyst = + 75 ?) Sensor = thermistor

Vid: + 0.000 V (VRM Version 10.0)

Alarms:

Beep_enable:

Sound alarm enabled

Here we can see that there is no CPU corresponding to the temperature, and we will slightly modify/etc/sensors. conf is enough, but we don't need to do it ourselves. Generally, we can download the configuration file from the motherboard manufacturer. With lmsensors, we can obtain information about the motherboard temperature, CPU voltage, and fan speed. We can monitor the operating status of the system based on the data to prevent system problems.

Let's integrate it with MRTG.

[Root @ securitycn ~] # Cd/usr/local/mrtg/bin

[Root @ securitycn ~] # Vi temp. sh

# Content:

#! /Bin/bash

Cputemp = '/usr/bin/sensors | grep temp1 | awk' {print $2}' | cut-c 2-4 '# Find the row with temp1, 2-4 characters in the second column

Systemp = '/usr/bin/sensors | grep temp2 | awk' {print $2}' | cut-c 2-5 'no need to explain

Echo $ cputemp

Echo $ systemp

# The uptime

Uptime | sed's: ^. * up \ (. * \), [0-9] [0-9] * users. * $: \ 1 :'

# My name

Uname-n

[Root @ securitycn ~] # Change chmod + x temp. sh to Executable

[Root @ securitycn ~] #./Temp. sh to see if there is any problem

39

33.5

15:36:19 up, 1 user, load average: 0.04, 0.09, 0.04

Securitycn

Write down the following file.

[Root @ securitycn ~] # Cd ../etc/

[Root @ securitycn ~] # Vi temp. cfg

WorkDir:/data1/usr/apache/htdocs/mrtg/temp/

Target [index]: '/usr/local/mrtg/bin/temp. Sh'

MaxBytes [index]: 80

Options [index]: gauge, nopercent, growright

YLegend [index]: Temp (degree)

ShortLegend [index]: Degree

LegendO [index]: system temperature;

LegendI [index]: CPU temperature;

Title [index]: system temperature table

PageTop [index]: Host temperature table

[Root @ securitycn ~] #/Usr/local/mrtg/bin/mrtg/usr/local/mrtg/etc/temp. cfg

No error will be reported if the task is executed three times.

Then add it to crontab.

*/5 */usr/local/mrtg/bin/mrtg/usr/local/mrtg/etc/temp. cfg
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.