Changeset 3829

Show
Ignore:
Timestamp:
07/27/10 14:42:48 (2 years ago)
Author:
ligne
Message:

non-multigraphs should get a multigraph header, so the master knows what it's looking at.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/node/lib/Munin/Node/SpoolWriter.pm

    r3828 r3829  
    4141 
    4242    print {$fh} "timestamp $timestamp\n"; 
     43    print {$fh} "multigraph $service\n" unless $data->[0] =~ m{^multigraph}; 
    4344 
    4445    foreach my $line (@$data) { 
  • trunk/node/t/munin_node_spoolwriter.t

    r3828 r3829  
    33use strict; 
    44 
    5 use Test::More tests => 17
     5use Test::More tests => 19
    66use Test::LongString; 
    77 
     
    5151    is_string($data, <<EOC, 'Data was written correctly'); 
    5252timestamp 1234567890 
     53multigraph fnord 
    5354graph_title CPU usage 
    5455graph_order system user nice idle iowait irq softirq 
     
    7374    is_string($data, <<EOC, 'Spool file was appended to'); 
    7475timestamp 1234567890 
     76multigraph fnord 
    7577graph_title CPU usage 
    7678graph_order system user nice idle iowait irq softirq 
     
    8082system.value 999999 
    8183timestamp 1234567891 
     84multigraph fnord 
    8285graph_title CPU usage! 
    8386graph_order system user nice idle iowait irq softirq 
     
    8992 
    9093} 
    91 ### writing different types of value. 
    92 ### values can also include a timestamp: http://munin-monitoring.org/wiki/protocol-multifetch 
     94 
     95# writing different types of value. 
     96# values can also include a timestamp: http://munin-monitoring.org/wiki/protocol-multifetch 
    9397{ 
    9498    my @tests = ( 
     
    131135} 
    132136 
     137# writing multigraph results 
     138{ 
     139    my $dir = tempdir( CLEANUP => 1 ); 
     140    my $writer = Munin::Node::SpoolWriter->new(spooldir => $dir); 
     141 
     142    $writer->write(1234567890, 'fnord', [ 
     143        'multigraph fnord', 
     144        'graph_title CPU usage', 
     145        'system.label system', 
     146        'system.value 999999', 
     147        'multigraph fnord.one', 
     148        'graph_title subfnord', 
     149        'subsystem.label subsystem', 
     150        'subsystem.value 123', 
     151    ]); 
     152 
     153    my $data_file = "$dir/munin-daemon.fnord"; 
     154    ok( -r $data_file, 'spool file is readable') or last; 
     155 
     156    my $data = read_file($data_file); 
     157    is_string($data, <<EOC, 'Data was written correctly'); 
     158timestamp 1234567890 
     159multigraph fnord 
     160graph_title CPU usage 
     161system.label system 
     162system.value 999999 
     163multigraph fnord.one 
     164graph_title subfnord 
     165subsystem.label subsystem 
     166subsystem.value 123 
     167EOC 
     168 
     169} 
     170