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
a9dced74
Commit
a9dced74
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
reverse return code in ph.hasParamoption
parent
42b157db
No related branches found
No related tags found
1 merge request
!157
reverse return code in ph.hasParamoption
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
check_mysqlserver
+9
-8
9 additions, 8 deletions
check_mysqlserver
check_psqlserver
+13
-12
13 additions, 12 deletions
check_psqlserver
docs/20_Checks/inc_pluginfunctions.md
+5
-3
5 additions, 3 deletions
docs/20_Checks/inc_pluginfunctions.md
inc_pluginfunctions
+5
-4
5 additions, 4 deletions
inc_pluginfunctions
with
32 additions
and
27 deletions
check_mysqlserver
+
9
−
8
View file @
a9dced74
...
@@ -20,11 +20,12 @@
...
@@ -20,11 +20,12 @@
# 2021-06-24 v0.2 <axel.hahn@iml.unibe.ch> check if query cache is enabled as a shared function
# 2021-06-24 v0.2 <axel.hahn@iml.unibe.ch> check if query cache is enabled as a shared function
# 2023-06-06 v0.3 <axel.hahn@unibe.ch> some shell fixes
# 2023-06-06 v0.3 <axel.hahn@unibe.ch> some shell fixes
# 2023-07-28 v1.0 <axel.hahn@unibe.ch> update help page; fix [client]: command not found
# 2023-07-28 v1.0 <axel.hahn@unibe.ch> update help page; fix [client]: command not found
# 2023-08-30 v1.1 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# ======================================================================
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
1.
0
export
self_APPVERSION
=
1.
1
# --- set HOME
# --- set HOME
HOME
=
/etc/icingaclient
HOME
=
/etc/icingaclient
...
@@ -194,12 +195,12 @@ function _verify_cache(){
...
@@ -194,12 +195,12 @@ function _verify_cache(){
# MAIN
# MAIN
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
bOptInstall
=
$(
ph.hasParamoption
"i"
"
$@
"
)
ph.hasParamoption
"i"
"
$@
"
;
bOptInstall
=
$?
bOptUninstall
=
$(
ph.hasParamoption
"u"
"
$@
"
)
ph.hasParamoption
"u"
"
$@
"
;
bOptUninstall
=
$?
bOptHelp
=
$(
ph.hasParamoption
"h"
"
$@
"
)
ph.hasParamoption
"h"
"
$@
"
;
bOptHelp
=
$?
if
[
$bOptHelp
-eq
1
-o
$#
-lt
1
]
;
then
if
[
$bOptHelp
-eq
0
-o
$#
-lt
1
]
;
then
showHelp
echo
"
showHelp
"
exit
0
exit
0
fi
fi
...
@@ -207,7 +208,7 @@ fi
...
@@ -207,7 +208,7 @@ fi
ph.require mysql
ph.require mysql
# --- install
# --- install
if
[
$bOptInstall
-eq
1
-a
"
$(
whoami
)
"
=
"root"
]
;
then
if
[
$bOptInstall
-eq
0
-a
"
$(
whoami
)
"
=
"root"
]
;
then
if
[
-f
$cfgfile
]
;
then
if
[
-f
$cfgfile
]
;
then
ph.status
"SKIP installation. config file already exists:
$cfgfile
."
ph.status
"SKIP installation. config file already exists:
$cfgfile
."
ph.exit
ph.exit
...
@@ -223,7 +224,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then
...
@@ -223,7 +224,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then
fi
fi
# --- uninstall
# --- uninstall
if
[
$bOptUninstall
-eq
1
-a
"
$(
whoami
)
"
=
"root"
]
;
then
if
[
$bOptUninstall
-eq
0
-a
"
$(
whoami
)
"
=
"root"
]
;
then
HOME
=
/root
HOME
=
/root
_uninstall
_uninstall
...
...
This diff is collapsed.
Click to expand it.
check_psqlserver
+
13
−
12
View file @
a9dced74
...
@@ -14,17 +14,18 @@
...
@@ -14,17 +14,18 @@
# https://www.postgresql.org/docs/current/monitoring-stats.html
# https://www.postgresql.org/docs/current/monitoring-stats.html
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2023-06-07 v0.2 <axel.hahn@unibe.ch>
# 2023-06-07 v0.2 <axel.hahn@unibe.ch>
# 2023-06-08 v0.3 <axel.hahn@unibe.ch> show unknown if database connection fails
# 2023-06-08 v0.3 <axel.hahn@unibe.ch> show unknown if database connection fails
# 2023-06-08 v0.4 <axel.hahn@unibe.ch> get summary for cronflicts and problems
# 2023-06-08 v0.4 <axel.hahn@unibe.ch> get summary for cronflicts and problems
# 2023-06-09 v0.5 <axel.hahn@unibe.ch> deltaunit can be set as parameter
# 2023-06-09 v0.5 <axel.hahn@unibe.ch> deltaunit can be set as parameter
# 2023-06-13 v0.6 <axel.hahn@unibe.ch> no output on activity; update replication check
# 2023-06-13 v0.6 <axel.hahn@unibe.ch> no output on activity; update replication check
# 2023-06-16 v0.7 <axel.hahn@unibe.ch> update help text
# 2023-06-16 v0.7 <axel.hahn@unibe.ch> update help text
# 2023-08-30 v0.8 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# ======================================================================
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
0.
7
self_APPVERSION
=
0.
8
# --- other vars...
# --- other vars...
cfgfile
=
/etc/icingaclient/.psql.conf
cfgfile
=
/etc/icingaclient/.psql.conf
...
@@ -176,11 +177,11 @@ function renderCounters(){
...
@@ -176,11 +177,11 @@ function renderCounters(){
# MAIN
# MAIN
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
bOptInstall
=
$(
ph.hasParamoption
"i"
"
$@
"
)
ph.hasParamoption
"i"
"
$@
"
;
bOptInstall
=
$?
bOptUninstall
=
$(
ph.hasParamoption
"u"
"
$@
"
)
ph.hasParamoption
"u"
"
$@
"
;
bOptUninstall
=
$?
bOptHelp
=
$(
ph.hasParamoption
"h"
"
$@
"
)
ph.hasParamoption
"h"
"
$@
"
;
bOptHelp
=
$?
if
[
$bOptHelp
-eq
1
-o
$#
-lt
1
]
;
then
if
[
$bOptHelp
-eq
0
-o
$#
-lt
1
]
;
then
_usage
_usage
exit
0
exit
0
fi
fi
...
@@ -189,7 +190,7 @@ fi
...
@@ -189,7 +190,7 @@ fi
# ph.require mysql
# ph.require mysql
# --- install
# --- install
if
[
$bOptInstall
-eq
1
-a
"
$(
whoami
)
"
=
"root"
]
;
then
if
[
$bOptInstall
-eq
0
-a
"
$(
whoami
)
"
=
"root"
]
;
then
if
[
-f
$cfgfile
]
;
then
if
[
-f
$cfgfile
]
;
then
ph.status
"SKIP installation. config file already exists:
$cfgfile
."
ph.status
"SKIP installation. config file already exists:
$cfgfile
."
ph.exit
ph.exit
...
@@ -203,7 +204,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then
...
@@ -203,7 +204,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then
fi
fi
# --- uninstall
# --- uninstall
if
[
$bOptUninstall
-eq
1
-a
"
$(
whoami
)
"
=
"root"
]
;
then
if
[
$bOptUninstall
-eq
0
-a
"
$(
whoami
)
"
=
"root"
]
;
then
_uninstall
_uninstall
rm
-f
$cfgfile
rm
-f
$cfgfile
...
...
This diff is collapsed.
Click to expand it.
docs/20_Checks/inc_pluginfunctions.md
+
5
−
3
View file @
a9dced74
...
@@ -186,7 +186,7 @@ This will set variable iWarnLimit based on CLI parameter -w [value] ... if it do
...
@@ -186,7 +186,7 @@ This will set variable iWarnLimit based on CLI parameter -w [value] ... if it do
### ph.hasParamoption
### ph.hasParamoption
check if a letter was used as command line option and return as 0 (=
no
) or 1 (=
yes
)
check if a letter was used as command line option and return as 0 (=
true
) or 1 (=
false
)
Syntax:
Syntax:
...
@@ -201,10 +201,12 @@ Parameters:
...
@@ -201,10 +201,12 @@ Parameters:
Example:
Example:
Show a help if command line param
``-h``
was given - or no parameter.
```
bash
```
bash
bOptHelp
=
`
ph.hasParamoption
"h"
"
$@
"
`
ph.hasParamoption
"h"
"
$@
"
;
bOptHelp
=
$?
if
[
$bOptHelp
-eq
1
-o
$#
-lt
1
]
;
then
if
[
$bOptHelp
-eq
0
-o
$#
-lt
1
]
;
then
_usage
_usage
exit
0
exit
0
fi
fi
...
...
This diff is collapsed.
Click to expand it.
inc_pluginfunctions
+
5
−
4
View file @
a9dced74
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
# 2023-05-17 v1.10 <axel.hahn@unibe.ch> ph.getOS searches in os-release first
# 2023-05-17 v1.10 <axel.hahn@unibe.ch> ph.getOS searches in os-release first
# 2023-06-22 v1.11 <axel.hahn@unibe.ch> fix ph.toUnit with float values; shell fixes
# 2023-06-22 v1.11 <axel.hahn@unibe.ch> fix ph.toUnit with float values; shell fixes
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "."
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "."
# 2023-08-30 v1.13 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# ======================================================================
# ======================================================================
...
@@ -169,13 +170,13 @@ function ph.hasParamoption(){
...
@@ -169,13 +170,13 @@ function ph.hasParamoption(){
# echo "DEBUG: testing $_sParam in ${_opt} ..."
# echo "DEBUG: testing $_sParam in ${_opt} ..."
case
"
${
_opt
}
"
in
case
"
${
_opt
}
"
in
"
$_sParam
"
)
"
$_sParam
"
)
echo
"
1
"
#
echo "
0
"
return
1
return
0
;;
;;
esac
esac
done
done
echo
"
0
"
#
echo "
1
"
return
0
return
1
}
}
...
...
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