Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to unpack MessagePack from C failing with "extra bytes (length should be 145)" message #9

Closed
alexander-potemkin opened this issue Sep 11, 2012 · 8 comments

Comments

@alexander-potemkin
Copy link

Hi,

I'm trying to unpack MessagePack created from latest MessagePack C library, but it fails with the following error message:

Data::MessagePack->unpack: extra bytes (length should be 145) at test.pl line 19

Here is the test.pl script (working with Pure Perl implementation):


use strict;
use Data::MessagePack;

my $dump_file_name = shift;

die "Can't file file: $dump_file_name" if (!-e $dump_file_name);

open DUMP_FILE, "<$dump_file_name"
or die "Can't open dump $dump_file_name: $!";

my $dump_content = do {local $/; <DUMP_FILE>};
close DUMP_FILE;

if (!Data::MessagePack->unpack($dump_content)) {
die "Can't unpack dump.";
}

At the same time, Python's bindings work just fine.

Any clue?

Thanks in advance.

@tokuhirom
Copy link
Member

Can you send me a data file to reproduce?

@alexander-potemkin
Copy link
Author

Sure, please, find it here: https://github.com/battleship-potemkin/test/blob/master/dump.cant_parse

Here is the command to reproduce:

perl test.pl dump.cant_parse

Please, let me know if any additional information required.

@syohex
Copy link
Collaborator

syohex commented Sep 12, 2012

Is dump.cant_parse valid ?

% od -t x1 dump.cant_parse
0000000 87 a7 6f 73 5f 6e 61 6d 65 a5 4c 69 6e 75 78 aa
0000020 6f 73 5f 72 65 6c 65 61 73 65 ae 32 2e 36 2e 33
0000040 32 2d 33 34 31 2d 65 63 32 a9 68 6f 73 74 5f 6e
0000060 61 6d 65 ba 70 68 69 6c 6f 73 6f 70 68 65 72 2e
....

First data type is 0x87, this is fix map and it has 7 key & value pairs.
So Data::MessagePack unpack 7 keys and 7 values then it stops unpacking
and dies, because there are still not unpacking data remaining.
I think this behavior is not wrong.

You should use 'map 32' or 'map 16' for unpacking dump.cant_parse correctly.

@alexander-potemkin
Copy link
Author

I guess it should, first of all, because Python's bindings unpack it very well.

Regarding the elements - yes, we have (were packing) 7 keys and values there.

@syohex
Copy link
Collaborator

syohex commented Sep 13, 2012

dump.cant_parse has multiple data structures.

They are following

Chunk from 0 to 145
{
  'host_address' => '10.128.101.100',
  'os_arch' => 'x86_64',
  'lib_arch' => '64',
  'os_name' => 'Linux',
  'uptime' => 20396890,
  'host_name' => 'philosopher.zoo.10bees.com',
  'os_release' => '2.6.32-341-ec2'
}

Chunk from 145 to 236
{
  'buffers' => 180372,
  'swap_total' => 0,
  'total' => 650456,
  'swap_used' => 0,
  'free' => 75108,
  'swap_free' => 0,
  'used' => 575348,
  'cached' => 254320
}

Chunk from 236 to 288
{
  'system' => 0,
  'idle' => 100,
  'nice' => 0,
  'irq' => 0,
  'sintr' => 0,
  'steal' => 0,
  'wait' => 0,
  'user' => 0
}

Chunk from 288 to 1917
{
  'cpudevours' => [
                    {
                      'uid' => 0,
                      'pid' => 19349,
                      'ppid' => 11884,
                      'cpu_usage' => 1,
                      'cmdline' => './proc_sysinfo-linux-x86_64',
                      'mem_usage' => 932,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 1,
                      'ppid' => 0,
                      'cpu_usage' => 0,
                      'cmdline' => '/sbin/init',
                      'mem_usage' => 1520,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 2,
                      'ppid' => 0,
                      'cpu_usage' => 0,
                      'cmdline' => 'kthreadd',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 3,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'migration/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 4,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'ksoftirqd/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 5,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'watchdog/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 6,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'events/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 7,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'cpuset',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 8,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'khelper',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 9,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'netns',
                      'mem_usage' => 0,
                      'username' => 'root'
                    }
                  ],
  'stopped' => 0,
  'zombies' => 0,
  'sleeping' => 66,
  'memdevours' => [
                    {
                      'uid' => 101,
                      'pid' => 408,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => 'rsyslogd',
                      'mem_usage' => 1260,
                      'username' => 'syslog'
                    },
                    {
                      'uid' => 1001,
                      'pid' => 11758,
                      'ppid' => 11689,
                      'cpu_usage' => 0,
                      'cmdline' => 'sshd: alexander@pts/0',
                      'mem_usage' => 1876,
                      'username' => 'alexander'
                    },
                    {
                      'uid' => 0,
                      'pid' => 11689,
                      'ppid' => 401,
                      'cpu_usage' => 0,
                      'cmdline' => 'sshd: alexander [priv]',
                      'mem_usage' => 3432,
                      'username' => 'root'
                    },
                    {
                      'uid' => 1006,
                      'pid' => 24114,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '10bees-agent',
                      'mem_usage' => 10544,
                      'username' => '10bees'
                    },
                    {
                      'uid' => 0,
                      'pid' => 532,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/sbin/console-kit-daemon',
                      'mem_usage' => 3924,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 401,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/sbin/sshd',
                      'mem_usage' => 1660,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 11877,
                      'ppid' => 11759,
                      'cpu_usage' => 0,
                      'cmdline' => 'su',
                      'mem_usage' => 1784,
                      'username' => 'root'
                    },
                    {
                      'uid' => 107,
                      'pid' => 27770,
                      'ppid' => 27767,
                      'cpu_usage' => 0,
                      'cmdline' => 'qmgr',
                      'mem_usage' => 2384,
                      'username' => 'postfix'
                    },
                    {
                      'uid' => 107,
                      'pid' => 18667,
                      'ppid' => 27767,
                      'cpu_usage' => 0,
                      'cmdline' => 'pickup',
                      'mem_usage' => 2200,
                      'username' => 'postfix'
                    },
                    {
                      'uid' => 0,
                      'pid' => 27767,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/lib/postfix/master',
                      'mem_usage' => 2292,
                      'username' => 'root'
                    }
                  ],
  'running' => 1,
  'total' => 67
}

Chunk from 1917 to 2004
{
  'mounts' => [
                {
                  'bsize' => 4096,
                  'bfree' => 5284724,
                  'filesystem' => '/dev/sda1',
                  'mounted_on' => '/',
                  'bused' => 2972228,
                  'btotal' => 8256952
                }
              ]
}

Chunk from 2004 to 4414
{
  'nics' => [
              {
                'recv' => 3059957,
                'name' => 'eth0',
                'sent' => 4838496,
                'ipv6_addr_count' => 1,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '10.128.101.100'
                                ],
                'ipv6_addrs' => [
                                  'fe80::1031:40ff:fe00:669a'
                                ]
              },
              {
                'recv' => 0,
                'name' => 'dummy0',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              },
              {
                'recv' => 0,
                'name' => 'ifb0',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              },
              {
                'recv' => 0,
                'name' => 'ifb1',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              }
            ]
}

Data::MessagePack::unpack can unpack 1 data structure,
So Data::MessagePack::unpack unpacks only first data(7 element map)
and finish unpacking and dies(because there are still not unpacking data remaining).

You should use Data::MessagePack::Stream such case.

Sample code is following

use strict;
use warnings;
use Data::MessagePack::Stream;
use Data::Dumper;

my $dump_file_name = shift or die "Usage: $0 message_packed_file";

my $dump_content = do {
    local $/;
    open my $fh, "<", $dump_file_name or die "Can't open $dump_file_name: $!";
    <$fh>;
};

my $unpacker = Data::MessagePack::Stream->new;
$unpacker->feed($dump_content);
local $Data::Dumper::Terse = 1;
while ($unpacker->next) {
    print Dumper($unpacker->data);
}

And I get following output same as above

% perl stream.pl dump.cant_parse
{
  'host_address' => '10.128.101.100',
  'os_arch' => 'x86_64',
  'lib_arch' => '64',
  'os_name' => 'Linux',
  'uptime' => 20396890,
  'host_name' => 'philosopher.zoo.10bees.com',
  'os_release' => '2.6.32-341-ec2'
}
{
  'buffers' => 180372,
  'swap_total' => 0,
  'total' => 650456,
  'swap_used' => 0,
  'free' => 75108,
  'swap_free' => 0,
  'used' => 575348,
  'cached' => 254320
}
{
  'system' => 0,
  'idle' => 100,
  'nice' => 0,
  'irq' => 0,
  'sintr' => 0,
  'steal' => 0,
  'wait' => 0,
  'user' => 0
}
{
  'cpudevours' => [
                    {
                      'uid' => 0,
                      'pid' => 19349,
                      'ppid' => 11884,
                      'cpu_usage' => 1,
                      'cmdline' => './proc_sysinfo-linux-x86_64',
                      'mem_usage' => 932,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 1,
                      'ppid' => 0,
                      'cpu_usage' => 0,
                      'cmdline' => '/sbin/init',
                      'mem_usage' => 1520,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 2,
                      'ppid' => 0,
                      'cpu_usage' => 0,
                      'cmdline' => 'kthreadd',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 3,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'migration/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 4,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'ksoftirqd/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 5,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'watchdog/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 6,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'events/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 7,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'cpuset',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 8,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'khelper',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 9,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'netns',
                      'mem_usage' => 0,
                      'username' => 'root'
                    }
                  ],
  'stopped' => 0,
  'zombies' => 0,
  'sleeping' => 66,
  'memdevours' => [
                    {
                      'uid' => 101,
                      'pid' => 408,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => 'rsyslogd',
                      'mem_usage' => 1260,
                      'username' => 'syslog'
                    },
                    {
                      'uid' => 1001,
                      'pid' => 11758,
                      'ppid' => 11689,
                      'cpu_usage' => 0,
                      'cmdline' => 'sshd: alexander@pts/0',
                      'mem_usage' => 1876,
                      'username' => 'alexander'
                    },
                    {
                      'uid' => 0,
                      'pid' => 11689,
                      'ppid' => 401,
                      'cpu_usage' => 0,
                      'cmdline' => 'sshd: alexander [priv]',
                      'mem_usage' => 3432,
                      'username' => 'root'
                    },
                    {
                      'uid' => 1006,
                      'pid' => 24114,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '10bees-agent',
                      'mem_usage' => 10544,
                      'username' => '10bees'
                    },
                    {
                      'uid' => 0,
                      'pid' => 532,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/sbin/console-kit-daemon',
                      'mem_usage' => 3924,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 401,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/sbin/sshd',
                      'mem_usage' => 1660,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 11877,
                      'ppid' => 11759,
                      'cpu_usage' => 0,
                      'cmdline' => 'su',
                      'mem_usage' => 1784,
                      'username' => 'root'
                    },
                    {
                      'uid' => 107,
                      'pid' => 27770,
                      'ppid' => 27767,
                      'cpu_usage' => 0,
                      'cmdline' => 'qmgr',
                      'mem_usage' => 2384,
                      'username' => 'postfix'
                    },
                    {
                      'uid' => 107,
                      'pid' => 18667,
                      'ppid' => 27767,
                      'cpu_usage' => 0,
                      'cmdline' => 'pickup',
                      'mem_usage' => 2200,
                      'username' => 'postfix'
                    },
                    {
                      'uid' => 0,
                      'pid' => 27767,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/lib/postfix/master',
                      'mem_usage' => 2292,
                      'username' => 'root'
                    }
                  ],
  'running' => 1,
  'total' => 67
}
{
  'mounts' => [
                {
                  'bsize' => 4096,
                  'bfree' => 5284724,
                  'filesystem' => '/dev/sda1',
                  'mounted_on' => '/',
                  'bused' => 2972228,
                  'btotal' => 8256952
                }
              ]
}
{
  'nics' => [
              {
                'recv' => 3059957,
                'name' => 'eth0',
                'sent' => 4838496,
                'ipv6_addr_count' => 1,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '10.128.101.100'
                                ],
                'ipv6_addrs' => [
                                  'fe80::1031:40ff:fe00:669a'
                                ]
              },
              {
                'recv' => 0,
                'name' => 'dummy0',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              },
              {
                'recv' => 0,
                'name' => 'ifb0',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              },
              {
                'recv' => 0,
                'name' => 'ifb1',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              }
            ]
}

@alexander-potemkin
Copy link
Author

Thanks. Any way for the streams to be unpacked by using Pure Perl solution? Or, at least, to verify the structure without using C library?

@syohex
Copy link
Collaborator

syohex commented Sep 13, 2012

You can use Data::MessagePack::PP::Unpacker(Pure perl implementation of Data::MessagePack::Unpacker).
But author says "Data::MessagePack::Unpacker is deprecated, use Data::MessagePack::Stream instead".

Sample code is following.

use strict;
use warnings;
use Data::MessagePack;
use Data::Dumper;

my $dump_file_name = shift or die "Usage: $0 message_packed_file";

my $dump_content = do {
    local $/;
    open my $fh, "<", $dump_file_name or die "Can't open $dump_file_name: $!";
    <$fh>;
};

local $Data::Dumper::Terse = 1;
my $unpacker = Data::MessagePack::Unpacker->new;

my $limit = length $dump_content;
my $off = 0;
while (1) {
    $off = $unpacker->execute($dump_content, $off);
    print Dumper($unpacker->data);

    $unpacker->reset;
    last if $off >= $limit;
}

output is

