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

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