Skip to content

Conversation

dantyan
Copy link
Contributor

@dantyan dantyan commented Mar 7, 2016

Added support for LVM RAID check, using command

dmsetup status --target=raid

Command output:

vg1-cache: 0 4194304 raid raid1 2 AA 4194304/4194304 idle 0
vg1-zoom: 0 2097152 raid raid1 2 AA 2097152/2097152 idle 0

added new file

lib/App/Monitoring/Plugin/CheckRaid/Plugins/lvm.pm

@glensc glensc added the dm label Mar 7, 2016
@glensc glensc merged commit 789718b into glensc:master Mar 7, 2016
glensc added a commit that referenced this pull request Mar 7, 2016
Merge branch 'pr/134'
@glensc
Copy link
Owner

glensc commented Mar 7, 2016

merged. thanks for the initial input!

@glensc
Copy link
Owner

glensc commented Mar 7, 2016

however i think it's best to add --noflush option to dmsetup status to make monitoring lightweight as possible. what you think?

@robbat2
Copy link
Contributor

robbat2 commented Mar 8, 2016

This covers the LVM "raid1" type, but not the older LVM "mirror" type.

Example outputs:

# dmsetup status --target=raid
vg-SWAP: 0 4194304 raid raid1 2 AA 4194304/4194304 idle 0
vg-root: 0 20971520 raid raid1 2 AA 20971520/20971520 idle 0
vg-testraid: 0 2097152 raid raid1 2 AA 2097152/2097152 idle 0
# dmsetup status --target=mirror
vg-testmirror: 0 2097152 mirror 2 252:14 252:15 2048/2048 1 AA 3 disk 252:13 A

@glensc
Copy link
Owner

glensc commented Mar 8, 2016

moving discussion to #130

@dantyan
Copy link
Contributor Author

dantyan commented Mar 9, 2016

After checkout of new master
run ./check_raid.sh
got message:

Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 168.
Use of uninitialized value in pattern match (m//) at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 169.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
Use of uninitialized value in concatenation (.) or string at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 171.
OK: **dm:[:, vg1-cache1:AA idle, :, :, :, :, :, :, vg1-zoom1:AA idle, :]**

print $this->parse result:

$VAR1 = [
          {},
          {
            'dmname' => 'vg1-cache1',
            'raid_type' => 'raid1',
            'raid_disks' => '2',
            'target' => 'raid',
            'mismatch_cnt' => '0',
            'status_chars' => 'AA',
            'sync_ratio' => '2097152/2097152',
            's' => '0',
            'sync_action' => 'idle',
            'l' => '2097152'
          },
          {},
          {},
          {},
          {},
          {},
          {},
          {
            'target' => 'raid',
            'mismatch_cnt' => '0',
            'raid_disks' => '2',
            'raid_type' => 'raid1',
            'dmname' => 'vg1-zoom1',
            'l' => '2097152',
            'sync_action' => 'idle',
            'sync_ratio' => '2097152/2097152',
            's' => '0',
            'status_chars' => 'AA'
          },
          {}
        ];

so we have some empty hashes.
and as result warnings and - OK: dm:[:, vg1-cache1:AA idle, :, :, :, :, :, :, vg1-zoom1:AA idle, :]

as variant is to add condition for empty hash

foreach my $dm (@$c)
{
    next unless %{$dm};

@glensc
Copy link
Owner

glensc commented Mar 9, 2016

this is expected. the plugin is in rewrite phase as of now, to support your configuration need output of dmsetup calls from your system

@dantyan
Copy link
Contributor Author

dantyan commented Mar 9, 2016

Output of my dmsetup status

vg1-zoom1_rimage_1: 0 2097152 linear 
vg1-cache1: 0 2097152 raid raid1 2 AA 2097152/2097152 idle 0
vg1-zoom1_rimage_0: 0 2097152 linear 
vg1-cache1_rmeta_1: 0 8192 linear 
vg1-cache1_rmeta_0: 0 8192 linear 
vg1-zoom1_rmeta_1: 0 8192 linear 
vg1-zoom1_rmeta_0: 0 8192 linear 
vg1-cache1_rimage_1: 0 2097152 linear 
vg1-zoom1: 0 2097152 raid raid1 2 AA 2097152/2097152 idle 0
vg1-cache1_rimage_0: 0 2097152 linear 

@glensc
Copy link
Owner

glensc commented Mar 9, 2016

should be fixed with 5367bda

@dantyan
Copy link
Contributor Author

dantyan commented Mar 9, 2016

i think we don't need this

warn "Unhandled:[$_]";
$this->unknown;

in parse function

in my case status always will be UNKNOWN

@dantyan dantyan deleted the check_lvm branch March 9, 2016 09:52
@glensc
Copy link
Owner

glensc commented Mar 9, 2016

not it's not. at least not with the perl testing using the data you gave 7e97c38.

@dantyan
Copy link
Contributor Author

dantyan commented Mar 9, 2016

now the answer of check_raid.sh looks like

Unhandled:[vg1-zoom1_rimage_1: 0 2097152 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 1.
Unhandled:[vg1-zoom1_rimage_0: 0 2097152 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 3.
Unhandled:[vg1-cache1_rmeta_1: 0 8192 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 4.
Unhandled:[vg1-cache1_rmeta_0: 0 8192 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 5.
Unhandled:[vg1-zoom1_rmeta_1: 0 8192 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 6.
Unhandled:[vg1-zoom1_rmeta_0: 0 8192 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 7.
Unhandled:[vg1-cache1_rimage_1: 0 2097152 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 8.
Unhandled:[vg1-cache1_rimage_0: 0 2097152 linear 
] at /home/dan/tmp/nagios-plugin-check_raid/lib/App/Monitoring/Plugin/CheckRaid/Plugins/dm.pm line 148, <$fh> line 10.
UNKNOWN: dm:[vg1-cache1:AA idle, vg1-zoom1:AA idle]

anyway warning brake plugin answer

@glensc
Copy link
Owner

glensc commented Mar 9, 2016

dunno. looks like you run old code.

otherwise if it is not so, could you save your dmsetup output in binary form (like gist.github.com) where you do not copy paste but send output directly to file: dmsetup > file

@dantyan
Copy link
Contributor Author

dantyan commented Mar 9, 2016

there is a space in output of dmsetup status for linear items
dmsetup status | xargs -i echo '['{}']'

[vg1-zoom1_rimage_1: 0 2097152 linear ]
[vg1-cache1: 0 2097152 raid raid1 2 AA 2097152/2097152 idle 0]
[vg1-zoom1_rimage_0: 0 2097152 linear ]
[vg1-cache1_rmeta_1: 0 8192 linear ]
[vg1-cache1_rmeta_0: 0 8192 linear ]
[vg1-zoom1_rmeta_1: 0 8192 linear ]
[vg1-zoom1_rmeta_0: 0 8192 linear ]
[vg1-cache1_rimage_1: 0 2097152 linear ]
[vg1-zoom1: 0 2097152 raid raid1 2 AA 2097152/2097152 idle 0]
[vg1-cache1_rimage_0: 0 2097152 linear ]

so regular expression doesn't work correctly

@glensc
Copy link
Owner

glensc commented Mar 9, 2016

that is why i ask you to provide output in binary form not some copy paste!

@glensc
Copy link
Owner

glensc commented Mar 9, 2016

fixed with 516c63f

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

Successfully merging this pull request may close these issues.

3 participants