Linux sensors support script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
piingouin

Linux sensors support script

Post by piingouin »

#!/usr/bin/perl -w

# Olivier Poitrey <rs@rhapsodyk.net>
#
# LM-sensors info grabber
#
# sensors_grab.pl chip [field1 [fieldN]]

use strict;

my $ship = shift or exit 1;
my %fields;
@fields{@ARGV} = ();

open(CMD, "/usr/bin/sensors $ship|") or exit 1;
while(<CMD>)
{
my($field, $value) = /^(.*?):\s+[+-]?([\d.]+)/;
if(defined $field && exists $fields{$field})
{
$fields{$field} = $value;
}
}
close(CMD);

print join ' ', map(defined $fields{$_} ? $fields{$_} : 0, @ARGV);
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests