Thread Dateinamen ändern (4 answers)
Opened by uneu1 at 2004-06-13 16:35

uneu1
 2004-06-13 16:35
#2874 #2874
User since
2004-06-13
2 Artikel
BenutzerIn
[default_avatar]
Hallo Leute,
ich lese hier den Namen einer Schnittstelle aus und verwende diesen zum erstellen einer Datei. Allerdings hat diese Schnittstelle einen Namen mit einem Slash darin. Wie ersetze ich diesen Slash durch ein Minuszeichen?
Code:
Code: (dl )
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);
}

Vielen Dank im voraus

Uwe

Edit format_c: Code-Tags spendiert\n\n

<!--EDIT|format_c|1087134581-->

View full thread Dateinamen ändern