Initial commit

This commit is contained in:
Charlie Root 2025-03-01 00:58:18 +01:00
commit 529efd53a1
140 changed files with 10310 additions and 0 deletions

341
rrdtools/archive/ciscoGraph.sh Executable file
View file

@ -0,0 +1,341 @@
#!/bin/sh
#
# $VER: ciscoGraphs.sh 0.10 (20.10.2005) Riccardo "VIC" Torrini
#
tmp=/tmp/tmp_$$
debug=
trap 'Break' 1 2 15
CleanUp ()
{
rm -f ${tmp}*
}
Break ()
{
echo "${Program}: ** User Break"
CleanUp
exit 2
}
Debug ()
{
[ ${debug} ] && echo "DEBUG: ${1}"
}
Error ()
{
echo "** Error ! ${1}"
CleanUp
exit 2
}
Warning ()
{
echo "* Warning ! ${1}"
CleanUp
exit 1
}
Panic ()
{
echo "** Internal error ! ${1}"
CleanUp
exit 3
}
Message ()
{
echo "* ${1}"
return 1
}
isNotNull ()
{
[ "_${2}" = "_" ] && Error "${1}"
}
CheckFile ()
{
isNotNull "Invalid parameter to CheckFile()" "${1}"
if [ ! -f ${1} ]
then
if [ "_${2}" = "_" ]
then
Error "File not found (${1})"
else
Error "${2}"
fi
fi
}
CheckDir ()
{
isNotNull "Invalid parameter to CheckDir()" "${1}"
if [ ! -d ${1} ]
then
if [ "_${2}" = "_" ]
then
Error "Directory not found (${1})"
else
Error "${2}"
fi
fi
}
FileNotFound ()
{
Message "File not found (`basename ${1}`)"
}
DirectoryNotFound ()
{
Message "Directory not found (${1})"
}
FileExist ()
{
Message "File exist (`basename ${1}`)"
}
# Main
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/local/vbin
dbHome=/var/db/rrd
###
#
# called as: # ${0} {action} "router|switch" {HOSTNAME} ...
#
action=${1:-NULL}
isNotNull "Missing action" "${action}"
service=${2:-NULL}
host=${3:-NULL}
db=${dbHome}/${service}-mpls-${host}.rrd
images=/home/web/virtual-internal/data/stats/services
CheckDir ${images}
CheckDir ${dbHome}
cd ${dbHome}
##
# we can't check 'coz variable parms
#
##isNotNull "Missing service" "${service}"
##isNotNull "Missing host name" "${host}"
case ${action:-NULL} in
create)
###
#
# called as: create {SERVICEDESC} {HOSTNAME}
#
case ${service:-NULL} in
ping|smtp|http)
test -f ${db} && Error "we are on-air, don't try to destroy existing db (${db})"
rrdtool create ${db} \
--start `date -v2000y -v6m -v21d -v0H -v0M -v0S +%s` \
--step 60 \
DS:trip:GAUGE:300:0:U \
DS:lost:GAUGE:300:0:U \
RRA:AVERAGE:0.5:1:50400 \
RRA:AVERAGE:0.5:60:43800 \
RRA:MAX:0.5:1:50400 \
RRA:MAX:0.5:60:43800
chown nagios ${db}
;;
router|switch)
test -f ${db} && Error "we are on-air, don't try to destroy existing db (${db})"
rrdtool create ${db} \
--start `date -v2000y -v6m -v21d -v0H -v0M -v0S +%s` \
--step 300 \
DS:load:GAUGE:600:0:100 \
DS:heat:GAUGE:600:0:U \
DS:io:COUNTER:600:0:U \
DS:oo:COUNTER:600:0:U \
DS:ie:COUNTER:600:0:U \
DS:oe:COUNTER:600:0:U \
RRA:AVERAGE:0.5:1:50400 \
RRA:AVERAGE:0.5:60:43800 \
RRA:MAX:0.5:1:50400 \
RRA:MAX:0.5:60:43800
chown nagios ${db}
;;
*)
Error "not yet !"
;;
esac
;;
collect)
###
#
# called as: collect {SERVICEDESC} {HOSTNAME}
#
case ${service:-NULL} in
ping)
##test -f ${db} || Error "db not found (${db})"
if [ -f ${db} ]
then
shift 5
data=`echo "${*}" | awk -F"@@" '
{
split($0, a);
gsub(/[a-zA-Z %]/, "", a[2]);
split(a[2], b, ",");
split(b[1], c, "=");
split(b[2], d, "=");
if ($0 ~ /timed out after 10 seconds/) {
d[2] = 10000;
c[2] = 100;
}
}
END {
printf( "%s:%s", d[2], c[2] );
}'`
rrdtool update ${db} ${when}:${data}
fi
;;
smtp)
echo "${*}" >> /tmp/nagios.debug
;;
http)
echo "${*}" >> /tmp/nagios.debug
;;
router|switch)
#
host=fi
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2fi.fi-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=fk
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2fi.fi-telecom.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=ge
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2ge.ge-fastweb.esaote.it ifInOctets.2 ifOutOctets.2 ifInErrors.2 ifOutErrors.2 | awk '{printf( ":%.0f", $NF)}'`
#
host=mi
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2mi.mi-fastweb.esaote.it ifInOctets.2 ifOutOctets.2 ifInErrors.2 ifOutErrors.2 | awk '{printf( ":%.0f", $NF)}'`
#
host=rm
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2rm.rm-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=nx
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2nx.nx-fastweb.esaote.it ifInOctets.2 ifOutOctets.2 ifInErrors.2 ifOutErrors.2 | awk '{printf( ":%.0f", $NF)}'`
#
host=pd
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2pd.pd-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=ba
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2ba.ba-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=bo
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2bo.bo-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=ct
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2ct.ct-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
#
host=na
db=${dbHome}/${service}-mpls-${host}.rrd
rrdtool update ${db} N:0:0`snmpget -cpublic -v1 fw2na.na-fastweb.esaote.it ifInOctets.1 ifOutOctets.1 ifInErrors.1 ifOutErrors.1 | awk '{printf( ":%.0f", $NF)}'`
;;
*)
Error "not yet !"
;;
esac
;;
dump)
;;
reload)
;;
daily|weekly|monthly|yearly)
###
#
# called as: (graph)? (daily|weekly|monthly|yearly)
#
case ${action} in
daily)
dfrom="-s `date -v-1d +%s`"
dend=""
;;
weekly)
dfrom="-s `date -v-1w +%s`"
dend=""
;;
monthly)
dfrom="-s `date -v-1m +%s`"
dend=""
;;
yearly)
dfrom="-s `date -v-6m +%s`"
dend=""
;;
esac
thisCanvas="--imgformat PNG"
thisGeometry=""
thisRange="${dfrom} ${dend}"
for service in router
do
for rrd in `ls ${service}-*.rrd`
do
host=${rrd##${service}-}
host=${host%%.rrd}
db=${dbHome}/${service}-${host}.rrd
rrdtool graph ${images}/pkt-${host}-${action}.png \
${thisCanvas} ${thisGeometry} ${thisRange} \
--lower-limit 0 \
--title "${host} bytes (${service} - ${action})" \
--vertical-label "bytes/sec" \
DEF:io=${db}:io:AVERAGE \
DEF:oo=${db}:oo:AVERAGE \
LINE2:io#00ff00 \
LINE2:oo#0000ff
rrdtool graph ${images}/err-${host}-${action}.png \
${thisCanvas} ${thisGeometry} ${thisRange} \
--lower-limit 0 \
--title "${host} errors (${service} - ${action})" \
--vertical-label "errors/sec" \
DEF:ie=${db}:ie:AVERAGE \
DEF:oe=${db}:oe:AVERAGE \
LINE2:ie#ff0000 \
LINE2:oe#808000
done
done
;;
help)
echo "Usage: ${0} [create|collect|update|dump|reload|daily|weekly|monthly|yearly|help]"
exit 1
;;
esac
exit 0

234
rrdtools/archive/cpuGuardian.sh Executable file
View file

@ -0,0 +1,234 @@
#!/bin/sh
#
# $VER: cpuGuardian.sh 0.6 (28.6.2005) Riccardo "VIC" Torrini
#
tmp=/tmp/tmp_$$
debug=
trap 'Break' 1 2 15
CleanUp ()
{
rm -f ${tmp}*
}
Break ()
{
echo "${Program}: ** User Break"
CleanUp
exit 2
}
Debug ()
{
[ ${debug} ] && echo "DEBUG: ${1}"
}
Error ()
{
echo "** Error ! ${1}"
CleanUp
exit 2
}
Warning ()
{
echo "* Warning ! ${1}"
CleanUp
exit 1
}
Panic ()
{
echo "** Internal error ! ${1}"
CleanUp
exit 3
}
Message ()
{
echo "* ${1}"
return 1
}
isNotNull ()
{
[ "_${2}" = "_" ] && Error "${1}"
}
CheckFile ()
{
isNotNull "Invalid parameter to CheckFile()" "${1}"
if [ ! -f ${1} ]
then
if [ "_${2}" = "_" ]
then
Error "File not found (${1})"
else
Error "${2}"
fi
fi
}
CheckDir ()
{
isNotNull "Invalid parameter to CheckDir()" "${1}"
if [ ! -d ${1} ]
then
if [ "_${2}" = "_" ]
then
Error "Directory not found (${1})"
else
Error "${2}"
fi
fi
}
FileNotFound ()
{
Message "File not found (`basename ${1}`)"
}
DirectoryNotFound ()
{
Message "Directory not found (${1})"
}
FileExist ()
{
Message "File exist (`basename ${1}`)"
}
# Main
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/local/vbin
dbHome=/var/db/rrd
db=${dbHome}/cpu.rrd
images=/home/web/data/stats/cpu
host=`hostname`
CheckDir ${images}
CheckDir ${dbHome}
cd ${dbHome}
case ${1:-NULL} in
NULL)
Error "missing command"
;;
createAndInitializeDB)
test -f ${db} && Error "we are on-air, don't try to destroy existing db (${db})"
rrdtool create ${db} \
--start `date -v2000y -v6m -v21d -v0H -v0M -v0S +%s` \
--step 300 \
DS:cpuHeat:GAUGE:600:0:200 \
DS:fan0Speed:GAUGE:600:0:9000 \
DS:fan1Speed:GAUGE:600:0:9000 \
DS:fan2Speed:GAUGE:600:0:9000 \
DS:Vcore:GAUGE:600:0:5 \
DS:cpuLoad:GAUGE:600:U:U \
DS:swapFree:GAUGE:600:0:100 \
DS:rootFree:GAUGE:600:0:100 \
DS:varFree:GAUGE:600:0:100 \
DS:tmpFree:GAUGE:600:0:100 \
DS:homeFree:GAUGE:600:0:100 \
DS:usrFree:GAUGE:600:0:100 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:12:840 \
RRA:AVERAGE:0.5:288:900 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:12:840 \
RRA:MAX:0.5:288:900 \
RRA:LAST:0.5:1:600 \
RRA:LAST:0.5:12:840 \
RRA:LAST:0.5:288:900
;;
collect)
CheckFile ${db} "db not found (${db})"
rrdtool update ${db} N:0:0:0:0:0:`uptime | awk '{gsub(",", ""); print $(NF-2)}'`:`swapinfo | awk '/Interleaved/ {gsub("%", ""); print $(NF-1)}'`:`df | awk '{gsub("%", "", $5); if($6 == "/") $6 = "/root"; gsub("/", "", $6); used[$6] = $5;} END {printf( "%d:%d:%d:%d:%d\n", used["root"], used["var"], used["tmp"], used["home"], used["usr"] )}'`
;;
dump)
;;
reload)
;;
daily|weekly|monthly|yearly)
CheckFile ${db} "db not found (${db})"
type=${1:-NULL}
case ${type} in
daily)
dfrom="-s `date -v-1d +%s`"
dend=""
;;
weekly)
dfrom="-s `date -v-1w +%s`"
dend=""
;;
monthly)
dfrom="-s `date -v-1m +%s`"
dend=""
;;
yearly)
dfrom="-s `date -v-12m +%s`"
dend=""
;;
esac
##thisCanvas="--imgformat PNG --width 400 --height 100"
##thisGeometry="--lower-limit 0 --base 1000 --upper-limit 100 --rigid"
##thisRange="--start -24h --end now"
thisCanvas="--imgformat PNG"
thisGeometry=""
thisRange="${dfrom} ${dend}"
rrdtool graph ${images}/${type}-load.png \
${thisCanvas} ${thisGeometry} ${thisRange} \
--title "${host} cpuLoad (${type})" \
--vertical-label load \
DEF:my=${db}:cpuLoad:AVERAGE \
LINE2:my#ff0000
rrdtool graph ${images}/${type}-disk.png \
${thisCanvas} ${thisGeometry} ${thisRange} \
--title "${host} diskSpace (${type})" \
--vertical-label space \
DEF:swap=${db}:swapFree:AVERAGE \
DEF:root=${db}:rootFree:AVERAGE \
DEF:var=${db}:varFree:AVERAGE \
DEF:tmp=${db}:tmpFree:AVERAGE \
DEF:home=${db}:homeFree:AVERAGE \
DEF:usr=${db}:usrFree:AVERAGE \
LINE2:swap#ff00FF:swap \
LINE2:root#c00000:/root \
LINE2:var#00ff00:/var \
LINE2:tmp#00c000:/tmp \
LINE2:home#0000ff:/home \
LINE2:usr#0000c0:/usr
##GPRINT:swap:MAX:%3.0lf%%
;;
help)
echo "Usage: ${0} [create|collect|update|dump|reload|daily|weekly|monthly|yearly|help]"
exit 1
;;
*)
echo "bad command"
exit 2
;;
esac
exit 0

BIN
rrdtools/archive/prove/cpu-load Executable file

Binary file not shown.

View file

@ -0,0 +1,153 @@
/*-
* Copyright (c) 1993, John Brezak
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD: src/usr.bin/rup/rup.c,v 1.10.2.1 1999/08/29 15:32:26 peter Exp $";
#endif /* not lint */
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netdb.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <arpa/inet.h>
#undef FSHIFT /* Use protocol's shift and scale values */
#undef FSCALE
#include <rpcsvc/rstat.h>
#define HOST_WIDTH 15
int
rstat_reply(char *replyp, struct sockaddr_in *raddrp)
{
struct tm *tmp_time;
struct tm host_time;
struct tm host_uptime;
char days_buf[16];
char hours_buf[16];
struct hostent *hp;
char *host;
statstime *host_stat = (statstime *)replyp;
hp = gethostbyaddr((char *)&raddrp->sin_addr.s_addr,
sizeof(struct in_addr), AF_INET);
if (hp)
host = hp->h_name;
else
host = inet_ntoa(raddrp->sin_addr);
printf("%.0f\n%.0f\n", 100*((double)host_stat->avenrun[1])/FSCALE, 100*((double)host_stat->avenrun[1])/FSCALE);
tmp_time = localtime((time_t *)&host_stat->curtime.tv_sec);
host_time = *tmp_time;
host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec;
tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec);
host_uptime = *tmp_time;
#define updays (host_stat->curtime.tv_sec / 86400)
if (host_uptime.tm_yday != 0)
sprintf(days_buf, "%3d day%s ", updays,
(updays > 1) ? "s" : "");
else
days_buf[0] = '\0';
if (host_uptime.tm_hour != 0)
sprintf(hours_buf, "%2d:%02d ",
host_uptime.tm_hour, host_uptime.tm_min);
else
if (host_uptime.tm_min != 0)
sprintf(hours_buf, "%2d mins ", host_uptime.tm_min);
else
hours_buf[0] = '\0';
printf("%9.9s%9.9s\n", days_buf, hours_buf);
printf("%s\n", host);
return(0);
}
int
onehost(char *host)
{
CLIENT *rstat_clnt;
statstime host_stat;
struct sockaddr_in addr;
struct hostent *hp;
struct timeval tv;
hp = gethostbyname(host);
if (hp == NULL) {
warnx("unknown host \"%s\"", host);
return(-1);
}
rstat_clnt = clnt_create(host, RSTATPROG, RSTATVERS_TIME, "udp");
if (rstat_clnt == NULL) {
warnx("%s %s", host, clnt_spcreateerror(""));
return(-1);
}
bzero((char *)&host_stat, sizeof(host_stat));
tv.tv_sec = 15; /* XXX ??? */
tv.tv_usec = 0;
if (clnt_call(rstat_clnt, RSTATPROC_STATS, xdr_void, NULL, xdr_statstime, &host_stat, tv) != RPC_SUCCESS) {
warnx("%s: %s", host, clnt_sperror(rstat_clnt, host));
return(-1);
}
addr.sin_addr.s_addr = *(int *)hp->h_addr;
rstat_reply((char *)&host_stat, &addr);
return (0);
}
int
main(int argc, char *argv[])
{
if (argc != 2) {
fprintf (stderr, "Usage %s <hostname>\n", argv[0]);
exit (0);
}
onehost(argv[1]);
}

View file

@ -0,0 +1,13 @@
#!/bin/sh
uptime
CPU=`uptime | awk '{print $11}'`
PIPPO=`expr eval ${CPU%,} + 0`
# echo $CPU
# PIPPO=${CPU%.}
# echo $PIPPO
# ultimo ${pippo%.}
# primo ${pippo#.}

View file

@ -0,0 +1,66 @@
#!/bin/sh
DBASE="/usr/local/www/data/rrdtools/dbase/bw-adsl.rrd"
IMG="/usr/local/www/data/rrdtools/pics/bw-adsl.png"
SIMG="/usr/local/www/data/rrdtools/pics/small-bw-adsl.png"
RRD="/usr/local/bin/rrdtool"
SNMPGET="/usr/local/bin/snmpget -v 1 -c public -Oqv localhost"
# RRA = 1 giorno
# Aggiungere :
# RRA:AVERAGE:0.5:288:31
# per salvare il report mensile
# ?
# RRA:AVERAGE:0.5:12:24
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:adsl_in:COUNTER:600:U:U \
DS:adsl_out:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} IF-MIB::ifInOctets.4`:`${SNMPGET} IF-MIB::ifOutOctets.4`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Adsl Bw" \
--font DEFAULT:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--upper-limit=180000 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="KB/sec" \
DEF:byte_in="${DBASE}":adsl_in:AVERAGE \
DEF:byte_out="${DBASE}":adsl_out:AVERAGE \
AREA:byte_in#00CF00:"IN\t" GPRINT:byte_in:LAST:"Last\:%8.2lf %s" GPRINT:byte_in:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_in:MAX:"Max\:%8.2lf %s\n" \
LINE1:byte_out#FF0000:"OUT\t" GPRINT:byte_out:LAST:"Last\:%8.2lf %s" GPRINT:byte_out:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_out:MAX:"Max\:%8.2lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--upper-limit=180000 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:byte_in="${DBASE}":adsl_in:AVERAGE \
DEF:byte_out="${DBASE}":adsl_out:AVERAGE \
AREA:byte_in#00CF00: \
LINE1:byte_out#FF0000:
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

