Merge remote-tracking branch 'origin/develop' into ent-9662-second-round
Conflicts: pandora_console/extras/mr/62.sql
This commit is contained in:
commit
cec81f1cc2
|
@ -6,21 +6,22 @@
|
|||
#
|
||||
# (c) A. Kevin Rojas <kevin.rojas@pandorafms.com>
|
||||
#
|
||||
# Edited in 2023 by Alejandro Sánchez <alejandro.sanchez@pandorafms.com>
|
||||
#
|
||||
# TO DO LIST:
|
||||
# - Enable child services detection (Windows)
|
||||
# - Make CPU/Memory usage available for child services (Windows)
|
||||
#
|
||||
###################################################
|
||||
|
||||
try:
|
||||
from sys import argv
|
||||
from sys import stderr
|
||||
from sys import exit
|
||||
import psutil
|
||||
from subprocess import Popen
|
||||
from subprocess import PIPE
|
||||
from subprocess import DEVNULL
|
||||
from subprocess import getstatusoutput
|
||||
import psutil
|
||||
except ModuleNotFoundError as err:
|
||||
print("{} error: {}. Exiting...".format(argv[0], err), file=stderr)
|
||||
exit(1)
|
||||
|
@ -28,99 +29,100 @@ except ModuleNotFoundError as err:
|
|||
module_list = []
|
||||
VERSION = "1.2"
|
||||
|
||||
def win_service(servicelist, option=False, memcpu=False):
|
||||
|
||||
#########################################################################################
|
||||
# Powershell class
|
||||
#########################################################################################
|
||||
class PSCheck:
|
||||
@staticmethod
|
||||
def check_service(servicename, option=False, memcpu=False):
|
||||
"""Check services with powershell by parsing their DisplayName. Returns a dict\
|
||||
list with the name of the service and a boolean with its status.\n
|
||||
Requires service name (case insensitive)."""
|
||||
pscall = Popen(["powershell", "Get-Service", "-Name", "'*"+ str(servicename) + "*'",
|
||||
"|", "Select-Object", "-ExpandProperty", "Name"],
|
||||
stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
|
||||
result = pscall.communicate()
|
||||
result = str(result[0]).strip().split("\n")
|
||||
procname = ''
|
||||
if result != '':
|
||||
output = []
|
||||
for element in result:
|
||||
if element != '':
|
||||
# Get process name
|
||||
procname = PSCheck.get_serviceprocess(element)
|
||||
# Get process status
|
||||
parstatus = PSCheck.getstatus(element)
|
||||
if memcpu and parstatus == 1:
|
||||
usage = get_memcpu(str(procname), str(element))
|
||||
output += usage
|
||||
# Generate module with name and status
|
||||
parent = service_module(str(element), parstatus)
|
||||
output += parent
|
||||
if option:
|
||||
children = PSCheck.getchildren(element, memcpu)
|
||||
if isinstance(children, list) and len(children) > 1:
|
||||
for child in children:
|
||||
output += child
|
||||
else:
|
||||
output += children
|
||||
else:
|
||||
next
|
||||
|
||||
if output and element and procname:
|
||||
return ({"name" : element, "process" : procname, "modules": output})
|
||||
modules_default = []
|
||||
modules_percentage=[]
|
||||
## take all services
|
||||
services=psutil.win_service_iter()
|
||||
for service in services:
|
||||
if service.name() in servicelist:
|
||||
serv=service.as_dict()
|
||||
if serv['status']=='running':
|
||||
value=1
|
||||
else:
|
||||
return (None)
|
||||
value=0
|
||||
|
||||
@staticmethod
|
||||
def getchildren(servicename, memcpu=False):
|
||||
"""Gets Dependent services of a given Windows service"""
|
||||
pschild = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) +
|
||||
"' -DS", "|", "Select-Object", "-ExpandProperty", "Name"],
|
||||
stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
|
||||
children = pschild.communicate()[0].strip()
|
||||
kids = []
|
||||
for child in (children.split("\n") if children != "" else []):
|
||||
status = PSCheck.getstatus(child)
|
||||
kids += service_module(str(child), status, "Service " + str(servicename) + " - Status")
|
||||
if status:
|
||||
if memcpu:
|
||||
kidsusage = get_memcpu(str(child))
|
||||
for usage in kidsusage:
|
||||
kids += usage
|
||||
## create module for each service
|
||||
parent = build_module("Service " + str(serv['name']) + " - Status", value,"generic_proc")
|
||||
modules_default +=parent
|
||||
|
||||
# memory and cpu percentage
|
||||
if memcpu:
|
||||
## process
|
||||
srv_pid = service.pid()
|
||||
process = psutil.Process(srv_pid)
|
||||
proc_name = process.name()
|
||||
##cpu
|
||||
value_cpu=process.cpu_percent(interval=0.5)
|
||||
parent = build_module("Service " + str(proc_name) + " - CPU usage", value_cpu,"generic_data")
|
||||
parent[0].update([("unit","%"),("module_parent",str(serv['name']))])
|
||||
modules_percentage +=parent
|
||||
##mem
|
||||
value_mem=process.memory_percent()
|
||||
parent = build_module("Service " + str(proc_name) + " - Memory usage", value_mem,"generic_data")
|
||||
parent[0].update([("unit","%"),("module_parent",str(serv['name']))])
|
||||
modules_percentage +=parent
|
||||
|
||||
|
||||
for module in modules_default:
|
||||
print_module(module, 1)
|
||||
if memcpu:
|
||||
for module in modules_percentage:
|
||||
print_module(module, 1)
|
||||
|
||||
def lnx_service(services_list, memcpu=False):
|
||||
"""Creates modules for Linux servers"""
|
||||
modules = []
|
||||
sysctl = getstatusoutput("command -v systemctl")[0]
|
||||
servic = getstatusoutput("command -v service")[0]
|
||||
for srvc in services_list:
|
||||
status = None
|
||||
if sysctl == 0:
|
||||
### Systemd available
|
||||
syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE,
|
||||
stdin=DEVNULL, universal_newlines=True)
|
||||
result = syscall.communicate()
|
||||
srvstatus = result[0].strip().lower().split("\n")
|
||||
if srvstatus[0] == "loadstate=not-found":
|
||||
next
|
||||
else:
|
||||
if srvstatus[1] == "activestate=active":
|
||||
modules += build_module("Service " + srvc + " - Status", 1, "generic_proc")
|
||||
status = 1
|
||||
elif srvstatus[1] == "activestate=inactive":
|
||||
modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc")
|
||||
status = 0
|
||||
elif sysctl != 0 and servic == 0:
|
||||
### Systemd not available, switch to service command
|
||||
syscall = Popen(["service", srvc, "status"], stdout=PIPE,
|
||||
stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
|
||||
result = syscall.communicate()[0].lower()
|
||||
if "is running" in result:
|
||||
modules += build_module("Service " + srvc + " - Status", 1, "generic_proc")
|
||||
status = 1
|
||||
elif "is stopped" in result:
|
||||
modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc")
|
||||
status = 0
|
||||
else:
|
||||
next
|
||||
return kids
|
||||
|
||||
@staticmethod
|
||||
def getstatus(servicename):
|
||||
"""Gets the status of a given Windows service"""
|
||||
running = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) +
|
||||
"' |", "Select-Object", "-ExpandProperty", "Status"],
|
||||
stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
|
||||
status = running.communicate()[0].strip()
|
||||
return int(status == "Running")
|
||||
|
||||
@staticmethod
|
||||
def get_serviceprocess(servicename):
|
||||
"""Gets name of the process of the service"""
|
||||
service = psutil.win_service_get(servicename)
|
||||
srv_pid = service.pid()
|
||||
process = psutil.Process(srv_pid)
|
||||
proc_name = process.name()
|
||||
return proc_name
|
||||
else:
|
||||
print("No systemd or service commands available. Exiting...", file=stderr)
|
||||
exit()
|
||||
if status:
|
||||
module_list.append(srvc)
|
||||
if memcpu:
|
||||
modules += get_memcpu(srvc, None)
|
||||
|
||||
for m in modules:
|
||||
print_module(m, 1)
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Services creation
|
||||
#########################################################################################
|
||||
|
||||
def service_module(name, value, parent=None):
|
||||
def build_module(name, value, module_type, parent=None):
|
||||
#print ("service_module BEGIN "+str(now(0,1)))
|
||||
module = [{
|
||||
"name" : "Service "+ name + " - Status",
|
||||
"type" : "generic_proc",
|
||||
"name" : name ,
|
||||
"type" : module_type,
|
||||
"value" : value,
|
||||
"module_parent" : parent,
|
||||
}]
|
||||
|
@ -167,74 +169,6 @@ def proc_percentbyname(procname): ############# 03/03/2020
|
|||
next
|
||||
#print ("proc_percentbyname END "+str(now(0,1)))
|
||||
return [sum(memory),sum(cpu)]
|
||||
|
||||
def win_service(servicelist, option=False, memcpu=False):
|
||||
"""Creates modules for Windows servers."""
|
||||
modules = []
|
||||
for srvc in servicelist:
|
||||
if srvc and len(srvc) > 2:
|
||||
output = PSCheck.check_service(srvc, option, memcpu)
|
||||
if output is not None and output["modules"]:
|
||||
modules += PSCheck.check_service(srvc.strip(), option, memcpu)["modules"]
|
||||
module_list.append(srvc)
|
||||
#winprocess = output["name"]
|
||||
#if memcpu == True:
|
||||
# modules += get_memcpu(winprocess) ## Only available for parent service ATM.
|
||||
else:
|
||||
next
|
||||
else:
|
||||
next
|
||||
for module in modules:
|
||||
print_module(module, 1)
|
||||
|
||||
|
||||
def lnx_service(services_list, memcpu=False):
|
||||
"""Creates modules for Linux servers"""
|
||||
modules = []
|
||||
sysctl = getstatusoutput("command -v systemctl")[0]
|
||||
servic = getstatusoutput("command -v service")[0]
|
||||
for srvc in services_list:
|
||||
status = None
|
||||
if sysctl == 0:
|
||||
### Systemd available
|
||||
syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE,
|
||||
stdin=DEVNULL, universal_newlines=True)
|
||||
result = syscall.communicate()
|
||||
srvstatus = result[0].strip().lower().split("\n")
|
||||
if srvstatus[0] == "loadstate=not-found":
|
||||
next
|
||||
else:
|
||||
if srvstatus[1] == "activestate=active":
|
||||
modules += service_module(srvc, 1)
|
||||
status = 1
|
||||
elif srvstatus[1] == "activestate=inactive":
|
||||
modules += service_module(srvc, 0)
|
||||
status = 0
|
||||
elif sysctl != 0 and servic == 0:
|
||||
### Systemd not available, switch to service command
|
||||
syscall = Popen(["service", srvc, "status"], stdout=PIPE,
|
||||
stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True)
|
||||
result = syscall.communicate()[0].lower()
|
||||
if "is running" in result:
|
||||
modules += service_module(srvc, 1)
|
||||
status = 1
|
||||
elif "is stopped" in result:
|
||||
modules += service_module(srvc, 0)
|
||||
status = 0
|
||||
else:
|
||||
next
|
||||
else:
|
||||
print("No systemd or service commands available. Exiting...", file=stderr)
|
||||
exit()
|
||||
if status:
|
||||
module_list.append(srvc)
|
||||
if memcpu:
|
||||
modules += get_memcpu(srvc, None)
|
||||
|
||||
for m in modules:
|
||||
print_module(m, 1)
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# print_module function
|
||||
#########################################################################################
|
||||
|
@ -356,6 +290,7 @@ def main():
|
|||
service_list = ["MySQL", "postgresql", "pgsql", "oracle", "MSSQL", "IISADMIN",
|
||||
"apache", "nginx", "W3svc", "NTDS", "Netlogon", "DNS", "MSExchangeADTopology",
|
||||
"MSExchangeServiceHost", "MSExchangeSA", "MSExchangeTransport"]
|
||||
|
||||
discover(OS, service_list)
|
||||
elif psutil.LINUX:
|
||||
OS = "Linux"
|
||||
|
|
|
@ -157,4 +157,13 @@ INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`, `filename`, `path`) VALUES
|
|||
|
||||
ALTER TABLE `tusuario` ADD COLUMN `show_tips_startup` TINYINT UNSIGNED NOT NULL DEFAULT 1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tfavmenu_user` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`id_user` VARCHAR(255) NOT NULL,
|
||||
`id_element` TEXT,
|
||||
`url` TEXT NOT NULL,
|
||||
`label` VARCHAR(255) NOT NULL,
|
||||
`section` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id`));
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -827,6 +827,12 @@ if ($id_agente) {
|
|||
'link' => '',
|
||||
'label' => $tab_name,
|
||||
],
|
||||
],
|
||||
[
|
||||
'id_element' => $id_agente,
|
||||
'url' => 'godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente,
|
||||
'label' => agents_get_alias($id_agente),
|
||||
'section' => 'Agents',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -59,6 +59,14 @@ if ($delete) {
|
|||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id_filter,
|
||||
'section' => 'Events',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
|
|
|
@ -714,6 +714,14 @@ if ($is_management_allowed === true
|
|||
);
|
||||
|
||||
if ($result && (!$usedGroup['return'])) {
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id_group,
|
||||
'section' => 'Tactic_group',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
ui_print_success_message(__('Group successfully deleted'));
|
||||
} else {
|
||||
ui_print_error_message(
|
||||
|
|
|
@ -74,6 +74,12 @@ if (is_metaconsole() === false) {
|
|||
'link' => '',
|
||||
'label' => __('Tactic group'),
|
||||
],
|
||||
],
|
||||
[
|
||||
'id_element' => $id_group,
|
||||
'url' => 'gagent&sec2=godmode/groups/tactical&id_group='.$id_group,
|
||||
'label' => groups_get_name($id_group),
|
||||
'section' => 'Tactic_group',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -189,6 +189,14 @@ if ($delete_layout || $copy_layout) {
|
|||
'tlayout',
|
||||
['id' => $id_layout]
|
||||
);
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id_layout,
|
||||
'section' => 'Visual_Console',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
|
||||
$auditMessage = ((bool) $result === true) ? 'Delete visual console' : 'Fail try to delete visual console';
|
||||
db_pandora_audit(
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 61.2 (89653) - https://sketch.com -->
|
||||
<title>Dark / 20 / star@svg</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="Dark-/-20-/-star" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M10,16.5 L5.32783438,18.9563028 C4.83898979,19.2133036 4.23436264,19.0253571 3.97736183,18.5365125 C3.87502276,18.3418521 3.83970808,18.118884 3.87688493,17.9021263 L4.76918916,12.6995935 L4.76918916,12.6995935 L0.989327772,9.01513923 C0.593844194,8.62963801 0.585751887,7.99652475 0.971253099,7.60104117 C1.1247617,7.44355754 1.32590411,7.34107036 1.54354115,7.30944585 L6.76718111,6.55040653 L6.76718111,6.55040653 L9.10326392,1.81698575 C9.34768622,1.32173209 9.94731205,1.11839309 10.4425657,1.36281539 C10.6397783,1.46014562 10.7994058,1.61977315 10.8967361,1.81698575 L13.2328189,6.55040653 L13.2328189,6.55040653 L18.4564589,7.30944585 C19.0030037,7.38886347 19.3816852,7.89630632 19.3022676,8.44285118 C19.270643,8.66048821 19.1681559,8.86163062 19.0106722,9.01513923 L15.2308108,12.6995935 L15.2308108,12.6995935 L16.1231151,17.9021263 C16.2164761,18.4464628 15.8508883,18.9634187 15.3065518,19.0567797 C15.0897942,19.0939566 14.8668261,19.0586419 14.6721656,18.9563028 L10,16.5 L10,16.5 Z" id="Star" fill="#a6adb2"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 581 B |
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* Fav menu
|
||||
*
|
||||
* @category Ajax library.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Modules.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
// Login check
|
||||
check_login();
|
||||
|
||||
if (is_ajax() === false) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_element = get_parameter('id_element', '');
|
||||
$url = io_safe_output(get_parameter('url', ''));
|
||||
$label = get_parameter('label', '');
|
||||
$section = get_parameter('section', '');
|
||||
$id_user = $config['id_user'];
|
||||
|
||||
$exist = db_get_row_filter(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'url' => $url,
|
||||
'id_user' => $config['id_user'],
|
||||
],
|
||||
['*']
|
||||
);
|
||||
$res = false;
|
||||
$action = '';
|
||||
if ($exist !== false) {
|
||||
$res = db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'url' => $url,
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
$action = 'delete';
|
||||
} else {
|
||||
$res = db_process_sql_insert(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id_element,
|
||||
'url' => $url,
|
||||
'label' => $label,
|
||||
'section' => $section,
|
||||
'id_user' => $id_user,
|
||||
]
|
||||
);
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if ($res !== false) {
|
||||
echo json_encode(['success' => true, 'action' => $action]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'action' => $action]);
|
||||
}
|
|
@ -2044,6 +2044,14 @@ if (check_login()) {
|
|||
if ($monitor_filters === false) {
|
||||
echo 'error';
|
||||
} else {
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id,
|
||||
'section' => 'Modules',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
echo 'ok';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2769,6 +2769,16 @@ function agents_delete_agent($id_agents, $disableACL=false)
|
|||
enterprise_include_once('include/functions_agents.php');
|
||||
enterprise_hook('agent_delete_from_cache', [$id_agent]);
|
||||
|
||||
// Delete agent from fav menu.
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id_agent,
|
||||
'section' => 'Agents',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
|
||||
// Break the loop on error.
|
||||
if ((bool) $error === true) {
|
||||
break;
|
||||
|
|
|
@ -221,6 +221,8 @@ function reports_update_report($id_report, $values)
|
|||
*/
|
||||
function reports_delete_report($id_report)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$id_report = safe_int($id_report);
|
||||
if (empty($id_report)) {
|
||||
return false;
|
||||
|
@ -231,6 +233,16 @@ function reports_delete_report($id_report)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Delete report from fav menu.
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id_report,
|
||||
'section' => 'Reporting',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
|
||||
@db_process_sql_delete('treport_content', ['id_report' => $id_report]);
|
||||
return @db_process_sql_delete('treport', ['id_report' => $id_report]);
|
||||
}
|
||||
|
|
|
@ -4998,7 +4998,8 @@ function ui_print_standard_header(
|
|||
string $help='',
|
||||
bool $godmode=false,
|
||||
array $options=[],
|
||||
array $breadcrumbs=[]
|
||||
array $breadcrumbs=[],
|
||||
array $fav_menu_config=[]
|
||||
) {
|
||||
// For standard breadcrumbs.
|
||||
ui_require_css_file('discovery');
|
||||
|
@ -5042,7 +5043,9 @@ function ui_print_standard_header(
|
|||
'',
|
||||
GENERIC_SIZE_TEXT,
|
||||
'',
|
||||
$headerInformation->printHeader(true)
|
||||
$headerInformation->printHeader(true),
|
||||
false,
|
||||
$fav_menu_config
|
||||
);
|
||||
// }
|
||||
if ($return !== true) {
|
||||
|
@ -5083,7 +5086,8 @@ function ui_print_page_header(
|
|||
$numChars=GENERIC_SIZE_TEXT,
|
||||
$alias='',
|
||||
$breadcrumbs='',
|
||||
$hide_left_small=false
|
||||
$hide_left_small=false,
|
||||
$fav_menu_config=[]
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -5147,6 +5151,17 @@ function ui_print_page_header(
|
|||
}
|
||||
}
|
||||
|
||||
if (is_array($fav_menu_config) === true && is_metaconsole() === false) {
|
||||
if (count($fav_menu_config) > 0) {
|
||||
$buffer .= ui_print_fav_menu(
|
||||
$fav_menu_config['id_element'],
|
||||
$fav_menu_config['url'],
|
||||
$fav_menu_config['label'],
|
||||
$fav_menu_config['section']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$buffer .= '</span>';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
|
@ -7779,4 +7794,48 @@ function ui_print_status_div($status)
|
|||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
function ui_print_fav_menu($id_element, $url, $label, $section)
|
||||
{
|
||||
global $config;
|
||||
$label = io_safe_output($label);
|
||||
if (strlen($label) > 18) {
|
||||
$label = io_safe_input(substr($label, 0, 18).'...');
|
||||
}
|
||||
|
||||
$fav = db_get_row_filter(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'url' => $url,
|
||||
'id_user' => $config['id_user'],
|
||||
],
|
||||
['*']
|
||||
);
|
||||
$config_fav_menu = [
|
||||
'id_element' => $id_element,
|
||||
'url' => $url,
|
||||
'label' => $label,
|
||||
'section' => $section,
|
||||
];
|
||||
|
||||
$output = '<span class="fav-menu">';
|
||||
$output .= html_print_input_image(
|
||||
'fav-menu-action',
|
||||
(($fav !== false) ? 'images/star_fav_menu.png' : 'images/star_dark.png'),
|
||||
base64_encode(json_encode($config_fav_menu)),
|
||||
'',
|
||||
true,
|
||||
[
|
||||
'onclick' => 'favMenuAction(this)',
|
||||
'class' => (($fav !== false) ? 'active' : ''),
|
||||
]
|
||||
);
|
||||
$output .= '</span>';
|
||||
$output .= '<div id="dialog-fav-menu">';
|
||||
$output .= '<p><b>'.__('Title').'</b></p>';
|
||||
$output .= html_print_input_text('label_fav_menu', '', '', 25, 255, true, false, true);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
}
|
|
@ -834,3 +834,55 @@ function unblockSubmit(button) {
|
|||
expireCookie("downloadReady");
|
||||
attempts = 30;
|
||||
}
|
||||
|
||||
function favMenuAction(e) {
|
||||
var data = JSON.parse(atob(e.value));
|
||||
if (data.label === "" && $(e).hasClass("active") === false) {
|
||||
$("#dialog-fav-menu").dialog({
|
||||
title: "Please choose a title",
|
||||
width: 330,
|
||||
buttons: [
|
||||
{
|
||||
class:
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next",
|
||||
text: "Confirm",
|
||||
click: function() {
|
||||
data.label = $("#text-label_fav_menu").val();
|
||||
if (data.label.length > 18) {
|
||||
data.label = data.label.slice(0, 18) + "...";
|
||||
}
|
||||
|
||||
$(e).val(btoa(JSON.stringify(data)));
|
||||
favMenuAction(e);
|
||||
$(this).dialog("close");
|
||||
$("input[name='label_fav_menu']").val("");
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "ajax.php",
|
||||
dataType: "json",
|
||||
data: {
|
||||
page: "include/ajax/fav_menu.ajax",
|
||||
id_element: data["id_element"],
|
||||
url: data["url"],
|
||||
label: data["label"],
|
||||
section: data["section"]
|
||||
},
|
||||
success: function(res) {
|
||||
if (res.success) {
|
||||
if (res.action === "create") {
|
||||
$("#image-fav-menu-action1").attr("src", "images/star_fav_menu.png");
|
||||
$("#image-fav-menu-action1").addClass("active");
|
||||
} else {
|
||||
$("#image-fav-menu-action1").attr("src", "images/star_dark.png");
|
||||
$("#image-fav-menu-action1").removeClass("active");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -568,6 +568,16 @@ class Manager implements PublicLogin
|
|||
'tdashboard',
|
||||
['id' => $this->dashboardId]
|
||||
);
|
||||
|
||||
// Delete dashboard from fav menu.
|
||||
\db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $this->dashboardId,
|
||||
'section' => 'Dashboard_',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Audit.
|
||||
|
|
|
@ -315,3 +315,15 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool
|
|||
bottom: -20px;
|
||||
top: auto;
|
||||
}
|
||||
#dialog-fav-menu {
|
||||
display: none;
|
||||
}
|
||||
#dialog-fav-menu p {
|
||||
margin: 0px;
|
||||
padding-top: 40px;
|
||||
}
|
||||
.fav-menu input {
|
||||
padding: 0px;
|
||||
max-width: 20px !important;
|
||||
max-height: 20px;
|
||||
}
|
||||
|
|
|
@ -248,6 +248,10 @@
|
|||
background: url(../../images/menu/events.svg) no-repeat 50% 50%;
|
||||
background-size: 18px;
|
||||
}
|
||||
.icon_fav-menu {
|
||||
background: url(../../images/menu/fav_menu_gray.svg) no-repeat 50% 50%;
|
||||
background-size: 18px;
|
||||
}
|
||||
|
||||
/* users */
|
||||
.icon_oper-users {
|
||||
|
@ -700,3 +704,7 @@ ul li {
|
|||
width: 215px !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.fav-menu {
|
||||
margin-left: 9px;
|
||||
}
|
||||
|
|
|
@ -548,6 +548,15 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
|||
|
||||
$result = networkmap_delete_networkmap($id);
|
||||
|
||||
// Delete network map from fav menu.
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
[
|
||||
'id_element' => $id,
|
||||
'section' => 'Network_map',
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
$result_txt = ui_print_result_message(
|
||||
$result,
|
||||
__('Succesfully deleted'),
|
||||
|
|
|
@ -2412,6 +2412,12 @@ if ($networkmap === false) {
|
|||
'link' => '',
|
||||
'label' => __('Network maps'),
|
||||
],
|
||||
],
|
||||
[
|
||||
'id_element' => $networkmap['id'],
|
||||
'url' => 'operation/agentes/pandora_networkmap&tab=view&id_networkmap='.$networkmap['id'],
|
||||
'label' => $networkmap['name'],
|
||||
'section' => 'Network_map',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -93,27 +93,6 @@ if (is_metaconsole() === false) {
|
|||
}
|
||||
}
|
||||
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
__('Monitor detail').$subpage,
|
||||
'images/agent.png',
|
||||
false,
|
||||
'',
|
||||
true,
|
||||
$buttons,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Monitoring'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Views'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
if ($section == 'fields') {
|
||||
include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php';
|
||||
|
@ -285,8 +264,79 @@ if ($loaded_filter['id_filter'] > 0) {
|
|||
$ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Fav menu.
|
||||
$fav_menu = [
|
||||
'id_element' => $loaded_filter['id_filter'],
|
||||
'url' => 'operation/agentes/status_monitor&pure=&load_filter=1&filter_id='.$loaded_filter['id_filter'],
|
||||
'label' => $loaded_filter['id_name'],
|
||||
'section' => 'Modules',
|
||||
];
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
$section = (string) get_parameter('section', 'view');
|
||||
|
||||
$buttons['fields'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=view&sec2=operation/agentes/status_monitor§ion=fields">'.html_print_image(
|
||||
'images/edit_columns@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Custom fields'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
'operation' => true,
|
||||
];
|
||||
|
||||
$buttons['view'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=view&sec2=operation/agentes/status_monitor">'.html_print_image(
|
||||
'images/logs@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('View'),
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
]
|
||||
).'</a>',
|
||||
'operation' => true,
|
||||
];
|
||||
|
||||
switch ($section) {
|
||||
case 'fields':
|
||||
$buttons['fields']['active'] = true;
|
||||
$subpage = ' » '.__('Custom fields');
|
||||
break;
|
||||
|
||||
default:
|
||||
$buttons['view']['active'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
__('Monitor detail').$subpage,
|
||||
'images/agent.png',
|
||||
false,
|
||||
'',
|
||||
true,
|
||||
$buttons,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Monitoring'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Views'),
|
||||
],
|
||||
],
|
||||
(empty($fav_menu) === true) ? [] : $fav_menu
|
||||
);
|
||||
|
||||
|
||||
$all_groups = [];
|
||||
|
||||
// Agent group selector.
|
||||
|
@ -2464,4 +2514,4 @@ if( value_swtich != "") {
|
|||
}else {
|
||||
chkbox.checked = false;
|
||||
}
|
||||
</script>
|
||||
</script>
|
|
@ -1071,7 +1071,7 @@ if (is_ajax() === true) {
|
|||
*/
|
||||
|
||||
$load_filter_id = (int) get_parameter('filter_id', 0);
|
||||
|
||||
$fav_menu = [];
|
||||
if ($load_filter_id === 0) {
|
||||
// Load user filter.
|
||||
$loaded_filter = db_get_row_sql(
|
||||
|
@ -1093,6 +1093,14 @@ if ($load_filter_id === 0) {
|
|||
'id_filter',
|
||||
$load_filter_id
|
||||
);
|
||||
|
||||
// Fav menu
|
||||
$fav_menu = [
|
||||
'id_element' => $load_filter_id,
|
||||
'url' => 'operation/events/events&pure=&load_filter=1&filter_id='.$load_filter_id,
|
||||
'label' => $loaded_filter['id_name'],
|
||||
'section' => 'Events',
|
||||
];
|
||||
}
|
||||
|
||||
// Do not load the user filter if we come from the 24h event graph.
|
||||
|
@ -1583,7 +1591,8 @@ if ($pure) {
|
|||
'link' => '',
|
||||
'label' => __('Events'),
|
||||
],
|
||||
]
|
||||
],
|
||||
$fav_menu
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -606,6 +606,44 @@ if ($access_console_node === true) {
|
|||
}
|
||||
}
|
||||
|
||||
$favorite_menu = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT id_element, url, label, section
|
||||
FROM tfavmenu_user
|
||||
WHERE id_user = "%s"
|
||||
ORDER BY section DESC',
|
||||
$config['id_user']
|
||||
)
|
||||
);
|
||||
// Favorite.
|
||||
if ($favorite_menu !== false) {
|
||||
$menu_operation['favorite']['text'] = __('Favorite');
|
||||
$menu_operation['favorite']['id'] = 'fav-menu';
|
||||
|
||||
$section = '';
|
||||
$sub = [];
|
||||
$sub2 = [];
|
||||
foreach ($favorite_menu as $key => $row) {
|
||||
if ($row['section'] !== $section) {
|
||||
$section = $row['section'];
|
||||
$sub2 = [];
|
||||
}
|
||||
|
||||
$sub[$section]['text'] = __(str_replace('_', ' ', $section));
|
||||
$sub[$section]['type'] = 'direct';
|
||||
$sub[$section]['subtype'] = 'nolink';
|
||||
$sub[$section]['id'] = $row['section'];
|
||||
|
||||
$sub2[$row['url']]['text'] = io_safe_output($row['label']);
|
||||
$sub[$section]['sub2'] = $sub2;
|
||||
}
|
||||
|
||||
$menu_operation['favorite']['sub'] = $sub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Workspace.
|
||||
$menu_operation['workspace']['text'] = __('Workspace');
|
||||
$menu_operation['workspace']['sec2'] = 'operation/users/user_edit';
|
||||
|
|
|
@ -221,6 +221,12 @@ ui_print_standard_header(
|
|||
'link' => '',
|
||||
'label' => __('Custom reports'),
|
||||
],
|
||||
],
|
||||
[
|
||||
'id_element' => $id_report,
|
||||
'url' => 'operation/reporting/reporting_viewer&id='.$id_report,
|
||||
'label' => reporting_get_name($id_report),
|
||||
'section' => 'Reporting',
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -240,6 +240,12 @@ if (!$config['pure']) {
|
|||
'link' => '',
|
||||
'label' => __('Visual console'),
|
||||
],
|
||||
],
|
||||
[
|
||||
'id_element' => $visualConsoleId,
|
||||
'url' => 'operation/visual_console/render_view&id='.$visualConsoleId,
|
||||
'label' => $visualConsoleName,
|
||||
'section' => 'Visual_Console',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4246,3 +4246,15 @@ CREATE TABLE IF NOT EXISTS `twelcome_tip_file` (
|
|||
REFERENCES `twelcome_tip` (`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tfavmenu_user`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tfavmenu_user` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`id_user` VARCHAR(255) NOT NULL,
|
||||
`id_element` TEXT,
|
||||
`url` TEXT NOT NULL,
|
||||
`label` VARCHAR(255) NOT NULL,
|
||||
`section` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id`));
|
|
@ -296,6 +296,12 @@ if ($publicLink === false) {
|
|||
'link' => '',
|
||||
'label' => __('Dashboard'),
|
||||
],
|
||||
],
|
||||
[
|
||||
'id_element' => $dashboardId,
|
||||
'url' => 'operation/dashboard/dashboard&dashboardId='.$dashboardId,
|
||||
'label' => $dashboardName,
|
||||
'section' => 'Dashboard_',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue