/usr/share/munin/plugins/hddtempd is in munin-plugins-extra 2.0.25-1+deb8u3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #!/usr/bin/perl -w
# -*- perl -*-
#
# Munin plugin to monitor hdd temperature from a hddtemp daemon.
#
# This plugin is an alternative to the hddtemp_smartctl, which is the
# preferred one.
#
# Author: Stein Magnus Jodal <jodal at users.sourceforge.net>
#
# Depends on `hddtemp` <http://coredump.free.fr/linux/hddtemp.php> by
# Emmanuel Varagnat <coredump@free.fr> running as a daemon.
#
# If fetching temp from another machine, remember to bind hddtempd to the right
# interface. Loopback only is default.
#
# Parameters understood:
#
# host - Change which host to graph (default localhost)
# port - Change which port to connect to (default 7634)
# scale - C for Celsius, F for Farenheit (default C)
#
# This plugin is based on the apt plugin.
#
#
# Usage: place in /etc/munin/node.d/ (or link it there using ln -s)
#
# Parameters understood:
# config (required)
# autoconf (optional - used by munin-config)
#
#
# v1.2 2004-06-07
# - Renamed to hddtempd
# - Now more generic, not only localhost
# v1.1 2004-05-23
# - Fixed support for multiple disks
# v1.0 2004-05-17
# - Initial version
#
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=contrib
#%# capabilities=autoconf
use strict;
use IO::Socket::INET;
# Config
our $address = $ENV{host} || "localhost"; # Default: localhost
our $port = $ENV{port} || 7634; # Default: 7634
our $scale = $ENV{scale} || "C"; # C (celcius) or F (fahrenheit)
# Don't edit below this line
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
# Try to connect to the daemon
my $socket = IO::Socket::INET->new("$address:$port")
or my $failed = 1;
if ($failed) {
print "no (failed to connect to $address port $port)\n";
exit 0;
} else {
print "yes\n";
exit 0;
}
}
if ($ARGV[0] and $ARGV[0] eq "config") {
print "graph_title HDD temperature\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Degrees $scale\n";
my @data = get_data();
for my $this (@data) {
print "${$this}[0].label ";
${$this}[0] =~ tr#_#/#;
print "${$this}[0]\n";
}
exit 0;
}
my @data = get_data();
for my $this (@data) {
# device.value temp
print "${$this}[0].value ${$this}[2]\n";
}
# Connect to hddtemp daemon and collect data from it
sub get_data {
my($socket, @raw, @data);
# Connect to the hddtemp daemon
$socket = IO::Socket::INET->new("$address:$port")
or die("Couldn't connect to $address port $port: $!");
# Read data and split into an array
@raw = split(/\|/, <$socket>);
# Parse data
for (my $i = 1; $i < scalar @raw; $i+=5) {
my @this = @raw[$i..$i+3];
# Remove /dev/-prefix on device
#$this[0] =~ s#.*/([^/]+)#$1#;
# Or, replace / with _
$this[0] =~ tr#/#_#;
# Adjust temp to the right scale
if ($scale eq "C" and $this[3] eq "F") {
# Convert from F to C
$this[2] = (5/9) * ($this[2] - 32);
} elsif ($scale eq "F" and $this[3] eq "C") {
# Convert from C to F
$this[2] = (9/5) * $this[2] + 32;
}
# Put @this into @data
push @data, [ @this ];
}
close($socket);
return @data;
}
# vim:syntax=perl
|