View file

@ -0,0 +1,79 @@
#!/bin/sh
DBASE="/usr/local/www/data/rrdtools/dbase/conn-server.rrd"
IMG="/usr/local/www/data/rrdtools/pics/conn-server.png"
SIMG="/usr/local/www/data/rrdtools/pics/small-conn-server.png"
RRD="/usr/local/bin/rrdtool"
SNMPGET="/usr/local/bin/snmpget -v 1 -c public -Oqv localhost"
# RRA = 1 giorno
# Aggiungere :
# RRA:AVERAGE:0.5:288:31
# per salvare il report mensile
# ?
# RRA:AVERAGE:0.5:12:24
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:conn_estab:GAUGE:600:U:U \
DS:conn_active:COUNTER:600:U:U \
DS:conn_passive:COUNTER:600:U:U \
DS:conn_fails:COUNTER:600:U:U \
DS:conn_reset:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} TCP-MIB::tcpCurrEstab.0`:`${SNMPGET} TCP-MIB::tcpActiveOpens.0`:`${SNMPGET} TCP-MIB::tcpPassiveOpens.0`:`${SNMPGET} TCP-MIB::tcpAttemptFails.0`:`${SNMPGET} TCP-MIB::tcpEstabResets.0`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Connections" \
--font DEFAULT:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="Connections" \
DEF:estab="${DBASE}":conn_estab:AVERAGE \
DEF:active="${DBASE}":conn_active:AVERAGE \
DEF:passive="${DBASE}":conn_passive:AVERAGE \
DEF:fails="${DBASE}":conn_fails:AVERAGE \
DEF:reset="${DBASE}":conn_reset:AVERAGE \
LINE1:estab#002A97:"TCP Estab\t" GPRINT:estab:LAST:"Last\:%4.0lf %s\t" GPRINT:estab:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:estab:MAX:"Max\:%4.0lf %s\n" \
LINE1:active#00CF00:"TCP Active\t" GPRINT:active:LAST:"Last\:%4.0lf %s\t" GPRINT:active:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:active:MAX:"Max\:%4.0lf %s\n" \
LINE1:passive#FF0000:"TCP Passive\t" GPRINT:passive:LAST:"Last\:%4.0lf %s\t" GPRINT:passive:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:passive:MAX:"Max\:%4.0lf %s\n" \
LINE1:fails#FF00FF:"TCP Fails\t" GPRINT:fails:LAST:"Last\:%4.0lf %s\t" GPRINT:fails:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:fails:MAX:"Max\:%4.0lf %s\n" \
LINE1:reset#009999:"TCP Reset\t" GPRINT:reset:LAST:"Last\:%4.0lf %s\t" GPRINT:reset:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:reset:MAX:"Max\:%4.0lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:estab="${DBASE}":conn_estab:AVERAGE \
DEF:active="${DBASE}":conn_active:AVERAGE \
DEF:passive="${DBASE}":conn_passive:AVERAGE \
DEF:fails="${DBASE}":conn_fails:AVERAGE \
DEF:reset="${DBASE}":conn_reset:AVERAGE \
LINE1:estab#002A97:\
LINE1:active#00CF00:\
LINE1:passive#FF0000:\
LINE1:fails#FF00FF:\
LINE1:reset#009999:\
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

View file

@ -0,0 +1,50 @@
#!/bin/sh
DBASE="/usr/local/www/data/rrdtools/dbase/temp-hd.rrd"
IMG="/usr/local/www/data/rrdtools/pics/temp-hd.png"
SIMG="/usr/local/www/data/rrdtools/pics/small-temp-hd.png"
RRD="/usr/local/bin/rrdtool"
TEMP=`/usr/local/sbin/smartctl -a /dev/ad0 | /usr/bin/grep Temperature_Celsius | /usr/bin/cut -c 88-89`
# RRA = 1 giorno
# Aggiungere :
# RRA:AVERAGE:0.5:288:31
# per salvare il report mensile
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:temp_hd:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:${TEMP}
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="HD Temperature" \
--font LEGEND:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--upper-limit=100 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="celsius" \
DEF:temp="${DBASE}":temp_hd:AVERAGE \
AREA:temp#00CF00:"TEMP\t" GPRINT:temp:LAST:"Last\:%4.0lf %s" GPRINT:temp:AVERAGE:"Avg\:%4.0lf %s" GPRINT:temp:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:temp="${DBASE}":temp_hd:AVERAGE \
AREA:temp#00CF00:

View file

@ -0,0 +1,4 @@
#!/bin/sh
. rrdtool.conf
echo $BASEPATH

61
rrdtools/archive/rrd-hddmon.pl Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/perl
# RRA:CF:xff:step:rows
$debug = 1;
$dbname = "dbase/hdtemp.rrd";
$pic="temp.gif";
$step = 10; # 5min , 5*60sec
$num_pdp=3600/$step; # 12 value of pdp = (5*60)*12 = 1 hour
$rows_pdp=24; # 24 value of $num_pdp = 1 day
$rrdtool = "/usr/local/bin/rrdtool";
#$create = "$rrdtool create $dbname ".
# " --start now-1h ".
# " --step $step ".
# " DS:hdtemp:GAUGE:".(2*$step).":0:100 ".
# " RRA:AVERAGE:0.5:$num_pdp:$rows_pdp ".
# " RRA:MIN:0.5:$num_pdp:$rows_pdp ".
# " RRA:MAX:0.5:$num_pdp:$rows_pdp ";
$create = "$rrdtool create $dbname ".
"--start now-1h ".
"--step $step ".
"DS:hdtemp:GAUGE:".(2*$step).":0:100 ".
"RRA:MIN:0.5:1:".(6*$step)." ".
"RRA:MAX:0.5:1:".(6*$step)." ".
"RRA:LAST:0.5:1:".(6*$step)." ".
"RRA:AVERAGE:0.5:1:".(6*$step);
system($create);
while(1) {
@hdparams = `smartctl -a /dev/ad0`;
foreach $line (@hdparams) {
if ($line =~ /Temperature_Celsius/){
@temp = split (" ",$line);
print $temp[9]." ";
}
}
$now = time();
$update = "$rrdtool update $dbname $now:$temp[9]";
system($update);
$graph ="$rrdtool graph $pic --title \"HD temp\" ".
"--start now-1h ".
"DEF:c=$dbname:hdtemp:AVERAGE ".
"AREA:c#0000FF:Temperature ".
"GPRINT:c:MIN:'Min\\: %3.1lf%S' ".
"GPRINT:c:MAX:'Max\\: %3.1lf%S' ".
"GPRINT:c:LAST:'Last\\: %3.1lf%S' ".
"GPRINT:c:AVERAGE:'Avg\\: %3.1lf%S' ";
system($graph." > /dev/null");
sleep $step;
}

BIN
rrdtools/dbase/bw-bge0.rrd Normal file

Binary file not shown.

BIN
rrdtools/dbase/bw-em0.rrd Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
rrdtools/dbase/temp-hd.rrd Normal file

Binary file not shown.

BIN
rrdtools/img/bw-bge0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
rrdtools/img/cpu-server.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
rrdtools/img/hd-server.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
rrdtools/img/temp-hd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

11
rrdtools/rrd-generate.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
MYDIR=`dirname $0`
cd ${MYDIR}
for PRG in `ls scripts/*.sh`; {
sh ${PRG} && echo $PRG
}

10
rrdtools/rrdtool.conf Normal file
View file

@ -0,0 +1,10 @@
# Simple config file
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:./
BASEDIR="/home/web/www.gimbo.org/www/rrdtools"
SCRIPTDIR=${BASEDIR}/scripts
IMGDIR=${BASEDIR}/img
DBASEDIR=${BASEDIR}/dbase
RRD="/usr/local/bin/rrdtool"
SNMPGET="/usr/local/bin/bsnmpget -s public@localhost -o quiet"

54
rrdtools/scripts/bw-bge0.sh Executable file
View file

@ -0,0 +1,54 @@
#!/bin/sh -x
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="bw-bge0"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:bge0_in:COUNTER:600:U:U \
DS:bge0_out:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} "ifInOctets[1]"`:`${SNMPGET} "ifOutOctets[1]"`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Bandwith" \
--font DEFAULT:7 \
--height=100 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="bytes/sec" \
DEF:byte_in="${DBASE}":bge0_in:AVERAGE \
DEF:byte_out="${DBASE}":bge0_out:AVERAGE \
AREA:byte_in#00CF00:"IN\t" GPRINT:byte_in:LAST:"Last\:%8.2lf %s" GPRINT:byte_in:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_in:MAX:"Max\:%8.2lf %s\n" \
LINE1:byte_out#FF0000:"OUT\t" GPRINT:byte_out:LAST:"Last\:%8.2lf %s" GPRINT:byte_out:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_out:MAX:"Max\:%8.2lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:byte_in="${DBASE}":bge0_in:AVERAGE \
DEF:byte_out="${DBASE}":bge0_out:AVERAGE \
AREA:byte_in#00CF00: \
LINE1:byte_out#FF0000:
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

91
rrdtools/scripts/conn-server.sh Executable file
View file

@ -0,0 +1,91 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="conn-server"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:conn_tot:GAUGE:600:U:U \
DS:conn_udp:GAUGE:600:U:U \
DS:conn_tcp:GAUGE:600:U:U \
DS:conn_pop:GAUGE:600:U:U \
DS:conn_www:GAUGE:600:U:U \
DS:conn_mai:GAUGE:600:U:U \
DS:conn_pcs:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
TOTSESS=`netstat -an | grep -ce '^.*p4'`
UDPSESS=`netstat -an | grep -ce '^udp4'`
TCPSESS=`netstat -an | grep -ce '^tcp4'`
POPSESS=`netstat -an | grep -ce '83.149.156.244.110 '`
WWWSESS=`netstat -an | grep -ce '83.149.156.244.80'`
MAISESS=`netstat -an | grep -ce '83.149.156.244.25'`
PCSSESS=`netstat -an | grep -ce '83.149.156.244.2110'`
${RRD} update ${DBASE} N:${TOTSESS}:${UDPSESS}:${TCPSESS}:${POPSESS}:${WWWSESS}:${MAISESS}:${PCSSESS}
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Connections" \
--font DEFAULT:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="Connections" \
DEF:tot="${DBASE}":conn_tot:AVERAGE \
DEF:udp="${DBASE}":conn_udp:AVERAGE \
DEF:tcp="${DBASE}":conn_tcp:AVERAGE \
DEF:pop="${DBASE}":conn_pop:AVERAGE \
DEF:www="${DBASE}":conn_www:AVERAGE \
DEF:mai="${DBASE}":conn_mai:AVERAGE \
DEF:pcs="${DBASE}":conn_pcs:AVERAGE \
AREA:tot#00CF00:"TOT\t\t" GPRINT:tot:LAST:"Last\:%4.0lf %s\t" GPRINT:tot:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:tot:MAX:"Max\:%4.0lf %s\n" \
LINE1:udp#FF0000:"UDP\t\t" GPRINT:udp:LAST:"Last\:%4.0lf %s\t" GPRINT:udp:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:udp:MAX:"Max\:%4.0lf %s\n" \
LINE1:tcp#002A97:"TCP\t\t" GPRINT:tcp:LAST:"Last\:%4.0lf %s\t" GPRINT:tcp:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:tcp:MAX:"Max\:%4.0lf %s\n" \
LINE1:pop#FF00FF:"pop3\t\t" GPRINT:pop:LAST:"Last\:%4.0lf %s\t" GPRINT:pop:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:pop:MAX:"Max\:%4.0lf %s\n" \
LINE1:www#009999:"www\t\t" GPRINT:www:LAST:"Last\:%4.0lf %s\t" GPRINT:www:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:www:MAX:"Max\:%4.0lf %s\n" \
LINE1:mai#DDDDDD:"smtp\t\t" GPRINT:mai:LAST:"Last\:%4.0lf %s\t" GPRINT:mai:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:mai:MAX:"Max\:%4.0lf %s\n" \
LINE1:pcs#FFFF66:"procsy\t" GPRINT:pcs:LAST:"Last\:%4.0lf %s\t" GPRINT:pcs:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:pcs:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:tot="${DBASE}":conn_tot:AVERAGE \
DEF:udp="${DBASE}":conn_udp:AVERAGE \
DEF:tcp="${DBASE}":conn_tcp:AVERAGE \
DEF:pop="${DBASE}":conn_pop:AVERAGE \
DEF:www="${DBASE}":conn_www:AVERAGE \
DEF:mai="${DBASE}":conn_mai:AVERAGE \
DEF:pcs="${DBASE}":conn_pcs:AVERAGE \
AREA:tot#00CF00 \
LINE1:udp#FF0000 \
LINE1:tcp#002A97 \
LINE1:pop#FF00FF \
LINE1:www#009999 \
LINE1:mai#DDDDDD \
LINE1:pcs#FFFF66
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

View file

@ -0,0 +1,71 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="conn-server"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:conn_estab:GAUGE:600:U:U \
DS:conn_active:COUNTER:600:U:U \
DS:conn_passive:COUNTER:600:U:U \
DS:conn_fails:COUNTER:600:U:U \
DS:conn_reset:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} TCP-MIB::tcpCurrEstab.0`:`${SNMPGET} TCP-MIB::tcpActiveOpens.0`:`${SNMPGET} TCP-MIB::tcpPassiveOpens.0`:`${SNMPGET} TCP-MIB::tcpAttemptFails.0`:`${SNMPGET} TCP-MIB::tcpEstabResets.0`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Connections" \
--font DEFAULT:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="Connections" \
DEF:estab="${DBASE}":conn_estab:AVERAGE \
DEF:active="${DBASE}":conn_active:AVERAGE \
DEF:passive="${DBASE}":conn_passive:AVERAGE \
DEF:fails="${DBASE}":conn_fails:AVERAGE \
DEF:reset="${DBASE}":conn_reset:AVERAGE \
LINE1:estab#002A97:"TCP Estab\t" GPRINT:estab:LAST:"Last\:%4.0lf %s\t" GPRINT:estab:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:estab:MAX:"Max\:%4.0lf %s\n" \
LINE1:active#00CF00:"TCP Active\t" GPRINT:active:LAST:"Last\:%4.0lf %s\t" GPRINT:active:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:active:MAX:"Max\:%4.0lf %s\n" \
LINE1:passive#FF0000:"TCP Passive\t" GPRINT:passive:LAST:"Last\:%4.0lf %s\t" GPRINT:passive:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:passive:MAX:"Max\:%4.0lf %s\n" \
LINE1:fails#FF00FF:"TCP Fails\t" GPRINT:fails:LAST:"Last\:%4.0lf %s\t" GPRINT:fails:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:fails:MAX:"Max\:%4.0lf %s\n" \
LINE1:reset#009999:"TCP Reset\t" GPRINT:reset:LAST:"Last\:%4.0lf %s\t" GPRINT:reset:AVERAGE:"Avg\:%4.0lf %s\t" GPRINT:reset:MAX:"Max\:%4.0lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:estab="${DBASE}":conn_estab:AVERAGE \
DEF:active="${DBASE}":conn_active:AVERAGE \
DEF:passive="${DBASE}":conn_passive:AVERAGE \
DEF:fails="${DBASE}":conn_fails:AVERAGE \
DEF:reset="${DBASE}":conn_reset:AVERAGE \
LINE1:estab#002A97:\
LINE1:active#00CF00:\
LINE1:passive#FF0000:\
LINE1:fails#FF00FF:\
LINE1:reset#009999:\
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

44
rrdtools/scripts/cpu-server.sh Executable file
View file

@ -0,0 +1,44 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="cpu-server"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:cpu_srv:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`uptime | awk '{gsub(",", ""); print $(NF-1)}' | awk '{print $1 * 100}'`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="CPU usage" \
--font LEGEND:7 \
--height=100 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="cpu usage %" \
DEF:cpu="${DBASE}":cpu_srv:AVERAGE \
AREA:cpu#00CF00:"CPU\t" GPRINT:cpu:LAST:"Last\:%4.0lf %s" GPRINT:cpu:AVERAGE:"Avg\:%4.0lf %s" GPRINT:cpu:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:cpu="${DBASE}":cpu_srv:AVERAGE \
AREA:cpu#00CF00:

50
rrdtools/scripts/hd-server.sh Executable file
View file

@ -0,0 +1,50 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="hd-server"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:hd0_srv:GAUGE:600:U:U \
DS:hd1_srv:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
HD0SPACE=`df | grep /dev/ad0s1a | awk '{gsub("%", ""); print $(NF-1)}'`
HD1SPACE=`df | grep /dev/ad1s1a | awk '{gsub("%", ""); print $(NF-1)}'`
${RRD} update ${DBASE} N:${HD0SPACE}:${HD1SPACE}
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="HD space" \
--font LEGEND:7 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="hd usage %" \
DEF:hd0="${DBASE}":hd0_srv:AVERAGE \
DEF:hd1="${DBASE}":hd1_srv:AVERAGE \
AREA:hd0#00CF00:"ad0 usage\t" GPRINT:hd0:LAST:"Last\:%4.0lf %s" GPRINT:hd0:AVERAGE:"Avg\:%4.0lf %s" GPRINT:hd0:MAX:"Max\:%4.0lf %s\n" \
LINE1:hd1#002A97:"ad1 usage\t" GPRINT:hd1:LAST:"Last\:%4.0lf %s" GPRINT:hd1:AVERAGE:"Avg\:%4.0lf %s" GPRINT:hd1:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:hd0="${DBASE}":hd0_srv:AVERAGE \
DEF:hd1="${DBASE}":hd1_srv:AVERAGE \
AREA:hd0#00CF00 \
LINE1:hd1#002A97

View file

@ -0,0 +1,58 @@
#!/bin/sh -x
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="bw-bge0"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:bge0_in:COUNTER:600:U:U \
DS:bge0_out:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} "ifInOctets[1]"`:`${SNMPGET} "ifOutOctets[1]"`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Bandwith" \
--font DEFAULT:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--upper-limit=180000 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="KB/sec" \
DEF:byte_in="${DBASE}":bge0_in:AVERAGE \
DEF:byte_out="${DBASE}":bge0_out:AVERAGE \
AREA:byte_in#00CF00:"IN\t" GPRINT:byte_in:LAST:"Last\:%8.2lf %s" GPRINT:byte_in:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_in:MAX:"Max\:%8.2lf %s\n" \
LINE1:byte_out#FF0000:"OUT\t" GPRINT:byte_out:LAST:"Last\:%8.2lf %s" GPRINT:byte_out:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_out:MAX:"Max\:%8.2lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--upper-limit=180000 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:byte_in="${DBASE}":bge0_in:AVERAGE \
DEF:byte_out="${DBASE}":bge0_out:AVERAGE \
AREA:byte_in#00CF00: \
LINE1:byte_out#FF0000:
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

54
rrdtools/scripts/old/bw-em0.sh Executable file
View file

@ -0,0 +1,54 @@
#!/bin/sh -x
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="bw-em0"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:em0_in:COUNTER:600:U:U \
DS:em0_out:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} "ifInOctets[1]"`:`${SNMPGET} "ifOutOctets[1]"`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Bandwith" \
--font DEFAULT:7 \
--height=100 \
--width=400 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="bytes/sec" \
DEF:byte_in="${DBASE}":em0_in:AVERAGE \
DEF:byte_out="${DBASE}":em0_out:AVERAGE \
AREA:byte_in#00CF00:"IN\t" GPRINT:byte_in:LAST:"Last\:%8.2lf %s" GPRINT:byte_in:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_in:MAX:"Max\:%8.2lf %s\n" \
LINE1:byte_out#FF0000:"OUT\t" GPRINT:byte_out:LAST:"Last\:%8.2lf %s" GPRINT:byte_out:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_out:MAX:"Max\:%8.2lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:byte_in="${DBASE}":em0_in:AVERAGE \
DEF:byte_out="${DBASE}":em0_out:AVERAGE \
AREA:byte_in#00CF00: \
LINE1:byte_out#FF0000:
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \

View file

@ -0,0 +1,48 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="hd-server"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:hd_srv:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`df | grep /dev/ad0s1a | awk '{gsub("%", ""); print $(NF-1)}'`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="HD space" \
--font LEGEND:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--tabwidth=20 \
--upper-limit=100 \
--lower-limit=0 \
--vertical-label="hd usage %" \
DEF:hd="${DBASE}":hd_srv:AVERAGE \
AREA:hd#00CF00:"SPACE USED\t" GPRINT:hd:LAST:"Last\:%4.0lf %s" GPRINT:hd:AVERAGE:"Avg\:%4.0lf %s" GPRINT:hd:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:hd="${DBASE}":hd_srv:AVERAGE \
AREA:hd#00CF00

View file

@ -0,0 +1,46 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="temp-hd"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:temp_hd:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`smartctl -a /dev/ad0 | grep Temperature_Celsius | cut -c 88-89`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="HD Temperature" \
--font LEGEND:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--upper-limit=100 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="celsius" \
DEF:temp="${DBASE}":temp_hd:AVERAGE \
AREA:temp#00CF00:"TEMP\t" GPRINT:temp:LAST:"Last\:%4.0lf %s" GPRINT:temp:AVERAGE:"Avg\:%4.0lf %s" GPRINT:temp:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:temp="${DBASE}":temp_hd:AVERAGE \
AREA:temp#00CF00:

55
rrdtools/scripts/temp-hd.sh Executable file
View file

@ -0,0 +1,55 @@
#!/bin/sh
BASEDIR=`pwd`
. ${BASEDIR%scripts}/rrdtool.conf
FILE="temp-hd"
DBASE="${DBASEDIR}/${FILE}.rrd"
IMG="${IMGDIR}/${FILE}.png"
SIMG="${IMGDIR}/small-${FILE}.png"
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:temp0_hd:GAUGE:600:U:U \
DS:temp1_hd:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
TEMP0=`smartctl -a /dev/ad0 | grep Temperature_Celsius | cut -c 88-89`
TEMP1=`smartctl -a /dev/ad1 | grep Temperature_Celsius | cut -c 88-89`
${RRD} update ${DBASE} N:${TEMP0}:${TEMP1}
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="HD Temperature" \
--font LEGEND:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--upper-limit=100 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="celsius" \
DEF:temp0="${DBASE}":temp0_hd:AVERAGE \
DEF:temp1="${DBASE}":temp1_hd:AVERAGE \
AREA:temp0#00CF00:"ad0\t" GPRINT:temp0:LAST:"Last\:%4.0lf %s" GPRINT:temp0:AVERAGE:"Avg\:%4.0lf %s" GPRINT:temp0:MAX:"Max\:%4.0lf %s\n" \
LINE1:temp1#FF0000:"ad1\t" GPRINT:temp1:LAST:"Last\:%4.0lf %s" GPRINT:temp1:AVERAGE:"Avg\:%4.0lf %s" GPRINT:temp1:MAX:"Max\:%4.0lf %s"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:temp0="${DBASE}":temp0_hd:AVERAGE \
DEF:temp1="${DBASE}":temp1_hd:AVERAGE \
AREA:temp0#00CF00: \
LINE1:temp1#FF0000:

5
rrdtools/test.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/sh
CPU=expr 0 + `uptime | awk '{gsub(",", ""); print $(NF-1)}'`
CCPU=`expr -e 100 \\* 0.14`
echo $CCPU