Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
centreon
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
centreon
Commits
86def14d
Commit
86def14d
authored
Jun 4, 2018
by
Kevin Duret
Browse files
Options
Downloads
Patches
Plain Diff
fix(notification): add service linked to host to contact notifications view
Refs: #6073
parent
999196c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
www/class/centreonNotification.class.php
+32
-11
32 additions, 11 deletions
www/class/centreonNotification.class.php
with
32 additions
and
11 deletions
www/class/centreonNotification.class.php
+
32
−
11
View file @
86def14d
...
@@ -40,6 +40,7 @@ class CentreonNotification
...
@@ -40,6 +40,7 @@ class CentreonNotification
protected
$svcNotifType
;
protected
$svcNotifType
;
protected
$svcBreak
;
protected
$svcBreak
;
protected
$hostNotifType
;
protected
$hostNotifType
;
protected
$notifiedHosts
;
protected
$hostBreak
;
protected
$hostBreak
;
const
HOST
=
0
;
const
HOST
=
0
;
const
SVC
=
1
;
const
SVC
=
1
;
...
@@ -58,6 +59,7 @@ class CentreonNotification
...
@@ -58,6 +59,7 @@ class CentreonNotification
$this
->
svcNotifType
=
array
();
$this
->
svcNotifType
=
array
();
$this
->
svcBreak
=
array
(
1
=>
false
,
2
=>
false
);
$this
->
svcBreak
=
array
(
1
=>
false
,
2
=>
false
);
$this
->
hostNotifType
=
array
();
$this
->
hostNotifType
=
array
();
$this
->
notifiedHosts
=
array
();
$this
->
hostBreak
=
array
(
1
=>
false
,
2
=>
false
);
$this
->
hostBreak
=
array
(
1
=>
false
,
2
=>
false
);
}
}
...
@@ -298,11 +300,11 @@ class CentreonNotification
...
@@ -298,11 +300,11 @@ class CentreonNotification
AND chr.host_host_id = h.host_id "
;
AND chr.host_host_id = h.host_id "
;
}
}
$res
=
$this
->
db
->
query
(
$sql
);
$res
=
$this
->
db
->
query
(
$sql
);
$
hostTab
=
array
();
$
this
->
notifiedHosts
=
array
();
$templates
=
array
();
$templates
=
array
();
while
(
$row
=
$res
->
fetchRow
())
{
while
(
$row
=
$res
->
fetchRow
())
{
if
(
$row
[
'host_register'
]
==
1
)
{
if
(
$row
[
'host_register'
]
==
1
)
{
$
hostTab
[
$row
[
'host_id'
]]
=
$row
[
'host_name'
];
$
this
->
notifiedHosts
[
$row
[
'host_id'
]]
=
$row
[
'host_name'
];
}
else
{
}
else
{
$templates
[
$row
[
'host_id'
]]
=
$row
[
'host_name'
];
$templates
[
$row
[
'host_id'
]]
=
$row
[
'host_name'
];
$this
->
hostNotifType
[
$row
[
'host_id'
]]
=
$row
[
'notif_type'
];
$this
->
hostNotifType
[
$row
[
'host_id'
]]
=
$row
[
'notif_type'
];
...
@@ -310,10 +312,10 @@ class CentreonNotification
...
@@ -310,10 +312,10 @@ class CentreonNotification
}
}
unset
(
$res
);
unset
(
$res
);
if
(
count
(
$
hostTab
))
{
if
(
count
(
$
this
->
notifiedHosts
))
{
$sql2
=
"SELECT host_id, host_name
$sql2
=
"SELECT host_id, host_name
FROM host
FROM host
WHERE host_id NOT IN ("
.
implode
(
','
,
array_keys
(
$
hostTab
))
.
") AND host_register = '1'"
;
WHERE host_id NOT IN ("
.
implode
(
','
,
array_keys
(
$
this
->
notifiedHosts
))
.
") AND host_register = '1'"
;
}
else
{
}
else
{
$sql2
=
"SELECT host_id, host_name FROM host WHERE host_register = '1'"
;
$sql2
=
"SELECT host_id, host_name FROM host WHERE host_register = '1'"
;
}
}
...
@@ -321,10 +323,10 @@ class CentreonNotification
...
@@ -321,10 +323,10 @@ class CentreonNotification
while
(
$row
=
$res2
->
fetchRow
())
{
while
(
$row
=
$res2
->
fetchRow
())
{
$this
->
hostBreak
=
array
(
1
=>
false
,
2
=>
false
);
$this
->
hostBreak
=
array
(
1
=>
false
,
2
=>
false
);
if
(
$this
->
getHostTemplateNotifications
(
$row
[
'host_id'
],
$templates
)
===
true
)
{
if
(
$this
->
getHostTemplateNotifications
(
$row
[
'host_id'
],
$templates
)
===
true
)
{
$
hostTab
[
$row
[
'host_id'
]]
=
$row
[
'host_name'
];
$
this
->
notifiedHosts
[
$row
[
'host_id'
]]
=
$row
[
'host_name'
];
}
}
}
}
return
$
hostTab
;
return
$
this
->
notifiedHosts
;
}
}
/**
/**
...
@@ -379,6 +381,7 @@ class CentreonNotification
...
@@ -379,6 +381,7 @@ class CentreonNotification
LEFT JOIN host h ON h.host_id = hsr.host_host_id
LEFT JOIN host h ON h.host_id = hsr.host_host_id
WHERE csr.contact_id = "
.
$contactId
.
"
WHERE csr.contact_id = "
.
$contactId
.
"
AND csr.service_service_id = s.service_id
AND csr.service_service_id = s.service_id
AND s.service_use_only_contacts_from_host != '1'
UNION
UNION
SELECT h.host_id, h.host_name, s.service_id, s.service_description, s.service_register, 1 as notif_type
SELECT h.host_id, h.host_name, s.service_id, s.service_description, s.service_register, 1 as notif_type
FROM contact_service_relation csr, service s, host h, host_service_relation hsr, hostgroup_relation hgr
FROM contact_service_relation csr, service s, host h, host_service_relation hsr, hostgroup_relation hgr
...
@@ -386,7 +389,8 @@ class CentreonNotification
...
@@ -386,7 +389,8 @@ class CentreonNotification
AND csr.service_service_id = s.service_id
AND csr.service_service_id = s.service_id
AND s.service_id = hsr.service_service_id
AND s.service_id = hsr.service_service_id
AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id
AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id
AND hgr.host_host_id = h.host_id "
;
AND hgr.host_host_id = h.host_id
AND s.service_use_only_contacts_from_host != '1'"
;
if
(
count
(
$contactGroups
))
{
if
(
count
(
$contactGroups
))
{
$contactGroups
=
implode
(
','
,
array_keys
(
$contactGroups
));
$contactGroups
=
implode
(
','
,
array_keys
(
$contactGroups
));
...
@@ -398,6 +402,7 @@ class CentreonNotification
...
@@ -398,6 +402,7 @@ class CentreonNotification
LEFT JOIN host h ON h.host_id = hsr.host_host_id
LEFT JOIN host h ON h.host_id = hsr.host_host_id
WHERE csr.contactgroup_cg_id IN ("
.
$contactGroups
.
")
WHERE csr.contactgroup_cg_id IN ("
.
$contactGroups
.
")
AND csr.service_service_id = s.service_id
AND csr.service_service_id = s.service_id
AND s.service_use_only_contacts_from_host != '1'
UNION
UNION
SELECT h.host_id, h.host_name, s.service_id, s.service_description, s.service_register,
SELECT h.host_id, h.host_name, s.service_id, s.service_description, s.service_register,
2 as notif_type
2 as notif_type
...
@@ -407,7 +412,8 @@ class CentreonNotification
...
@@ -407,7 +412,8 @@ class CentreonNotification
AND csr.service_service_id = s.service_id
AND csr.service_service_id = s.service_id
AND s.service_id = hsr.service_service_id
AND s.service_id = hsr.service_service_id
AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id
AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id
AND hgr.host_host_id = h.host_id "
;
AND hgr.host_host_id = h.host_id
AND s.service_use_only_contacts_from_host != '1'"
;
}
}
$res
=
$this
->
db
->
query
(
$sql
);
$res
=
$this
->
db
->
query
(
$sql
);
$svcTab
=
array
();
$svcTab
=
array
();
...
@@ -429,6 +435,21 @@ class CentreonNotification
...
@@ -429,6 +435,21 @@ class CentreonNotification
}
}
unset
(
$res
);
unset
(
$res
);
if
(
count
(
$this
->
notifiedHosts
))
{
$sql
=
"SELECT h.host_id, h.host_name, s.service_id, s.service_description "
.
"FROM service s, host h, host_service_relation hsr "
.
"WHERE hsr.service_service_id = s.service_id "
.
"AND hsr.host_host_id = h.host_id "
.
"AND h.host_id IN ("
.
implode
(
','
,
array_keys
(
$this
->
notifiedHosts
))
.
")"
;
$res
=
$this
->
db
->
query
(
$sql
);
while
(
$row
=
$res
->
fetchRow
())
{
$svcTab
[
$row
[
'host_id'
]][
$row
[
'service_id'
]]
=
array
();
$svcTab
[
$row
[
'host_id'
]][
$row
[
'service_id'
]][
'host_name'
]
=
$row
[
'host_name'
];
$svcTab
[
$row
[
'host_id'
]][
$row
[
'service_id'
]][
'service_description'
]
=
$row
[
'service_description'
];
}
unset
(
$res
);
}
if
(
count
(
$svcTab
))
{
if
(
count
(
$svcTab
))
{
$tab
=
array
();
$tab
=
array
();
foreach
(
$svcTab
as
$tmp
)
{
foreach
(
$svcTab
as
$tmp
)
{
...
...
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
sign in
to comment