"Fossies" - the Fresh Open Source Software Archive

Member "munin-2.0.52/plugins/node.d.freebsd/coretemp.in" (20 Nov 2019, 2483 Bytes) of package /linux/misc/munin-2.0.52.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!@@GOODSH@@
    2 # -*- sh -*-
    3 #
    4 # Copyright (c) 2008 Dag-Erling Coïdan Smørgrav
    5 # All rights reserved.
    6 #
    7 # Redistribution and use in source and binary forms, with or without
    8 # modification, are permitted provided that the following conditions
    9 # are met:
   10 # 1. Redistributions of source code must retain the above copyright
   11 #    notice, this list of conditions and the following disclaimer
   12 #    in this position and unchanged.
   13 # 2. Redistributions in binary form must reproduce the above copyright
   14 #    notice, this list of conditions and the following disclaimer in the
   15 #    documentation and/or other materials provided with the distribution.
   16 #
   17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27 # SUCH DAMAGE.
   28 #
   29 # $Id$
   30 #
   31 
   32 # This plugin's functionality has been replaced by the dev_cpu_ plugin.
   33 #%# family=legacy
   34 
   35 # Munin plugin for CPU temperature on CPUs supported by FreeBSD's
   36 # coretemp driver (includes all Intel Core and Core 2 CPUs)
   37 
   38 die() {
   39 	echo "$@" 1>&2
   40 	exit 1
   41 }
   42 
   43 cpus() {
   44 	sysctl -N dev.cpu |
   45 	awk -F. '$4 == "temperature" { print $3 }'
   46 }
   47 
   48 reqcpus() {
   49 	if [ -z "$cpus" ] ; then
   50 		die "No supported CPUs"
   51 	fi
   52 }
   53 
   54 autoconf() {
   55 	if [ -n "$cpus" ] ; then
   56 		echo "yes"
   57 	else
   58 		echo "no"
   59 	fi
   60 }
   61 
   62 config() {
   63 	reqcpus
   64 	echo "graph_title CPU Core Temperature"
   65 	echo -n "graph_order"
   66 	for cpu in $cpus ; do
   67 		echo -n " CPU$cpu"
   68 	done
   69 	echo ""
   70 	echo "graph_category sensors"
   71 	echo "graph_vlabel Core temperature in °C"
   72 	echo "graph_scale no"
   73 	for cpu in $cpus ; do
   74 		echo "CPU$cpu.label CPU $cpu"
   75 	done
   76 }
   77 
   78 get() {
   79 	reqcpus
   80 	for cpu in $cpus ; do
   81 		echo -n "CPU$cpu.value "
   82 		sysctl -n dev.cpu.$cpu.temperature | tr -d C
   83 	done
   84 }
   85 
   86 self=$(basename $0)
   87 cpus=$(cpus)
   88 
   89 case "$*" in
   90 autoconf)
   91 	autoconf
   92 	;;
   93 config)
   94 	config
   95         ;;
   96 "")
   97 	get
   98 	;;
   99 *)
  100 	die "usage: $self [autoconf|config]"
  101 	;;
  102 esac