Graphing proxy HITs with MRTG.

I’m monitoring with MRTG some RouterOS variables in order to get
a idea how it is working.

This is my script to monitor CACHE HITS on my ROUTER OS 3.0rc11

#!/usr/bin/perl

$SSH=“/usr/bin/ssh”;
$USERMT=“linux”;
$CERTMT=“/root/.ssh/id_dsa”;
$HOSTMT=“168.192.1.2”;

###################################################################
sub script {
my $linea = shift;
$script.=$linea." \n";
}


###################################################################
sub run {
my $ejecutar = shift;
my $resultado = $ejecutar;
}


###################################################################
sub ejecutarScript {
my($CMD) = shift;
run(“$SSH -l $USERMT -i $CERTMT $HOSTMT "$CMD"”);
}

###################################################################

M A I N

###################################################################

#################### Inicializacion Script
script(“#”);
script(“# Inicializacion del script en $theTime “);
script(”#”);

script(“/ip proxy monitor once”);
$resultado=ejecutarScript($script);

$resultado=~/requests:\s+(\d+)/gi;
$requests=$1;
$resultado=~/hits:\s+(\d+)/gi;
$hits=$1;
print “$requests\n$hits\n”;

And this is my MRTG code:

############### HITS CACHE #################
Target[127.0.0.1_8]: /usr/bin/perl /scripts/mikrotik/hits-count.pl
Options[127.0.0.1_8]: growright,noinfo, nobanner
MaxBytes[127.0.0.1_8]: 100000000
Title[127.0.0.1_8]: CACHE HITS
YLegend[127.0.0.1_8]: Total Requests
ShortLegend[127.0.0.1_8]: req
LegendI[127.0.0.1_8]: Total Requests:
LegendO[127.0.0.1_8]: HITS requests:
PageTop[127.0.0.1_8]:

CACHE HITS

System: CACHE HITS
Maintainer: mac
ifName: eth1

You need to create ssh certificates in order to run securely your
script.

regards. :sunglasses:

Nice Shoot!!

Max

Thanks Maxi :slight_smile:

MRTG Cache Hits example graphics,

and another script that count PPPoE active sessiones (green line) and total sessions (blue line)

I will post later mrtg / perl script that count pppoe sessions.

Enjoy :sunglasses:
pppoe-sesiones.gif
cache-hits.gif