summaryrefslogtreecommitdiff
path: root/src/contrib/linux_stat
diff options
context:
space:
mode:
authorbeatrice <beatrice@dangofactory.net>2026-11-22 20:00:14 +0900
committerbeatrice <beatrice@dangofactory.net>2026-11-22 20:00:14 +0900
commit8f68d02045982da8f00a559835b500caf3a1967d (patch)
treec8d0e92969b92e1b6559a0e032b6aa710a8ae2d9 /src/contrib/linux_stat
parentbb5ff95073e5001be7dbf58ffce80d7926deff0b (diff)
downloadmrtg-master.tar.gz
mrtg-master.zip
Release tarball mrtg-2.17.7.tar.gz (dist-generated files / local differences from tag)HEADmaster
Diffstat (limited to 'src/contrib/linux_stat')
-rw-r--r--src/contrib/linux_stat/linux_stats.pl76
-rw-r--r--src/contrib/linux_stat/readme9
2 files changed, 0 insertions, 85 deletions
diff --git a/src/contrib/linux_stat/linux_stats.pl b/src/contrib/linux_stat/linux_stats.pl
deleted file mode 100644
index 5459de2..0000000
--- a/src/contrib/linux_stat/linux_stats.pl
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/perl -Tw
-####################################################################
-# linux_stats.pl 1.0 Mike Machado #
-# mike@innercite.com #
-# 2000-07-19 #
-# #
-# Script to read traffic stats off linux 2.2 and greater systems #
-# #
-####################################################################
-use strict;
-
-
-
-#### Options ####
-my $uptimeprog = '/usr/bin/uptime'; # Set to program to give system uptime
-my $hostnameprog = '/bin/hostname'; # Set to program to give system hostname
-my $defaultinterface = 'eth0'; # Set to default interface
-my $defaultstatfile = '/proc/net/dev'; # Set to traffic stats file location
-
-
-##### Nothing below here should have to be changed #####
-
-if (@ARGV && $ARGV[0] eq '-h') {
- print "Usage: linux_stats.pl [interface] [stats file]\n";
- print "\tIf left blank 'eth0' and '/proc/net/dev' are used\n";
- print "\tInterface of 'ALL' will total all interface traffic, excluding lo\n";
- exit;
-}
-
-my $interface = shift || $defaultinterface;
-my $statfile = shift || $defaultstatfile;
-
-# Clear path and get uptime
-delete $ENV{PATH};
-delete $ENV{BASH_ENV};
-my $uptime = `$uptimeprog`;
-chomp($uptime);
-my $hostname = `$hostnameprog`;
-chomp($hostname);
-
-my ($in, $out, $found);
-open(STATS, $statfile) || die "Cannot open $statfile: $!\n";
-while (<STATS>) {
- my $line = $_;
- chomp($line);
- if (uc($interface) eq 'ALL') {
- if ($line =~ /^\s+(.*):\s*(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+$/) {
- next if $1 eq 'lo';
- $in += $2;
- $out += $3;
- $found++;
- }
- } else {
- if ($line =~ /^\s*$interface:\s*(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+$/) {
- $in = $1;
- $out = $2;
- $found = 1;
- last;
- }
- }
-}
-close(STATS);
-
-if (!$found) {
- print "0\n0\n$uptime\n$hostname: Unknown Interface: $interface\n";
-} else {
- print "$in\n$out\n$uptime\n$hostname: Interface: $interface";
- if (uc($interface) eq 'ALL') {
- print " (counted $found interface";
- if ($found > 1) {
- print "s";
- }
- print ")";
- }
- print "\n";
-}
diff --git a/src/contrib/linux_stat/readme b/src/contrib/linux_stat/readme
deleted file mode 100644
index 861b2a7..0000000
--- a/src/contrib/linux_stat/readme
+++ /dev/null
@@ -1,9 +0,0 @@
-
-I could not find a simple script to get the current traffic off a linux
-machine, so in open source sprit, I wrote my own. Here it is to share with
-all those looking for such a tool.
-
-Mike Machado
-mike@innercite.com
-InnerCite
-Network Specialist