% PERL_ONLY=1 perl pp_stream.pl dump.cant_parse
{
  'host_address' => '10.128.101.100',
  'os_arch' => 'x86_64',
  'lib_arch' => '64',
  'os_name' => 'Linux',
  'uptime' => 20396890,
  'host_name' => 'philosopher.zoo.10bees.com',
  'os_release' => '2.6.32-341-ec2'
}
{
  'buffers' => 180372,
  'swap_total' => 0,
  'total' => 650456,
  'swap_used' => 0,
  'free' => 75108,
  'swap_free' => 0,
  'used' => 575348,
  'cached' => 254320
}
{
  'system' => 0,
  'idle' => 100,
  'nice' => 0,
  'irq' => 0,
  'sintr' => 0,
  'steal' => 0,
  'wait' => 0,
  'user' => 0
}
{
  'cpudevours' => [
                    {
                      'uid' => 0,
                      'pid' => 19349,
                      'ppid' => 11884,
                      'cpu_usage' => 1,
                      'cmdline' => './proc_sysinfo-linux-x86_64',
                      'mem_usage' => 932,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 1,
                      'ppid' => 0,
                      'cpu_usage' => 0,
                      'cmdline' => '/sbin/init',
                      'mem_usage' => 1520,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 2,
                      'ppid' => 0,
                      'cpu_usage' => 0,
                      'cmdline' => 'kthreadd',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 3,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'migration/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 4,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'ksoftirqd/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 5,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'watchdog/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 6,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'events/0',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 7,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'cpuset',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 8,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'khelper',
                      'mem_usage' => 0,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 9,
                      'ppid' => 2,
                      'cpu_usage' => 0,
                      'cmdline' => 'netns',
                      'mem_usage' => 0,
                      'username' => 'root'
                    }
                  ],
  'stopped' => 0,
  'zombies' => 0,
  'sleeping' => 66,
  'memdevours' => [
                    {
                      'uid' => 101,
                      'pid' => 408,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => 'rsyslogd',
                      'mem_usage' => 1260,
                      'username' => 'syslog'
                    },
                    {
                      'uid' => 1001,
                      'pid' => 11758,
                      'ppid' => 11689,
                      'cpu_usage' => 0,
                      'cmdline' => 'sshd: alexander@pts/0',
                      'mem_usage' => 1876,
                      'username' => 'alexander'
                    },
                    {
                      'uid' => 0,
                      'pid' => 11689,
                      'ppid' => 401,
                      'cpu_usage' => 0,
                      'cmdline' => 'sshd: alexander [priv]',
                      'mem_usage' => 3432,
                      'username' => 'root'
                    },
                    {
                      'uid' => 1006,
                      'pid' => 24114,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '10bees-agent',
                      'mem_usage' => 10544,
                      'username' => '10bees'
                    },
                    {
                      'uid' => 0,
                      'pid' => 532,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/sbin/console-kit-daemon',
                      'mem_usage' => 3924,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 401,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/sbin/sshd',
                      'mem_usage' => 1660,
                      'username' => 'root'
                    },
                    {
                      'uid' => 0,
                      'pid' => 11877,
                      'ppid' => 11759,
                      'cpu_usage' => 0,
                      'cmdline' => 'su',
                      'mem_usage' => 1784,
                      'username' => 'root'
                    },
                    {
                      'uid' => 107,
                      'pid' => 27770,
                      'ppid' => 27767,
                      'cpu_usage' => 0,
                      'cmdline' => 'qmgr',
                      'mem_usage' => 2384,
                      'username' => 'postfix'
                    },
                    {
                      'uid' => 107,
                      'pid' => 18667,
                      'ppid' => 27767,
                      'cpu_usage' => 0,
                      'cmdline' => 'pickup',
                      'mem_usage' => 2200,
                      'username' => 'postfix'
                    },
                    {
                      'uid' => 0,
                      'pid' => 27767,
                      'ppid' => 1,
                      'cpu_usage' => 0,
                      'cmdline' => '/usr/lib/postfix/master',
                      'mem_usage' => 2292,
                      'username' => 'root'
                    }
                  ],
  'running' => 1,
  'total' => 67
}
{
  'mounts' => [
                {
                  'bsize' => 4096,
                  'bfree' => 5284724,
                  'filesystem' => '/dev/sda1',
                  'mounted_on' => '/',
                  'bused' => 2972228,
                  'btotal' => 8256952
                }
              ]
}
{
  'nics' => [
              {
                'recv' => 3059957,
                'name' => 'eth0',
                'sent' => 4838496,
                'ipv6_addr_count' => 1,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '10.128.101.100'
                                ],
                'ipv6_addrs' => [
                                  'fe80::1031:40ff:fe00:669a'
                                ]
              },
              {
                'recv' => 0,
                'name' => 'dummy0',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              },
              {
                'recv' => 0,
                'name' => 'ifb0',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              },
              {
                'recv' => 0,
                'name' => 'ifb1',
                'sent' => 0,
                'ipv6_addr_count' => 0,
                'ipv4_addr_count' => 1,
                'ipv4_addrs' => [
                                  '0.0.0.0'
                                ],
                'ipv6_addrs' => []
              }
            ]
}

@alexander-potemkin
Copy link
Author

Lovely, it works now.

Hope the module will keep working as it's the only Pure Perl unpack implementation available.

Thanks syohex, tokuhirom for prompt reply, great help and scripts examples!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants