Leser: 1
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@walk = `$SNMPWALK -v 1 $HOST -c $COMMUNITY interfaces.ifTable.ifEntry.ifDescr`;
%interfaces = ();
my $count = 0;
foreach $interface (@walk)
{
@ifDescr = split("=",$interface);
if($ifDescr[0] =~ m/.(\d*)\s$/) { $ifNumber = $1; }
$_ = $ifDescr[1];
if($ifDescr[1] =~ m/STRING:/) # Some SNMP Agents add field type identifier before
{ # value, so we omitting it.
m/STRING:\s(\S*)/;
$interfaces{$ifNumber} = $1;
} else
{
m/\s(\S*)/;
$interfaces{$ifNumber} = $1;
}
$count++;
}
print "Number of Interfaces found: $count\n\n";
if($WITH_RRD)
{
$samples_4hrs = (60 * 4) / $CHECK_INTERVAL;
$average_1day = 30 / $CHECK_INTERVAL;
$average_1mon = $average_1day * 4;
if ((30%$CHECK_INTERVAL) or ((60*4)%$CHECK_INTERVAL))
{
die "\nERROR: Value \$CHECK_INTERVAL is illegal. Enter another and try again.\n";
}
}
# - Writing service definitions fo file.
open (CONFIG, ">>$OUTPUT_SERVICE_FILE");
print CONFIG "# - Service definitions for 'check_traffic' plugin\n\n";
foreach $ifNumber (keys %interfaces)
{
$_ = `$SNMPGET -v 1 $HOST -c $COMMUNITY interfaces.ifTable.ifEntry.ifSpeed.$ifNumber`;
m/\s(\d*)\s$/;
$max_speed = $1 / 8;
if(!$max_speed)
{
print "Can't determine maximum speed for interface $interfaces{$ifNumber}.\n";
print "Enter it manually [bps]: ";
chop($max_speed = <STDIN>);
}
if($WITH_RRD)
{
$start_time = time;
$db_file = $HOST."_".$interfaces{$ifNumber}.".rrd";
`$RRDTOOL create $DB_PATH/$db_file --start $start_time DS:input:COUNTER:600:U:U DS:output:COUNTER:600:U:U RRA:AVERAGE:0.5:1:$samples_4hrs RRA:AVERAGE:0.5:$average_1day:48 RRA:AVERAGE:0.5:$average_1mon:372 RRA:MAX:0.5:1:48 RRA:MAX:0.5:$average_1day:48 RRA:MAX:0.5:$average_1mon:372`;
create_rrd_cgi($HOSTNAME,$interfaces{$ifNumber},$db_file);
}
5 Einträge, 1 Seite |