Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
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
Imldeployment
Commits
104da9f7
Commit
104da9f7
authored
6 years ago
by
hahn
Browse files
Options
Downloads
Patches
Plain Diff
update appmonitor; add ssl check
parent
e4e5a93e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/appmonitor/classes/appmonitor-checks.class.php
+11
-13
11 additions, 13 deletions
public_html/appmonitor/classes/appmonitor-checks.class.php
public_html/appmonitor/index.php
+14
-0
14 additions, 0 deletions
public_html/appmonitor/index.php
with
25 additions
and
13 deletions
public_html/appmonitor/classes/appmonitor-checks.class.php
+
11
−
13
View file @
104da9f7
...
@@ -249,7 +249,7 @@ class appmonitorcheck {
...
@@ -249,7 +249,7 @@ class appmonitorcheck {
;
;
$iWarn
=
isset
(
$aParams
[
"warning"
])
?
(
int
)(
$aParams
[
"warning"
])
:
30
;
$iWarn
=
isset
(
$aParams
[
"warning"
])
?
(
int
)(
$aParams
[
"warning"
])
:
30
;
$sMessage
=
"url
$sUrl
... "
;
$sMessage
=
"
Checked
url
:
$sUrl
... "
;
$certinfo
=
$this
->
_certGetInfos
(
$sUrl
);
$certinfo
=
$this
->
_certGetInfos
(
$sUrl
);
if
(
isset
(
$certinfo
[
'_error'
])){
if
(
isset
(
$certinfo
[
'_error'
])){
$this
->
_setReturn
(
RESULT_ERROR
,
$certinfo
[
'_error'
]
.
$sMessage
);
$this
->
_setReturn
(
RESULT_ERROR
,
$certinfo
[
'_error'
]
.
$sMessage
);
...
@@ -270,15 +270,15 @@ class appmonitorcheck {
...
@@ -270,15 +270,15 @@ class appmonitorcheck {
.
(
$iDaysleft
?
"(
$iDaysleft
days left)"
:
"expired since "
.
(
-
$iDaysleft
)
.
" days."
)
.
(
$iDaysleft
?
"(
$iDaysleft
days left)"
:
"expired since "
.
(
-
$iDaysleft
)
.
" days."
)
;
;
if
(
$iDaysleft
<
0
)
{
if
(
$iDaysleft
<
0
)
{
$this
->
_setReturn
(
RESULT_ERROR
,
'Expired '
.
$sMessage
);
$this
->
_setReturn
(
RESULT_ERROR
,
'Expired
!
'
.
$sMessage
);
return
true
;
return
true
;
}
}
if
(
$iDaysleft
<=
$iWarn
)
{
if
(
$iDaysleft
<=
$iWarn
)
{
$this
->
_setReturn
(
RESULT_WARNING
,
'Expires soon '
.
$sMessage
);
$this
->
_setReturn
(
RESULT_WARNING
,
'Expires soon
.
'
.
$sMessage
);
return
true
;
return
true
;
}
}
// echo '<pre>';
// echo '<pre>';
$this
->
_setReturn
(
RESULT_OK
,
'OK, is valid '
.
$sMessage
);
$this
->
_setReturn
(
RESULT_OK
,
'OK, is valid
.
'
.
$sMessage
);
return
true
;
return
true
;
}
}
...
@@ -448,7 +448,7 @@ class appmonitorcheck {
...
@@ -448,7 +448,7 @@ class appmonitorcheck {
}
}
/**
/**
* check mysql connection to a database
* check mysql connection to a database
using mysqli
* @param array $aParams
* @param array $aParams
* array(
* array(
* "server"
* "server"
...
@@ -460,12 +460,10 @@ class appmonitorcheck {
...
@@ -460,12 +460,10 @@ class appmonitorcheck {
*/
*/
private
function
checkMysqlConnect
(
$aParams
)
{
private
function
checkMysqlConnect
(
$aParams
)
{
$this
->
_checkArrayKeys
(
$aParams
,
"server,user,password,db"
);
$this
->
_checkArrayKeys
(
$aParams
,
"server,user,password,db"
);
if
(
!
isset
(
$aParams
[
"port"
]))
{
$db
=
(
isset
(
$aParams
[
"port"
])
&&
$aParams
[
"port"
])
$aParams
[
"port"
]
=
false
;
?
mysqli_connect
(
$aParams
[
"server"
],
$aParams
[
"user"
],
$aParams
[
"password"
],
$aParams
[
"db"
],
$aParams
[
"port"
])
}
:
mysqli_connect
(
$aParams
[
"server"
],
$aParams
[
"user"
],
$aParams
[
"password"
],
$aParams
[
"db"
])
$db
=
mysqli_connect
(
;
$aParams
[
"server"
],
$aParams
[
"user"
],
$aParams
[
"password"
],
$aParams
[
"db"
],
$aParams
[
"port"
]
);
if
(
$db
)
{
if
(
$db
)
{
$this
->
_setReturn
(
RESULT_OK
,
"OK: Mysql database "
.
$aParams
[
"db"
]
.
" was connected"
);
$this
->
_setReturn
(
RESULT_OK
,
"OK: Mysql database "
.
$aParams
[
"db"
]
.
" was connected"
);
mysqli_close
(
$db
);
mysqli_close
(
$db
);
...
@@ -544,8 +542,8 @@ class appmonitorcheck {
...
@@ -544,8 +542,8 @@ class appmonitorcheck {
$o
=
new
PDO
(
"sqlite:"
.
$aParams
[
"db"
]);
$o
=
new
PDO
(
"sqlite:"
.
$aParams
[
"db"
]);
$this
->
_setReturn
(
RESULT_OK
,
"OK: Sqlite database "
.
$aParams
[
"db"
]
.
" was connected"
);
$this
->
_setReturn
(
RESULT_OK
,
"OK: Sqlite database "
.
$aParams
[
"db"
]
.
" was connected"
);
return
true
;
return
true
;
}
catch
(
Exception
$e
xc
)
{
}
catch
(
Exception
$e
)
{
$this
->
_setReturn
(
RESULT_ERROR
,
"ERROR: Sqlite database "
.
$aParams
[
"db"
]
.
" was not connected. "
.
mysqli_connect_error
());
$this
->
_setReturn
(
RESULT_ERROR
,
"ERROR: Sqlite database "
.
$aParams
[
"db"
]
.
" was not connected. "
.
$e
->
getMessage
());
return
false
;
return
false
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
public_html/appmonitor/index.php
+
14
−
0
View file @
104da9f7
...
@@ -131,6 +131,20 @@ $oMonitor->addCheck(
...
@@ -131,6 +131,20 @@ $oMonitor->addCheck(
)
)
);
);
// ----------------------------------------------------------------------
// ssl cert
// ----------------------------------------------------------------------
if
(
isset
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]){
$oMonitor
->
addCheck
(
array
(
"name"
=>
"Certificate check"
,
"description"
=>
"Check if SSL cert is valid and does not expire soon"
,
"check"
=>
array
(
"function"
=>
"Cert"
,
),
)
);
}
// Gesamt-Ergebnis - ohne Param=aut. max. Wert nehmen
// Gesamt-Ergebnis - ohne Param=aut. max. Wert nehmen
$oMonitor
->
setResult
();
$oMonitor
->
setResult
();
...
...
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