From 1070546b2ab104edc2055b60070d2a045403dfb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20=C3=96hrn?= Date: Mon, 2 Feb 2004 17:45:57 +0000 Subject: [PATCH] Add a README file. Add an alternative webpage script. Adjust the graphs a bit. --- ipmitool/contrib/Makefile.am | 2 +- ipmitool/contrib/README | 93 +++++++++++++ ipmitool/contrib/create_webpage.sh | 78 +++++++---- ipmitool/contrib/create_webpage_compact.sh | 151 +++++++++++++++++++++ 4 files changed, 294 insertions(+), 30 deletions(-) create mode 100644 ipmitool/contrib/README create mode 100755 ipmitool/contrib/create_webpage_compact.sh diff --git a/ipmitool/contrib/Makefile.am b/ipmitool/contrib/Makefile.am index 99ddb21..00c9c27 100644 --- a/ipmitool/contrib/Makefile.am +++ b/ipmitool/contrib/Makefile.am @@ -34,5 +34,5 @@ MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = collect_data.sh create_rrds.sh create_webpage.sh +EXTRA_DIST = collect_data.sh create_rrds.sh create_webpage_compact.sh create_webpage.sh diff --git a/ipmitool/contrib/README b/ipmitool/contrib/README new file mode 100644 index 0000000..0a166d5 --- /dev/null +++ b/ipmitool/contrib/README @@ -0,0 +1,93 @@ + +Graphs for ipmitool +------------------- + +This is a set of shell-scripts to quickly create a webpage with pretty graphs! + +Prerequisites are a webserver with cgi-bin support and RRDtool, a data +collection and graphing utility you can get here: + +http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/ + + +First, decide on a directory where to store the RRDtool database files and make +sure it exists. The user that will run the cronjob to collect updates must have +write permissions in this dir. + +Next, you'll need to edit some variables at the top of each script. + +Common to all scripts: + +hostname Override this if you are collecting data from a remote host, + or if the $HOSTNAME variable is incorrect. + +ipmi_cmd Command line used to call ipmitool. Default is to collect + data from the local server using OpenIPMI. + + If you want to collect data from a remote host, add the + -I lan, -H, -U and -P options as necessary. + + BIG NOTE! I do not recommend using remote data collection since + you'll have to store the password in the script. If you do, + make sure unauthorized people can't read or execute the scripts + or they'll be able to wreak havoc on your server. + +rrd_dir Enter the dir where to store the RRDtool database here. + + +Now you can get the data collection going. Run create_rrds.sh to create the +RDDtool database, you'll find one .rrd file per sensor in the designated dir. +Add a line to your crontab that executes collect_data.sh every 5 minutes. + +Something like this: +*/5 * * * * /usr/local/bin/collect_data.sh + +If you are a Solaris user you'll have to write the more verbose: +0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/collect_data.sh + + +Finally it's time to create the webpage, begin with editing some more variables +in the create_webpage.sh and/or create_webpage_compact.sh scripts: + +img_dir Directory to store the graph images. This path must be within + the document root and writable by the web server user. + + Example: /usr/local/apache2/htdocs/images/graphs + +web_dir Relative path of the URL where the images will show up + on the web server. + + Example: With the img_dir path above the corresponding web_dir + would be /images/graphs + +graph_width Size of the graph area in pixels (excluding title, legends etc.) +graph_height + +graph_daily Decide which of daily, weekly and monthly graphs you want +graph_weekly included on the page. +graph_monthly + + +Finally run the create webpage script and store the output as a cgi-script and +don't forget to make it executable. + +Example: + +create_webpage.sh > /usr/local/apache2/cgi-bin/my_ipmi_graphs.cgi +chmod 755 /usr/local/apache2/cgi-bin/my_ipmi_graphs.cgi + +Now you can surf to http://my.server.com/cgi-bin/my_ipmi_graphs.cgi and enjoy! + + +The difference between create_webpage.sh and create_webpage_compact.sh is that +the first script displays sensor thresholds in the graphs. The second script +collects all sensors that measure the same unit into the same graph thus +producing a lot fewer graphs. + +Note, RRDtool sometimes scales the graphs such that the sensor thresholds +fall outside the visible area. + + +Happy graphing! + + diff --git a/ipmitool/contrib/create_webpage.sh b/ipmitool/contrib/create_webpage.sh index 33a04e6..7152b3d 100755 --- a/ipmitool/contrib/create_webpage.sh +++ b/ipmitool/contrib/create_webpage.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2003 Fredrik Ohrn. All Rights Reserved. +# Copyright (c) 2003-2004 Fredrik Ohrn. All Rights Reserved. # # See the included COPYING file for license details. # @@ -22,20 +22,30 @@ img_dir=/usr/local/apache2/htdocs/images/graphs # Where will the graphs show up on the webserver? web_dir=/images/graphs +# Size of graph area (excluding title, legends etc.) +graph_width=500 +graph_height=150 + +# Graphs to include on page +graph_daily=1 +graph_weekly=1 +graph_monthly=0 + + # No need to edit below this point. -color[0]="0000FF" -color[1]="00FF00" -color[2]="FF0000" -color[3]="FFFF00" -color[4]="FF00FF" -color[5]="00FFFF" -color[6]="4444AA" -color[7]="44AA44" -color[8]="AA4444" -color[9]="AAAA44" -color[10]="AA44AA" -color[11]="44AAAA" +color[0]="2020FF" +color[1]="20FF20" +color[2]="FF2020" +color[3]="FF21FF" +color[4]="21FFFF" +color[5]="FFFF21" +color[6]="8F21FF" +color[7]="21FF8F" +color[8]="FF8F21" +color[9]="FF2190" +color[10]="2190FF" +color[11]="90FF21" cat << EOF #!$rrdcgi @@ -151,38 +161,48 @@ for group in $groups ; do fi fi + echo "

