Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CSD
public
zabbix-templates
Commits
647dcd0d
Commit
647dcd0d
authored
Nov 16, 2017
by
Fulvio Galeazzi
Browse files
2017-11-16: FG; Added OSD in/out up/down.
parent
9ea49a6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Ceph/Config/userparameter_ceph.conf
View file @
647dcd0d
...
...
@@ -11,6 +11,10 @@ UserParameter=ceph.global.slowosd[*],/etc/zabbix/scripts/cephHealth.pl $1 --slow
UserParameter
=
ceph
.
global
.
slowreq
[*],/
etc
/
zabbix
/
scripts
/
cephHealth
.
pl
$
1
--
slowreq
UserParameter
=
ceph
.
osd
.
nearfull
[*],/
etc
/
zabbix
/
scripts
/
cephHealth
.
pl
$
1
--
nearfull
UserParameter
=
ceph
.
osd
.
full
[*],/
etc
/
zabbix
/
scripts
/
cephHealth
.
pl
$
1
--
full
UserParameter
=
ceph
.
osd
.
down
[*],/
etc
/
zabbix
/
scripts
/
cephOsdStat
.
pl
$
1
-
s
down
UserParameter
=
ceph
.
osd
.
up
[*],/
etc
/
zabbix
/
scripts
/
cephOsdStat
.
pl
$
1
-
s
up
UserParameter
=
ceph
.
osd
.
out
[*],/
etc
/
zabbix
/
scripts
/
cephOsdStat
.
pl
$
1
-
s
out
UserParameter
=
ceph
.
osd
.
in
[*],/
etc
/
zabbix
/
scripts
/
cephOsdStat
.
pl
$
1
-
s
in
# Pools
UserParameter
=
ceph
.
pool
.
num
[*],/
etc
/
zabbix
/
scripts
/
queryCephPools
.
pl
$
1
UserParameter
=
ceph
.
pool
.
discovery
[*],/
etc
/
zabbix
/
scripts
/
queryCephPools
.
pl
$
1
-
j
...
...
Ceph/Script/cephOsdStat.pl
0 → 100755
View file @
647dcd0d
#!/usr/bin/perl
################################################################################
# cephOsdStat.pl - Return number of disks up/down in/out
################################################################################
#
# This script executes 'ceph osd dump' and returns number of disks which
# are up,down in,out or all of these information if flag --all is used.
#
# cephOsdStat.pl -s in # return number of disks which are 'in'
# cephOsdStat.pl -s all # return blank-tabbed list of all possible states (for debugging)
#
# Originator:
# 2017-11-16: Fulvio Galeazzi (Consortium GARR)
# Contributors:
#
################################################################################
use
strict
;
use
warnings
;
use
Getopt::
Long
;
sub
fail_usage
{
my
(
$msg
)
=
@_
;
print
STDERR
$msg
.
"
\n
"
if
$msg
;
print
STDERR
"
Please use '-h' for usage.
\n
";
exit
1
;
}
my
$_sudo
=
`
which sudo
`;
chomp
$_sudo
;
### Options
our
(
$opt_exec
,
$opt_become
,
$opt_cluster
,
$opt_user
,
$opt_keyring
,
$opt_monhost
,
$opt_state
,
$opt_debug
,
$opt_h
);
if
(
@ARGV
>
0
)
{
GetOptions
("
e=s
"
=>\
$opt_exec
,
"
b
"
=>\
$opt_become
,
"
c=s
"
=>\
$opt_cluster
,
"
u=s
"
=>\
$opt_user
,
"
k=s
"
=>\
$opt_keyring
,
"
m=s
"
=>\
$opt_monhost
,
"
s=s
"
=>\
$opt_state
,
"
d
"
=>\
$opt_debug
,
"
h
"
=>\
$opt_h
)
||
fail_usage
;
}
fail_usage
"
Unknown parameter.
"
if
(
@ARGV
>
0
);
my
$cephCmd
=
"";
if
(
defined
$opt_exec
)
{
$cephCmd
=
"
$opt_exec
";
}
else
{
$cephCmd
=
"
/usr/bin/ceph
";
}
if
(
!
-
e
$cephCmd
)
{
die
"
Executable
$cephCmd
not found!
";
}
if
(
defined
$opt_become
)
{
$cephCmd
=
"
$_sudo
$cephCmd
";
}
#
if
(
defined
$opt_cluster
)
{
$cephCmd
.=
"
--cluster
$opt_cluster
";
}
if
(
defined
$opt_user
)
{
$cephCmd
.=
"
--user
$opt_user
";
}
if
(
defined
$opt_keyring
)
{
$cephCmd
.=
"
--keyring
$opt_keyring
";
}
if
(
defined
$opt_monhost
)
{
$cephCmd
.=
"
-m
$opt_monhost
";
}
#
if
(
not
defined
$opt_state
)
{
fail_usage
"
Please use '-s <desired_state>' or '-s all' flag.
";
}
my
$wantAll
=
0
;
if
(
defined
$opt_state
&&
$opt_state
=~
/^all$/
)
{
$wantAll
=
1
;
}
my
%statesHash
=
(
'
down
'
=>
0
,
'
up
'
=>
0
,
'
in
'
=>
0
,
'
out
'
=>
0
,
);
# Fetch the data and put it in an array
my
@_data
=
`
$cephCmd
osd dump
`;
chomp
@_data
;
# Read the array and print the wanted data
foreach
my
$_line
(
@_data
)
{
if
(
$_line
=~
m/^osd\.\d+\s+(\w+)\s+(\w+)/
)
{
my
$updown
=
$
1
;
my
$inout
=
$
2
;
$statesHash
{
$updown
}
=
$statesHash
{
$updown
}
+
1
;
$statesHash
{
$inout
}
=
$statesHash
{
$inout
}
+
1
;
}
}
if
(
$wantAll
)
{
my
$line
=
"
ALL:
";
foreach
my
$akey
(
sort
keys
%statesHash
)
{
$line
.=
"
"
.
$akey
.
"
:
"
.
$statesHash
{
$akey
};
}
print
$line
.
"
\n
";
}
else
{
if
(
defined
$statesHash
{
$opt_state
})
{
print
$statesHash
{
$opt_state
}
.
"
\n
";
}
else
{
print
"
-1
\n
";
}
}
exit
0
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment