1#!/bin/bash 2# 3# Copyright (c) 2003-2004 Fredrik Ohrn. All Rights Reserved. 4# 5# See the included COPYING file for license details. 6# 7 8# Edit the variables 9 10hostname=$HOSTNAME 11 12ipmi_cmd="/usr/local/bin/ipmitool -I open" 13rrd_dir="/some/dir/rrd" 14 15# Full path to the rrdcgi executable. 16rrdcgi=/usr/local/bin/rrdcgi 17 18# Where should rrdcgi store the graphs? This path must be within the 19# document root and writable by the webserver user. 20img_dir=/usr/local/apache2/htdocs/images/graphs 21 22# Where will the graphs show up on the webserver? 23web_dir=/images/graphs 24 25# Size of graph area (excluding title, legends etc.) 26graph_width=500 27graph_height=150 28 29# Graphs to include on page 30graph_daily=1 31graph_weekly=1 32graph_monthly=0 33 34 35# No need to edit below this point. 36 37color[0]="2020FF" 38color[1]="20FF20" 39color[2]="FF2020" 40color[3]="FF21FF" 41color[4]="21FFFF" 42color[5]="FFFF21" 43color[6]="8F21FF" 44color[7]="21FF8F" 45color[8]="FF8F21" 46color[9]="FF2190" 47color[10]="2190FF" 48color[11]="90FF21" 49 50cat << EOF 51#!$rrdcgi 52<html> 53<head> 54<title>$hostname</title> 55<RRD::GOODFOR 300> 56<body> 57<h2>$hostname</h2> 58EOF 59 60 61IFS=" 62" 63 64i=0 65groups= 66 67for line in `eval $ipmi_cmd -c -v sdr list full` ; do 68 69 IFS=, 70 71 split=($line) 72 73 file="$rrd_dir/$hostname-${split[0]}.rrd" 74 group=`echo "${split[2]}" | tr ' .-' ___` 75 76 group_color=${group}_color 77 78 if [ -z "${!group}" ] ; then 79 groups="$groups $group" 80 81 declare $group_color=0 82 83 group_unit=${group}_unit 84 declare $group_unit="${split[2]}" 85 fi 86 87 declare $group="${!group} 88 DEF:var$i=\"$file\":var:AVERAGE LINE1:var$i#${color[${!group_color}]}:\"${split[0]}\"" 89 90 declare $group_color=$[ ${!group_color} + 1 ] 91 92 c=$[ c + 1 ] 93 i=$[ i + 1 ] 94done 95 96IFS=" " 97 98for group in $groups ; do 99 100 group_unit=${group}_unit 101 102 IFS=, 103 104 echo "<h3>${!group_unit}</h3>" 105 106 if [ "$graph_daily" -ne 0 ] ; then 107 cat << EOF 108<RRD::GRAPH "$img_dir/$hostname-$group-daily.gif" 109 --imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">" 110 --lazy 111 --vertical-label "${!group_unit}" 112 --title "Daily graph" 113 --height $graph_height 114 --width $graph_width ${!group} 115> 116EOF 117 fi 118 119 if [ "$graph_weekly" -ne 0 ] ; then 120 cat << EOF 121<RRD::GRAPH "$img_dir/$hostname-$group-weekly.gif" 122 --imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">" 123 --lazy 124 --start -7d 125 --vertical-label "${!group_unit}" 126 --title "Weelky graph" 127 --height $graph_height 128 --width $graph_width ${!group} 129> 130EOF 131 fi 132 133 if [ "$graph_monthly" -ne 0 ] ; then 134 cat << EOF 135<RRD::GRAPH "$img_dir/$hostname-$group-monthly.gif" 136 --imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">" 137 --lazy 138 --start -30d 139 --vertical-label "${!group_unit}" 140 --title "Monthly graph" 141 --height $graph_height 142 --width $graph_width ${!group} 143> 144EOF 145 fi 146done 147 148cat << EOF 149</body> 150</html> 151EOF 152