${!group_title}

" - cat << EOF -

${!group_title}

+ if [ "$graph_daily" -ne 0 ] ; then + cat << EOF " --lazy - --height 200 --vertical-label "${!group_unit}" --title "Daily graph" - --width 576 ${!group} $thres + --height $graph_height + --width $graph_width ${!group} $thres > +EOF + fi + + if [ "$graph_weekly" -ne 0 ] ; then + cat << EOF " --lazy --start -7d - --height 200 --vertical-label "${!group_unit}" --title "Weelky graph" - --width 672 ${!group} $thres + --height $graph_height + --width $graph_width ${!group} $thres > EOF -#" -# --lazy -# --start -30d -# --height 200 -# --vertical-label "${!group_unit}" -# --title "Monthly graph" -# --width 720 ${!group} $thres -#> -#EOF + fi + if [ "$graph_monthly" -ne 0 ] ; then + cat << EOF +" + --lazy + --start -30d + --vertical-label "${!group_unit}" + --title "Monthly graph" + --height $graph_height + --width $graph_width ${!group} $thres +> +EOF + fi done cat << EOF diff --git a/ipmitool/contrib/create_webpage_compact.sh b/ipmitool/contrib/create_webpage_compact.sh new file mode 100755 index 0000000..d8df05b --- /dev/null +++ b/ipmitool/contrib/create_webpage_compact.sh @@ -0,0 +1,151 @@ +#!/bin/bash +# +# Copyright (c) 2003-2004 Fredrik Ohrn. All Rights Reserved. +# +# See the included COPYING file for license details. +# + +# Edit the variables + +hostname=$HOSTNAME + +ipmi_cmd="/usr/local/bin/ipmitool -I open" +rrd_dir="/some/dir/rrd" + +# Full path to the rrdcgi executable. +rrdcgi=/usr/local/bin/rrdcgi + +# Where should rrdcgi store the graphs? This path must be within the +# document root and writable by the webserver user. +img_dir=/usr/local/apache2/htdocs/images/graphs + +# Where will the graphs show up on the webserver? +web_dir=/images/graphs + +# Size of graph area (excluding title, legends etc.) +graph_width=500 +graph_height=150 + +# Graphs to include on page +graph_daily=1 +graph_weekly=1 +graph_monthly=0 + + +# No need to edit below this point. + +color[0]="2020FF" +color[1]="20FF20" +color[2]="FF2020" +color[3]="FF21FF" +color[4]="21FFFF" +color[5]="FFFF21" +color[6]="8F21FF" +color[7]="21FF8F" +color[8]="FF8F21" +color[9]="FF2190" +color[10]="2190FF" +color[11]="90FF21" + +cat << EOF +#!$rrdcgi + + +$hostname + + +

$hostname

+EOF + + +IFS=" +" + +i=0 +groups= + +for line in `eval $ipmi_cmd -c -v sdr list full` ; do + + IFS=, + + split=($line) + + file="$rrd_dir/$hostname-${split[0]}.rrd" + group=`echo "${split[2]}" | tr ' .-' ___` + + group_color=${group}_color + + if [ -z "${!group}" ] ; then + groups="$groups $group" + + declare $group_color=0 + + group_unit=${group}_unit + declare $group_unit="${split[2]}" + fi + + declare $group="${!group} + DEF:var$i=\"$file\":var:AVERAGE LINE1:var$i#${color[${!group_color}]}:\"${split[0]}\"" + + declare $group_color=$[ ${!group_color} + 1 ] + + c=$[ c + 1 ] + i=$[ i + 1 ] +done + +IFS=" " + +for group in $groups ; do + + group_unit=${group}_unit + + IFS=, + + echo "

${!group_unit}

" + + if [ "$graph_daily" -ne 0 ] ; then + cat << EOF +" + --lazy + --vertical-label "${!group_unit}" + --title "Daily graph" + --height $graph_height + --width $graph_width ${!group} +> +EOF + fi + + if [ "$graph_weekly" -ne 0 ] ; then + cat << EOF +" + --lazy + --start -7d + --vertical-label "${!group_unit}" + --title "Weelky graph" + --height $graph_height + --width $graph_width ${!group} +> +EOF + fi + + if [ "$graph_monthly" -ne 0 ] ; then + cat << EOF +" + --lazy + --start -30d + --vertical-label "${!group_unit}" + --title "Monthly graph" + --height $graph_height + --width $graph_width ${!group} +> +EOF + fi +done + +cat << EOF + + +EOF