Changeset 3828
- Timestamp:
- 07/27/10 14:33:53 (2 years ago)
- Files:
-
- trunk/node/lib/Munin/Node/SpoolWriter.pm (modified) (1 diff)
- trunk/node/t/munin_node_spoolwriter.t (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/node/lib/Munin/Node/SpoolWriter.pm
r3827 r3828 40 40 or die "Unable to open spool file: $!"; 41 41 42 print {$fh} "timestamp $timestamp\n"; 43 42 44 foreach my $line (@$data) { 43 45 # Ignore blank lines and "."-ones. 44 46 next if (!defined($line) || $line eq '' || $line eq '.'); 45 46 # If the value line isn't timestamped47 # we have to add the timestamp on the line48 $line =~ s/(\w+)\.value (?!\d+:)(-?[0-9.]+|U)/$1.value $timestamp:$2/;49 47 50 48 print {$fh} $line, "\n" or logger("Error writing results: $!"); trunk/node/t/munin_node_spoolwriter.t
r3827 r3828 3 3 use strict; 4 4 5 use Test::More tests => 20;5 use Test::More tests => 17; 6 6 use Test::LongString; 7 7 … … 50 50 my $data = read_file($data_file); 51 51 is_string($data, <<EOC, 'Data was written correctly'); 52 timestamp 1234567890 52 53 graph_title CPU usage 53 54 graph_order system user nice idle iowait irq softirq … … 55 56 update_rate 86400 56 57 system.label system 57 system.value 1234567890:99999958 system.value 999999 58 59 EOC 59 60 … … 71 72 $data = read_file($data_file); 72 73 is_string($data, <<EOC, 'Spool file was appended to'); 74 timestamp 1234567890 73 75 graph_title CPU usage 74 76 graph_order system user nice idle iowait irq softirq … … 76 78 update_rate 86400 77 79 system.label system 78 system.value 1234567890:999999 80 system.value 999999 81 timestamp 1234567891 79 82 graph_title CPU usage! 80 83 graph_order system user nice idle iowait irq softirq … … 82 85 update_rate 86400 83 86 system.label system 84 system.value 1234567891:99999887 system.value 999998 85 88 EOC 86 89 … … 91 94 my @tests = ( 92 95 # timestamp, value, expected 93 [ 1234567890, '999999', '1234567890:999999', 'Integer without timestamp' ],96 [ 1234567890, '999999', '999999', 'Integer without timestamp' ], 94 97 [ 1234567890, '2134567890:999999', '2134567890:999999', 'Integer with timestamp' ], 95 98 96 [ 1234567890, 'U', '1234567890:U', 'Unknown without timestamp' ],99 [ 1234567890, 'U', 'U', 'Unknown without timestamp' ], 97 100 [ 1234567890, '2134567890:U', '2134567890:U', 'Unknown with timestamp' ], 98 101 99 [ 1234567890, '-2', '1234567890:-2', 'Negative without timestamp' ],102 [ 1234567890, '-2', '-2', 'Negative without timestamp' ], 100 103 [ 1234567890, '2134567890:-2', '2134567890:-2', 'Negative with timestamp' ], 101 104 102 [ 1234567890, '3.141', '1234567890:3.141', 'Float without timestamp' ],105 [ 1234567890, '3.141', '3.141', 'Float without timestamp' ], 103 106 [ 1234567890, '2134567890:3.141', '2134567890:3.141', 'Float with timestamp' ], 104 107 105 [ 1234567890, '1.05e-34', '1234567890:1.05e-34', 'E-notation without timestamp' ],108 [ 1234567890, '1.05e-34', '1.05e-34', 'E-notation without timestamp' ], 106 109 [ 1234567890, '2134567890:1.05e-34', '2134567890:1.05e-34', 'E-notation with timestamp' ], 107 110 ); … … 124 127 125 128 my $data = read_file($data_file); 126 is_string($data, "system.value $expected\n", $msg);129 like($data, qr(^system\.value $expected\n$)m, $msg); 127 130 } 128 131 }
