File: munin_master_plugin_fetch.t

package info (click to toggle)
munin 2.0.76-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,068 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (105 lines) | stat: -rw-r--r-- 2,439 bytes parent folder | download | duplicates (11)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# -*- cperl -*-
use warnings;
use strict;

use English qw(-no_match_vars);
use Data::Dumper;

# use Test::More qw(no_plan);
use Test::More tests => 2;

use_ok('Munin::Master::Node');

my $node = bless { address => "127.0.0.1",
		   port => "4949",
		   host => "localhost" }, "Munin::Master::Node";

$INPUT_RECORD_SEPARATOR = '';
my @input = split("\n",<DATA>);

# make time() return a known-good value.
BEGIN { *CORE::GLOBAL::time = sub { 1234567890 }; }
my $time = time;

my %answer = $node->parse_service_data("cpu", \@input);

=comment

Keep old correct answer for reference.

my $fasit = {
          'irq' => {
                     'when' => '1256305015',
                     'value' => '2770'
                   },
          'system' => {
                        'when' => 'N',
                        'value' => '66594'
                      },
          'softirq' => {
                         'when' => '1256305015',
                         'value' => '127'
                       },
          'user' => {
                      'when' => 'N',
                      'value' => '145923'
                    },
          'idle' => {
                      'when' => 'N',
                      'value' => '2245122'
                    },
          'iowait' => {
                        'when' => 'N',
                        'value' => '14375'
                      },
          'nice' => {
                      'when' => 'N',
                      'value' => '268'
                    }
        };

=cut

my $fasit = {
    cpu => {
        irq => {
            when  => [ 1256305015 ],
            value => [ 2770       ],
        },
        system => {
            when  => [ $time ],
            value => [ 66594 ],
        },
        softirq => {
            when  => [ 1256305015 ],
            value => [ 127        ],
        },
        user => {
            when  => [ $time  ],
            value => [ 145923 ],
        },
        iowait => {
            when  => [ $time ],
            value => [ 14375 ],
        },
        idle => {
            when  => [ $time   ],
            value => [ 2245122 ],
        },
        nice => {
            when  => [ $time ],
            value => [ 268   ],
        },
    },
};

is_deeply(\%answer,$fasit,"Plugin fetch output");

__DATA__
user.value 145923
nice.value 268
system.value 66594
idle.value 2245122
iowait.value 14375
irq.value 1256305015:2770
softirq.value 1256305015:127