Система мониторинга ресурсов и сервисов локальной вычислительной сети

Основные проблемы, возникающие у сетевых администраторов предприятий. Программные средства диагностики. Установка ядра системы. Настройка модуля отслеживания загрузки. Расчет затрат на разработку системы сетевого мониторинга, её внедрение и сопровождение.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 13.08.2014
Размер файла 4,5 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

sub check_options {

Getopt::Long::Configure ("bundling");

GetOptions(

'v' => \$o_verb, 'verbose' => \$o_verb,

'h' => \$o_help, 'help' => \$o_help,

'H:s' => \$o_host, 'hostname:s' => \$o_host,

'p:i' => \$o_port, 'port:i' => \$o_port,

'C:s' => \$o_community, 'community:s' => \$o_community,

'l:s' => \$o_login, 'login:s' => \$o_login,

'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd,

'X:s' => \$o_privpass, 'privpass:s' => \$o_privpass,

'L:s' => \$v3protocols, 'protocols:s' => \$v3protocols,

't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,

'V' => \$o_version, 'version' => \$o_version,

'2' => \$o_version2, 'v2c' => \$o_version2,

'c:s' => \$o_crit, 'critical:s' => \$o_crit,

'w:s' => \$o_warn, 'warn:s' => \$o_warn,

'f' => \$o_perf, 'perfparse' => \$o_perf,

'T:s' => \$o_check_type, 'type:s' => \$o_check_type

);

# check the -T option

my $T_option_valid=0;

foreach (@valid_types) { if ($_ eq $o_check_type) {$T_option_valid=1} };

if ( $T_option_valid == 0 )

{print "Invalid check type (-T)!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

# Basic checks

if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60)))

{ print "Timeout must be >1 and <60 !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

if (!defined($o_timeout)) {$o_timeout=5;}

if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}};

if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}};

if ( ! defined($o_host) ) # check host and filter

{ print_usage(); exit $ERRORS{"UNKNOWN"}}

# check snmp information

if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) )

{ print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2)) )

{ print "Can't mix snmp v1,2c,3 protocols!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

if (defined ($v3protocols)) {

if (!defined($o_login)) { print "Put snmp V3 login info with protocols!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

my @v3proto=split(/,/,$v3protocols);

if ((defined ($v3proto[0])) && ($v3proto[0] ne "")) {$o_authproto=$v3proto[0]; } # Auth protocol

if (defined ($v3proto[1])) {$o_privproto=$v3proto[1]; } # Priv protocol

if ((defined ($v3proto[1])) && (!defined($o_privpass))) {

print "Put snmp V3 priv login info with priv protocols!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

}

# Check warnings and critical

if (!defined($o_warn) || !defined($o_crit))

{ print "put warning and critical info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

# Get rid of % sign

$o_warn =~ s/\%//g;

$o_crit =~ s/\%//g;

# Check for multiple warning and crit in case of -L

if (($o_check_type eq "netsl") || ($o_check_type eq "cisco") || ($o_check_type eq "cata") ||

($o_check_type eq "nsc") || ($o_check_type eq "hpux")) {

@o_warnL=split(/,/ , $o_warn);

@o_critL=split(/,/ , $o_crit);

if (($#o_warnL != 2) || ($#o_critL != 2))

{ print "3 warnings and critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

for (my $i=0;$i<3;$i++) {

if ( isnnum($o_warnL[$i]) || isnnum($o_critL[$i]))

{ print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

if ($o_warnL[$i] > $o_critL[$i])

{ print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}}

}

} else {

if (($o_warn =~ /,/) || ($o_crit =~ /,/)) {

{ print "Multiple warning/critical levels not available for this check\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

}

if ( isnnum($o_warn) || isnnum($o_crit) )

{ print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

if ($o_warn > $o_crit)

{ print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}}

}

}

########## MAIN #######

check_options();

# Check gobal timeout if snmp screws up

if (defined($TIMEOUT)) {

verb("Alarm at $TIMEOUT + 5");

alarm($TIMEOUT+5);

} else {

verb("no global timeout defined : $o_timeout + 10");

alarm ($o_timeout+10);

}

$SIG{'ALRM'} = sub {

print "No answer from host\n";

exit $ERRORS{"UNKNOWN"};

};

# Connect to host

my ($session,$error);

if ( defined($o_login) && defined($o_passwd)) {

# SNMPv3 login

verb("SNMPv3 login");

if (!defined ($o_privpass)) {

verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-version => '3',

-username => $o_login,

-authpassword => $o_passwd,

-authprotocol => $o_authproto,

-timeout => $o_timeout

);

} else {

verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-version => '3',

-username => $o_login,

-authpassword => $o_passwd,

-authprotocol => $o_authproto,

-privpassword => $o_privpass,

-privprotocol => $o_privproto,

-timeout => $o_timeout

);

}

} else {

if (defined ($o_version2)) {

# SNMPv2 Login

verb("SNMP v2c login");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-version => 2,

-community => $o_community,

-port => $o_port,

-timeout => $o_timeout

);

} else {

# SNMPV1 login

verb("SNMP v1 login");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-community => $o_community,

-port => $o_port,

-timeout => $o_timeout

);

}

}

if (!defined($session)) {

printf("ERROR opening session: %s.\n", $error);

exit $ERRORS{"UNKNOWN"};

}

my $exit_val=undef;

########### Linux load check ##############

if ($o_check_type eq "netsl") {

verb("Checking linux load");

# Get load table

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_table($linload_table)

: $session->get_table(Baseoid => $linload_table);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

my @load = undef;

my @iload = undef;

my @oid=undef;

my $exist=0;

foreach my $key ( keys %$resultat) {

verb("OID : $key, Desc : $$resultat{$key}");

if ( $key =~ /$linload_name/ ) {

@oid=split (/\./,$key);

$iload[0]= pop(@oid) if ($$resultat{$key} eq "Load-1");

$iload[1]= pop(@oid) if ($$resultat{$key} eq "Load-5");

$iload[2]= pop(@oid) if ($$resultat{$key} eq "Load-15");

$exist=1

}

}

if ($exist == 0) {

print "Can't find snmp information on load : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

for (my $i=0;$i<3;$i++) { $load[$i] = $$resultat{$linload_load . "." . $iload[$i]}};

print "Load : $load[0] $load[1] $load[2] :";

$exit_val=$ERRORS{"OK"};

for (my $i=0;$i<3;$i++) {

if ( $load[$i] > $o_critL[$i] ) {

print " $load[$i] > $o_critL[$i] : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

}

if ( $load[$i] > $o_warnL[$i] ) {

# output warn error only if no critical was found

if ($exit_val eq $ERRORS{"OK"}) {

print " $load[$i] > $o_warnL[$i] : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

}

print " OK" if ($exit_val eq $ERRORS{"OK"});

if (defined($o_perf)) {

print " | load_1_min=$load[0];$o_warnL[0];$o_critL[0] ";

print "load_5_min=$load[1];$o_warnL[1];$o_critL[1] ";

print "load_15_min=$load[2];$o_warnL[2];$o_critL[2]\n";

} else {

print "\n";

}

exit $exit_val;

}

############## Cisco CPU check ################

if ($o_check_type eq "cisco") {

my @oidlists = ($cisco_cpu_5m, $cisco_cpu_1m, $cisco_cpu_5s);

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_request(@oidlists)

: $session->get_request(-varbindlist => \@oidlists);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

if (!defined ($$resultat{$cisco_cpu_5s})) {

print "No CPU information : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

my @load = undef;

$load[0]=$$resultat{$cisco_cpu_5s};

$load[1]=$$resultat{$cisco_cpu_1m};

$load[2]=$$resultat{$cisco_cpu_5m};

print "CPU : $load[0] $load[1] $load[2] :";

$exit_val=$ERRORS{"OK"};

for (my $i=0;$i<3;$i++) {

if ( $load[$i] > $o_critL[$i] ) {

print " $load[$i] > $o_critL[$i] : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

}

if ( $load[$i] > $o_warnL[$i] ) {

# output warn error only if no critical was found

if ($exit_val eq $ERRORS{"OK"}) {

print " $load[$i] > $o_warnL[$i] : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

}

print " OK" if ($exit_val eq $ERRORS{"OK"});

if (defined($o_perf)) {

print " | load_5_sec=$load[0]%;$o_warnL[0];$o_critL[0] ";

print "load_1_min=$load[1]%;$o_warnL[1];$o_critL[1] ";

print "load_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";

} else {

print "\n";

}

exit $exit_val;

}

############## Cisco Catalyst CPU check ################

if ($o_check_type eq "cata") {

my @oidlists = ($ciscocata_cpu_5m, $ciscocata_cpu_1m, $ciscocata_cpu_5s);

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_request(@oidlists)

: $session->get_request(-varbindlist => \@oidlists);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

if (!defined ($$resultat{$ciscocata_cpu_5s})) {

print "No CPU information : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

my @load = undef;

$load[0]=$$resultat{$ciscocata_cpu_5s};

$load[1]=$$resultat{$ciscocata_cpu_1m};

$load[2]=$$resultat{$ciscocata_cpu_5m};

print "CPU : $load[0] $load[1] $load[2] :";

$exit_val=$ERRORS{"OK"};

for (my $i=0;$i<3;$i++) {

if ( $load[$i] > $o_critL[$i] ) {

print " $load[$i] > $o_critL[$i] : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

}

if ( $load[$i] > $o_warnL[$i] ) {

# output warn error only if no critical was found

if ($exit_val eq $ERRORS{"OK"}) {

print " $load[$i] > $o_warnL[$i] : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

}

print " OK" if ($exit_val eq $ERRORS{"OK"});

if (defined($o_perf)) {

print " | load_5_sec=$load[0]%;$o_warnL[0];$o_critL[0] ";

print "load_1_min=$load[1]%;$o_warnL[1];$o_critL[1] ";

print "load_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";

} else {

print "\n";

}

exit $exit_val;

}

############## Netscreen CPU check ################

if ($o_check_type eq "nsc") {

my @oidlists = ($nsc_cpu_5m, $nsc_cpu_1m, $nsc_cpu_5s);

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_request(@oidlists)

: $session->get_request(-varbindlist => \@oidlists);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

if (!defined ($$resultat{$nsc_cpu_5s})) {

print "No CPU information : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

my @load = undef;

$load[0]=$$resultat{$nsc_cpu_5s};

$load[1]=$$resultat{$nsc_cpu_1m};

$load[2]=$$resultat{$nsc_cpu_5m};

print "CPU : $load[0] $load[1] $load[2] :";

$exit_val=$ERRORS{"OK"};

for (my $i=0;$i<3;$i++) {

if ( $load[$i] > $o_critL[$i] ) {

print " $load[$i] > $o_critL[$i] : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

}

if ( $load[$i] > $o_warnL[$i] ) {

# output warn error only if no critical was found

if ($exit_val eq $ERRORS{"OK"}) {

print " $load[$i] > $o_warnL[$i] : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

}

print " OK" if ($exit_val eq $ERRORS{"OK"});

if (defined($o_perf)) {

print " | cpu_5_sec=$load[0]%;$o_warnL[0];$o_critL[0] ";

print "cpu_1_min=$load[1]%;$o_warnL[1];$o_critL[1] ";

print "cpu_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";

} else {

print "\n";

}

exit $exit_val;

}

################## CPU for : AS/400 , Netsnmp, HP, Bluecoat, linkproof, fortigate ###########

if ( $o_check_type =~ /netsc|as400|bc|nokia|^hp$|lp|fg/ ) {

# Get load table

my @oidlist = $cpu_oid{$o_check_type};

verb("Checking OID : @oidlist");

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_request(@oidlist)

: $session->get_request(-varbindlist => \@oidlist);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

if (!defined ($$resultat{$cpu_oid{$o_check_type}})) {

print "No CPU information : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

my $load=$$resultat{$cpu_oid{$o_check_type}};

verb("OID returned $load");

# for AS400, divide by 100

if ($o_check_type eq "as400") {$load /= 100; };

# for Net-snmp : oid returned idle time so load = 100-idle.

if ($o_check_type eq "netsc") {$load = 100 - $load; };

printf("CPU used %.1f%% (",$load);

$exit_val=$ERRORS{"OK"};

if ($load > $o_crit) {

print ">$o_crit) : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

} else {

if ($load > $o_warn) {

print ">$o_warn) : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

print "<$o_warn) : OK" if ($exit_val eq $ERRORS{"OK"});

(defined($o_perf)) ?

print " | cpu_prct_used=$load%;$o_warn;$o_crit\n"

: print "\n";

exit $exit_val;

}

##### Checking hpux load

if ($o_check_type eq "hpux") {

verb("Checking hpux load");

my @oidlists = ($hpux_load_1_min, $hpux_load_5_min, $hpux_load_15_min);

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_request(@oidlists)

: $session->get_request(-varbindlist => \@oidlists);

if (!defined($resultat)) {

printf("ERROR: Load table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

if (!defined ($$resultat{$hpux_load_1_min})) {

print "No Load information : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

my @load = undef;

$load[0]=$$resultat{$hpux_load_1_min}/100;

$load[1]=$$resultat{$hpux_load_5_min}/100;

$load[2]=$$resultat{$hpux_load_15_min}/100;

print "Load : $load[0] $load[1] $load[2] :";

$exit_val=$ERRORS{"OK"};

for (my $i=0;$i<3;$i++) {

if ( $load[$i] > $o_critL[$i] ) {

print " $load[$i] > $o_critL[$i] : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

}

if ( $load[$i] > $o_warnL[$i] ) {

# output warn error only if no critical was found

if ($exit_val eq $ERRORS{"OK"}) {

print " $load[$i] > $o_warnL[$i] : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

}

print " OK" if ($exit_val eq $ERRORS{"OK"});

if (defined($o_perf)) {

print " | load_1_min=$load[0]%;$o_warnL[0];$o_critL[0] ";

print "load_5_min=$load[1]%;$o_warnL[1];$o_critL[1] ";

print "load_15_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";

} else {

print "\n";

}

exit $exit_val;

}

########## Standard cpu usage check ############

# Get desctiption table

my $resultat = (Net::SNMP->VERSION < 4) ?

$session->get_table($base_proc)

: $session->get_table(Baseoid => $base_proc);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

$session->close;

my ($cpu_used,$ncpu)=(0,0);

foreach my $key ( keys %$resultat) {

verb("OID : $key, Desc : $$resultat{$key}");

if ( $key =~ /$proc_load/) {

$cpu_used += $$resultat{$key};

$ncpu++;

}

}

if ($ncpu==0) {

print "Can't find CPU usage information : UNKNOWN\n";

exit $ERRORS{"UNKNOWN"};

}

$cpu_used /= $ncpu;

print "$ncpu CPU, ", $ncpu==1 ? "load" : "average load";

printf(" %.1f%%",$cpu_used);

$exit_val=$ERRORS{"OK"};

if ($cpu_used > $o_crit) {

print " > $o_crit% : CRITICAL";

$exit_val=$ERRORS{"CRITICAL"};

} else {

if ($cpu_used > $o_warn) {

print " > $o_warn% : WARNING";

$exit_val=$ERRORS{"WARNING"};

}

}

print " < $o_warn% : OK" if ($exit_val eq $ERRORS{"OK"});

(defined($o_perf)) ?

print " | cpu_prct_used=$cpu_used%;$o_warn;$o_crit\n"

: print "\n";

exit $exit_val;

/usr/lib/nagios/plugins/check_snmp_mem.pl

#!/usr/bin/perl -w

# nagios: -epn

############################## check_snmp_mem ##############

#

# Help : ./check_snmp_mem.pl -h

#

use strict;

use Net::SNMP;

use Getopt::Long;

# Nagios specific

use lib "/usr/lib/nagios/plugins";

use utils qw(%ERRORS $TIMEOUT);

#my $TIMEOUT = 15;

#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);

# SNMP Datas

# Net-snmp memory

my $nets_ram_free = "1.3.6.1.4.1.2021.4.6.0"; # Real memory free

my $nets_ram_total = "1.3.6.1.4.1.2021.4.5.0"; # Real memory total

my $nets_ram_cache = "1.3.6.1.4.1.2021.4.15.0"; # Real memory cached

my $nets_swap_free = "1.3.6.1.4.1.2021.4.4.0"; # swap memory free

my $nets_swap_total = "1.3.6.1.4.1.2021.4.3.0"; # Swap memory total

my @nets_oids = ($nets_ram_free,$nets_ram_total,$nets_swap_free,$nets_swap_total,$nets_ram_cache);

# Cisco

my $cisco_mem_pool = "1.3.6.1.4.1.9.9.48.1.1.1"; # Cisco memory pool

my $cisco_index = "1.3.6.1.4.1.9.9.48.1.1.1.2"; # memory pool name and index

my $cisco_valid = "1.3.6.1.4.1.9.9.48.1.1.1.4"; # Valid memory if 1

my $cisco_used = "1.3.6.1.4.1.9.9.48.1.1.1.5"; # Used memory

my $cisco_free = "1.3.6.1.4.1.9.9.48.1.1.1.6"; # Free memory

# .1 : type, .2 : name, .3 : alternate, .4 : valid, .5 : used, .6 : free, .7 : max free

# HP Procurve

my $hp_mem_pool = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1"; # HP memory pool

my $hp_mem_index = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.1"; # memory slot index

my $hp_mem_total = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5"; # Total Bytes

my $hp_mem_free = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6"; # Free Bytes

my $hp_mem_free_seg = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.3"; # Free segments

# AS/400

# Windows NT/2K/(XP?)

# check_snmp_storage.pl -C <community> -H <hostIP> -m "^Virtual Memory$" -w <warn %> -c <crit %>

# Globals

my $Version='1.1';

my $o_host = undef; # hostname

my $o_community = undef; # community

my $o_port = 161; # port

my $o_help= undef; # wan't some help ?

my $o_verb= undef; # verbose mode

my $o_version= undef; # print version

my $o_netsnmp= 1; # Check with netsnmp (default)

my $o_cisco= undef; # Check cisco router mem

my $o_hp= undef; # Check hp procurve mem

my $o_warn= undef; # warning level option

my $o_warnR= undef; # warning level for Real memory

my $o_warnS= undef; # warning levels for swap

my $o_crit= undef; # Critical level option

my $o_critR= undef; # critical level for Real memory

my $o_critS= undef; # critical level for swap

my $o_perf= undef; # Performance data option

my $o_cache= undef; # Include cached memory as used memory

my $o_timeout= undef; # Timeout (Default 5)

my $o_version2= undef; # use snmp v2c

# SNMPv3 specific

my $o_login= undef; # Login for snmpv3

my $o_passwd= undef; # Pass for snmpv3

my $v3protocols=undef; # V3 protocol list.

my $o_authproto='md5'; # Auth protocol

my $o_privproto='des'; # Priv protocol

my $o_privpass= undef; # priv password

# functions

sub p_version { print "check_snmp_mem version : $Version\n"; }

sub print_usage {

print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -w <warn level> -c <crit level> [-I|-N|-E] [-f] [-m] [-t <timeout>] [-V]\n";

}

sub isnnum { # Return true if arg is not a number

my $num = shift;

if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;}

return 1;

}

sub round ($$) {

sprintf "%.$_[1]f", $_[0];

}

sub help {

print "\nSNMP Memory Monitor for Nagios version ",$Version,"\n";

print "(c)2004-2006 to my cat Ratoune - Author: Patrick Proy\n\n";

print_usage();

print <<EOT;

-v, --verbose

print extra debugging information (including interface list on the system)

-h, --help

print this help message

-H, --hostname=HOST

name or IP address of host to check

-C, --community=COMMUNITY NAME

community name for the host's SNMP agent (implies SNMP v1 or v2c with option)

-2, --v2c

Use snmp v2c

-l, --login=LOGIN ; -x, --passwd=PASSWD

Login and auth password for snmpv3 authentication

If no priv password exists, implies AuthNoPriv

-X, --privpass=PASSWD

Priv password for snmpv3 (AuthPriv protocol)

-L, --protocols=<authproto>,<privproto>

<authproto> : Authentication protocol (md5|sha : default md5)

<privproto> : Priv protocole (des|aes : default des)

-P, --port=PORT

SNMP port (Default 161)

-w, --warn=INTEGER | INT,INT

warning level for memory in percent (0 for no checks)

Default (-N switch) : comma separated level for Real Memory and Swap

-I switch : warning level

-c, --crit=INTEGER | INT,INT

critical level for memory in percent (0 for no checks)

Default (-N switch) : comma separated level for Real Memory and Swap

-I switch : critical level

-N, --netsnmp (default)

check linux memory & swap provided by Net SNMP

-m, --memcache

include cached memory in used memory (only with Net-SNMP)

-I, --cisco

check cisco memory (sum of all memory pools)

-E, --hp

check HP proccurve memory

-f, --perfdata

Performance data output

-t, --timeout=INTEGER

timeout for SNMP in seconds (Default: 5)

-V, --version

prints version number

EOT

}

# For verbose output

sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; }

# Get the alarm signal (just in case snmp timout screws up)

$SIG{'ALRM'} = sub {

print ("ERROR: Alarm signal (Nagios time-out)\n");

exit $ERRORS{"UNKNOWN"};

};

sub check_options {

Getopt::Long::Configure ("bundling");

GetOptions(

'v' => \$o_verb, 'verbose' => \$o_verb,

'h' => \$o_help, 'help' => \$o_help,

'H:s' => \$o_host, 'hostname:s' => \$o_host,

'p:i' => \$o_port, 'port:i' => \$o_port,

'C:s' => \$o_community, 'community:s' => \$o_community,

'l:s' => \$o_login, 'login:s' => \$o_login,

'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd,

'X:s' => \$o_privpass, 'privpass:s' => \$o_privpass,

'L:s' => \$v3protocols, 'protocols:s' => \$v3protocols,

't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,

'V' => \$o_version, 'version' => \$o_version,

'I' => \$o_cisco, 'cisco' => \$o_cisco,

'N' => \$o_netsnmp, 'netsnmp' => \$o_netsnmp,

'E' => \$o_hp, 'hp' => \$o_hp,

'2' => \$o_version2, 'v2c' => \$o_version2,

'c:s' => \$o_crit, 'critical:s' => \$o_crit,

'w:s' => \$o_warn, 'warn:s' => \$o_warn,

'm' => \$o_cache, 'memcache' => \$o_cache,

'f' => \$o_perf, 'perfdata' => \$o_perf

);

if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}};

if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}};

if ( ! defined($o_host) ) # check host and filter

{ print "No host defined!\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

# check snmp information

if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) )

{ print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2)) )

{ print "Can't mix snmp v1,2c,3 protocols!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

if (defined ($v3protocols)) {

if (!defined($o_login)) { print "Put snmp V3 login info with protocols!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

my @v3proto=split(/,/,$v3protocols);

if ((defined ($v3proto[0])) && ($v3proto[0] ne "")) {$o_authproto=$v3proto[0]; } # Auth protocol

if (defined ($v3proto[1])) {$o_privproto=$v3proto[1]; } # Priv protocol

if ((defined ($v3proto[1])) && (!defined($o_privpass))) {

print "Put snmp V3 priv login info with priv protocols!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

}

if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60)))

{ print "Timeout must be >1 and <60 !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

if (!defined($o_timeout)) {$o_timeout=5;}

#Check Warning and crit are present

if ( ! defined($o_warn) || ! defined($o_crit))

{ print "Put warning and critical values!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}

# Get rid of % sign

$o_warn =~ s/\%//g;

$o_crit =~ s/\%//g;

# if -N or -E switch , undef $o_netsnmp

if (defined($o_cisco) || defined($o_hp) ) {

$o_netsnmp=undef;

if ( isnnum($o_warn) || isnnum($o_crit))

{ print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"} }

if ( ($o_crit != 0) && ($o_warn > $o_crit) )

{ print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}}

}

if (defined($o_netsnmp)) {

my @o_warnL=split(/,/ , $o_warn);

my @o_critL=split(/,/ , $o_crit);

if (($#o_warnL != 1) || ($#o_critL != 1))

{ print "2 warnings and critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

for (my $i=0;$i<2;$i++) {

if ( isnnum($o_warnL[$i]) || isnnum($o_critL[$i]))

{ print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"} }

if (($o_critL[$i]!= 0) && ($o_warnL[$i] > $o_critL[$i]))

{ print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}}

if ( $o_critL[$i] > 100)

{ print "critical percent must be < 100 !\n";print_usage(); exit $ERRORS{"UNKNOWN"}}

}

$o_warnR=$o_warnL[0];$o_warnS=$o_warnL[1];

$o_critR=$o_critL[0];$o_critS=$o_critL[1];

}

}

########## MAIN #######

check_options();

# Check gobal timeout if snmp screws up

if (defined($TIMEOUT)) {

verb("Alarm at $TIMEOUT");

alarm($TIMEOUT);

} else {

verb("no timeout defined : $o_timeout + 10");

alarm ($o_timeout+10);

}

# Connect to host

my ($session,$error);

if ( defined($o_login) && defined($o_passwd)) {

# SNMPv3 login

if (!defined ($o_privpass)) {

verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-version => '3',

-username => $o_login,

-authpassword => $o_passwd,

-authprotocol => $o_authproto,

-timeout => $o_timeout

);

} else {

verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-version => '3',

-username => $o_login,

-authpassword => $o_passwd,

-authprotocol => $o_authproto,

-privpassword => $o_privpass,

-privprotocol => $o_privproto,

-timeout => $o_timeout

);

}

} else {

if (defined ($o_version2)) {

# SNMPv2 Login

verb("SNMP v2c login");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-version => 2,

-community => $o_community,

-port => $o_port,

-timeout => $o_timeout

);

} else {

# SNMPV1 login

verb("SNMP v1 login");

($session, $error) = Net::SNMP->session(

-hostname => $o_host,

-community => $o_community,

-port => $o_port,

-timeout => $o_timeout

);

}

}

if (!defined($session)) {

printf("ERROR opening session: %s.\n", $error);

exit $ERRORS{"UNKNOWN"};

}

# Global variable

my $resultat=undef;

########### Cisco memory check ############

if (defined ($o_cisco)) {

# Get Cisco memory table

$resultat = (Net::SNMP->VERSION < 4) ?

$session->get_table($cisco_mem_pool)

:$session->get_table(Baseoid => $cisco_mem_pool);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

my (@oid,@index)=(undef,undef);

my $nindex=0;

foreach my $key ( keys %$resultat) {

verb("OID : $key, Desc : $$resultat{$key}");

if ( $key =~ /$cisco_index/ ) {

@oid=split (/\./,$key);

$index[$nindex++] = pop(@oid);

}

}

# Check if at least 1 memory pool exists

if ($nindex == 0) {

printf("ERROR: No memory pools found");

$session->close;

exit $ERRORS{"UNKNOWN"};

}

# Test every memory pool

my ($c_output,$prct_free)=(undef,undef);

my ($warn_s,$crit_s)=(0,0);

my ($used,$free)=(0,0);

foreach (@index) {

$c_output .="," if defined ($c_output);

if ( $$resultat{$cisco_valid . "." . $_} == 1 ) {

$used += $$resultat{$cisco_used . "." . $_};

$free += $$resultat{$cisco_free . "." . $_};

$prct_free=round($$resultat{$cisco_used . "." . $_}*100/($$resultat{$cisco_free . "." . $_}+$$resultat{$cisco_used . "." . $_}) ,0);

$c_output .= $$resultat{$cisco_index . "." . $_} . ":" . $prct_free . "%";

if (($o_crit!=0)&&($o_crit <= $prct_free)) {

$crit_s =1;

} elsif (($o_warn!=0)&&($o_warn <= $prct_free)) {

$warn_s=1;

}

} else {

$c_output .= $$resultat{$cisco_index . "." . $_} . ": INVALID";

$crit_s =1;

}

}

my $total=$used+$free;

$prct_free=round($used*100/($total),0);

verb("Total used : $used, free: $free, output : $c_output");

my $c_status="OK";

$c_output .=" : " . $prct_free ."% : ";

if ($crit_s == 1 ) {

$c_output .= " > " . $o_crit ;

$c_status="CRITICAL";

} else {

if ($warn_s == 1 ) {

$c_output.=" > " . $o_warn;

$c_status="WARNING";

}

}

$c_output .= " ; ".$c_status;

if (defined ($o_perf)) {

$c_output .= " | ram_used=" . $used.";";

$c_output .= ($o_warn ==0)? ";" : round($o_warn * $total/100,0).";";

$c_output .= ($o_crit ==0)? ";" : round($o_crit * $total/100,0).";";

$c_output .= "0;" . $total ;

}

$session->close;

print "$c_output \n";

exit $ERRORS{$c_status};

}

########### HP Procurve memory check ############

if (defined ($o_hp)) {

# Get hp memory table

$resultat = (Net::SNMP->VERSION < 4) ?

$session->get_table($hp_mem_pool)

:$session->get_table(Baseoid => $hp_mem_pool);

if (!defined($resultat)) {

printf("ERROR: Description table : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

my (@oid,@index)=(undef,undef);

my $nindex=0;

foreach my $key ( keys %$resultat) {

verb("OID : $key, Desc : $$resultat{$key}");

if ( $key =~ /$hp_mem_index/ ) {

@oid=split (/\./,$key);

$index[$nindex++] = pop(@oid);

}

}

# Check if at least 1 memory slots exists

if ($nindex == 0) {

printf("ERROR: No memory slots found");

$session->close;

exit $ERRORS{"UNKNOWN"};

}

# Consolidate the datas

my ($total,$free)=(0,0);

my ($c_output,$prct_free)=(undef,undef);

foreach (@index) {

$c_output .="," if defined ($c_output);

$total += $$resultat{$hp_mem_total . "." . $_};

$free += $$resultat{$hp_mem_free . "." . $_};

$c_output .= "Slot " . $$resultat{$hp_mem_index . "." . $_} . ":"

.round(

100 - ($$resultat{$hp_mem_free . "." . $_} *100 /

$$resultat{$hp_mem_total . "." . $_}) ,0)

. "%";

}

my $used = $total - $free;

$prct_free=round($used*100/($total),0);

verb("Used : $used, Free: $free, Output : $c_output");

my $c_status="OK";

$c_output .=" : " . $prct_free ."% : ";

if (($o_crit!=0)&&($o_crit <= $prct_free)) {

$c_output .= " > " . $o_crit ;

$c_status="CRITICAL";

} else {

if (($o_warn!=0)&&($o_warn <= $prct_free)) {

$c_output.=" > " . $o_warn;

$c_status="WARNING";

}

}

$c_output .= " ; ".$c_status;

if (defined ($o_perf)) {

$c_output .= " | ram_used=" . $used.";";

$c_output .= ($o_warn ==0)? ";" : round($o_warn * $total/100,0).";";

$c_output .= ($o_crit ==0)? ";" : round($o_crit * $total/100,0).";";

$c_output .= "0;" . $total ;

}

$session->close;

print "$c_output \n";

exit $ERRORS{$c_status};

}

########### Net snmp memory check ############

if (defined ($o_netsnmp)) {

# Get NetSNMP memory values

$resultat = (Net::SNMP->VERSION < 4) ?

$session->get_request(@nets_oids)

:$session->get_request(-varbindlist => \@nets_oids);

if (!defined($resultat)) {

printf("ERROR: netsnmp : %s.\n", $session->error);

$session->close;

exit $ERRORS{"UNKNOWN"};

}

my ($realused,$swapused)=(undef,undef);

$realused= defined($o_cache) ?

($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free})/$$resultat{$nets_ram_total}

:

($$resultat{$nets_ram_total}-($$resultat{$nets_ram_free}+$$resultat{$nets_ram_cache}))/$$resultat{$nets_ram_total};

if($$resultat{$nets_ram_total} == 0) { $realused = 0; }

$swapused= ($$resultat{$nets_swap_total} == 0) ? 0 :

($$resultat{$nets_swap_total}-$$resultat{$nets_swap_free})/$$resultat{$nets_swap_total};

$realused=round($realused*100,0);

$swapused=round($swapused*100,0);

defined($o_cache) ?

verb ("Ram : $$resultat{$nets_ram_free} / $$resultat{$nets_ram_total} : $realused")

:

verb ("Ram : $$resultat{$nets_ram_free} ($$resultat{$nets_ram_cache} cached) / $$resultat{$nets_ram_total} : $realused");

verb ("Swap : $$resultat{$nets_swap_free} / $$resultat{$nets_swap_total} : $swapused");

my $n_status="OK";

my $n_output="Ram : " . $realused . "%, Swap : " . $swapused . "% :";

if ((($o_critR!=0)&&($o_critR <= $realused)) || (($o_critS!=0)&&($o_critS <= $swapused))) {

$n_output .= " > " . $o_critR . ", " . $o_critS;

$n_status="CRITICAL";

} else {

if ((($o_warnR!=0)&&($o_warnR <= $realused)) || (($o_warnS!=0)&&($o_warnS <= $swapused))) {

$n_output.=" > " . $o_warnR . ", " . $o_warnS;

$n_status="WARNING";

}

}

$n_output .= " ; ".$n_status;

if (defined ($o_perf)) {

if (defined ($o_cache)) {

$n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}).";";

}

else {

$n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}-$$resultat{$nets_ram_cache}).";";

}

$n_output .= ($o_warnR ==0)? ";" : round($o_warnR * $$resultat{$nets_ram_total}/100,0).";";

$n_output .= ($o_critR ==0)? ";" : round($o_critR * $$resultat{$nets_ram_total}/100,0).";";

$n_output .= "0;" . $$resultat{$nets_ram_total}. " ";

$n_output .= "swap_used=" . ($$resultat{$nets_swap_total}-$$resultat{$nets_swap_free}).";";

$n_output .= ($o_warnS ==0)? ";" : round($o_warnS * $$resultat{$nets_swap_total}/100,0).";";

$n_output .= ($o_critS ==0)? ";" : round($o_critS * $$resultat{$nets_swap_total}/100,0).";";

$n_output .= "0;" . $$resultat{$nets_swap_total};

}

$session->close;

print "$n_output \n";

exit $ERRORS{$n_status};

}

Приложение К

Конфигурация протокола SNMP на удаленных хостах

# sec.name source community

#com2sec paranoid default public

com2sec readonly default public

#com2sec readwrite default private

####

# Second, map the security names into group names:

# sec.model sec.name

group MyROSystem v1 paranoid

group MyROSystem v2c paranoid

group MyROSystem usm paranoid

group MyROGroup v1 readonly

group MyROGroup v2c readonly

group MyROGroup usm readonly

group MyRWGroup v1 readwrite

group MyRWGroup v2c readwrite

group MyRWGroup usm readwrite

####

# Third, create a view for us to let the groups have rights to:

# incl/excl subtree mask

view all included .1 80

view system included .iso.org.dod.internet.mgmt.mib-2.system

####

# Finally, grant the 2 groups access to the 1 view with different

# write permissions:

# context sec.model sec.level match read write notif

access MyROSystem "" any noauth exact system none none

access MyROGroup "" any noauth exact all none none

access MyRWGroup "" any noauth exact all all none

Приложение Л

Конфигурация агента ядра сетевого мониторинга на удаленных хостах

/etc/nagios/nrpe.cfg

# PID FILE

# The name of the file in which the NRPE daemon should write it's process ID

# number. The file is only written if the NRPE daemon is started by the root

# user and is running in standalone mode.

pid_file=/var/run/nrpe.pid

# PORT NUMBER

# Port number we should wait for connections on.

# NOTE: This must be a non-priviledged port (i.e. > 1024).

# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

server_port=5666

# SERVER ADDRESS

# Address that nrpe should bind to in case there are more than one interface

# and you do not want nrpe to bind on all interfaces.

# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

server_address=192.168.10.158

# NRPE USER

# This determines the effective user that the NRPE daemon should run as.

# You can either supply a username or a UID.

#

# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

nrpe_user=nagios

# NRPE GROUP

# This determines the effective group that the NRPE daemon should run as.

# You can either supply a group name or a GID.

#

# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

nrpe_group=nagios

# ALLOWED HOST ADDRESSES

# This is an optional comma-delimited list of IP address or hostnames

# that are allowed to talk to the NRPE daemon.

#

# Note: The daemon only does rudimentary checking of the client's IP

# address. I would highly recommend adding entries in your /etc/hosts.allow

# file to allow only the specified host to connect to the port

# you are running this daemon on.

#

# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

allowed_hosts=127.0.0.1,192.168.10.2

# COMMAND ARGUMENT PROCESSING

# This option determines whether or not the NRPE daemon will allow clients

# to specify arguments to commands that are executed. This option only works

# if the daemon was configured with the --enable-command-args configure script

# option.

#

# *** ENABLING THIS OPTION IS A SECURITY RISK! ***

# Read the SECURITY file for information on some of the security implications

# of enabling this variable.

#

# Values: 0=do not allow arguments, 1=allow command arguments

dont_blame_nrpe=0

# COMMAND PREFIX

# This option allows you to prefix all commands with a user-defined string.

# A space is automatically added between the specified prefix string and the

# command line from the command definition.

#

# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! ***

# Usage scenario:

# Execute restricted commmands using sudo. For this to work, you need to add

# the nagios user to your /etc/sudoers. An example entry for alllowing

# execution of the plugins from might be:

#

# nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/

#

# This lets the nagios user run all commands in that directory (and only them)

# without asking for a password. If you do this, make sure you don't give

# random users write access to that directory or its contents!

# command_prefix=/usr/bin/sudo

# DEBUGGING OPTION

# This option determines whether or not debugging messages are logged to the

# syslog facility.

# Values: 0=debugging off, 1=debugging on

debug=0

# COMMAND TIMEOUT

# This specifies the maximum number of seconds that the NRPE daemon will

# allow plugins to finish executing before killing them off.

command_timeout=60

# WEEK RANDOM SEED OPTION

# This directive allows you to use SSL even if your system does not have

# a /dev/random or /dev/urandom (on purpose or because the necessary patches

# were not applied). The random number generator will be seeded from a file

# which is either a file pointed to by the environment valiable $RANDFILE

# or $HOME/.rnd. If neither exists, the pseudo random number generator will

# be initialized and a warning will be issued.

# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness

#allow_weak_random_seed=1

# INCLUDE CONFIG FILE

# This directive allows you to include definitions from an external config file.

#include=<somefile.cfg>

# INCLUDE CONFIG DIRECTORY

# This directive allows you to include definitions from config files (with a

# .cfg extension) in one or more directories (with recursion).

#include_dir=<somedirectory>

#include_dir=<someotherdirectory>

# COMMAND DEFINITIONS

# Command definitions that this daemon will run. Definitions

# are in the following format:

#

# command[<command_name>]=<command_line>

#

# When the daemon receives a request to return the results of <command_name>

# it will execute the command specified by the <command_line> argument.

#

# Unlike Nagios, the command line cannot contain macros - it must be

# typed exactly as it should be executed.

#

# Note: Any plugins that are used in the command lines must reside

# on the machine that this daemon is running on! The examples below

# assume that you have plugins installed in a /usr/local/nagios/libexec

# directory. Also note that you will have to modify the definitions below

# to match the argument format the plugins expect. Remember, these are

# examples only!

# The following examples use hardcoded command arguments...

command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10

command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,15,15 -c 30,25,20

command[check_disk1]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hda1

command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 17000 -c 18000 -s Z

command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 17000 -c 20000

# The following examples allow user-supplied arguments and can

# only be used if the NRPE daemon was compiled with support for

# command arguments *AND* the dont_blame_nrpe directive in this

# config file is set to '1'...

#command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$

#command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$

#command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$

#command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$

#

# local configuration:

# if you'd prefer, you can instead place directives here

include=/etc/nagios/nrpe_local.cfg

Приложение М

Пример конфигурационного файла MRTG

/etc/mrtg/shaper/mrtg.cfg

# Created by

# /usr/bin/cfgmaker public@192.168.10.1

### Global Config Options

# for UNIX

# WorkDir: /home/http/mrtg

# for Debian

WorkDir: /var/www/mrtg/shaper

# or for NT

# WorkDir: c:\mrtgdata

### Global Defaults

# to get bits instead of bytes and graphs growing to the right

Options[_]: growright, bits

EnableIPv6: no

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

# System: shaper

# Description: Linux shaper 2.6.31-bfs311 #1 SMP Fri Dec 4 10:23:03 YEKT 2009 x86_64

# Contact: Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)

# Location: Unknown (configure /etc/snmp/snmpd.local.conf)

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

### Interface 1 >> Descr: 'lo' | Name: 'lo' | Ip: '127.0.0.1' | Eth: '' ###

### The following interface is commented out because:

### * it is a Software Loopback interface

#

# Target[192.168.10.1_1]: 1:public@192.168.10.1:

# SetEnv[192.168.10.1_1]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo"

# MaxBytes[192.168.10.1_1]: 1250000

# Title[192.168.10.1_1]: Traffic Analysis for 1 -- shaper

# PageTop[192.168.10.1_1]: <h1>Traffic Analysis for 1 -- shaper</h1>

# <div id="sysdetails">

# <table>

# <tr>

# <td>System:</td>

# <td>shaper in Unknown (configure /etc/snmp/snmpd.local.conf)</td>

# </tr>

# <tr>

# <td>Maintainer:</td>

# <td>Root &lt;root@localhost&gt; (configure /etc/snmp/snmpd.local.conf)</td>

# </tr>

# <tr>

# <td>Description:</td>

# <td>lo </td>

# </tr>

# <tr>

# <td>ifType:</td>

# <td>softwareLoopback (24)</td>

# </tr>

# <tr>

# <td>ifName:</td>

# <td>lo</td>

# </tr>

# <tr>

# <td>Max Speed:</td>

# <td>1250.0 kBytes/s</td>

# </tr>

# <tr>

# <td>Ip:</td>

# <td>127.0.0.1 (localhost)</td>

# </tr>

# </table>

# </div>

### Interface 2 >> Descr: 'eth2' | Name: 'eth2' | Ip: '' | Eth: '30-78-30-30-32-33-35-34-32-35-34-33-30-66' ###

### The following interface is commented out because:

### * it is administratively DOWN

### * it is operationally DOWN

#

# Target[192.168.10.1_2]: 2:public@192.168.10.1:

# SetEnv[192.168.10.1_2]: MRTG_INT_IP="" MRTG_INT_DESCR="eth2"

# MaxBytes[192.168.10.1_2]: 1250000

# Title[192.168.10.1_2]: Traffic Analysis for 2 -- shaper

# PageTop[192.168.10.1_2]: <h1>Traffic Analysis for 2 -- shaper</h1>

# <div id="sysdetails">

# <table>

# <tr>

# <td>System:</td>

# <td>shaper in Unknown (configure /etc/snmp/snmpd.local.conf)</td>

# </tr>

# <tr>

# <td>Maintainer:</td>

# <td>Root &lt;root@localhost&gt; (configure /etc/snmp/snmpd.local.conf)</td>

# </tr>

# <tr>

# <td>Description:</td>

# <td>eth2 </td>

# </tr>

# <tr>

# <td>ifType:</td>

# <td>ethernetCsmacd (6)</td>

# </tr>

# <tr>

# <td>ifName:</td>

# <td>eth2</td>

# </tr>

# <tr>

# <td>Max Speed:</td>

# <td>1250.0 kBytes/s</td>

# </tr>

# </table>

# </div>

### Interface 3 >> Descr: 'eth0' | Name: 'eth0' | Ip: '192.168.10.1' | Eth: '30-78-30-30-31-62-32-31-32-65-37-62-65-36' ###

Target[192.168.10.1_3]: 3:public@192.168.10.1:

SetEnv[192.168.10.1_3]: MRTG_INT_IP="192.168.10.1" MRTG_INT_DESCR="eth0"

MaxBytes[192.168.10.1_3]: 125000000

Title[192.168.10.1_3]: Traffic Analysis for 3 -- shaper

PageTop[192.168.10.1_3]: <h1>Traffic Analysis for 3 -- shaper</h1>

<div id="sysdetails">

<table>

<tr>

<td>System:</td>

<td>shaper in Unknown (configure /etc/snmp/snmpd.local.conf)</td>

</tr>

<tr>

<td>Maintainer:</td>

<td>Root &lt;root@localhost&gt; (configure /etc/snmp/snmpd.local.conf)</td>

</tr>

<tr>

<td>Description:</td>

<td>eth0 </td>

</tr>

<tr>

<td>ifType:</td>

<td>ethernetCsmacd (6)</td>

</tr>

<tr>

<td>ifName:</td>

<td>eth0</td>

</tr>

<tr>

<td>Max Speed:</td>

<td>1250.0 kBytes/s</td>

</tr>

<tr>

<td>Ip:</td>

<td>192.168.10.1 (shaper)</td>

</tr>

</table>

</div>

### Interface 4 >> Descr: 'eth1' | Name: 'eth1' | Ip: '91.192.168.250' | Eth: '30-78-30-30-31-62-32-31-32-65-37-62-63-38' ###

Target[192.168.10.1_4]: 4:public@192.168.10.1:

SetEnv[192.168.10.1_4]: MRTG_INT_IP="91.192.168.250" MRTG_INT_DESCR="eth1"

MaxBytes[192.168.10.1_4]: 125000000

Title[192.168.10.1_4]: Traffic Analysis for 4 -- shaper

PageTop[192.168.10.1_4]: <h1>Traffic Analysis for 4 -- shaper</h1>

<div id="sysdetails">

<table>

<tr>

<td>System:</td>

<td>shaper in Unknown (configure /etc/snmp/snmpd.local.conf)</td>

</tr>

<tr>

<td>Maintainer:</td>

<td>Root &lt;root@localhost&gt; (configure /etc/snmp/snmpd.local.conf)</td>

</tr>

<tr>

<td>Description:</td>

<td>eth1 </td>

</tr>

<tr>

<td>ifType:</td>

<td>ethernetCsmacd (6)</td>

</tr>

<tr>

<td>ifName:</td>

<td>eth1</td>

</tr>

<tr>

<td>Max Speed:</td>

<td>1250.0 kBytes/s</td>

</tr>

<tr>

<td>Ip:</td>

<td>91.192.168.250 (shaper.vpcit.ru)</td>

</tr>

</table>

</div>

Приложение Н

Рис. Н.1 - Пример представления графиков загрузки интерфейсов посредством MRTG

Приложение О

Параметры crontab

/etc/cron.d/mrtg

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/bgp/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/bgp/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/AT-9924/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/AT-9924/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/DES-3627G/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/DES-3627G/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/Rapier_24i/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/Rapier_24i/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/host_mail/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/host_mail/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/monitoring/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/monitoring/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/urrab_39a/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/urrab_39a/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/len_58a/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/len_58a/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/krivous_36b/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/krivous_36b/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/shaper/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/shaper/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg/for/for.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg/for/for.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

Приложение П

Таблица П.1 - Подробное сравнение технических особенностей различных сборщиков системных журналов

Параметр/Служба

syslogd

syslog-ng OSE

syslog-ng PE

Получение журналов от

UNIX domain socket (stream & dgram)

Да

Да

Да

UDP

Да

Да

Да

UDP использующий IETF-syslog стандартный протокол

-

Да

Да

TCP

-

Да

Да

TCP использующий IETF-syslog стандартный протокол

-

Да

Да

UDP6

Зависит от ОС

Да

Да

TCP6

-

Да

Да

TLS-шифрованные каналы

-

Да

Да

TLS использующий IETF-syslog стандартный протокол

-

Да

Да

Именованные каналы

-

Да

Да

Файл

-

Да

Да

Стандартный вывод (stdout) приложения

-

Да

Да

Устройство протоколирования ядра на Linux, Solaris, BSD

klogd

Да

Да

Файл со звездочками в имени или пути

-

-

Да

IBM System i журанл аудита (QAUDJRN) & журнал оператора терминала (QSYSOPR) (через отдельное приложение агента)

-

-

Да

Windows EventLog /файлы журналов (через отделное агентское приложение)

-

-

Да

Отправка системных журналов к

UNIX domain sockets (stream & dgram)

-

Да

Да

UDP

Да

Да

Да

UDP использующий IETF-syslog стандартный протокол

-

Да

Да

TCP

-

Да

Да

TCP использующий IETF-syslog стандартный протокол

-

Да

Да

UDP6

depends on the OS

Да

Да

TCP6

-

Да

Да

Именованый канал

Да

Да

Да

Файл

Да

Да

Да

Шифрованый, сжатый, с метками времени и проиндексированный двоичный файл

-

-

Да

SQL база данных (MySQL, Microsoft SQL (MSSQL), Oracle, PostgreSQL, SQLite)

-

Да

Да

Стандартный ввод любой указанной пользователем программы

-

Да

Да

Пользовательский tty

Да

Да

Да

Поддержка встроенного TLS шифрования при использовании TCP, TCP6, или IETF-syslog протокола

-

Да

Да

Производительность

Принятие 75000 сообщений в секунда (измерено с 150-байтовыми сообщениями на серверной платформе низшего уровня)

-

Да

Да

Форматы сообщений

Поддержка сырых, не формата syslog сообщений

-

Да

Да

Поддержка RFC3164 формата сообщений (BSD)

Да

Да

Да

Поддержка IETF-syslog формата сообщений

-

Да

Да

Поддержка расширенных RFC3339 (ISO 8601) временных меток

-

Да

Да

Поддержка некоторых нестандартных формтаов временных меток (Cisco PIX, LinkSys, и др.)

-

Да

Да

Поддержка микросекундного определения времени (точность настраивается пользователем)

-

Да

Да

Поддержка информации о временных зонах

-

Да

Да

Поддержка определения неверных имен хостов (позволяет принимать сообщения от приложений, которые отправляют syslog сообщения в неправильном формате)

-

Да

Да

Поддержка сцепленного имени хоста, котороая позволяет определить путь прохождения сообщения через релеи.

-

Да

Да

Обработка сообщений/фильтрация

Поддержка разрешения имен через DNS

Да

Да

Да

Поддержка разрешения имен через файл (локальная карта IP->host)

-

Да

Да

Кэширование DNS запросов для предотвращения перегрузки DNS серверов и повышения производительности

-

Да

Да

Поддержка нормализации имен хостов (принудительное приведение имен в нижний регистр)

-

Да

Да

Сообщения могут назначаться нескольким независимым адресатам (файл, sql, несколько удаленных серверов, и др.) одновременно

Да

Да

Да

Одна фильтрующая операция может направлять сообщения по нескольким адресатам

-

Да

Да

Сегментирования текстовых сообщений в пары имя=значение с использованием парсеров.

-

Да

Да

Использования результатов парсинга как макросов

-

Да

Да

Определение значений по умолчанию для макросов

-

Да

Да

Замена выбранных частей сообщения

-

Да

Да

Установка значения пар имя=значение

-

Да

Да

Поддержка преобразования временных меток между временными зонами

-

Да

Да

Поддержка контролируемых потоков для путей журналов событий: принятие сообщений со входа приостанавливается, пока адресат заполнен, пока адресам не сможет принимать сообщения.


Подобные документы

  • Разработка структуры локально-вычислительной сети ГБОУ СПО "ВПТ". Обоснование топологии, выбор аппаратного обеспечения для коммутации и сегментации. Установка и настройка сетевых протоколов и служб. Система мониторинга сетевых узлов и сетевого трафика.

    дипломная работа [1,8 M], добавлен 25.10.2013

  • Типы сетевых кабелей локальной вычислительной сети. Особенности установки беспроводного соединения Wi-Fi. Расчет трудоемкости работ по созданию ЛВС, затрат на ее разработку и монтаж. Предполагаемая прибыль от реализации ЛВС, капитальных затрат покупателя.

    курсовая работа [295,9 K], добавлен 27.12.2010

  • Анализ административного программного обеспечения локальной сети. Структура сетевых операционных систем. Планирование и сетевая архитектура локальной сети. Использование сетевых ресурсов на примере предприятия, предоставляющего услуги Интернет-провайдера.

    контрольная работа [112,5 K], добавлен 15.12.2010

  • Анализ и практическая реализация использования администрирования и мониторинга сети на предприятии. Процесс создания карты сети в программе LANState. Сетевые программы для сисадминов, программы мониторинга сети. Описание локальной вычислительной сети.

    курсовая работа [3,6 M], добавлен 15.02.2017

  • Классификация локальной вычислительной сети. Типы топологий локальной вычислительной сети. Модель взаимодействия систем OSI. Сетевые устройства и средства коммуникаций. Виды сетевых кабелей. Конфигурация компьютеров-серверов, техники рабочих станций.

    курсовая работа [1,3 M], добавлен 05.01.2013

  • Топология и принципы администрирования кабельной сети, выбор метода подключения сетевого оборудования. Проектирование локальной вычислительной сети. Оценка затрат на внедрение структурированной кабельной системы и системы бесперебойного питания.

    дипломная работа [1,8 M], добавлен 28.10.2013

  • Выбор спецификации активного и пассивного сетевого оборудования локальной вычислительной сети. Расчет количества кабеля и кабель-каналов. Выбор операционной системы рабочих станций. Настройка серверного, активного сетевого и серверного оборудования.

    курсовая работа [2,5 M], добавлен 18.05.2021

  • Функциональная схема локальной вычислительной сети. Планирование структуры и топология сети. IP–адресация и протокол TCP/IP. Настройка сетевого принтера и антивирусной системы NOD32. Технология прокладки кабельной системы. Технология создания патч-корда.

    курсовая работа [6,0 M], добавлен 08.08.2015

  • Способы классификации сетей. Разработка и описание структуры локальной вычислительной сети, расположенной в пятиэтажном здании. Технические сведения, топология иерархической звезды. Клиентское аппаратное обеспечение. Установка и настройка сервера.

    курсовая работа [58,1 K], добавлен 27.07.2011

  • Подбор пассивного сетевого оборудования. Обоснование необходимости модернизации локальной вычислительной сети предприятия. Выбор операционной системы для рабочих мест и сервера. Сравнительные характеристики коммутаторов D-Link. Схемы локальной сети.

    курсовая работа [1,9 M], добавлен 10.10.2015

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.