Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
56f550a4
Commit
56f550a4
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
detect failed and unknown vms
parent
cb615a66
No related branches found
No related tags found
1 merge request
!105
detect failed and unknown vms
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_onevm
+22
-6
22 additions, 6 deletions
check_onevm
with
22 additions
and
6 deletions
check_onevm
100644 → 100755
+
22
−
6
View file @
56f550a4
...
@@ -3,8 +3,7 @@
...
@@ -3,8 +3,7 @@
#
#
# Check ONEVM
# Check ONEVM
# show virtual machines
# show virtual machines
#
## requirements:
# requirements:
# - sudo onevm
# - sudo onevm
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -57,7 +56,10 @@ v$self_APPVERSION
...
@@ -57,7 +56,10 @@ v$self_APPVERSION
Licence: GNU GPL 3
Licence: GNU GPL 3
______________________________________________________________________
______________________________________________________________________
show count of vms in OpenNebula
Show count of vms in OpenNebula - listed by state and by host.
It will go to warning if a non running state was found.
It will go to critical if a vm is on failure.
SYNTAX:
SYNTAX:
$(
basename
$0
)
$(
basename
$0
)
...
@@ -98,7 +100,7 @@ cmdout=$( sudo onevm list --csv 2>&1 )
...
@@ -98,7 +100,7 @@ cmdout=$( sudo onevm list --csv 2>&1 )
if
!
grep
"ID,USER"
<<<
"
$cmdout
"
>
/dev/null
;
then
if
!
grep
"ID,USER"
<<<
"
$cmdout
"
>
/dev/null
;
then
ph.setStatus
"unknown"
ph.setStatus
"unknown"
echo
"UNKNOWN: sudo one
host
failed."
echo
"UNKNOWN: sudo one
vm
failed."
echo
"
$cmdout
"
echo
"
$cmdout
"
ph.exit
ph.exit
fi
fi
...
@@ -111,17 +113,31 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' )
...
@@ -111,17 +113,31 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' )
out
=
""
out
=
""
typeset
-i
iTotal
;
iTotal
=
$(
echo
"
$csvdata
"
|
wc
-l
)
typeset
-i
iTotal
;
iTotal
=
$(
echo
"
$csvdata
"
|
wc
-l
)
typeset
-i
iRunning
;
iRunning
=
$(
echo
"
$csvdata
"
|
grep
-c
",runn,"
)
typeset
-i
iRunning
;
iRunning
=
$(
echo
"
$csvdata
"
|
grep
-c
",runn,"
)
typeset
-i
iOther
;
iOther
=
$iTotal
-
$iRunning
typeset
-i
iFail
;
iFail
=
$(
echo
"
$csvdata
"
|
grep
-c
",fail,"
)
typeset
-i
iUnknown
;
iUnknown
=
$(
echo
"
$csvdata
"
|
grep
-c
",unkn,"
)
typeset
-i
iOther
;
iOther
=
$iTotal
-
$iRunning
-
$iFail
-
$iUnknown
ph.perfadd
"total"
"
${
iTotal
}
"
ph.perfadd
"total"
"
${
iTotal
}
"
ph.perfadd
"running"
"
${
iRunning
}
"
ph.perfadd
"running"
"
${
iRunning
}
"
ph.perfadd
"other"
"
${
iOther
}
"
ph.perfadd
"fail"
"
${
iFail
}
"
ph.perfadd
"unknown"
"
${
iUnknown
}
"
ph.perfadd
"other"
"
${
iOther
}
"
if
[
$iUnknown
-ne
0
]
;
then
ps.setStatus
"warning"
out+
=
"WARNING: a vm with status [Unknown] was found."
fi
if
[
$iOther
-ne
0
]
;
then
if
[
$iOther
-ne
0
]
;
then
ps.setStatus
"warning"
ps.setStatus
"warning"
out+
=
"WARNING: There is a VM that has another status than [running]."
out+
=
"WARNING: There is a VM that has another status than [running]."
fi
fi
if
[
$iFail
-ne
0
]
;
then
ps.setStatus
"critical"
out+
=
"ERROR: a vm with status [Failed] was found."
fi
out+
=
$(
out+
=
$(
echo
'>>>>>> By state'
echo
'>>>>>> By state'
grep
"^# STAT:"
"
$0
"
|
while
read
-r
line
grep
"^# STAT:"
"
$0
"
|
while
read
-r
line
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment