-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_proxmox_lv
79 lines (62 loc) · 1.5 KB
/
check_proxmox_lv
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
#!/usr/bin/perl
##################
#
# Simple Perl script to check lv on a Proxmox host
#
# Usage: check_proxmox_lv vg_name/lv_name
#
# Copyright (C) 2010 Bernd Arnold
# https://github.com/wopfel/monitoring-plugins
#
##################
use strict;
use warnings;
my $verbose = 0;
my $errors = 0;
my $warnings = 0;
if ( scalar @ARGV != 1 ) {
print "Error: only 1 argument allowed. Usage: $0 vg/lv\n";
exit 3;
}
my $vg_lv = $ARGV[0];
# Check for invalid characters
if ( $vg_lv !~ /^[-_a-z0-9]+\/[-_a-z0-9]+$/ ) {
print "Error: illegal characters in parameter found. Usage: $0 vg/lv\n";
exit 3;
}
$ENV{'LANG'} = "C";
my $output = qx/lvdisplay $vg_lv/;
print $output if $verbose;
###
( my $alloc_pool_data ) = $output =~ /^\s*Allocated pool data\s*([0-9.]+)%/m;
print "$alloc_pool_data" if $verbose;
if ( $alloc_pool_data > 90 ) {
$errors++;
} elsif ( $alloc_pool_data > 80 ) {
$warnings++;
}
###
( my $alloc_meta_data ) = $output =~ /^\s*Allocated metadata\s*([0-9.]+)%/m;
print "$alloc_meta_data" if $verbose;
if ( $alloc_meta_data > 90 ) {
$errors++;
} elsif ( $alloc_meta_data > 80 ) {
$warnings++;
}
###
if ( $errors ) {
print "CRITICAL: ";
} elsif ( $warnings) {
print "WARNING: ";
} else {
print "OK: ";
}
print "LV $vg_lv. Allocated pool data $alloc_pool_data %, metadata $alloc_meta_data %. ";
print "| alloc_pool_data_pct=$alloc_pool_data alloc_meta_data_pct=$alloc_meta_data\n";
if ( $errors ) {
exit 2;
} elsif ( $warnings) {
exit 1;
} else {
exit 0;
}