Файл: Способы представления данных в информационных системах (Понятие, виды, классификация и способы предоставления данных в ИС).pdf

ВУЗ: Не указан

Категория: Курсовая работа

Дисциплина: Не указана

Добавлен: 01.04.2023

Просмотров: 465

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

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

#

# local configuration:

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

include=/etc/nagios/nrpe_local.cfg

Приложение З

Исходные тексты плагинов, не идущих в поставке с пакетом ядра системы.

/usr/lib/nagios/plugins/check_snmp_load.pl

#!/usr/bin/perl -w

# nagios: -epn

############################## check_snmp_load #################

my $Version='1.12';

#

# Help : ./check_snmp_load.pl -h

#

use strict;

use Net::SNMP;

use Getopt::Long;

# Nagios specific

my $TIMEOUT = 15;

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

# SNMP Datas

# Generic with host-ressource-mib

my $base_proc = "1.3.6.1.2.1.25.3.3.1"; # oid for all proc info

my $proc_id = "1.3.6.1.2.1.25.3.3.1.1"; # list of processors (product ID)

my $proc_load = "1.3.6.1.2.1.25.3.3.1.2"; # %time the proc was not idle over last minute

# Linux load

my $linload_table= "1.3.6.1.4.1.2021.10.1"; # net-snmp load table

my $linload_name = "1.3.6.1.4.1.2021.10.1.2"; # text 'Load-1','Load-5', 'Load-15'

my $linload_load = "1.3.6.1.4.1.2021.10.1.3"; # effective load table

# Cisco cpu/load

my $cisco_cpu_5m = "1.3.6.1.4.1.9.2.1.58.0"; # Cisco CPU load (5min %)

my $cisco_cpu_1m = "1.3.6.1.4.1.9.2.1.57.0"; # Cisco CPU load (1min %)

my $cisco_cpu_5s = "1.3.6.1.4.1.9.2.1.56.0"; # Cisco CPU load (5sec %)

# Cisco catalyst cpu/load

my $ciscocata_cpu_5m = ".1.3.6.1.4.1.9.9.109.1.1.1.1.5.9"; # Cisco CPU load (5min %)

my $ciscocata_cpu_1m = ".1.3.6.1.4.1.9.9.109.1.1.1.1.3.9"; # Cisco CPU load (1min %)

my $ciscocata_cpu_5s = ".1.3.6.1.4.1.9.9.109.1.1.1.1.4.9"; # Cisco CPU load (5sec %)

# Netscreen cpu/load

my $nsc_cpu_5m = "1.3.6.1.4.1.3224.16.1.4.0"; # NS CPU load (5min %)

my $nsc_cpu_1m = "1.3.6.1.4.1.3224.16.1.2.0"; # NS CPU load (1min %)

my $nsc_cpu_5s = "1.3.6.1.4.1.3224.16.1.3.0"; # NS CPU load (5sec %)

# AS/400 CPU

my $as400_cpu = "1.3.6.1.4.1.2.6.4.5.1.0"; # AS400 CPU load (10000=100%);

# Net-SNMP CPU

my $ns_cpu_idle = "1.3.6.1.4.1.2021.11.11.0"; # Net-snmp cpu idle

my $ns_cpu_user = "1.3.6.1.4.1.2021.11.9.0"; # Net-snmp user cpu usage

my $ns_cpu_system = "1.3.6.1.4.1.2021.11.10.0"; # Net-snmp system cpu usage

# Procurve CPU

my $procurve_cpu = "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0"; # Procurve CPU Counter

# Nokia CPU

-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) ; }

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"}}

########### 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";

##### 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";

}

return 1;

}

sub round ($$) {

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

}

########### 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_

Приложение И

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

# sec.name source community

#com2sec paranoid default public

com2sec readonly default public