This commit is contained in:
Jose Gonzalez 2020-12-02 11:28:46 +01:00
commit eeac1ca35e
186 changed files with 12532 additions and 3700 deletions

View File

@ -3,309 +3,321 @@ var isFetching = null;
var storedEvents = new Array();
var notVisited = {};
$(window).on('load', function() {
initilise();
// Wait some ms to throw main function
var delay = setTimeout(main, 100);
resetInterval();
$(window).on("load", function() {
initilise();
// Wait some ms to throw main function
var delay = setTimeout(main, 100);
resetInterval();
});
function fetchEvents() {
return storedEvents;
return storedEvents;
}
function fetchNotVisited() {
return notVisited;
return notVisited;
}
function removeNotVisited(eventId) {
if (notVisited[eventId] === true) delete notVisited[eventId];
if (notVisited[eventId] === true) delete notVisited[eventId];
}
function main() {
chrome.runtime.sendMessage({ text: "FETCH_EVENTS" });
// Do not fetch if is fetching now
if (isFetching) return;
isFetching = true;
chrome.runtime.sendMessage({text: "FETCH_EVENTS"});
// Do not fetch if is fetching now
if (isFetching) return;
isFetching = true;
var url =
localStorage["ip_address"] +
"/include/api.php?op=get&op2=events&return_type=json";
var feedUrl = url;
var data = new FormData();
var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=json&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"];
data.append("apipass", localStorage["api_pass"]);
data.append("user", localStorage["user_name"]);
data.append("pass", localStorage["pass"]);
req = new XMLHttpRequest();
req.onload = handleResponse;
req.onerror = handleError;
req.open("GET", feedUrl, true);
req.withCredentials = true
req.send(null);
req = new XMLHttpRequest();
req.onload = handleResponse;
req.onerror = handleError;
req.open("POST", feedUrl, true);
req.withCredentials = true;
req.send(data);
}
function handleError() {
chrome.runtime.sendMessage({text: "FETCH_EVENTS_URL_ERROR"});
isFetching = false;
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_URL_ERROR" });
isFetching = false;
}
function handleResponse() {
var doc = req.responseText;
if (doc=="auth error") {
chrome.runtime.sendMessage({text: "FETCH_EVENTS_URL_ERROR"});
} else {
var n = doc.search("404 Not Found");
if (n>0) {
chrome.runtime.sendMessage({text: "FETCH_EVENTS_DATA_ERROR"});
} else {
getEvents(doc);
chrome.runtime.sendMessage({text: "FETCH_EVENTS_SUCCESS"});
}
}
isFetching = false;
var doc = req.responseText;
if (doc == "auth error") {
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_URL_ERROR" });
} else {
var n = doc.search("404 Not Found");
if (n > 0) {
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_DATA_ERROR" });
} else {
getEvents(doc);
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_SUCCESS" });
}
}
isFetching = false;
}
function getEvents(reply){
var fetchedEvents = parseReplyEvents(reply);
function getEvents(reply) {
var fetchedEvents = parseReplyEvents(reply);
// If there is no events requested, mark all as visited
if (storedEvents.length == 0) {
notVisited = {};
storedEvents = fetchedEvents;
return;
}
// If there is no events requested, mark all as visited
if (typeof storedEvents != "undefined" && storedEvents.length == 0) {
notVisited = {};
storedEvents = fetchedEvents;
return;
}
// Discriminate the new events
newEvents=fetchNewEvents(fetchedEvents,storedEvents);
var newNotVisited = {};
var notVisitedCount = 0;
// Check if popup is displayed to make some actions
var views = chrome.extension.getViews({ type: "popup" });
for(var k=0;k<newEvents.length;k++){
newNotVisited[newEvents[k]['id']] = true;
if (views.length == 0) {
notVisitedCount++;
displayNotification (newEvents[k])
alertsSound(newEvents[k]);
}
}
// Discriminate the new events
newEvents = fetchNewEvents(fetchedEvents, storedEvents);
var newNotVisited = {};
var notVisitedCount = 0;
// Make that the old events marked as not visited remains with the
// same status
for(var k=0;k<fetchedEvents.length;k++){
if (notVisited[fetchedEvents[k]['id']] === true) {
newNotVisited[fetchedEvents[k]['id']] = true;
notVisitedCount++;
}
}
notVisited = newNotVisited;
// Check if popup is displayed to make some actions
var views = chrome.extension.getViews({ type: "popup" });
for (var k = 0; k < newEvents.length; k++) {
newNotVisited[newEvents[k]["id"]] = true;
if (views.length == 0) {
notVisitedCount++;
displayNotification(newEvents[k]);
alertsSound(newEvents[k]);
}
}
// Update the number
localStorage["new_events"] = (views.length == 0) ? notVisitedCount : 0;
updateBadge();
// Make that the old events marked as not visited remains with the
// same status
for (var k = 0; k < fetchedEvents.length; k++) {
if (notVisited[fetchedEvents[k]["id"]] === true) {
newNotVisited[fetchedEvents[k]["id"]] = true;
notVisitedCount++;
}
}
notVisited = newNotVisited;
// Store the requested events
storedEvents = fetchedEvents;
// Update the number
localStorage["new_events"] = views.length == 0 ? notVisitedCount : 0;
updateBadge();
// Store the requested events
storedEvents = fetchedEvents;
}
function updateBadge() {
if (localStorage["new_events"] != 0) {
chrome.browserAction.setBadgeBackgroundColor({color:[0,200,0,255]});
chrome.browserAction.setBadgeText({ text: localStorage["new_events"] });
} else {
chrome.browserAction.setBadgeText({ text: "" });
}
if (localStorage["new_events"] != 0) {
chrome.browserAction.setBadgeBackgroundColor({ color: [0, 200, 0, 255] });
chrome.browserAction.setBadgeText({ text: localStorage["new_events"] });
} else {
chrome.browserAction.setBadgeText({ text: "" });
}
}
function fetchNewEvents(A,B){
var arrDiff = new Array();
for(var i = 0; i < A.length; i++) {
var id = false;
for(var j = 0; j < B.length; j++) {
if(A[i]['id'] == B[j]['id']) {
id = true;
break;
}
}
if(!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
function fetchNewEvents(A, B) {
var arrDiff = new Array();
for (var i = 0; i < A.length; i++) {
var id = false;
for (var j = 0; j < B.length; j++) {
if (A[i]["id"] == B[j]["id"]) {
id = true;
break;
}
}
if (!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
}
function parseReplyEvents(reply) {
// Split the API response
var data;
try {
data = JSON.parse(reply);
} catch (error) {
console.log(error);
return [];
}
var e_array = JSON.parse(reply).data;
function parseReplyEvents (reply) {
// Split the API response
var data = JSON.parse(reply)
var e_array = JSON.parse(reply).data;
// Form a properly object
var fetchedEvents=new Array();
for(var i=0;i<e_array.length;i++){
var event=e_array[i];
fetchedEvents.push({
'id' : event.id_evento,
'agent_name' : event.agent_name,
'agent' : event.id_agente,
'date' : event.timestamp,
'title' : event.evento,
'module' : event.id_agentmodule,
'type' : event.event_type,
'source' : event.source,
'severity' : event.criticity_name,
'visited' : false
});
}
// Return the events
return fetchedEvents;
// Form a properly object
var fetchedEvents = new Array();
for (var i = 0; i < e_array.length; i++) {
var event = e_array[i];
fetchedEvents.push({
id: event.id_evento,
agent_name: event.agent_name,
agent: event.id_agente,
date: event.timestamp,
title: event.evento,
module: event.id_agentmodule,
type: event.event_type,
source: event.source,
severity: event.criticity_name,
visited: false
});
}
// Return the events
return fetchedEvents;
}
function alertsSound(pEvent){
if(localStorage["sound_alert"]!="on"){
return;
}
function alertsSound(pEvent) {
if (localStorage["sound_alert"] != "on") {
return;
}
switch (pEvent['severity']) {
case "Critical":
playSound(localStorage["critical"]);
break;
case "Informational":
playSound(localStorage["informational"]);
break;
case "Maintenance":
playSound(localStorage["maintenance"]);
break;
case "Normal":
playSound(localStorage["normal"]);
break;
case "Warning":
playSound(localStorage["warning"]);
break;
}
switch (pEvent["severity"]) {
case "Critical":
playSound(localStorage["critical"]);
break;
case "Informational":
playSound(localStorage["informational"]);
break;
case "Maintenance":
playSound(localStorage["maintenance"]);
break;
case "Normal":
playSound(localStorage["normal"]);
break;
case "Warning":
playSound(localStorage["warning"]);
break;
}
}
function displayNotification (pEvent) {
function displayNotification(pEvent) {
// Check if the user is okay to get some notification
if (Notification.permission === "granted") {
// If it's okay create a notification
getNotification(pEvent);
}
// Check if the user is okay to get some notification
if (Notification.permission === "granted") {
// If it's okay create a notification
getNotification(pEvent);
}
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// Whatever the user answers, we make sure we store the information
if(!('permission' in Notification)) {
Notification.permission = permission;
}
// If the user is okay, let's create a notification
if (permission === "granted") getNotification(pEvent);
});
}
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== "denied") {
Notification.requestPermission(function(permission) {
// Whatever the user answers, we make sure we store the information
if (!("permission" in Notification)) {
Notification.permission = permission;
}
// If the user is okay, let's create a notification
if (permission === "granted") getNotification(pEvent);
});
}
}
function getNotification(pEvent){
// Build the event text
var even = pEvent['type'];
if (pEvent['source'] != '') even += " : " + pEvent['source'];
even += ". Event occured at " + pEvent['date'];
if(pEvent['module'] != 0) even += " in the module with Id "+ pEvent['module'];
even += ".";
function getNotification(pEvent) {
// Build the event text
var even = pEvent["type"];
if (pEvent["source"] != "") even += " : " + pEvent["source"];
even += ". Event occured at " + pEvent["date"];
if (pEvent["module"] != 0)
even += " in the module with Id " + pEvent["module"];
even += ".";
var url = (pEvent['agent'] == 0)
? localStorage["ip_address"]+"/index.php?sec=eventos&sec2=operation/events/events"
: localStorage["ip_address"]+"/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" + pEvent['agent'];
var url =
pEvent["agent"] == 0
? localStorage["ip_address"] +
"/index.php?sec=eventos&sec2=operation/events/events"
: localStorage["ip_address"] +
"/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" +
pEvent["agent"];
var notification = new Notification(
pEvent['title'],
{
body: even,
icon: "images/icon.png"
}
);
var notification = new Notification(pEvent["title"], {
body: even,
icon: "images/icon.png"
});
// Add the link
notification.onclick = function (event) {
event.preventDefault();
window.open(url, '_blank');
}
// Add the link
notification.onclick = function(event) {
event.preventDefault();
window.open(url, "_blank");
};
// Close notification after 10 secs
setTimeout(function() {notification.close()}, 10000);
// Close notification after 10 secs
setTimeout(function() {
notification.close();
}, 10000);
}
function resetInterval () {
if (refreshTimer) clearInterval(refreshTimer);
refreshTimer = setInterval(main, localStorage["refresh"]*1000);
function resetInterval() {
if (refreshTimer) clearInterval(refreshTimer);
refreshTimer = setInterval(main, localStorage["refresh"] * 1000);
}
function initilise(){
function initilise() {
if (isFetching == null) isFetching = false;
if (localStorage["ip_address"] == undefined) {
localStorage["ip_address"] = "http://firefly.artica.es/pandora_demo";
}
if (isFetching == null) isFetching = false;
if(localStorage["ip_address"]==undefined){
localStorage["ip_address"]="http://firefly.artica.es/pandora_demo";
}
if(localStorage["api_pass"]==undefined){
localStorage["api_pass"]="doreik0";
}
if(localStorage["user_name"]==undefined){
localStorage["user_name"]="demo";
}
if(localStorage["pass"]==undefined){
localStorage["pass"]="demo";
}
if(localStorage["critical"]==null){
localStorage["critical"]="11";
}
if(localStorage["informational"]==null){
localStorage["informational"]="1";
}
if(localStorage["maintenance"]==null){
localStorage["maintenance"]="10";
}
if(localStorage["normal"]==null){
localStorage["normal"]="6";
}
if(localStorage["warning"]==null){
localStorage["warning"]="2";
}
if(localStorage["events"]==null){
localStorage["events"]=20;
}
if(localStorage["refresh"]==null){
localStorage["refresh"]="10";
}
if(localStorage["ip_address"]==null){
localStorage["ip_address"]="http://firefly.artica.es/pandora_demo";
}
if(localStorage["api_pass"]==null){
localStorage["api_pass"]="doreik0";
}
if(localStorage["user_name"]==null){
localStorage["user_name"]="demo";
}
if(localStorage["pass"]==null){
localStorage["pass"]="demo";
}
if(localStorage["sound_alert"]==null){
localStorage["sound_alert"]="on";
}
if(localStorage["changed"]==null){
localStorage["changed"]="false";
}
if(localStorage["new_events"]==null){
localStorage["new_events"]=parseInt(localStorage["events"]);
}
if(localStorage["error"]==null) {
localStorage["error"] = true;
}
if (localStorage["api_pass"] == undefined) {
localStorage["api_pass"] = "doreik0";
}
if (localStorage["user_name"] == undefined) {
localStorage["user_name"] = "demo";
}
if (localStorage["pass"] == undefined) {
localStorage["pass"] = "demo";
}
if (localStorage["critical"] == null) {
localStorage["critical"] = "11";
}
if (localStorage["informational"] == null) {
localStorage["informational"] = "1";
}
if (localStorage["maintenance"] == null) {
localStorage["maintenance"] = "10";
}
if (localStorage["normal"] == null) {
localStorage["normal"] = "6";
}
if (localStorage["warning"] == null) {
localStorage["warning"] = "2";
}
if (localStorage["events"] == null) {
localStorage["events"] = 20;
}
if (localStorage["refresh"] == null) {
localStorage["refresh"] = "10";
}
if (localStorage["ip_address"] == null) {
localStorage["ip_address"] = "http://firefly.artica.es/pandora_demo";
}
if (localStorage["api_pass"] == null) {
localStorage["api_pass"] = "doreik0";
}
if (localStorage["user_name"] == null) {
localStorage["user_name"] = "demo";
}
if (localStorage["pass"] == null) {
localStorage["pass"] = "demo";
}
if (localStorage["sound_alert"] == null) {
localStorage["sound_alert"] = "on";
}
if (localStorage["changed"] == null) {
localStorage["changed"] = "false";
}
if (localStorage["new_events"] == null) {
localStorage["new_events"] = parseInt(localStorage["events"]);
}
if (localStorage["error"] == null) {
localStorage["error"] = true;
}
}

View File

@ -8,7 +8,10 @@ $(document).ready(function() {
bg = chrome.extension.getBackgroundPage();
// Display the information
if (bg.fetchEvents().length == 0) {
var events = bg.fetchEvents();
if (!events) {
showError("Failed to retrieve events, please retry");
} else if (events.length == 0) {
showError("No events");
} else {
showEvents();

View File

@ -1,6 +1,6 @@
{
"name": "__MSG_name__",
"version": "2.2",
"version": "2.3",
"manifest_version": 2,
"description": "Pandora FMS Event viewer Chrome extension",
"homepage_url": "http://pandorafms.com",

View File

@ -0,0 +1,145 @@
![Image of Pandora FMS](https://pandorafms.org/wp-content/uploads/2016/06/logo_pandora_community.png)
Pandora FMS is a __monitoring solution__ that provides unparalleled flexibility for IT to address both immediate and unforeseen operational issues, including infrastructure and IT processes.
It uniquely enables business and IT to adapt to changing needs through a flexible and rapid approach to IT and business deployment.
For community support you can visit our forums at [forums.pandorafms.org](http://forums.pandorafms.org). Check out our community website at [pandorafms.org](http://pandorafms.org), and if you need sales information or/and professional support, visit [pandorafms.com](http://pandorafms.com).
# Pandora FMS full stack based on Centos 8
## Try it
You can try it on a cloud env for 4 hours using play with docker just click in the icon bellow, wait for the pulling image and the containers will be up and running automatically
If you want to open the console just click on the port 8080 on the upside and will be redirected to the pandora consola.
[![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/rafaelameijeiras/PandoraFMS/master/pandorafms_community/docker-compose-official.yml)
https://www.youtube.com/watch?v=Hw2P6hHQpeI
Note: could take a couple of minutes for the console to be ready so if you click in the 8080 port and nothing and have a blank page wait a little and reload the page
## Usage
```
docker run --name Pandora_new %container_name% --rm \
-p %local_httpd_port%:80 \
-p %local_tentacle_port%:41121 \
-e DBHOST=%Mysql_Server_IP% \
-e DBNAME=%database_name% \
-e DBUSER=%Mysql_user% \
-e DBPASS=%Mysql_pass% \
-e DBPORT=%Mysql_port% \
-e INSTANCE_NAME=%server name% \
-ti pandorafms-open-stack-el8
```
Example:
```
docker run --name Pandora_new --rm \
-p 8081:80 \
-p 41125:41121 \
-e DBHOST=192.168.80.45 \
-e DBNAME=pandora_demos_1 \
-e DBUSER=pandora \
-e DBPASS=pandora \
-e DBPORT=3306 \
-e INSTANCE_NAME=pandora201 \
-ti pandorafms-open-stack-el8
```
### Integrated database for PandoraFMS container
There is a preconfigured database image in this repo to connect the Pandora environment so you can up the database and then point the pandora container to the database.
Example:
```
docker run --name Pandora_DB \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=pandora \
-e MYSQL_DATABASE=pandora \
-e MYSQL_USER=pandora \
-e MYSQL_PASSWORD=pandora \
-d pandorafms/pandorafms-percona-base
```
This creates a Percona mysql docker and a database called Pandora with grants to the pandora user (optional) and the credentials for root user.
In this example we expose the 3306 for database connection.
Using this configuration (getting the container ip from DB container ip) you can execute the next container Pandora pointing to it:
```
docker run --name Pandora_new --rm \
-p 8081:80 \
-p 41125:41121 \
-e DBHOST=<percona container ip> \
-e DBNAME=pandora \
-e DBUSER=pandora \
-e DBPASS=pandora \
-e DBPORT=3306 \
-e INSTANCE_NAME=pandora_inst \
-ti pandorafms/pandorafms-open-stack-el8
```
### Docker Compose Stack
if you want to run an easy to deploy stack you may use the docker-compose.yml file
```
version: '3.1'
services:
db:
image: pandorafms/pandorafms-percona-base
restart: always
#command: ["mysqld", "--innodb-buffer-pool-size=900M"]
environment:
MYSQL_ROOT_PASSWORD: pandora
MYSQL_DATABASE: pandora
MYSQL_USER: pandora
MYSQL_PASSWORD: pandora
networks:
- pandora
pandora:
image: pandorafms/pandorafms-open-stack-el8:latest
restart: always
depends_on:
- db
environment:
MYSQL_ROOT_PASSWORD: pandora
DBHOST: db
DBNAME: pandora
DBUSER: pandora
DBPASS: pandora
DBPORT: 3306
INSTANCE_NAME: pandora01
PUBLICURL: ""
SLEEP: 5
RETRIES: 10
networks:
- pandora
ports:
- "8080:80"
- "41121:41121"
- "162:162/udp"
- "9995:9995/udp"
networks:
pandora:
```
just by running: `docker-compose -f <docker-compose-file> up`
## Important Parameters:
* __INSTANCE_NAME__: Pandora Server name
* __DBHOST__: DB host IP to MySQL engine
* __DBNAME__: The name of the database. If your user have enough permissions to create databases, the container will create it in case automatically if didn't exist
* __DBUSER__: The user to connect MySQL engine.
* __DBPASS__: User password to connect MySQL engine.
* __DBPORT__: The port to connect MySQL engine. by default 33306
* __PUBLICURL__: Define a public URL. Useful when Pandora is used behind a reverse proxy
* __SLEEP__: Time to wait between retries
* __RETRIES__: How many times Pandora will try to connect to MySQL engine before fail.
Note1: the SLEEP and RETRIES variables will be used to wait for database container to fully start, if you are in a slower system maybe you will need to increase these variables values, in this example will wait 5 seconds for the database container to be up and retries 3 times.

View File

@ -0,0 +1,257 @@
#docker build -t pandorafms/pandorafms-open-base-el8 -f $HOME/code/pandorafms/extras/docker/centos8/base/Dockerfile $HOME/code/pandorafms/extras/docker/centos8/base/
#docker push pandorafms/pandorafms-open-base-el8
FROM centos:8
RUN dnf install -y --setopt=tsflags=nodocs \
epel-release \
dnf-utils \
http://rpms.remirepo.net/enterprise/remi-release-8.rpm
RUN dnf module reset -y php && dnf module install -y php:remi-7.3
RUN dnf config-manager --set-enabled PowerTools
# Install console
RUN dnf install -y --setopt=tsflags=nodocs \
php \
php-mcrypt \php-cli \
php-gd \
php-curl \
php-session \
php-mysqlnd \
php-ldap \
php-zip \
php-zlib \
php-fileinfo \
php-gettext \
php-snmp \
php-mbstring \
php-pecl-zip \
php-xmlrpc \
libxslt \
wget \
php-xml \
httpd \
mod_php \
atk \
avahi-libs \
cairo \
cups-libs \
fribidi \
gd \
gdk-pixbuf2 \
ghostscript \
graphite2 \
graphviz \
gtk2 \
harfbuzz \
hicolor-icon-theme \
hwdata \
jasper-libs \
lcms2 \
libICE \
libSM \
libXaw \
libXcomposite \
libXcursor \
libXdamage \
libXext \
libXfixes \
libXft \
libXi \
libXinerama \
libXmu \
libXrandr \
libXrender \
libXt \
libXxf86vm \
libcroco \
libdrm \
libfontenc \
libglvnd \
libglvnd-egl \
libglvnd-glx \
libpciaccess \
librsvg2 \
libthai \
libtool-ltdl \
libwayland-client \
libwayland-server \
libxshmfence \
mesa-libEGL \
mesa-libGL \
mesa-libgbm \
mesa-libglapi \
pango \
pixman \
nfdump \
xorg-x11-fonts-75dpi \
xorg-x11-fonts-misc \
poppler-data \
php-yaml; yum clean all
RUN mkdir -p /run/php-fpm/ ; chown -R root:apache /run/php-fpm/
# not installed perl-Net-Telnet gtk-update-icon-cach ghostscript-fonts
# Install server
RUN dnf install -y --setopt=tsflags=nodocs \
GeoIP \
GeoIP-GeoLite-data \
dwz \
efi-srpm-macros \
ghc-srpm-macros \
go-srpm-macros \
ocaml-srpm-macros \
openblas-srpm-macros \
perl \
perl-Algorithm-Diff \
perl-Archive-Tar \
perl-Archive-Zip \
perl-Attribute-Handlers \
perl-B-Debug \
perl-CPAN \
perl-CPAN-Meta \
perl-CPAN-Meta-Requirements \
perl-CPAN-Meta-YAML \
perl-Compress-Bzip2 \
perl-Config-Perl-V \
perl-DBD-MySQL \
perl-DBI \
perl-DB_File \
perl-Data-Dump \
perl-Data-OptList \
perl-Data-Section \
perl-Devel-PPPort \
perl-Devel-Peek \
perl-Devel-SelfStubber \
perl-Devel-Size \
perl-Digest-HMAC \
perl-Digest-SHA \
perl-Encode-Locale \
perl-Encode-devel \
perl-Env \
perl-ExtUtils-CBuilder \
perl-ExtUtils-Command \
perl-ExtUtils-Embed \
perl-ExtUtils-Install \
perl-ExtUtils-MM-Utils \
perl-ExtUtils-MakeMaker \
perl-ExtUtils-Manifest \
perl-ExtUtils-Miniperl \
perl-ExtUtils-ParseXS \
perl-File-Fetch \
perl-File-HomeDir \
perl-File-Listing \
perl-File-Which \
perl-Filter \
perl-Filter-Simple \
perl-Geo-IP \
perl-HTML-Parser \
perl-HTML-Tagset \
perl-HTML-Tree \
perl-HTTP-Cookies \
perl-HTTP-Date \
perl-HTTP-Message \
perl-HTTP-Negotiate \
perl-IO-HTML \
perl-IO-Socket-INET6 \
perl-IO-Zlib \
perl-IO-stringy \
perl-IPC-Cmd \
perl-IPC-SysV \
perl-IPC-System-Simple \
perl-JSON \
perl-JSON-PP \
perl-LWP-MediaTypes \
perl-Locale-Codes \
perl-Locale-Maketext \
perl-Locale-Maketext-Simple \
perl-MRO-Compat \
perl-Math-BigInt \
perl-Math-BigInt-FastCalc \
perl-Math-BigRat \
perl-Memoize \
perl-Module-Build \
perl-Module-CoreList \
perl-Module-CoreList-tools \
perl-Module-Load \
perl-Module-Load-Conditional \
perl-Module-Loaded \
perl-Module-Metadata \
perl-NTLM \
perl-Net-HTTP \
perl-Net-Ping \
perl-NetAddr-IP \
perl-Package-Generator \
perl-Params-Check \
perl-Params-Util \
perl-Perl-OSType \
perl-PerlIO-via-QuotedPrint \
perl-Pod-Checker \
perl-Pod-Html \
perl-Pod-Parser \
perl-SelfLoader \
perl-Socket6 \
perl-Software-License \
perl-Sub-Exporter \
perl-Sub-Install \
perl-Sys-Syslog \
perl-Test \
perl-Test-Harness \
perl-Test-Simple \
perl-Text-Balanced \
perl-Text-Diff \
perl-Text-Glob \
perl-Text-Template \
perl-Thread-Queue \
perl-Time-Piece \
perl-TimeDate \
perl-Try-Tiny \
perl-Unicode-Collate \
perl-WWW-RobotRules \
perl-XML-NamespaceSupport \
perl-XML-Parser \
perl-XML-SAX \
perl-XML-SAX-Base \
perl-XML-Simple \
perl-XML-Twig \
perl-autodie \
perl-bignum \
perl-devel \
perl-encoding \
perl-experimental \
perl-inc-latest \
perl-libnetcfg \
perl-libwww-perl \
perl-local-lib \
perl-open \
perl-perlfaq \
perl-srpm-macros \
perl-utils \
perl-version \
python-srpm-macros \
python3-pyparsing \
python3-rpm-macros \
qt5-srpm-macros \
redhat-rpm-config \
rust-srpm-macros \
systemtap-sdt-devel \
perl-TermReadKey \
perl \
perl-DBD-MySQL \
perl-DBI \
initscripts \
net-tools \
nmap-ncat \
nmap \
net-snmp-utils \
sudo \
http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \
http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/wmi-1.3.14-4.el7.art.x86_64.rpm
RUN dnf install -y supervisor crontabs mysql http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs
EXPOSE 80 443 41121 162/udp

View File

@ -0,0 +1,112 @@
#!/bin/bash
VERSION=$1
ENT="$HOME/code/pandora_enterprise"
OPEN="$HOME/code/pandorafms"
OS="Centos"
ARCH="x86_64"
EL="el7"
EXT="demo"
TARGET_URL="http://atlantis.artica.es"
DOCKER_PATH="$OPEN/extras/docker/centos8/"
OSTACK_IMAGE="pandorafms/pandorafms-open-stack-el8"
OBASE_IMAGE="pandorafms/pandorafms-open-base-el8"
PERCONA_IMAGE="pandorafms/pandorafms-percona-base"
function help {
echo "To excute the builder you must declare 4 parameters: the version image, upload (push) tokens, build base (rebuild centos base image), build percona (rebuild percona base image)"
echo ""
echo "$0 <version> [ <push 0|1> ] [<build base 0|1>] [<build percona 0|1>]"
echo "Ex creates a local image from 749 packages : $0 749 0 1 1"
}
if [ "$1" == "" ] || [ "$1" == "-h" ] ; then
help
exit
fi
if [ "$2" == "1" ]; then
UPDATE="1"
fi
if [ "$3" == "1" ]; then
BASEBUILD="1"
fi
if [ "$4" == "1" ]; then
DBBUILD="1"
fi
#Defining packages urls
oconsoleurl=$TARGET_URL/Releases/7.0NG.$VERSION/$OS/noarch/pandorafms_console-7.0NG.$VERSION.noarch.rpm
oserverurl=$TARGET_URL/Releases/7.0NG.$VERSION/$OS/noarch/pandorafms_server-7.0NG.$VERSION.noarch.rpm
url=$(curl -I -s $TARGET_URL/Releases/7.0NG.$VERSION/ 2> /dev/null | grep "200 OK" | wc -l)
# log in into docker acount to acces private repo.
# docker login -u $DOCKERUSER -p$DOCKERPASS
Check athlantis is reachable
if [ "$url" -lt 1 ] ; then
echo "$url Athlantis unreachable ..."
exit
fi
echo "Start"
# Removing old packages
cd $DOCKER_PATH/pandora-stack/sources
rm -rf ./pandorafms_*
# Downloading new packages
wget $oconsoleurl
wget $oserverurl
if [ "$BASEBUILD" == 1 ] ; then
# Open Base image
echo "building Base el8 image"
cd $DOCKER_PATH/base
docker build -t $OBASE_IMAGE:$VERSION -f $DOCKER_PATH/base/Dockerfile $DOCKER_PATH/base
echo "Taging Open stack el8 latest image before upload"
docker tag $OBASE_IMAGE:$VERSION $OBASE_IMAGE:latest
echo -e ">>>> \n"
fi
if [ "$DBBUILD" == 1 ] ; then
# Percona image
echo "building Percona image"
cd $OPEN/extras/docker/percona
docker build -t $PERCONA_IMAGE:latest -f $OPEN/extras/docker/percona/Dockerfile $OPEN/extras/docker/percona
echo -e ">>>> \n"
fi
#Open Stack image
echo "building Open el8 image"
cd $DOCKER_PATH/pandora-stack
docker build -t $OSTACK_IMAGE:$VERSION -f $DOCKER_PATH/pandora-stack/Dockerfile $DOCKER_PATH/pandora-stack
echo "Taging Open base latest image before upload"
docker tag $OSTACK_IMAGE:$VERSION $OSTACK_IMAGE:latest
echo -e ">>>> \n"
# Upload images
if [ "$UPDATE" == 1 ] ; then
if [ "$BASEBUILD" == 1 ] ; then
#Open base Images
echo "Uploading Open $OBASE_IMAGE:$VERSION . . ."
docker push $OBASE_IMAGE:$VERSION
docker push $OBASE_IMAGE:latest
fi
if [ "$DBBUILD" == 1 ] ; then
#Open base Images
echo "Uploading percona $PERCONA_IMAGE:latest . . ."
docker push $PERCONA_IMAGE:latest
fi
#Open Stack Images
echo "Uploading Open $OSTACK_IMAGE:$VERSION . . ."
docker push $OSTACK_IMAGE:$VERSION
docker push $OSTACK_IMAGE:latest
fi

View File

@ -0,0 +1,43 @@
# Use root/example as user/password credentials
# este compose incluye la base de datos en otro docker y levanta aplicacion y DB juntos
version: '3.1'
services:
db:
image: pandorafms/pandorafms-percona-base
restart: always
#command: ["mysqld", "--innodb-buffer-pool-size=900M"]
environment:
MYSQL_ROOT_PASSWORD: pandora
MYSQL_DATABASE: pandora
MYSQL_USER: pandora
MYSQL_PASSWORD: pandora
networks:
- pandora
pandora:
image: pandorafms/pandorafms-open-stack-el8:latest
restart: always
depends_on:
- db
environment:
MYSQL_ROOT_PASSWORD: pandora
DBHOST: db
DBNAME: pandora
DBUSER: pandora
DBPASS: pandora
DBPORT: 3306
INSTANCE_NAME: pandora01
PUBLICURL: ""
SLEEP: 5
RETRIES: 10
networks:
- pandora
ports:
- "8080:80"
- "41121:41121"
- "162:162/udp"
- "9995:9995/udp"
networks:
pandora:

View File

@ -0,0 +1,24 @@
#docker build -t pandorafms/pandorafms-open-stack-el8:$VERSION -f $HOME/code/pandorafms/extras/docker/centos8/pandora-stack/Dockerfile $HOME/code/pandorafms/extras/docker/centos8/pandora-stack/
FROM pandorafms/pandorafms-open-base-el8
ENV DBNAME=pandora
ENV DBUSER=pandora
ENV DBPASS=pandora
ENV DBHOST=pandora
ENV DBPORT=3306
ENV SLEEP=5
ENV RETRIES=1
ENV OPEN=1
ENV LC_ALL=C
RUN rm -rf /etc/localtime ; ln -s /usr/share/zoneinfo/Europe/Madrid /etc/localtime
COPY ./sources /opt/pandora
# Install the Pandora console
RUN dnf install -y /opt/pandora/pandorafms_console-*.rpm /opt/pandora/pandorafms_server-*.rpm ; yum clean all
EXPOSE 80 443 41121 162/udp 9995/udp
CMD sh /opt/pandora/init_pandora.sh

View File

@ -0,0 +1,5 @@
# exclude packages
demos/
*.tar*
*.rpm
phantomjs

View File

@ -0,0 +1,336 @@
#!/bin/bash
#
# Prepares environment and launchs Pandora FMS
#
# Global vars
#
PANDORA_CONSOLE=/var/www/html/pandora_console
PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_SERVER_BIN=/usr/bin/pandora_server
PANDORA_HA_BIN=/usr/bin/pandora_ha
PANDORA_TABLES_MIN=160
#
# Check database
#
function db_check {
# Check DB
echo -n ">> Checking dbengine connection: "
for i in `seq $RETRIES`; do
r=`echo 'select 1' | mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST -A`
if [ $? -ne 0 ]; then
echo -n "retriying DB conection in $SLEEP seconds: "
sleep $SLEEP
else
break
fi
done
r=`echo 'select 1' | mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST -A`
if [ $? -eq 0 ]; then
echo "OK"
echo -n ">> Checking database connection: "
r=`echo 'select 1' | mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST -A $DBNAME`
if [ $? -eq 0 ]; then
echo "OK"
return 0
fi
echo -n ">> Cannot connect to $DBNAME, trying to create: "
r=`echo "create database $DBNAME" | mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST`
if [ $? -eq 0 ]; then
echo "OK"
return 0
fi
echo "Cannot create database $DBNAME on $DBUSER@$DBHOST:$DBPORT"
return 1
fi
if [ "$DEBUG" == "1" ]; then
echo "Command: [echo 'select 1' | mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST -A $DBNAME]"
echo "Output: [$r]"
traceroute $DBHOST
nmap $DBHOST -v -v -p $DBPORT
fi
return 1
}
# Load database
#
function db_load {
# Load DB
echo -n ">> Checking database state:"
r=`mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST -A $DBNAME -s -e 'show tables'| wc -l`
if [ "$DEBUG" == "1" ]; then
echo "Command: [mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST -A $DBNAME -s -e 'show tables'| wc -l]"
echo "Output: [$r]"
fi
if [ "$r" -ge "$PANDORA_TABLES_MIN" ]; then
echo 'OK. Already exists, '$r' tables detected'
return 0
fi
echo 'Empty database detected';
# Needs to be loaded.
echo -n "- Loading database schema: "
r=`mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb.sql`
if [ $? -ne 0 ]; then
echo "mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb.sql"
echo "ERROR"
echo "$r"
return 1;
fi
echo "OK"
echo -n "- Loading database data: "
r=`mysql -u$DBUSER -p$DBPASS -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb_data.sql`
if [ $? -ne 0 ]; then
echo "ERROR"
echo $r
return 2;
fi
echo "OK"
# Loaded.
return 0
}
#
# Prepare & start Pandora FMS Console
#
function console_prepare {
CONSOLE_PATH=/var/www/html/pandora_console
echo ">> Preparing console"
# Delete install and license files.
mv $CONSOLE_PATH/install.php $CONSOLE_PATH/install.done
rm -f $CONSOLE_PATH/enterprise/PandoraFMS_Enteprise_Licence.txt
# Configure console.
cat > $CONSOLE_PATH/include/config.php << EO_CONFIG_F
<?php
\$config["dbtype"] = "mysql";
\$config["dbname"]="$DBNAME";
\$config["dbuser"]="$DBUSER";
\$config["dbpass"]="$DBPASS";
\$config["dbhost"]="$DBHOST";
\$config["homedir"]="/var/www/html/pandora_console";
\$config["homeurl"]="/pandora_console";
error_reporting(0);
\$ownDir = dirname(__FILE__) . '/';
include (\$ownDir . "config_process.php");
EO_CONFIG_F
# enable allow override
cat > /etc/httpd/conf.d/pandora.conf << EO_CONFIG_F
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
EO_CONFIG_F
cat > /var/www/html/index.html << EOF_INDEX
<meta HTTP-EQUIV="REFRESH" content="0; url=/pandora_console/">
EOF_INDEX
echo "- Fixing permissions"
chmod 600 $CONSOLE_PATH/include/config.php
chown -R apache. $CONSOLE_PATH
# prepare php.ini
sed -i -e "s/^max_input_time.*/max_input_time = -1/g" /etc/php.ini
sed -i -e "s/^max_execution_time.*/max_execution_time = 0/g" /etc/php.ini
sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini
sed -i -e "s/^memory_limit.*/memory_limit = 500M/g" /etc/php.ini
echo "- Setting Public URL: $PUBLICURL"
q=$(mysql -u$DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "select token from tconfig;" | grep public_url)
[[ ! "$q" ]] && mysql -u $DBUSER -p$DBPASS $DBNAME -P$DBPORT -h$DBHOST -sNe "INSERT INTO tconfig (token,value) VALUES ('public_url',\"$PUBLICURL\");"
mysql -u$DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "UPDATE tconfig SET value=\"$PUBLICURL\" WHERE token=\"public_url\";"
#touch $CONSOLE_PATH/pandora_console.log
#chown apache. $CONSOLE_PATH/pandora_console.log
}
function check_mr {
## geting MR + Package
CMR=$(mysql -u$DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "select value from tconfig where token = 'MR'")
CPK=$(mysql -u$DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "select value from tconfig where token = 'current_package_enterprise'")
DPK=$(grep pandora_version $PANDORA_CONSOLE/include/config_process.php | awk '{print $3}' | tr -d "'" | tr -d ";" | cut -d . -f 3)
DMR=$(ls $PANDORA_CONSOLE/extras/mr/ | sort -n | tail -1 | cut -d . -f 1)
if [[ $DMR -gt $CMR ]]; then
echo ">> Fixing DB: MR: $CMR Current Package: $CPK Desired MR: $DMR"
cd $PANDORA_CONSOLE/extras/mr/
for i in $(ls | sort -n); do
cat $i | mysql -u$DBUSER -p$DBPASS $DBNAME -h$DBHOST
done
cd -
echo ">> Updating DB: MR: $CMR Current Package: $CPK Desired MR: $DMR"
mysql -u $DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "update tconfig set value = $DMR where token = 'MR';"
mysql -u $DBUSER -p$DBPASS $DBNAME -h$DBHOST -sNe "update tconfig set value = $DPK where token = 'current_package_enterprise';"
fi
}
function server_prepare {
sed -i -e "s/^dbhost.*/dbhost $DBHOST/g" $PANDORA_SERVER_CONF
sed -i -e "s/^dbname.*/dbname $DBNAME/g" $PANDORA_SERVER_CONF
sed -i -e "s/^dbuser.*/dbuser $DBUSER/g" $PANDORA_SERVER_CONF
sed -i -e "s|^dbpass.*|dbpass $DBPASS|g" $PANDORA_SERVER_CONF
sed -i -e "s/^dbport.*/dbport $DBPORT/g" $PANDORA_SERVER_CONF
sed -i -e "s/^#servername.*/servername $INSTANCE_NAME/g" $PANDORA_SERVER_CONF
echo "pandora_service_cmd /etc/init.d/pandora_server" >> $PANDORA_SERVER_CONF
# prepare snmptrapd
cat > /etc/snmp/snmptrapd.conf << EOF
authCommunity log public
disableAuthorization yes
EOF
## Enable WUX
if [ "$WUX_SERVER" == "1" ] && [ "$WUX_HOST" ]; then
if [ ! $WUX_PORT ]; then
WUX_PORT=4444
fi
echo "Enabling WUX server HOST=$WUX_HOST PORT=$WUX_PORT"
sed -i -r "s/#?wuxserver.*/wuxserver 1/g" $PANDORA_SERVER_CONF
sed -i -r "s/#?wux_host.*/wux_host $WUX_HOST/g" $PANDORA_SERVER_CONF
sed -i -r "s/#?wux_port.*/wux_port $WUX_PORT/g" $PANDORA_SERVER_CONF
fi
}
##
## MAIN
##
if [ "$DBUSER" == "" ] || [ "$DBPASS" == "" ] || [ "$DBNAME" == "" ] || [ "$DBHOST" == "" ]; then
echo "Required environemntal variables DBUSER, DBPASS, DBNAME, DBHOST"
exit 1
fi
if [ "$DBPORT" == "" ]; then
DBPORT=3306
fi
echo "" > /opt/pandora/crontasks || touch /opt/pandora/crontasks
#install pandora packages
echo "-> Istalling pandorafms"
cd /opt/pandora
useradd pandora
if [[ $OPEN != 1 ]]; then
# install enterprise
dnf install -y /opt/pandora/pandorafms_console*.rpm
tar xvfz /opt/pandora/pandorafms_server_*tar* && cd pandora_server && ./pandora_server_installer --install ; rm -rf /opt/pandora/pandora_server
[[ -e /var/www/html/pandora_console/include/config.php ]] || yum reinstall -y /opt/pandora/pandorafms*.rpm
PANDORA_BIN="pandora_ha"
PANDORA_EXEC="/usr/bin/pandora_ha /etc/pandora/pandora_server.conf"
else
install only open
dnf install -y /opt/pandora/pandorafms_console-*.rpm /opt/pandora/pandorafms_server-*.rpm
dnf reinstall -y /opt/pandora/pandorafms_server-*.rpm
[[ -e /var/www/html/pandora_console/include/config.php ]] || dnf reinstall -y /opt/pandora/pandorafms_console-*.rpm
PANDORA_BIN="pandora_server"
PANDORA_EXEC="/usr/bin/pandora_server /etc/pandora/pandora_server.conf"
fi
db_check && db_load
# Sync to MC.
if [ "$META_DBNAME" != "" ] && [ "$META_DBHOST" != "" ]; then
if [ "$META_DBPORT" == "" ]; then
META_DBPORT=3306
fi
register_mc
fi
check_mr
console_prepare
server_prepare
echo ">> Enable oracle env file cron: "
cat > /etc/pandora/pandora_server.env << 'EOF_ENV'
#!/bin/bash
VERSION=19.8
export PATH=$PATH:$HOME/bin:/usr/lib/oracle/$VERSION/client64/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/$VERSION/client64/lib
export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64
EOF_ENV
echo ">> Enable discovery cron: "
#while true ; do wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done &
echo "*/5 * * * * wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks
echo ">> Enable pandora_db cron: "
/usr/bin/perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf
#while true ; do sleep 1h && /usr/bin/pandora_db /etc/pandora/pandora_server.conf; done &
echo "0 */1 * * * /usr/bin/pandora_db /etc/pandora/pandora_server.conf" >> /opt/pandora/crontasks
echo ">> Loading crontab tasks"
crontab -r
crontab /opt/pandora/crontasks && crontab -l
ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -F '/' '{print "-> Go to http://"$1"/pandora_console to manage this server"}'
# Check and launch supervisord
echo ">> Starting process: Running supervisord"
# Create supervisor.conf
cat > /etc/supervisord.conf << EOF_CON
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
nodaemon=true
loglevel = debug
[program:php-fpm]
command=/usr/sbin/php-fpm -F
riredirect_stderr=true
[program:httpd]
command=/usr/sbin/apachectl -DFOREGROUND
riredirect_stderr=true
[program:tentacle]
command=/etc/init.d/tentacle_serverd restart
[program:$PANDORA_BIN]
command=$PANDORA_EXEC
riredirect_stderr=true
[program:cron]
command=crond -n
[group:allservices]
programs=httpd,cron,php-fpm,$PANDORA_BIN,tentacle
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
EOF_CON
# execute supervisor
touch /var/log/pandora/pandora_server.log ; tail -F /var/log/pandora/* &
su - -c supervisord

View File

@ -0,0 +1,31 @@
#docker build -t pandorafms/pandorafms-percona-base -f $HOME/code/pandorafms/extras/docker/percona/Dockerfile $HOME/code/pandorafms/extras/docker/percona
FROM percona:5.7
RUN echo -e '#PandoraFMS configuration \n\
[mysqld] \n\
max_allowed_packet = 64M \n\
innodb_buffer_pool_size = 500M \n\
innodb_lock_wait_timeout = 90 \n\
innodb_file_per_table \n\
innodb_flush_log_at_trx_commit = 0 \n\
innodb_flush_method = O_DIRECT \n\
innodb_log_file_size = 64M \n\
innodb_log_buffer_size = 16M \n\
innodb_io_capacity = 100 \n\
thread_cache_size = 8 \n\
thread_stack = 256K \n\
max_connections = 100 \n \n\
key_buffer_size=4M \n\
read_buffer_size=128K \n\
read_rnd_buffer_size=128K \n\
sort_buffer_size=128K \n\
join_buffer_size=4M \n\n\
query_cache_type = 1 \n\
query_cache_size = 64M \n\
query_cache_min_res_unit = 2k \n\
query_cache_limit = 256K \n\n\
sql_mode="" ' > /etc/my.cnf.d/pandora.cnf
EXPOSE 3306

View File

@ -0,0 +1,50 @@
![Image of Pandora FMS](https://pandorafms.org/wp-content/uploads/2016/06/logo_pandora_community.png)
# Pandora FMS database container
This container image is designed for optimal performance using Pandora FMS.
Is based on the official Percona database image turned to get the maximum performance on PandoraFMS
## Official Gitgub repo
Dockerfiles and more info in our official repository: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/percona
## USAGE
Similar to the official percona image:
Example:
```
docker run --name Pandora_DB \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=pandora \
-e MYSQL_DATABASE=pandora \
-e MYSQL_USER=pandora \
-e MYSQL_PASSWORD=pandora \
-d pandorafms/pandorafms-percona-base
```
## Environment Variables
When you start the percona image, you can adjust the configuration of the instance by passing one or more environment variables on the docker run command line. Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.
__MYSQL_ROOT_PASSWORD__ : This variable is mandatory and specifies the password that will be set for the root superuser account. In the above example, it was set to my-secret-pw.
__MYSQL_ROOT_HOST__ : By default, root can connect from anywhere. This option restricts root connections to be from the specified host only. Also localhost can be used here for the local-only root access.
__MYSQL_DATABASE__ :
This variable is optional and allows you to specify the name of a database to be created on image startup. If a user/password was supplied (see below) then that user will be granted superuser access (corresponding to GRANT ALL) to this database.
__MYSQL_USER, MYSQL_PASSWORD__ :These variables are optional, used in conjunction to create a new user and to set that user's password. This user will be granted superuser permissions (see above) for the database specified by the MYSQL_DATABASE variable. Both variables are required for a user to be created.
Do note that there is no need to use this mechanism to create the root superuser, that user gets created by default with the password specified by the MYSQL_ROOT_PASSWORD variable.
__MYSQL_ALLOW_EMPTY_PASSWORD__ : This is an optional variable. Set to yes to allow the container to be started with a blank password for the root user. NOTE: Setting this variable to yes is not recommended unless you really know what you are doing, since this will leave your instance completely unprotected, allowing anyone to gain complete superuser access.
__MYSQL_RANDOM_ROOT_PASSWORD__ : This is an optional variable. Set to yes to generate a random initial password for the root user (using pwgen). The generated root password will be printed to stdout (GENERATED ROOT PASSWORD: .....).
__MYSQL_ONETIME_PASSWORD__ : Sets root (not the user specified in MYSQL_USER!) user as expired once init is complete, forcing a password change on first login. NOTE: This feature is supported on MySQL 5.6+ only. Using this option on MySQL 5.5 will throw an appropriate error during initialization.
__MYSQL_INITDB_SKIP_TZINFO__ : At first run MySQL automatically loads from the local system the timezone information needed for the CONVERT_TZ() function. If it's is not what is intended, this option disables timezone loading.
__INIT_TOKUDB__ : Tuns on TokuDB Engine. It can be activated only when transparent huge pages (THP) are disabled.
__INIT_ROCKSDB__ : Tuns on RocksDB Engine.

View File

@ -1,245 +1,262 @@
if ("undefined" == typeof(PandoraChrome)) {
var PandoraChrome = {};
var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("pandora.");
/* globals Components, req */
if ("undefined" == typeof PandoraChrome) {
var PandoraChrome = {};
var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("pandora.");
var timer = null;
var allEvents=new Array();
var newEvents=new Array();
var oldEvents=new Array();
var api_div_numbers=21;
};
PandoraChrome.fn = function(){
return {
displaySideBar: function(){
PandoraChrome.fn.hideNotification();
PandoraChrome.fn.hideBadge();
toggleSidebar('viewPandoraSidebar');
},
displayDialog : function(){
window.openDialog("chrome://pandorasidebar/content/options.xul", "","chrome, centerscreen, dialog, modal, resizable=no", null).focus();
},
handleClick: function(e){
if(e.button == 0){
toggleSidebar('viewPandoraSidebar');
PandoraChrome.fn.setIcon('icon16');
}
},
Onloading: function () {
if(prefManager.getBoolPref("firstLoad")){
prefManager.setIntPref("new_events",prefManager.getIntPref("events"));
prefManager.setBoolPref("firstLoad",false);
}
var timer = null;
var allEvents = new Array();
var newEvents = new Array();
var oldEvents = new Array();
var api_div_numbers = 21;
}
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 100 );
},
PandoraChrome.fn = (function() {
return {
displaySideBar: function() {
PandoraChrome.fn.hideNotification();
PandoraChrome.fn.hideBadge();
toggleSidebar("viewPandoraSidebar");
},
displayDialog: function() {
window
.openDialog(
"chrome://pandorasidebar/content/options.xul",
"",
"chrome, centerscreen, dialog, modal, resizable=no",
null
)
.focus();
},
handleClick: function(e) {
if (e.button == 0) {
toggleSidebar("viewPandoraSidebar");
PandoraChrome.fn.setIcon("icon16");
}
},
Onloading: function() {
if (prefManager.getBoolPref("firstLoad")) {
prefManager.setIntPref("new_events", prefManager.getIntPref("events"));
prefManager.setBoolPref("firstLoad", false);
}
main: function() {
// alert('test_main');
var url=prefManager.getCharPref("ip_address")+'/include/api.php?op=get&op2=events&return_type=csv&apipass='+prefManager.getCharPref("api_pass")+'&user='+prefManager.getCharPref("user_name")+'&pass='+prefManager.getCharPref("pass");
var feedUrl = url;
prefManager.setBoolPref("data_check", true);
req = new XMLHttpRequest();
req.onload = PandoraChrome.fn.handleResponse;
req.onerror = PandoraChrome.fn.handleError;
req.open("GET", feedUrl, true);
req.send(null);
},
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 100);
},
handleError: function() {
//alert("error");
prefManager.setCharPref("data",null);
prefManager.setBoolPref("data_check", false);
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 1000);
},
main: function() {
// alert('test_main');
var url =
prefManager.getCharPref("ip_address") +
"/include/api.php?op=get&op2=events&return_type=json";
var feedUrl = url;
var data = new FormData();
handleResponse: function () {
var doc = req.responseText;
if (doc=="auth error") {
prefManager.setCharPref("data",null);
prefManager.setBoolPref("data_check", false);
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 1000);
data.append("apipass", prefManager.getCharPref("api_pass"));
data.append("user", prefManager.getCharPref("user_name"));
data.append("pass", prefManager.getCharPref("pass"));
}
else{
var n=doc.search("404 Not Found");
if(n>0){
prefManager.setBoolPref("data_check", true);
req = new XMLHttpRequest();
req.onload = PandoraChrome.fn.handleResponse;
req.onerror = PandoraChrome.fn.handleError;
req.open("POST", feedUrl, true);
req.send(data);
},
prefManager.setCharPref("data",null);
prefManager.setBoolPref("data_check", false);
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 1000);
}
else{
prefManager.setBoolPref("data_check", true);
handleError: function() {
//alert("error");
prefManager.setCharPref("data", null);
prefManager.setBoolPref("data_check", false);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 1000);
},
prefManager.setCharPref("data",doc);
PandoraChrome.fn.getEvents(doc);
}
}
},
handleResponse: function() {
var doc = req.responseText;
if (doc == "auth error") {
prefManager.setCharPref("data", null);
prefManager.setBoolPref("data_check", false);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 1000);
} else {
var n = doc.search("404 Not Found");
if (n > 0) {
prefManager.setCharPref("data", null);
prefManager.setBoolPref("data_check", false);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 1000);
} else {
prefManager.setBoolPref("data_check", true);
getEvents: function (reply){
if(reply.length>100){
all_event_array=reply.split("\n");
allEvents=PandoraChrome.fn.divideArray(all_event_array);
if(oldEvents.length==0){
oldEvents=allEvents;
}
prefManager.setCharPref("data", doc);
PandoraChrome.fn.getEvents(doc);
}
}
},
newEvents=PandoraChrome.fn.fetchNewEvents(allEvents,oldEvents);
if(newEvents.length!=0){
for(var k=0;k<newEvents.length;k++){
var temp=prefManager.getIntPref("new_events")+1;
prefManager.setIntPref("new_events",temp);
PandoraChrome.fn.showNotification(k);
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
}
}
oldEvents=allEvents;
if(prefManager.getIntPref("new_events")>0){
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
}
else{
PandoraChrome.fn.hideBadge();
}
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , prefManager.getIntPref("refresh")*1000 );
}
},
showNotification: function(eventId){
//alert("notify"+eventId);
if(prefManager.getBoolPref("sound_alert")){
if(newEvents[eventId][19]=="Critical"){
Sounds.playSound(prefManager.getIntPref("critical"));
}
if(newEvents[eventId][19]=="Informational"){
Sounds.playSound(prefManager.getIntPref("informational"));
}
if(newEvents[eventId][19]=="Maintenance"){
Sounds.playSound(prefManager.getIntPref("maintenance"));
}
if(newEvents[eventId][19]=="Normal"){
Sounds.playSound(prefManager.getIntPref("normal"));
}
if(newEvents[eventId][19]=="Warning"){
Sounds.playSound(prefManager.getIntPref("warning"));
}
}
var newEve = document.getElementById('newEvent');
newEve.label="Last Event : "+newEvents[eventId][6];
var id;
if(newEvents[eventId][9]==0){
id=".";
}
else {
id= " in the module with Id "+ newEvents[eventId][9] + ".";
}
var event = newEvents[eventId][14]+" : "+newEvents[eventId][17]+". Event occured at "+ newEvents[eventId][5]+id;
newEve.tooltipText=event;
$('#newEvent').show();
return;
},
hideNotification:function(){
//alert("Hide Notif");
$('#newEvent').hide();
},
showBadge: function (txt) {
//alert(txt);
var updateCount = document.getElementById('temp');
updateCount.setAttribute("style","cursor:pointer; font-size:11px; color:#123863; font-weight:bold; display:none;") ;
updateCount.label=txt;
$('#temp').show();
},
hideBadge: function () {
var updateCount = document.getElementById('temp');
//alert("hide B");
$('#temp').hide();
},
divideArray: function (e_array){
var Events=new Array();
for(var i=0;i<e_array.length;i++){
var event=e_array[i].split(";");
Events.push(event);
}
return Events;
},
fetchNewEvents: function (A,B){
var arrDiff = new Array();
// alert(A.length);
//alert(B.length);
for(var i = 0; i < A.length; i++) {
var id = false;
for(var j = 0; j < B.length; j++) {
if(A[i][0] == B[j][0]) {
id = true;
break;
}
}
if(!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
},
getNotification:function (eventId){
var title=newEvents[eventId][6];
var id;
if(newEvents[eventId][9]==0){
id=".";
}
else {
id= " in the module with Id "+ newEvents[eventId][9] + ".";
}
var event = newEvents[eventId][14]+" : "+newEvents[eventId][17]+". Event occured at "+ newEvents[eventId][5]+id;
//var event=newEvents[eventId][14]+' '+newEvents[eventId][17]+' Event occured at:'+ newEvents[eventId][5] +'in the module with Id '+ newEvents[eventId][9];
return '<a>' + title + '</a> <br/> <span style="font-size:80%">' + event + '</span>';
getEvents: function(reply) {
if (reply.length > 100) {
all_event_array = reply.split("\n");
allEvents = PandoraChrome.fn.divideArray(all_event_array);
if (oldEvents.length == 0) {
oldEvents = allEvents;
}
};
}();
newEvents = PandoraChrome.fn.fetchNewEvents(allEvents, oldEvents);
if (newEvents.length != 0) {
for (var k = 0; k < newEvents.length; k++) {
var temp = prefManager.getIntPref("new_events") + 1;
prefManager.setIntPref("new_events", temp);
PandoraChrome.fn.showNotification(k);
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
}
}
oldEvents = allEvents;
if (prefManager.getIntPref("new_events") > 0) {
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
} else {
PandoraChrome.fn.hideBadge();
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(
PandoraChrome.fn.main,
prefManager.getIntPref("refresh") * 1000
);
}
},
showNotification: function(eventId) {
//alert("notify"+eventId);
if (prefManager.getBoolPref("sound_alert")) {
if (newEvents[eventId][19] == "Critical") {
Sounds.playSound(prefManager.getIntPref("critical"));
}
if (newEvents[eventId][19] == "Informational") {
Sounds.playSound(prefManager.getIntPref("informational"));
}
if (newEvents[eventId][19] == "Maintenance") {
Sounds.playSound(prefManager.getIntPref("maintenance"));
}
if (newEvents[eventId][19] == "Normal") {
Sounds.playSound(prefManager.getIntPref("normal"));
}
if (newEvents[eventId][19] == "Warning") {
Sounds.playSound(prefManager.getIntPref("warning"));
}
}
var newEve = document.getElementById("newEvent");
newEve.label = "Last Event : " + newEvents[eventId][6];
var id;
if (newEvents[eventId][9] == 0) {
id = ".";
} else {
id = " in the module with Id " + newEvents[eventId][9] + ".";
}
var event =
newEvents[eventId][14] +
" : " +
newEvents[eventId][17] +
". Event occured at " +
newEvents[eventId][5] +
id;
newEve.tooltipText = event;
$("#newEvent").show();
return;
},
hideNotification: function() {
//alert("Hide Notif");
$("#newEvent").hide();
},
showBadge: function(txt) {
//alert(txt);
var updateCount = document.getElementById("temp");
updateCount.setAttribute(
"style",
"cursor:pointer; font-size:11px; color:#123863; font-weight:bold; display:none;"
);
updateCount.label = txt;
$("#temp").show();
},
hideBadge: function() {
var updateCount = document.getElementById("temp");
//alert("hide B");
$("#temp").hide();
},
divideArray: function(e_array) {
var Events = new Array();
for (var i = 0; i < e_array.length; i++) {
var event = e_array[i].split(";");
Events.push(event);
}
return Events;
},
fetchNewEvents: function(A, B) {
var arrDiff = new Array();
// alert(A.length);
//alert(B.length);
for (var i = 0; i < A.length; i++) {
var id = false;
for (var j = 0; j < B.length; j++) {
if (A[i][0] == B[j][0]) {
id = true;
break;
}
}
if (!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
},
getNotification: function(eventId) {
var title = newEvents[eventId][6];
var id;
if (newEvents[eventId][9] == 0) {
id = ".";
} else {
id = " in the module with Id " + newEvents[eventId][9] + ".";
}
var event =
newEvents[eventId][14] +
" : " +
newEvents[eventId][17] +
". Event occured at " +
newEvents[eventId][5] +
id;
//var event=newEvents[eventId][14]+' '+newEvents[eventId][17]+' Event occured at:'+ newEvents[eventId][5] +'in the module with Id '+ newEvents[eventId][9];
return (
"<a>" +
title +
'</a> <br/> <span style="font-size:80%">' +
event +
"</span>"
);
}
};
})();
/* Add Event Listener */
window.addEventListener("load", PandoraChrome.fn.Onloading(), false);

View File

@ -143,7 +143,7 @@ done
# Darwin dmg installer files
echo "Updating DARWIN DMG files..."
sed -i -e "/VERSION/s/=.*/=\"$VERSION\"/" "$AGENT_DARWIN_BUILDER"
sed -i -e "/VERSION/s/=\"7.0NG.*/=\"$VERSION\"/" "$AGENT_DARWIN_BUILDER"
sed -i -r "s/(version=\").*(\"\s+onConclusion=)/\1$VERSION\2/g" "$AGENT_DARWIN_DISTR"
sed -i -r "s/(CFBundleVersion<\/key>\s*<string>).*(<\/string>)/\1$VERSION\2/g" "$AGENT_DARWIN_PLIST"
sed -i -r "s/(CFBundleShortVersionString<\/key>\s*<string>).*(<\/string>)/\1$VERSION\2/g" "$AGENT_DARWIN_PLIST"

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.750
Version: 7.0NG.750-201202
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.750"
pandora_version="7.0NG.750-201202"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -22,7 +22,7 @@ fi
# DMG package version
if [ "$#" -ge 2 ]; then
VERSION="7.0NG.750"
VERSION="$2"
else
VERSION="7.0NG.750"
fi
@ -37,7 +37,7 @@ fi
BUILD_DMG="$BUILD_PATH/build"
BUILD_TMP="$BUILD_PATH/buildtmp"
FULLNAME="7.0NG.749"
FULLNAME="$DMGNAME-$VERSION.dmg"
echo "VERSION-"$VERSION" NAME-"$DMGNAME
pushd .
cd $LOCALINST

View File

@ -26,11 +26,13 @@ else
`/usr/local/share/pandora_agent/inst_utilities/print_conf.pl /usr/local/share/pandora_agent/pandora_agent.conf remote_config $REMOTECFG`
# Create agent directories and files
mkdir -p /usr/local/share/pandora_agent/collections
mkdir -p /usr/local/share/pandora_agent/commands
mkdir -p /usr/local/bin/
mkdir -p /usr/local/share/man/man1/
mkdir -p /usr/local/share/pandora_agent/collections/
mkdir -p /usr/local/share/pandora_agent/commands/
mkdir -p /etc/pandora/
mkdir -p /var/spool/pandora/data_out
mkdir -p /var/log/pandora
mkdir -p /var/spool/pandora/data_out/
mkdir -p /var/log/pandora/
mv pandora_agent.conf /etc/pandora/
touch /var/log/pandora/pandora_agent.log
@ -70,9 +72,9 @@ ln -s /usr/local/share/pandora_agent/collections /etc/pandora/collections
# Copy manuals
cp -f man/man1/pandora_agent.1.gz /usr/local/share/man/man1
cp -f man/man1/pandora_agent.1.gz /usr/local/share/man/man1/
chmod 644 /usr/local/share/man/man1/pandora_agent.1.gz
cp -f man/man1/tentacle_client.1.gz /usr/local/share/man/man1
cp -f man/man1/tentacle_client.1.gz /usr/local/share/man/man1/
chmod 644 /usr/local/share/man/man1/tentacle_client.1.gz
# Create newsyslog entry

View File

@ -33,17 +33,8 @@ use IO::Socket;
use Sys::Syslog;
use Time::Local;
my $YAML = 0;
# Dynamic load. Avoid unwanted behaviour.
eval {
eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');
};
if ($@) {
$YAML = 0;
print STDERR $@;
} else {
$YAML = 1;
}
use lib '/usr/lib/perl5';
use PandoraFMS::Omnishell;
# Agent XML data
my $Xml;
@ -55,7 +46,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.750';
use constant AGENT_BUILD => '201015';
use constant AGENT_BUILD => '201202';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -285,20 +276,6 @@ sub error ($) {
exit 1;
}
################################################################################
# Try to load extra libraries.c
################################################################################
sub load_libraries() {
# Dynamic load. Avoid unwanted behaviour.
eval {eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');};
if ($@) {
$YAML = 0;
print STDERR $@;
} else {
$YAML = 1;
}
}
################################################################################
# Erase blank spaces before and after the string
################################################################################
@ -1084,8 +1061,6 @@ sub fix_directory ($) {
return $dir . $char;
}
################################################################################
# Sends a file to the server.
################################################################################
@ -1488,336 +1463,6 @@ sub check_collections () {
}
}
################################################################################
# Check for remote commands defined.
################################################################################
sub prepare_commands {
if ($YAML == 0) {
log_message(
'error',
'Cannot use commands without YAML dependency, please install it.'
);
return;
}
# Force configuration file read.
my @commands = read_config('cmd_file');
if (empty(\@commands)) {
$Conf{'commands'} = {};
} else {
foreach my $rcmd (@commands) {
$Conf{'commands'}->{trim($rcmd)} = {};
}
}
# Cleanup old commands. Not registered.
cleanup_old_commands();
foreach my $ref (keys %{$Conf{'commands'}}) {
my $file_content;
my $download = 0;
my $rcmd_file = $ConfDir.'/commands/'.$ref.'.rcmd';
# Check for local .rcmd.done files
if (-e $rcmd_file.'.done') {
# Ignore.
delete $Conf{'commands'}->{$ref};
next;
}
# Search for local .rcmd file
if (-e $rcmd_file) {
my $remote_md5_file = $Conf{'temporal'}.'/'.$ref.'.md5';
$file_content = read_file($rcmd_file);
if (recv_file($ref.'.md5', $remote_md5_file) != 0) {
# Remote file could not be retrieved, skip.
delete $Conf{'commands'}->{$ref};
next;
}
my $local_md5 = md5($file_content);
my $remote_md5 = md5(read_file($remote_md5_file));
if ($local_md5 ne $remote_md5) {
# Must be downloaded again.
$download = 1;
}
} else {
$download = 1;
}
# Search for remote .rcmd file
if ($download == 1) {
# Download .rcmd file
if (recv_file($ref.'.rcmd') != 0) {
# Remote file could not be retrieved, skip.
delete $Conf{'commands'}->{$ref};
next;
} else {
# Success
move($Conf{'temporal'}.'/'.$ref.'.rcmd', $rcmd_file);
}
}
# Parse and prepare in memory skel.
eval {
$Conf{'commands'}->{$ref} = YAML::Tiny->read($rcmd_file);
};
if ($@) {
# Failed.
log_message('error', 'Failed to decode command. ' . "\n".$@);
delete $Conf{'commands'}->{$ref};
next;
}
}
}
################################################################################
# Command report.
################################################################################
sub report_command {
my ($ref, $err_level) = @_;
# Retrieve content from .stdout and .stderr
my $stdout_file = $Conf{'temporal'}.'/'.$ref.'.stdout';
my $stderr_file = $Conf{'temporal'}.'/'.$ref.'.stderr';
my $return;
eval {
$return = {
'error_level' => $err_level,
'stdout' => read_file($stdout_file),
'stderr' => read_file($stderr_file),
};
$return->{'name'} = $Conf{'commands'}->{$ref}->[0]->{'name'};
};
if ($@) {
log_message('error', 'Failed to report command output. ' . $@);
}
# Cleanup
unlink($stdout_file) if (-e $stdout_file);
unlink($stderr_file) if (-e $stderr_file);
# Mark command as done.
open (my $R_FILE, '> '.$ConfDir.'/commands/'.$ref.'.rcmd.done');
print $R_FILE $err_level;
close($R_FILE);
$return->{'stdout'} = '' unless defined ($return->{'stdout'});
$return->{'stderr'} = '' unless defined ($return->{'stderr'});
return $return;
}
################################################################################
# Cleanup unreferenced rcmd and rcmd.done files.
################################################################################
sub cleanup_old_commands {
# Cleanup old .rcmd and .rcmd.done files.
my %registered = map { $_.'.rcmd' => 1 } keys %{$Conf{'commands'}};
if(opendir(my $dir, $ConfDir.'/commands/')) {
while (my $item = readdir($dir)) {
# Skip other files.
next if ($item !~ /\.rcmd$/);
# Clean .rcmd.done file if its command is not referenced in conf.
if (!defined($registered{$item})) {
if (-e $ConfDir.'/commands/'.$item) {
unlink($ConfDir.'/commands/'.$item);
}
if (-e $ConfDir.'/commands/'.$item.'.done') {
unlink($ConfDir.'/commands/'.$item.'.done');
}
}
}
# Close dir.
closedir($dir);
}
}
################################################################################
# Executes a command using defined timeout.
################################################################################
sub execute_command_timeout {
my ($cmd, $timeout) = @_;
if (!defined($timeout)
|| !looks_like_number($timeout)
|| $timeout <= 0
) {
`$cmd`;
return $?>>8;
}
my $remaining_timeout = $timeout;
my $RET;
my $output;
my $pid = open ($RET, "-|");
if (!defined($pid)) {
# Failed to fork.
log_message('error', '[command] Failed to fork.');
return undef;
}
if ($pid == 0) {
# Child.
my $ret;
eval {
local $SIG{ALRM} = sub { die "timeout\n" };
alarm $timeout;
`$cmd`;
alarm 0;
};
my $result = ($?>>8);
return $result;
# Exit child.
# Child finishes.
exit;
} else {
# Parent waiting.
while( --$remaining_timeout > 0 ){
if (wait == -1) {
last;
}
# Wait child up to timeout seconds.
sleep 1;
}
}
if ($remaining_timeout > 0) {
# Retrieve output from child.
$output = do { local $/; <$RET> };
$output = $output>>8;
}
else {
# Timeout expired.
return 124;
}
close($RET);
return $output;
}
################################################################################
# Executes a block of commands, returns error level, leaves output in
# redirection set by $std_files. E.g:
# $std_files = ' >> /tmp/stdout 2>> /tmp/stderr
################################################################################
sub execute_command_block {
my ($commands, $std_files, $timeout, $retry) = @_;
return 0 unless defined($commands);
my $retries = $retry;
$retries = 1 unless looks_like_number($retries) && $retries > 0;
my $err_level = 0;
$std_files = '' unless defined ($std_files);
if (ref($commands) ne "ARRAY") {
return 0 if $commands eq '';
do {
$err_level = execute_command_timeout(
"($commands) $std_files",
$timeout
);
# Do not retry if success.
last if looks_like_number($err_level) && $err_level == 0;
} while ((--$retries) > 0);
} else {
foreach my $comm (@{$commands}) {
next unless defined($comm);
$retries = $retry;
$retries = 1 unless looks_like_number($retries) && $retries > 0;
do {
$err_level = execute_command_timeout(
"($comm) $std_files",
$timeout
);
# Do not retry if success.
$retries = 0 if looks_like_number($err_level) && $err_level == 0;
} while ((--$retries) > 0);
# Do not continue evaluating block if failed.
last unless ($err_level == 0);
}
}
return $err_level;
}
################################################################################
# Evalate given command.
################################################################################
sub evaluate_command {
my ($ref) = @_;
# Not found.
return unless defined $Conf{'commands'}->{$ref};
# Already completed.
return if (-e $ConfDir.'/commands/'.$ref.'.rcmd.done');
# [0] because how library works.
my $cmd = $Conf{'commands'}->{$ref}->[0];
my $std_files = ' >> '.$Conf{'temporal'}.'/'.$ref.'.stdout ';
$std_files .= ' 2>> '.$Conf{'temporal'}.'/'.$ref.'.stderr ';
# Check preconditions
my $err_level;
$err_level = execute_command_block(
$cmd->{'preconditions'},
$std_files,
$cmd->{'timeout'}
);
# Precondition not satisfied.
return report_command($ref, $err_level) unless ($err_level == 0);
# Main run.
$err_level = execute_command_block(
$cmd->{'script'},
$std_files,
$cmd->{'timeout'}
);
# Script not success.
return report_command($ref, $err_level) unless ($err_level == 0);
# Check postconditions
$err_level = execute_command_block(
$cmd->{'postconditions'},
$std_files,
$cmd->{'timeout'}
);
# Return results.
return report_command($ref, $err_level);
}
################################################################################
# Sleep function
################################################################################
@ -3435,9 +3080,10 @@ my $main_agent = -1;
# base time to start eatch iteration with the same interval.
my $iter_base_time = time();
$LogFileIdx = -1;
# Loop
while (1) {
load_libraries();
my $omnishell;
if (-e $Conf{'logfile'} && (stat($Conf{'logfile'}))[7] > $Conf{'logsize'}) {
rotate_log();
@ -3453,8 +3099,18 @@ while (1) {
# Check file collections
check_collections () unless ($Conf{'debug'} eq '1');
# Check scheduled commands
prepare_commands() unless ($Conf{'debug'} eq '1');
eval {
# Omnishell controller.
$omnishell = new PandoraFMS::Omnishell(
{
%Conf,
'ConfDir' => $ConfDir
}
);
};
if ($@) {
log_message('error', "Omnishell process error: ".$@);
}
# Launch broker agents
@BrokerPid = ();
@ -3587,18 +3243,22 @@ while (1) {
if (ref ($Conf{'commands'}) eq "HASH") {
foreach my $command (keys %{$Conf{'commands'}}) {
my $result = evaluate_command($command);
if (ref($result) eq "HASH") {
# Process command result.
$Xml .= "<cmd_report>\n";
$Xml .= " <cmd_response>\n";
$Xml .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n";
$Xml .= " <cmd_key><![CDATA[".$command."]]></cmd_key>\n";
$Xml .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
$Xml .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
$Xml .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
$Xml .= " </cmd_response>\n";
$Xml .= "</cmd_report>\n";
eval {
if ($Conf{'debug'} eq '1') {
log_message('debug', 'Running omnishell commmand ['.$command.']');
}
my $output = $omnishell->runCommand($command, 'xml');
if (!empty($output)) {
$Xml .= $output;
} else {
if ($Conf{'debug'} eq '1') {
log_message('error', 'Omnishell result: '.$omnishell->get_last_error());
}
}
};
if ($@) {
log_message('error', 'Omnishell error: '.$@);
}
}
}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.750
%define release 1
%define release 201202
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.750
%define release 1
%define release 201202
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.750"
PI_BUILD="201015"
PI_BUILD="201202"
OS_NAME=`uname -s`
FORCE=0

Binary file not shown.

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{201015}
{201202}
ViewReadme
{Yes}
@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives
{No}
Windows,Executable
{<%AppName%>-Setup<%Ext%>}
{<%AppName%>-<%Version%>-Setup<%Ext%>}
Windows,FileDescription
{<%AppName%> <%Version%> Setup}

View File

@ -0,0 +1,93 @@
#!/usr/bin/perl
################################################################################
# Pandora FMS Omnishell client.
#
# (c) Fco de Borja Sánchez <fborja.sanchez@pandorafms.com>
#
# Usage: omnishell_client "C:\Program Files\pandora_agent\pandora_agent.conf"
#
################################################################################
use strict;
use warnings;
use File::Basename;
use lib '/usr/lib/perl5';
use PandoraFMS::PluginTools;
use PandoraFMS::Omnishell;
################################################################################
# Definitions
################################################################################
my $HELP=<<EO_H;
Pandora FMS Omnishell client.
Usage:
$0 <configuration_file> [-debug 1]
Where <configuration_file> is your Pandora FMS Agent configuration.
*Recommended: use full path.
Use -debug 1 to get information extra in STDERR
EO_H
################################################################################
# Parse commands.
################################################################################
sub read_commands {
my ($config, $exp, $line, $file) = @_;
if (empty($config->{'commands'})) {
$config->{'commands'} = {};
}
my ($ref) = $line =~ /$exp\s+(.*)/;
$config->{'commands'}->{trim($ref)} = {};
return $config;
}
################################################################################
# MAIN
################################################################################
my $ConfFile = $ARGV[0];
my $config = read_configuration({},' ', [
{
'exp' => 'cmd_file',
'target' => \&read_commands
},
]);
if (!defined($ConfFile) || !-e $ConfFile) {
print $HELP;
exit 1;
}
if(!-d dirname($ConfFile).'\commands') {
mkdir(dirname($ConfFile).'\commands');
}
eval {
# Check scheduled commands
my $omnishell = new PandoraFMS::Omnishell(
{
%{$config},
'ConfDir' => dirname($ConfFile)
}
);
if (empty($omnishell->run('xml')) && is_enabled($config->{'debug'}) ) {
print STDERR $omnishell->get_last_error()."\n";
}
};
if ($@) {
if (is_enabled($config->{'debug'})) {
print STDERR $@."\n";
}
exit 1;
}
exit 0;

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.750(Build 201015)")
#define PANDORA_VERSION ("7.0NG.750(Build 201202)")
string pandora_path;
string pandora_dir;

View File

@ -1704,7 +1704,7 @@ Pandora_Windows_Service::checkConfig (string file) {
}
int
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) {
int rc = 0, rc_sec = 0, xml_buffer;
string data_xml;
string xml_filename, random_integer;
@ -1785,10 +1785,13 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
modules->goNext ();
}
}
/* Write extra content (omnishell, for instance) */
data_xml += extra;
/* Close the XML header */
data_xml += "</agent_data>";
/* Generate temporal filename */
random_integer = inttostr (rand());
tmp_filename = conf->getValue ("agent_name");
@ -2018,7 +2021,7 @@ Pandora_Windows_Service::pandora_run () {
void
Pandora_Windows_Service::pandora_run (int forced_run) {
Pandora_Agent_Conf *conf = NULL;
string server_addr, conf_file, *all_conf;
string server_addr, conf_file, *all_conf, omnishell_output, omnishell_path;
int startup_delay = 0;
int i, num;
static bool startup = true;
@ -2055,6 +2058,15 @@ Pandora_Windows_Service::pandora_run (int forced_run) {
this->checkCollections ();
}
/* Execute omnishell commands */
omnishell_path = '"'+Pandora::getPandoraInstallDir ();
omnishell_path += "util\\omnishell_client.exe\" \"" + conf_file+"\"";
if (getPandoraDebug () != false) {
pandoraLog ("Omnishell: Running");
}
omnishell_output = getValueFromCmdExec(omnishell_path.c_str(), 6000000);
server_addr = conf->getValue ("server_ip");
execution_number++;
@ -2126,7 +2138,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) {
// Send the XML
if (!server_addr.empty ()) {
this->sendXml (this->modules);
this->sendXml (this->modules, omnishell_output);
}
}

View File

@ -117,7 +117,7 @@ namespace Pandora {
const char *svc_description);
void start ();
int sendXml (Pandora_Module_List *modules);
int sendXml (Pandora_Module_List *modules, string extra = "");
void sendBufferedXml (string path, copy_func_p copy_func, bool secondary_buffer);
Pandora_Agent_Conf *getConf ();
string getEHKey (string ehorus_conf);

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.750(Build 201015))"
VALUE "ProductVersion", "(7.0NG.750(Build 201202))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.750
Version: 7.0NG.750-201202
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.750"
pandora_version="7.0NG.750-201202"
package_pear=0
package_pandora=1

View File

@ -1,651 +1,91 @@
<?php
/**
* Agents/Alerts Monitoring view.
*
* @category Operations
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2020 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php';
// Begin.
global $config;
// Require needed class.
require_once $config['homedir'].'/include/class/AgentsAlerts.class.php';
// Get the parameter.
$sec2 = get_parameter_get('sec2');
// Add operation menu option.
extensions_add_operation_menu_option(
__('Agents/Alerts view'),
'estado',
null,
'v1r1',
'view'
);
// If sec2 parameter come with this page info.
if ($sec2 === 'extensions/agents_alerts') {
extensions_add_main_function('mainAgentsAlerts');
}
/**
* Function for load the controller.
*
* @return void
*/
function mainAgentsAlerts()
{
global $config;
// Load global vars
include_once 'include/config.php';
include_once 'include/functions_reporting.php';
check_login();
// ACL Check
if (! check_acl($config['id_user'], 0, 'AR')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Agent view (Grouped)'
);
include 'general/noaccess.php';
exit;
}
// Update network modules for this group
// Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side
if (isset($_GET['update_netgroup'])) {
$group = get_parameter_get('update_netgroup', 0);
if (check_acl($config['id_user'], $group, 'AW')) {
$where = ['id_agente' => 'ANY(SELECT id_agente FROM tagente WHERE id_grupo = '.$group];
db_process_sql_update('tagente_modulo', ['flag' => 1], $where);
} else {
db_pandora_audit('ACL Violation', 'Trying to set flag for groups');
include 'general/noaccess.php';
// Ajax variables.
$pageName = '[AgentsAlerts]';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$obj = new AgentsAlerts();
} catch (Exception $e) {
if (is_ajax() === true) {
echo json_encode(['error' => $pageName.$e->getMessage() ]);
exit;
}
}
if ($config['realtimestats'] == 0) {
$updated_info = __('Last update').' : '.ui_print_timestamp(db_get_sql('SELECT min(utimestamp) FROM tgroup_stat'), true);
} else {
// $updated_info = __("Updated at realtime");
$updated_info = '';
}
$updated_time = $updated_info;
$create_alert = (int) get_parameter('create_alert', 0);
if ($create_alert) {
$template2 = get_parameter('template');
$module_action_threshold = get_parameter('module_action_threshold');
$id_alert = alerts_create_alert_agent_module($create_alert, $template2);
if ($id_alert !== false) {
$action_select = get_parameter('action_select', 0);
if ($action_select != 0) {
$values = [];
$values['fires_min'] = 0;
$values['fires_max'] = 0;
$values['module_action_threshold'] = (int) get_parameter('module_action_threshold');
alerts_add_alert_agent_module_action($id_alert, $action_select, $values);
}
}
}
$refr = (int) get_parameter('refr', 30);
// By default 30 seconds
$show_modules = (bool) get_parameter('show_modules', 0);
$group_id = get_parameter('group_id', 0);
$offset = get_parameter('offset', 0);
$hor_offset = get_parameter('hor_offset', 0);
$block = 20;
$groups = users_get_groups();
$filter_groups .= '<b>'.__('Group').'</b>';
$filter_groups .= '<div class="w250px inline margin-left-2">';
$filter_groups .= html_print_select_groups(false, 'AR', true, 'group_id', $group_id, false, '', '', true, false, true, '', false, 'margin-right: 10px; margin-top: 5px;');
$filter_groups .= '</div>';
$check = '<b>'.__('Show modules without alerts').'</b>';
$check .= html_print_checkbox('slides_ids[]', $d['id'], $show_modules, true, false, '', true);
$comborefr = '<form method="post" action="'.ui_get_url_refresh(['offset' => 0, 'hor_offset' => 0]).'">';
$comborefr .= '<b>'.__('Refresh').'</b>';
$comborefr .= html_print_select(
[
'30' => '30 '.__('seconds'),
(string) SECONDS_1MINUTE => __('1 minute'),
(string) SECONDS_2MINUTES => __('2 minutes'),
(string) SECONDS_5MINUTES => __('5 minutes'),
(string) SECONDS_10MINUTES => __('10 minutes'),
],
'refr',
(int) get_parameter('refr', 0),
$script = 'this.form.submit()',
'',
0,
true,
false,
false,
'',
false,
'width: 100px; margin-right: 10px; margin-top: 5px;'
);
$comborefr .= '</form>';
if ($config['pure'] == 0) {
$fullscreen['text'] = '<a href="'.ui_get_url_refresh(['pure' => 1]).'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode')]).'</a>';
} else {
$fullscreen['text'] = '<a href="'.ui_get_url_refresh(['pure' => 0]).'">'.html_print_image('images/normal_screen.png', true, ['title' => __('Back to normal mode')]).'</a>';
$config['refr'] = $refr;
}
$onheader = [
'updated_time' => $updated_time,
'fullscreen' => $fullscreen,
'combo_groups' => $filter_groups,
];
if ($config['pure'] == 1) {
$onheader['combo_refr'] = $comborefr;
}
// Header.
ui_print_page_header(
__('Agents/Alerts'),
'images/op_alerts.png',
false,
'',
false,
$updated_time
);
// Old style table, we need a lot of special formatting,don't use table function
// Prepare old-style table
echo '<table class="databox filters" cellpadding="0" cellspacing="0" border="0" style="width:100%;">';
echo '<tr>';
echo '<td>'.$filter_groups.'</td>';
echo '<td>'.$check.'</td>';
if ($config['pure'] == 1) {
echo '<td>'.$comborefr.'</td>';
}
echo '<td> <strong>'.__('Full screen').'</strong>'.$fullscreen['text'].'</td>';
echo '</tr>';
echo '</table>';
if ($show_modules) {
if ($group_id > 0) {
$grupo = " AND tagente.id_grupo = $group_id";
} else {
$grupo = '';
echo $pageName.$e->getMessage();
}
$offset_modules = get_parameter('offset', 0);
$sql_count = "SELECT COUNT(tagente_modulo.nombre) FROM tagente_modulo
INNER JOIN tagente ON tagente.id_agente = tagente_modulo.id_agente
WHERE id_agente_modulo NOT IN (SELECT id_agent_module FROM talert_template_modules)
$grupo";
$count_agent_module = db_get_all_rows_sql($sql_count);
$sql = "SELECT tagente.alias, tagente_modulo.nombre,
tagente_modulo.id_agente_modulo FROM tagente_modulo
INNER JOIN tagente ON tagente.id_agente = tagente_modulo.id_agente
WHERE id_agente_modulo NOT IN (SELECT id_agent_module FROM talert_template_modules)
$grupo LIMIT 20 OFFSET $offset_modules";
$agent_modules = db_get_all_rows_sql($sql);
ui_pagination(
$count_agent_module[0]['COUNT(tagente_modulo.nombre)'],
ui_get_url_refresh(),
0,
0,
false,
'offset',
true,
'',
'',
false,
'alerts_modules'
);
$table->width = '100%';
$table->class = 'databox data';
$table->id = 'table_agent_module';
$table->data = [];
$table->head[0] = __('Agents');
$table->head[1] = __('Modules');
$table->head[2] = __('Actions');
$table->style[0] = 'width: 25%;';
$table->style[1] = 'width: 33%;';
$table->style[2] = 'width: 33%;';
foreach ($agent_modules as $agent_module) {
$data[0] = io_safe_output($agent_module['alias']);
$data[1] = io_safe_output($agent_module['nombre']);
$uniqid = $agent_module['id_agente_modulo'];
$data[2] = "<a title='".__('Create alert')."' href='javascript:show_add_alerts(\"$uniqid\")'>".html_print_image('images/add_mc.png', true).'</a>';
array_push($table->data, $data);
$table2->width = '100%';
$table2->id = 'table_add_alert';
$table2->class = 'databox filters';
$table2->data = [];
// $data[0] =
$table2->data[0][0] = __('Actions');
$groups_user = users_get_groups($config['id_user']);
if (!empty($groups_user)) {
$groups = implode(',', array_keys($groups_user));
$sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)";
$actions = db_get_all_rows_sql($sql);
}
$table2->data[0][1] = html_print_select(
index_array($actions, 'id', 'name'),
'action_select',
'',
'',
__('Default action'),
'0',
true,
'',
true,
'',
false,
'width: 250px;'
);
$table2->data[0][1] .= '<span id="advanced_action" class="advanced_actions invisible"><br>';
$table2->data[0][1] .= __('Number of alerts match from').' ';
$table2->data[0][1] .= html_print_input_text('fires_min', '', '', 4, 10, true);
$table2->data[0][1] .= ' '.__('to').' ';
$table2->data[0][1] .= html_print_input_text('fires_max', '', '', 4, 10, true);
$table2->data[0][1] .= ui_print_help_icon(
'alert-matches',
true,
ui_get_full_url(false, false, false, false)
);
$table2->data[0][1] .= '</span>';
if (check_acl($config['id_user'], 0, 'LM')) {
$table2->data[0][1] .= '<a style="margin-left:5px;" href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">';
$table2->data[0][1] .= html_print_image('images/add.png', true);
$table2->data[0][1] .= '<span style="margin-left:5px;vertical-align:middle;">'.__('Create Action').'</span>';
$table2->data[0][1] .= '</a>';
}
$table2->data[1][0] = __('Template');
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
$templates = alerts_get_alert_templates(false, ['id', 'name']);
} else {
$usr_groups = users_get_groups($config['id_user'], 'LW', true);
$filter_groups = '';
$filter_groups = implode(',', array_keys($usr_groups));
$templates = alerts_get_alert_templates(['id_group IN ('.$filter_groups.')'], ['id', 'name']);
}
$table2->data[1][1] = html_print_select(
index_array($templates, 'id', 'name'),
'template',
'',
'',
__('Select'),
0,
true,
false,
true,
'',
false,
'width: 250px;'
);
$table2->data[1][1] .= ' <a class="template_details invisible" href="#">'.html_print_image('images/zoom.png', true, ['class' => 'img_help']).'</a>';
if (check_acl($config['id_user'], 0, 'LM')) {
$table2->data[1][1] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">';
$table2->data[1][1] .= html_print_image('images/add.png', true);
$table2->data[1][1] .= '<span style="margin-left:5px;vertical-align:middle;">'.__('Create Template').'</span>';
$table2->data[1][1] .= '</a>';
}
$table2->data[2][0] = __('Threshold');
$table2->data[2][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true);
$table2->data[2][1] .= ' '.__('seconds');
$content2 = '<form class="add_alert_form" method="post">';
$content2 .= html_print_table($table2, true);
$content2 .= '<div class="action-buttons" style="width: '.$table2->width.'">';
$content2 .= html_print_submit_button(__('Add alert'), 'add', false, 'class="sub wand"', true);
$content2 .= html_print_input_hidden('create_alert', $uniqid, true);
$content2 .= '</div></form>';
$module_name = ui_print_truncate_text(io_safe_output($agent_module['nombre']), 40, false, true, false, '&hellip;', false);
echo '<div id="add_alerts_dialog_'.$uniqid.'" title="'.__('Agent').': '.$agent_module['alias'].' / '.__('module').': '.$module_name.'" style="display:none">'.$content2.'</div>';
}
html_print_table($table);
} else {
$filter = [
'offset' => (int) $offset,
'limit' => (int) $config['block_size'],
];
$filter_count = [];
if ($group_id > 0) {
$filter['id_grupo'] = $group_id;
$filter_count['id_grupo'] = $group_id;
}
// Get the id of all agents with alerts
$sql = 'SELECT DISTINCT(id_agente)
FROM tagente_modulo
WHERE id_agente_modulo IN
(SELECT id_agent_module
FROM talert_template_modules)';
$agents_with_alerts_raw = db_get_all_rows_sql($sql);
if ($agents_with_alerts_raw === false) {
$agents_with_alerts_raw = [];
}
$agents_with_alerts = [];
foreach ($agents_with_alerts_raw as $awar) {
$agents_with_alerts[] = $awar['id_agente'];
}
$filter['id_agente'] = $agents_with_alerts;
$filter_count['id_agente'] = $agents_with_alerts;
$agents = agents_get_agents($filter);
$nagents = count(agents_get_agents($filter_count));
if ($agents == false) {
ui_print_info_message(['no_close' => true, 'message' => __('There are no agents with alerts') ]);
return;
}
$all_alerts = agents_get_alerts_simple();
if ($config['pure'] == 1) {
$block = count($all_alerts);
}
$templates = [];
$agent_alerts = [];
foreach ($all_alerts as $alert) {
$templates[$alert['id_alert_template']] = '';
$agent_alerts[$alert['agent_name']][$alert['id_alert_template']][] = $alert;
}
// Prepare pagination
ui_pagination(
$nagents,
false,
0,
0,
false,
'offset',
true,
'',
'',
[
'count' => '',
'offset' => 'offset_param',
],
'alerts_agents'
);
echo '<table class="info_table" cellpadding="0" cellspacing="0" border="0" width=100%>';
echo '<thead><tr>';
echo "<th width='140px' >".__('Agents').' / '.__('Alert templates').'</th>';
if ($hor_offset > 0) {
$new_hor_offset = ($hor_offset - $block);
echo "<th width='20px' style='' rowspan='".($nagents + 1)."'>
<a href='index.php?sec=extensions&sec2=extensions/agents_alerts&refr=0&hor_offset=".$new_hor_offset.'&offset='.$offset.'&group_id='.$group_id."'>".html_print_image('images/darrowleft.png', true, ['title' => __('Previous templates')]).'</a> </th>';
}
$templates_raw = [];
if (!empty($templates)) {
$sql = sprintf(
'SELECT id, name
FROM talert_templates
WHERE id IN (%s)',
implode(',', array_keys($templates))
);
$templates_raw = db_get_all_rows_sql($sql);
}
if (empty($templates_raw)) {
$templates_raw = [];
}
$alerts = [];
$ntemplates = 0;
foreach ($templates_raw as $temp) {
if (isset($templates[$temp['id']]) && $templates[$temp['id']] == '') {
$ntemplates++;
if ($ntemplates <= $hor_offset || $ntemplates > ($hor_offset + $block)) {
continue;
}
$templates[$temp['id']] = $temp['name'];
}
}
foreach ($templates as $tid => $tname) {
if ($tname == '') {
continue;
}
echo '<th width="20px" >'.io_safe_output($tname).'</th>';
}
echo '</tr></thead>';
if (($hor_offset + $block) < $ntemplates) {
$new_hor_offset = ($hor_offset + $block);
echo "<th width='20px' style='' rowspan='".($nagents + 1)."'>
<a href='index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=".$new_hor_offset.'&offset='.$offset.'&group_id='.$group_id."'>".html_print_image('images/darrowright.png', true, ['title' => __('More templates')]).'</a> </th>';
}
foreach ($agents as $agent) {
$alias = db_get_row('tagente', 'id_agente', $agent['id_agente']);
echo '<tr>';
// Name of the agent
echo '<td style="font-weight:bold;">'.$alias['alias'].'</td>';
// Alerts of the agent
$anyfired = false;
foreach ($templates as $tid => $tname) {
if ($tname == '') {
continue;
}
if (isset($agent_alerts[$agent['nombre']][$tid])) {
foreach ($agent_alerts[$agent['nombre']][$tid] as $alert) {
if ($alert['times_fired'] > 0) {
$anyfired = true;
}
}
$cellstyle = '';
if ($anyfired) {
$cellstyle = 'background:'.COL_ALERTFIRED.';';
}
echo '<td style=";'.$cellstyle.'" class="action_buttons"> ';
$uniqid = uniqid();
echo '<div>';
echo count($agent_alerts[$agent['nombre']][$tid]).' '.__('Alerts').' ';
echo "<a href='javascript:show_alerts_details(\"$uniqid\")'>".html_print_image('images/zoom.png', true).'</a>';
echo '</div>';
print_alerts_summary_modal_window($uniqid, $agent_alerts[$agent['nombre']][$tid]);
} else {
echo '<td style="text-align:center"> ';
}
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
ui_pagination(
$nagents,
false,
0,
0,
false,
'offset',
true,
'pagination-bottom',
'',
[
'count' => '',
'offset' => 'offset_param',
],
'alerts_agents'
);
// Stop this execution, but continue 'globally'.
return;
}
// AJAX controller.
if (is_ajax() === true) {
$method = get_parameter('method');
if (method_exists($obj, $method) === true) {
$obj->{$method}();
} else {
$obj->error('Method not found. ['.$method.']');
}
// Stop any execution.
exit;
} else {
// Run.
$obj->run();
}
}
// Print the modal window for the summary of each alerts group
function print_alerts_summary_modal_window($id, $alerts)
{
$table->width = '98%';
$table->class = 'info_table';
$table->data = [];
$table->head[0] = __('Module');
$table->head[1] = __('Action');
$table->head[2] = __('Last fired');
$table->head[3] = __('Status');
foreach ($alerts as $alert) {
$data[0] = modules_get_agentmodule_name($alert['id_agent_module']);
$actions = alerts_get_alert_agent_module_actions($alert['id']);
$actionDefault = db_get_value_sql(
'
SELECT id_alert_action
FROM talert_templates
WHERE id = '.$alert['id_alert_template']
);
$actionText = '';
if (!empty($actions)) {
$actionText = '<div style="margin-left: 10px;"><ul class="action_list">';
foreach ($actions as $action) {
$actionText .= '<div><span class="action_name"><li>'.$action['name'];
if ($action['fires_min'] != $action['fires_max']) {
$actionText .= ' ('.$action['fires_min'].' / '.$action['fires_max'].')';
}
$actionText .= '</li></span><br /></div>';
}
$actionText .= '</ul></div>';
} else {
if (!empty($actionDefault)) {
$actionText = db_get_sql(
"SELECT name
FROM talert_actions
WHERE id = $actionDefault"
).' <i>('.__('Default').')</i>';
}
}
$data[1] = $actionText;
$data[2] = ui_print_timestamp($alert['last_fired'], true);
$status = STATUS_ALERT_NOT_FIRED;
if ($alert['times_fired'] > 0) {
$status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert['internal_counter'].' '.__('time(s)');
} else if ($alert['disabled'] > 0) {
$status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled');
} else {
$status = STATUS_ALERT_NOT_FIRED;
$title = __('Alert not fired');
}
$data[3] = ui_print_status_image($status, $title, true);
array_push($table->data, $data);
}
$content = html_print_table($table, true);
$agent = modules_get_agentmodule_agent_alias($alerts[0]['id_agent_module']);
$template = alerts_get_alert_template_name($alerts[0]['id_alert_template']);
echo '<div id="alerts_details_'.$id.'" title="'.__('Agent').': '.$agent.' / '.__('Template').': '.$template.'" style="display:none">'.$content.'</div>';
}
extensions_add_operation_menu_option(__('Agents/Alerts view'), 'estado', null, 'v1r1', 'view');
extensions_add_main_function('mainAgentsAlerts');
ui_require_jquery_file('pandora');
?>
<script type="text/javascript">
function show_alerts_details(id) {
$("#alerts_details_"+id).dialog({
resizable: true,
draggable: true,
modal: true,
height: 280,
width: 800,
overlay: {
opacity: 0.5,
background: "black"
}
});
}
function show_add_alerts(id) {
$("#add_alerts_dialog_"+id).dialog({
resizable: true,
draggable: true,
modal: true,
height: 235,
width: 600,
overlay: {
opacity: 0.5,
background: "black"
}
});
}
// checkbox-slides_ids
$(document).ready(function () {
$('#checkbox-slides_ids').click(function(){
if ($('#checkbox-slides_ids').prop('checked')){
var url = location.href.replace("&show_modules=true", "");
location.href = url+"&show_modules=true";
} else {
var url = location.href.replace("&show_modules=true", "");
var re = /&offset=\d*/g;
location.href = url.replace(re, "");
}
});
$('#group_id').change(function(){
if(location.href.indexOf("extensions/agents_modules") == -1){
var regx = /&group_id=\d*/g;
var url = location.href.replace(regx, "");
location.href = url+"&group_id="+$("#group_id").val();
}
});
});
</script>

View File

@ -26,17 +26,6 @@ function agents_modules_load_js()
$ignored_params['refresh'] = '';
?>
<style type='text/css'>
.rotate_text_module {
-ms-transform: rotate(270deg);
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
writing-mode: lr-tb;
white-space: nowrap;
}
</style>
<script type='text/javascript'>
$(document).ready(function () {
//Get max width of name of modules
@ -668,7 +657,7 @@ function mainAgentsModules()
if ($recursion) {
$filter_groups['id_grupo'] = array_merge(
$group_id,
groups_get_id_recursive($group_id, true)
groups_get_children_ids($group_id, true)
);
} else {
$filter_groups['id_grupo'] = $group_id;

View File

@ -86,7 +86,6 @@ function mainModuleGroups()
);
$info = $tree_group->getArray();
$info = groupview_plain_groups($info);
$counter = count($info);
$offset = get_parameter('offset', 0);
$agent_group_search = get_parameter('agent_group_search', '');
$module_group_search = get_parameter('module_group_search', '');
@ -134,6 +133,8 @@ function mainModuleGroups()
$ids_group = -1;
}
$counter = count($info);
$condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT);
$condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT);
$condition_unknown = modules_get_state_condition(AGENT_MODULE_STATUS_UNKNOWN);

View File

@ -468,6 +468,7 @@ function quickShellSettings()
100,
true
);
$hidden->data[1][1] .= ui_print_reveal_password('gotty_pass', true);
html_print_table($t);

View File

@ -1,22 +1,42 @@
<?php
/**
* Funtions real time.
*
* @category Realtime
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2014 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; 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.
global $config;
require_once $config['homedir'].'/include/graphs/fgraph.php';
require_once $config['homedir'].'/include/functions_snmp_browser.php';
/**
* Real time charts.
*
* @return void
*/
function pandora_realtime_graphs()
{
global $config;
@ -28,7 +48,7 @@ function pandora_realtime_graphs()
$onheader = [];
$hide_header = get_parameter('hide_header', 0);
if (!$hide_header) {
if ($hide_header === 0) {
ui_print_page_header(
__('Realtime graphs'),
'images/extensions.png',
@ -96,18 +116,42 @@ function pandora_realtime_graphs()
$table->data = [];
$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name());
$graph_fields['pending_packets'] = __('Pending packages from %s Server', get_product_name());
$graph_fields['disk_io_wait'] = __('%s Server Disk IO Wait', get_product_name());
$graph_fields['apache_load'] = __('%s Server Apache load', get_product_name());
$graph_fields['mysql_load'] = __('%s Server MySQL load', get_product_name());
$graph_fields['server_load'] = __('%s Server load', get_product_name());
$graph_fields['pending_packets'] = __(
'Pending packages from %s Server',
get_product_name()
);
$graph_fields['disk_io_wait'] = __(
'%s Server Disk IO Wait',
get_product_name()
);
$graph_fields['apache_load'] = __(
'%s Server Apache load',
get_product_name()
);
$graph_fields['mysql_load'] = __(
'%s Server MySQL load',
get_product_name()
);
$graph_fields['server_load'] = __(
'%s Server load',
get_product_name()
);
$graph_fields['snmp_interface'] = __('SNMP Interface throughput');
$graph = get_parameter('graph', 'cpu_load');
$refresh = get_parameter('refresh', '1000');
if ($graph != 'snmp_module') {
$data['graph'] = __('Graph').'&nbsp;&nbsp;'.html_print_select($graph_fields, 'graph', $graph, '', '', 0, true);
$data['graph'] = __('Graph').'&nbsp;&nbsp;';
$data['graph'] .= html_print_select(
$graph_fields,
'graph',
$graph,
'',
'',
0,
true
);
}
$refresh_fields[1000] = human_time_description_raw(1, true, 'large');
@ -119,10 +163,14 @@ function pandora_realtime_graphs()
$agent_alias = io_safe_output(get_parameter('agent_alias', ''));
$module_name = io_safe_output(get_parameter('module_name', ''));
$module_incremental = get_parameter('incremental', 0);
$data['module_info'] = "$agent_alias: <b>$module_name</b>";
$data['module_info'] = $agent_alias.': <b>'.$module_name.'</b>';
// Append all the hidden in this cell
$data['module_info'] .= html_print_input_hidden('incremental', $module_incremental, true);
// Append all the hidden in this cell.
$data['module_info'] .= html_print_input_hidden(
'incremental',
$module_incremental,
true
);
$data['module_info'] .= html_print_select(
['snmp_module' => '-'],
'graph',
@ -139,76 +187,72 @@ function pandora_realtime_graphs()
);
}
$data['refresh'] = __('Refresh interval').'&nbsp;&nbsp;'.html_print_select($refresh_fields, 'refresh', $refresh, '', '', 0, true);
$data['refresh'] = __('Refresh interval').'&nbsp;&nbsp;';
$data['refresh'] .= html_print_select(
$refresh_fields,
'refresh',
$refresh,
'',
'',
0,
true
);
if ($graph != 'snmp_module') {
$data['incremental'] = __('Incremental').'&nbsp;&nbsp;'.html_print_checkbox('incremental', 1, 0, true);
$data['incremental'] = __('Incremental').'&nbsp;&nbsp;';
$data['incremental'] .= html_print_checkbox('incremental', 1, 0, true);
}
$data['reset'] = html_print_button(__('Clear graph'), 'reset', false, 'javascript:realtimeGraphs.clearGraph();', 'class="sub delete" style="margin-top:0px;"', true);
$data['reset'] = html_print_button(
__('Clear graph'),
'reset',
false,
'javascript:realtimeGraphs.clearGraph();',
'class="sub delete" style="margin-top:0px;"',
true
);
$table->data[] = $data;
if ($graph == 'snmp_interface' || $graph == 'snmp_module') {
$snmp_address = get_parameter('snmp_address', '');
$snmp_community = get_parameter('snmp_community', '');
$snmp_oid = get_parameter('snmp_oid', '');
$snmp_ver = get_parameter('snmp_ver', '');
$data = [];
$data['snmp_address'] = __('Target IP').'&nbsp;&nbsp;'.html_print_input_text('ip_target', $snmp_address, '', 50, 255, true);
$table->colspan[1]['snmp_address'] = 2;
$data['snmp_community'] = __('Community').'&nbsp;&nbsp;'.html_print_input_text('snmp_community', $snmp_community, '', 50, 255, true);
$table->colspan[1]['snmp_community'] = 2;
$table->data[] = $data;
$snmp_versions = [];
$snmp_versions['1'] = '1';
$snmp_versions['2'] = '2';
$snmp_versions['2c'] = '2c';
$data = [];
$data['snmp_oid'] = __('OID').'&nbsp;&nbsp;'.html_print_input_text('snmp_oid', $snmp_oid, '', 100, 255, true);
$table->colspan[2]['snmp_oid'] = 2;
$data['snmp_ver'] = __('Version').'&nbsp;&nbsp;'.html_print_select($snmp_versions, 'snmp_version', $snmp_ver, '', '', 0, true);
$data['snmp_ver'] .= '&nbsp;&nbsp;'.html_print_button(__('SNMP walk'), 'snmp_walk', false, 'javascript:snmpBrowserWindow();', 'class="sub next"', true);
$table->colspan[2]['snmp_ver'] = 2;
$table->data[] = $data;
// Hide some options in snmp_module graphs
if ($graph == 'snmp_module') {
$table->rowstyle[1] = 'display: none;';
$table->rowstyle[2] = 'display: none;';
}
snmp_browser_print_container(false, '100%', '60%', 'none');
echo snmp_browser_print_container(true, '100%', '60%', 'none');
}
// Print the relative path to AJAX calls:
// Print the relative path to AJAX calls.
html_print_input_hidden('rel_path', get_parameter('rel_path', ''));
// Print the form
// Print the form.
echo '<form id="realgraph" method="post">';
html_print_table($table);
echo '</form>';
// Define a custom action to save the OID selected in the SNMP browser to the form
html_print_input_hidden('custom_action', urlencode(base64_encode('&nbsp;<a href="javascript:realtimeGraphs.setOID();"><img src="'.ui_get_full_url('images').'/input_filter.disabled.png" title="'.__('Use this OID').'" style="vertical-align: middle;"></img></a>')), false);
// Define a custom action to save
// the OID selected in the SNMP browser to the form.
html_print_input_hidden(
'custom_action',
urlencode(
base64_encode(
'&nbsp;<a href="javascript:realtimeGraphs.setOID();"><img src="'.ui_get_full_url('images').'/input_filter.disabled.png" title="'.__('Use this OID').'" style="vertical-align: middle;"></img></a>'
)
),
false
);
html_print_input_hidden('incremental_base', '0');
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/pandora_snmp_browser.js').'"></script>';
echo '<script type="text/javascript" src="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.js').'"></script>';
echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.css').'"></style>';
// Store servers timezone offset to be retrieved from js
// Store servers timezone offset to be retrieved from js.
set_js_value('timezone_offset', date('Z', time()));
}
extensions_add_operation_menu_option(__('Realtime graphs'), 'estado', null, 'v1r1', 'view');
extensions_add_operation_menu_option(
__('Realtime graphs'),
'estado',
null,
'v1r1',
'view'
);
extensions_add_main_function('pandora_realtime_graphs');
$db = null;

View File

@ -69,15 +69,34 @@ switch ($graph) {
case 'snmp_interface':
case 'snmp_module':
$snmp_address = $_POST['snmp_address'];
$snmp_community = $_POST['snmp_community'];
$snmp_ver = $_POST['snmp_ver'];
$snmp_oid = $_POST['snmp_oid'];
$snmp_address = get_parameter('snmp_address', '');
$snmp_community = get_parameter('snmp_community', '');
$snmp_ver = get_parameter('snmp_ver', '');
$snmp_oid = get_parameter('snmp_oid', '');
$snmp3_auth_user = get_parameter('snmp3_auth_user', '');
$snmp3_security_level = get_parameter('snmp3_security_level', '');
$snmp3_auth_method = get_parameter('snmp3_auth_method', '');
$snmp3_auth_pass = get_parameter('snmp3_auth_pass', '');
$snmp3_privacy_method = get_parameter('snmp3_privacy_method', '');
$snmp3_privacy_pass = get_parameter('snmp3_privacy_pass', '');
if (empty($snmp_address) || empty($snmp_oid)) {
$data = 0;
} else {
$data = get_snmpwalk($snmp_address, $snmp_ver, $snmp_community, '', '', '', '', '', '', 0, $snmp_oid);
$data = get_snmpwalk(
$snmp_address,
$snmp_ver,
$snmp_community,
$snmp3_auth_user,
$snmp3_security_level,
$snmp3_auth_method,
$snmp3_auth_pass,
$snmp3_privacy_method,
$snmp3_privacy_pass,
0,
$snmp_oid,
$snmp_port
);
$data_index = array_keys($data);
$graph_title = $data_index[0];
if (!empty($data)) {

View File

@ -1,3 +1,4 @@
/* global $, get_php_value */
(function() {
var numberOfPoints = 100;
var refresh = parseInt($("#refresh").val());
@ -14,7 +15,7 @@
container: $("#chartLegend")
},
xaxis: {
tickFormatter: function(timestamp, axis) {
tickFormatter: function(timestamp) {
var date = new Date(timestamp * 1000);
var server_timezone_offset = get_php_value("timezone_offset");
@ -39,7 +40,7 @@
}
},
yaxis: {
tickFormatter: function(value, axis) {
tickFormatter: function(value) {
return shortNumber(roundToTwo(value));
}
},
@ -66,10 +67,16 @@
data: {
graph: $("#graph :selected").val(),
graph_title: $("#graph :selected").html(),
snmp_community: $("#text-snmp_community").val(),
snmp_oid: $("#text-snmp_oid").val(),
snmp_ver: $("#snmp_version :selected").val(),
snmp_address: $("#text-ip_target").val(),
snmp_community: $("#text-community").val(),
snmp_oid: $("#text-starting_oid").val(),
snmp_ver: $("#snmp_browser_version").val(),
snmp_address: $("#text-target_ip").val(),
snmp3_auth_user: $("#text-snmp3_browser_auth_user").val(),
snmp3_security_level: $("#snmp3_browser_security_level").val(),
snmp3_auth_method: $("#snmp3_browser_auth_method").val(),
snmp3_auth_pass: $("#password-snmp3_browser_auth_pass").val(),
snmp3_privacy_method: $("#snmp3_browser_privacy_method").val(),
snmp3_privacy_pass: $("#password-snmp3_browser_privacy_pass").val(),
refresh: refresh
},
success: function(serie) {
@ -87,7 +94,7 @@
}
if (data.length === 0) {
for (i = 0; i < numberOfPoints; i++) {
for (var i = 0; i < numberOfPoints; i++) {
var step = i * (refresh / 1000);
serie.data.unshift([timestamp - step, 0]);
}
@ -123,7 +130,7 @@
var data = plot.getData();
if (data.length === 0) return;
for (i = 0; i < data[0].data.length; i++) {
for (var i = 0; i < data[0].data.length; i++) {
data[0].data[i][1] = 0;
}
if (incremental) lastIncVal = null;

View File

@ -92,7 +92,11 @@ function output_xml_report($id)
$group = db_get_value('nombre', 'tgrupo', 'id_grupo', $report['id_group']);
echo '<group><![CDATA['.io_safe_output($group)."]]></group>\n";
$items = db_get_all_rows_field_filter('treport_content', 'id_report', $report['id_report']);
$items = db_get_all_rows_field_filter(
'treport_content',
'id_report',
$report['id_report']
);
foreach ($items as $item) {
echo "<item>\n";
echo '<type>'.io_safe_output($item['type'])."</type>\n";

View File

@ -37,8 +37,16 @@ function insert_item_report($report_id, $values)
ui_print_result_message(
$result,
sprintf(__("Success add '%s' item in report '%s'."), $values['type'], $name),
sprintf(__("Error create '%s' item in report '%s'."), $values['type'], $name)
sprintf(
__("Success add '%s' item in report '%s'."),
$values['type'],
$name
),
sprintf(
__("Error create '%s' item in report '%s'."),
$values['type'],
$name
)
);
}
}
@ -55,9 +63,12 @@ function process_upload_xml_report($xml, $group_filter=0)
$posible_name = $values['name'];
$exist = true;
$loops = 30;
// Loops to exit or tries
// Loops to exit or tries.
while ($exist && $loops > 0) {
$exist = (bool) db_get_row_filter('treport', ['name' => io_safe_input($posible_name)]);
$exist = (bool) db_get_row_filter(
'treport',
['name' => io_safe_input($posible_name)]
);
if ($exist) {
$loops--;
@ -74,7 +85,7 @@ function process_upload_xml_report($xml, $group_filter=0)
);
break;
} else if ($loops != 30) {
ui_print_error_message(
ui_print_warning_message(
sprintf(
__("Warning create '%s' report, the name exist, the report have a name %s."),
$reportElement->name,
@ -89,13 +100,22 @@ function process_upload_xml_report($xml, $group_filter=0)
break;
}
$id_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $reportElement->group);
if ($id_group === false) {
ui_print_error_message(__("Error the report haven't group."));
break;
if (isset($reportElement->group) === true
&& empty($reportElement->group) === false
) {
$id_group = db_get_value(
'id_grupo',
'tgrupo',
'nombre',
$reportElement->group
);
if ($id_group === false) {
ui_print_error_message(__("Error the report haven't group."));
break;
}
}
if (isset($reportElement->description)) {
if (isset($reportElement->description) === true) {
$values['description'] = $reportElement->description;
}
@ -108,9 +128,19 @@ function process_upload_xml_report($xml, $group_filter=0)
);
if ($id_report) {
db_pandora_audit('Report management', 'Create report '.$id_report, false, false);
db_pandora_audit(
'Report management',
'Create report '.$id_report,
false,
false
);
} else {
db_pandora_audit('Report management', 'Fail to create report', false, false);
db_pandora_audit(
'Report management',
'Fail to create report',
false,
false
);
break;
}
@ -119,45 +149,52 @@ function process_upload_xml_report($xml, $group_filter=0)
$values = [];
$values['id_report'] = $id_report;
if (isset($item['description'])) {
if (isset($item['description']) === true) {
$values['description'] = io_safe_input($item['description']);
}
if (isset($item['period'])) {
if (isset($item['period']) === true) {
$values['period'] = io_safe_input($item['period']);
}
if (isset($item['type'])) {
if (isset($item['type']) === true) {
$values['type'] = io_safe_input($item['type']);
}
$agents_item = [];
if (isset($item['agent'])) {
if (isset($item['agent']) === true) {
$agents = agents_get_agents(
['id_grupo' => $group_filter],
[
'id_agente',
'nombre',
'alias',
]
);
$agent_clean = str_replace(['[', ']'], '', $item['agent']);
$agent_clean = str_replace(
[
'[',
']',
],
'',
io_safe_output($item['agent'])
);
$regular_expresion = ($agent_clean != $item['agent']);
foreach ($agents as $agent) {
if ($regular_expresion) {
if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent['nombre']))) {
$agents_item[$agent['id_agente']]['name'] = $agent['nombre'];
if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent['alias']))) {
$agents_item[$agent['id_agente']]['name'] = $agent['alias'];
}
} else {
if ($agent_clean == io_safe_output($agent['nombre'])) {
$agents_item[$agent['id_agente']]['name'] = $agent['nombre'];
if ($agent_clean == io_safe_output($agent['alias'])) {
$agents_item[$agent['id_agente']]['name'] = $agent['alias'];
}
}
}
}
if (isset($item['module'])) {
if (isset($item['module']) === true) {
$module_clean = str_replace(['[', ']'], '', $item['module']);
$regular_expresion = ($module_clean != $item['module']);

View File

@ -31,4 +31,6 @@ ALTER TABLE `treport` ADD COLUMN `index_render` tinyint(1) NOT NULL DEFAULT 1;
ALTER TABLE `treport_template` ADD COLUMN `cover_page_render` tinyint(1) NOT NULL DEFAULT 1;
ALTER TABLE `treport_template` ADD COLUMN `index_render` tinyint(1) NOT NULL DEFAULT 1;
UPDATE `tconfig` SET value = '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}' WHERE token = 'post_process_custom_values';
COMMIT;

View File

@ -2,4 +2,10 @@ START TRANSACTION;
ALTER TABLE `tagente_modulo` ADD COLUMN `debug_content` varchar(200);
ALTER TABLE `talert_snmp` ADD COLUMN `al_field16` TEXT NOT NULL AFTER `al_field15`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field17` TEXT NOT NULL AFTER `al_field16`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field18` TEXT NOT NULL AFTER `al_field17`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field19` TEXT NOT NULL AFTER `al_field18`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field20` TEXT NOT NULL AFTER `al_field19`;
COMMIT;

View File

@ -1256,11 +1256,16 @@ ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `talert_snmp`
-- ---------------------------------------------------------------------
ALTER TABLE talert_snmp ADD COLUMN `al_field11` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field11` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field16` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field17` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field18` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field19` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field20` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL,
MODIFY COLUMN `al_field12` text NOT NULL,
@ -1268,6 +1273,7 @@ ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL,
MODIFY COLUMN `al_field14` text NOT NULL,
MODIFY COLUMN `al_field15` text NOT NULL;
-- ---------------------------------------------------------------------
-- Table `talert_snmp_action`
-- ---------------------------------------------------------------------
@ -1405,6 +1411,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_type', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_status', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_title', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', '');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}');
-- ---------------------------------------------------------------------
-- Table `tconfig_os`

View File

@ -114,6 +114,13 @@ foreach ($custom_fields as $field) {
}
}
// Connection lost alert.
ui_require_css_file('register', 'include/styles/', true);
ui_require_javascript_file('connection_check');
$conn_title = __('Connection with server has been lost');
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
// Get the custom icons.
$docs_logo = ui_get_docs_logo();
$support_logo = ui_get_support_logo();
@ -450,7 +457,12 @@ if ($login_screen == 'logout') {
echo '<div class="content_message_alert">';
echo '<div class="text_message_alert">';
echo '<h1>'.__('Logged out').'</h1>';
echo '<p>'.__('Your session has ended. Please close your browser window to close this %s session.', get_product_name()).'</p>';
if (empty($config['logout_msg']) === true) {
echo '<p>'.__('Your session has ended. Please close your browser window to close this %s session.', get_product_name()).'</p>';
} else {
echo '<p>'.__($config['logout_msg']).'</p>';
}
echo '</div>';
echo '<div class="button_message_alert">';
html_print_submit_button('Ok', 'hide-login-logout', false);

View File

@ -148,7 +148,8 @@ if ($initial && users_is_admin()) {
config_wiz_modal(
false,
true,
(($registration === true) ? 'show_registration_wizard()' : null)
(($registration === true) ? 'show_registration_wizard()' : null),
true
);
}
@ -159,7 +160,8 @@ if (!$config['disabled_newsletter']) {
false,
// Launch only if not being launch from 'initial'.
!$initial,
(($show_newsletter === true) ? 'force_run_newsletter()' : null)
(($show_newsletter === false) ? 'force_run_newsletter()' : null),
true
);
} else {
if ($show_newsletter) {
@ -167,7 +169,8 @@ if (!$config['disabled_newsletter']) {
newsletter_wiz_modal(
false,
// Launch only if not being call from 'registration'.
!$registration && !$initial
!$registration && !$initial,
true
);
}
}
@ -183,6 +186,88 @@ try {
$welcome = false;
}
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']);
if (!$double_auth_enabled && $config['2FA_all_users'] != ''
&& $config['2Fa_auth'] != '1'
&& $config['double_auth_enabled']
) {
echo '<div id="doble_auth_window" style="display: none"; >';
?>
<script type="text/javascript">
var userID = "<?php echo $config['id_user']; ?>";
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#doble_auth_window");
$dialogContainer.html($loadingSpinner);
// Load the info page
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'html',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
get_double_auth_info_page: 1,
containerID: $dialogContainer.prop('id')
},
complete: function (xhr, textStatus) {
},
success: function (data, textStatus, xhr) {
// isNaN = is not a number
if (isNaN(data)) {
$dialogContainer.html(data);
}
// data is a number, convert it to integer to do the compare
else if (Number(data) === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
}
},
error: function (xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error loading the data').'</div></b>'; ?>");
}
});
$("div#doble_auth_window").dialog({
<?php config_update_value('2Fa_auth', ''); ?>
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 500,
height: 400,
close: function (event, ui) {
<?php
if (!$double_auth_enabled) {
config_update_value('2Fa_auth', '1');
}
?>
// Abort the ajax request
if (typeof request != 'undefined'){
request.abort();
}
// Remove the contained html
$dialogContainer.empty();
//document.location.reload();
}
})
.show(); </script>
<?php
echo '</div>';
}
$newsletter = null;
?>

View File

@ -149,7 +149,7 @@ if (is_ajax()) {
ui_require_javascript_file('openlayers.pandora');
$new_agent = (bool) get_parameter('new_agent');
$new_agent = (empty($id_agente)) ? true : false;
if (! isset($id_agente) && ! $new_agent) {
db_pandora_audit('ACL Violation', 'Trying to access agent manager witout an agent');
@ -1222,6 +1222,7 @@ ui_require_jquery_file('bgiframe');
$(document).ready (function() {
var $id_agent = '<?php echo $id_agente; ?>';
var previous_primary_group_select;
$("#grupo").on('focus', function () {
previous_primary_group_select = this.value;
@ -1276,12 +1277,14 @@ ui_require_jquery_file('bgiframe');
}
});
paint_qrcode(
"<?php echo ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente); ?>",
"#qr_code_agent_view",
128,
128
);
if (typeof $id_agent !== 'undefined' && $id_agent !== '0') {
paint_qrcode(
"<?php echo ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente); ?>",
"#qr_code_agent_view",
128,
128
);
}
$("#text-agente").prop('readonly', true);
});

View File

@ -408,7 +408,7 @@ if ($ag_group > 0) {
$ag_groups = [];
$ag_groups = (array) $ag_group;
if ($recursion) {
$ag_groups = groups_get_id_recursive($ag_group, true);
$ag_groups = groups_get_children_ids($ag_group, true);
}
$user_groups_to_sql = implode(',', $ag_groups);
@ -754,7 +754,6 @@ if (check_acl($config['id_user'], 0, 'AW')) {
// Create agent button.
echo '<div style="text-align: right;">';
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
html_print_input_hidden('new_agent', 1);
html_print_submit_button(
__('Create agent'),
'crt-2',

View File

@ -535,20 +535,30 @@ $table_advanced->data[0][1] = html_print_input_text(
);
$table_advanced->data[0][3] = __('Unit');
// $table_advanced->data[1][4] = html_print_input_text ('unit', $unit, '', 20, 65, true,
// $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
// $table_advanced->colspan[1][4] = 3;
$table_advanced->data[0][4] = html_print_extended_select_for_unit(
$table_advanced->data[0][4] = html_print_input_text(
'unit',
$unit,
'',
'',
'0',
false,
20,
65,
true,
$disabledBecauseInPolicy,
false,
false
'',
$classdisabledBecauseInPolicy
);
// $table_advanced->colspan[1][4] = 3;
// $table_advanced->data[0][4] = html_print_extended_select_for_unit(
// 'unit',
// $unit,
// '',
// '',
// '0',
// false,
// true,
// false,
// false
// );
$table_advanced->colspan[0][4] = 3;
$module_id_policy_module = 0;
@ -1340,115 +1350,117 @@ $(document).ready (function () {
var type_name_selected = type_names[type_selected];
var element = document.getElementById("module_type_help");
var language = "<?php echo $config['language']; ?>" ;
element.onclick = function (event) {
if(type_name_selected == 'async_data' ||
type_name_selected == 'async_proc' ||
type_name_selected == 'async_string' ||
type_name_selected == 'generic_proc'||
type_name_selected == 'generic_data' ||
type_name_selected == 'generic_data_inc' ||
type_name_selected == 'generic_data_inc_abs'||
type_name_selected == 'generic_data_string' ||
type_name_selected == 'keep_alive'
){
if (language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Operacion&printable=yes#Tipos_de_m.C3.B3dulos',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Operations&printable=yes#Types_of_Modules',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_icmp' ||
type_name_selected == 'remote_icmp_proc'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_ICMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#ICMP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_snmp_string' ||
type_name_selected == 'remote_snmp_proc' ||
type_name_selected == 'remote_snmp_inc' ||
type_name_selected == 'remote_snmp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizando_con_m.C3.B3dulos_de_red_tipo_SNMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#Monitoring_by_Network_Modules_with_SNMP',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_tcp_string' ||
type_name_selected == 'remote_tcp_proc' ||
type_name_selected == 'remote_tcp_inc' ||
type_name_selected == 'remote_tcp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_TCP',
'_blank',
'width=800,height=600'
);
if (typeof element !== 'undefined' && element !== null) {
element.onclick = function (event) {
if(type_name_selected == 'async_data' ||
type_name_selected == 'async_proc' ||
type_name_selected == 'async_string' ||
type_name_selected == 'generic_proc'||
type_name_selected == 'generic_data' ||
type_name_selected == 'generic_data_inc' ||
type_name_selected == 'generic_data_inc_abs'||
type_name_selected == 'generic_data_string' ||
type_name_selected == 'keep_alive'
){
if (language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Operacion&printable=yes#Tipos_de_m.C3.B3dulos',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#TCP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'web_data' ||
type_name_selected == 'web_proc' ||
type_name_selected == 'web_content_data' ||
type_name_selected == 'web_content_string'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_web&printable=yes#Creaci.C3.B3n_de_m.C3.B3dulos_web',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Web_Monitoring&printable=yes#Creating_Web_Modules',
'_blank',
'width=800,height=600'
);
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Operations&printable=yes#Types_of_Modules',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_icmp' ||
type_name_selected == 'remote_icmp_proc'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_ICMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#ICMP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_snmp_string' ||
type_name_selected == 'remote_snmp_proc' ||
type_name_selected == 'remote_snmp_inc' ||
type_name_selected == 'remote_snmp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizando_con_m.C3.B3dulos_de_red_tipo_SNMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#Monitoring_by_Network_Modules_with_SNMP',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_tcp_string' ||
type_name_selected == 'remote_tcp_proc' ||
type_name_selected == 'remote_tcp_inc' ||
type_name_selected == 'remote_tcp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_TCP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#TCP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'web_data' ||
type_name_selected == 'web_proc' ||
type_name_selected == 'web_content_data' ||
type_name_selected == 'web_content_string'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_web&printable=yes#Creaci.C3.B3n_de_m.C3.B3dulos_web',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Web_Monitoring&printable=yes#Creating_Web_Modules',
'_blank',
'width=800,height=600'
);
}
}
}
}

View File

@ -354,8 +354,8 @@ if ($create_downtime || $update_downtime) {
__('Not created. Error inserting data').'. '.__('The end date must be higher than the current time')
);
} else if ($type_execution == 'periodically'
&& (($type_periodicity == 'weekly' && $periodically_time_from >= $periodically_time_to)
|| ($type_periodicity == 'monthly' && $periodically_day_from == $periodically_day_to && $periodically_time_from >= $periodically_time_to))
&& $type_periodicity == 'monthly'
&& $periodically_day_from == $periodically_day_to
) {
ui_print_error_message(
__('Not created. Error inserting data').'. '.__('The end time must be higher than the start time')
@ -877,7 +877,7 @@ if ($id_downtime > 0) {
$filter_cond = '';
if ($filter_group > 0) {
if ($recursion) {
$rg = groups_get_id_recursive($filter_group, true);
$rg = groups_get_children_ids($filter_group, true);
$filter_cond .= ' AND id_grupo IN (';
$i = 0;

View File

@ -131,7 +131,7 @@ if (check_acl($config['id_user'], 0, 'LM')) {
$table->data[2][0] = __('Template');
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
if ($own_info['is_admin']) {
$templates = alerts_get_alert_templates(false, ['id', 'name']);
} else {
$usr_groups = users_get_groups($config['id_user'], 'LW', true);

View File

@ -130,6 +130,16 @@ if ($update || $create) {
$id_agent = (int) get_parameter('id_agent');
$text_module = get_parameter('text_module', '');
$id_agent_module = (int) get_parameter('module_search_hidden');
if ($text_module === '') {
$text_module = io_safe_output(
db_get_value_filter(
'nombre',
'tagente_modulo',
['id_agente_modulo' => $id_agent_module]
)
);
}
$pagination = get_parameter('pagination', '');
$event_view_hr = get_parameter('event_view_hr', '');
$id_user_ack = get_parameter('id_user_ack', '');

View File

@ -168,7 +168,15 @@ if ($id_group) {
}
} else {
$table->data[2][1] = '<div class="w250px inline">';
$table->data[2][1] .= html_print_select_groups(false, 'AR', true, 'id_parent', $id_parent, '', '', '', true);
$table->data[2][1] .= html_print_input(
[
'type' => 'select_groups',
'name' => 'id_parent',
'selected' => $id_parent,
'return' => true,
'returnAllGroup' => true,
]
);
$table->data[2][1] .= '</div>';
}

View File

@ -419,45 +419,52 @@ if ($update_group) {
$aviable_name = false;
}
// Check if group name is unique.
$check = db_get_value_filter(
'nombre',
'tgrupo',
[
'nombre' => $name,
'id_grupo' => $id_group,
],
'AND NOT'
);
// Check if name field is empty.
if ($name != '' && $aviable_name === true) {
$sql = sprintf(
'UPDATE tgrupo
SET nombre = "%s",
icon = "%s",
disabled = %d,
parent = %d,
custom_id = "%s",
propagate = %d,
id_skin = %d,
description = "%s",
contact = "%s",
other = "%s",
password = "%s"
WHERE id_grupo = %d',
$name,
empty($icon) ? '' : substr($icon, 0, -4),
!$alerts_enabled,
$id_parent,
$custom_id,
$propagate,
$skin,
$description,
$contact,
$other,
$group_pass,
$id_group
);
if ($name != '') {
if (!$check) {
if ($aviable_name === true) {
$values = [
'nombre' => $name,
'icon' => empty($icon) ? '' : substr($icon, 0, -4),
'parent' => $id_parent,
'disabled' => !$alerts_enabled,
'custom_id' => $custom_id,
'id_skin' => $skin,
'description' => $description,
'contact' => $contact,
'propagate' => $propagate,
'other' => $other,
'password' => io_safe_input($group_pass),
];
$result = db_process_sql($sql);
} else {
$result = false;
}
$result = db_process_sql_update(
'tgrupo',
$values,
['id_grupo' => $id_group]
);
}
if ($result !== false) {
ui_print_success_message(__('Group successfully updated'));
if ($result) {
ui_print_success_message(__('Group successfully updated'));
} else {
ui_print_error_message(__('There was a problem modifying group'));
}
} else {
ui_print_error_message(__('Each group must have a different name'));
}
} else {
ui_print_error_message(__('There was a problem modifying group'));
ui_print_error_message(__('Group must have a name'));
}
}

View File

@ -67,10 +67,30 @@ if ($add) {
$modules = get_parameter('module');
$modules_id = [];
if (!empty($modules)) {
$modules_id = [];
foreach ($modules as $module) {
foreach ($id_agents as $id_agent) {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
if ($module == '0') {
// Get all modules of agent.
$agent_modules = db_get_all_rows_filter(
'tagente_modulo',
['id_agente' => $id_agent],
'id_agente_modulo'
);
$agent_modules_id = array_map(
function ($field) {
return $field['id_agente_modulo'];
},
$agent_modules
);
$modules_id = array_merge($modules_id, $agent_modules_id);
} else {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
}
}
}

View File

@ -106,15 +106,31 @@ function process_manage_add($id_alert_template, $id_agents, $module_names)
return false;
}
$modules_id = [];
foreach ($module_names as $module) {
foreach ($id_agents as $id_agent) {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
}
}
if ($module == '0') {
// Get all modules of agent.
$agent_modules = db_get_all_rows_filter(
'tagente_modulo',
['id_agente' => $id_agent],
'id_agente_modulo'
);
if (count($module_names) == 1 && $module_names[0] == '0') {
$modules_id = agents_common_modules($id_agents, false, true);
$agent_modules_id = array_map(
function ($field) {
return $field['id_agente_modulo'];
},
$agent_modules
);
$modules_id = array_merge($modules_id, $agent_modules_id);
} else {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
}
}
}
$conttotal = 0;

View File

@ -66,10 +66,29 @@ if ($delete) {
$modules = (array) get_parameter('module');
$modules_id = [];
if (!empty($modules)) {
$modules_id = [];
foreach ($modules as $module) {
foreach ($id_agents as $id_agent) {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
if ($module == '0') {
// Get all modules of agent.
$agent_modules = db_get_all_rows_filter(
'tagente_modulo',
['id_agente' => $id_agent],
'id_agente_modulo'
);
$agent_modules_id = array_map(
function ($field) {
return $field['id_agente_modulo'];
},
$agent_modules
);
$modules_id = array_merge($modules_id, $agent_modules_id);
} else {
$module_id = modules_get_agentmodule_id($module, $id_agent);
$modules_id[] = $module_id['id_agente_modulo'];
}
}
}

View File

@ -40,7 +40,7 @@ if (is_ajax()) {
$keys_prefix = (string) get_parameter('keys_prefix', '');
if ($recursion) {
$groups = groups_get_id_recursive($id_group, true);
$groups = groups_get_children_ids($id_group, true);
} else {
$groups = [$id_group];
}

View File

@ -450,7 +450,7 @@ $table->data['form_modules_2'][1] = html_print_select(
'',
false,
'width:100%'
);
).' '.__('Select all modules').' '.html_print_checkbox('select_all_modules', 1, false, true, false, '', false, "class='static'");
$table->data['form_modules_2'][2] = __('When select modules');
$table->data['form_modules_2'][2] .= '<br>';
@ -522,7 +522,8 @@ $table->data['form_agents_3'][1] = html_print_select(
'',
false,
'width:100%'
);
).' '.__('Select all agents').' '.html_print_checkbox('select_all_agents', 1, false, true, false, '', false, "class='static'");
$table->data['form_agents_3'][2] = __('When select agents');
$table->data['form_agents_3'][2] .= '<br>';
$table->data['form_agents_3'][2] .= html_print_select(
@ -588,6 +589,44 @@ if ($selection_mode == 'modules') {
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () {
$("#checkbox-select_all_modules").change(function() {
if( $('#checkbox-select_all_modules').prop('checked')) {
$("#module_name option").prop('selected', 'selected');
$("#module_name").trigger('change');
} else {
$("#module_name option").prop('selected', false);
$("#module_name").trigger('change');
}
});
$("#module_name").change(function() {
var options_length = $("#module_name option").length;
var options_selected_length = $("#module_name option:selected").length;
if (options_selected_length < options_length) {
$('#checkbox-select_all_modules').prop("checked", false);
}
});
$("#checkbox-select_all_agents").change(function() {
if( $('#checkbox-select_all_agents').prop('checked')) {
$("#id_agents option").prop('selected', 'selected');
$("#id_agents").trigger('change');
} else {
$("#id_agents option").prop('selected', false);
$("#id_agents").trigger('change');
}
});
$("#id_agents").change(function() {
var options_length = $("#id_agents option").length;
var options_selected_length = $("#id_agents option:selected").length;
if (options_selected_length < options_length) {
$('#checkbox-select_all_agents').prop("checked", false);
}
});
$("#id_agents").change(agent_changed_by_multiple_agents);
$("#module_name").change(module_changed_by_multiple_modules);
@ -680,7 +719,7 @@ $(document).ready (function () {
$('#groups_select').val(-1);
}
$('input[type=checkbox]').change (
$('input[type=checkbox]').not(".static").change (
function () {
if (this.id == "checkbox-force_type") {
if (this.checked) {

View File

@ -406,7 +406,8 @@ $table->data['form_modules_2'][1] = html_print_select(
true,
true,
true
);
).' '.__('Select all modules').' '.html_print_checkbox('select_all_modules', 1, false, true, false, '', false, "class='static'");
$table->data['form_modules_2'][2] = __('When select modules');
$table->data['form_modules_2'][2] .= '<br>';
$table->data['form_modules_2'][2] .= html_print_select(
@ -491,7 +492,7 @@ $table->data['form_agents_3'][1] = html_print_select(
true,
true,
false
);
).' '.__('Select all agents').' '.html_print_checkbox('select_all_agents', 1, false, true, false, '', false, "class='static'");
$table->data['form_agents_3'][2] = __('When select agents');
$table->data['form_agents_3'][2] .= '<br>';
@ -1212,7 +1213,45 @@ $(document).ready (function () {
return false;
}
});
$("#checkbox-select_all_modules").change(function() {
if( $('#checkbox-select_all_modules').prop('checked')) {
$("#module_name option").prop('selected', 'selected');
$("#module_name").trigger('change');
} else {
$("#module_name option").prop('selected', false);
$("#module_name").trigger('change');
}
});
$("#module_name").change(function() {
var options_length = $("#module_name option").length;
var options_selected_length = $("#module_name option:selected").length;
if (options_selected_length < options_length) {
$('#checkbox-select_all_modules').prop("checked", false);
}
});
$("#checkbox-select_all_agents").change(function() {
if( $('#checkbox-select_all_agents').prop('checked')) {
$("#id_agents option").prop('selected', 'selected');
$("#id_agents").trigger('change');
} else {
$("#id_agents option").prop('selected', false);
$("#id_agents").trigger('change');
}
});
$("#id_agents").change(function() {
var options_length = $("#id_agents option").length;
var options_selected_length = $("#id_agents option:selected").length;
if (options_selected_length < options_length) {
$('#checkbox-select_all_agents').prop("checked", false);
}
});
$("#text-custom_ip_target").hide();
$("#id_agents").change(agent_changed_by_multiple_agents);
@ -1463,7 +1502,7 @@ $(document).ready (function () {
$('#groups_select').val(-1);
}
$('input[type=checkbox]').change (
$('input[type=checkbox]').not(".static").change (
function () {
if (this.id == "checkbox-force_type") {
if (this.checked) {

View File

@ -258,7 +258,7 @@ if ($id_modulo === COMPONENT_TYPE_WIZARD) {
if ($execution_type === EXECUTION_TYPE_PLUGIN || $module_protocol === 'wmi') {
// Search all parameters received with extra_fields.
foreach ($_REQUEST as $parameter => $thisValue) {
// Extra fields (OIDs Macros or WMI Extra fields)
// Extra fields (OIDs Macros or WMI Extra fields).
if (preg_match('/extra_field_'.$module_protocol.'_/', $parameter) !== 0) {
$tmpParameter = explode('_', $parameter);
$extra_fields['extra_field_'.$tmpParameter[3]] = get_parameter($parameter);
@ -330,7 +330,7 @@ if ($create_component) {
if ($name && !$name_check) {
$id = network_components_create_network_component(
strip_tags(io_safe_input($name), '<br>'),
$name,
$type,
$id_group,
[
@ -431,7 +431,7 @@ if ($update_component) {
$id,
[
'type' => $type,
'name' => strip_tags(io_safe_input($name, '<br>')),
'name' => $name,
'id_group' => $id_group,
'description' => $description,
'module_interval' => $module_interval,

View File

@ -386,121 +386,124 @@ $next_row++;
console.log(type_name_selected);
var element = document.getElementById("module_type_help");
var language = "<?php echo $config['language']; ?>" ;
element.onclick = function (event) {
if(type_name_selected == 'async_data' ||
type_name_selected == 'async_proc' ||
type_name_selected == 'async_string' ||
type_name_selected == 'generic_proc'||
type_name_selected == 'generic_data' ||
type_name_selected == 'generic_data_inc' ||
type_name_selected == 'generic_data_inc_abs'||
type_name_selected == 'generic_data_string' ||
type_name_selected == 'keep_alive'
){
if (language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Operacion&printable=yes#Tipos_de_m.C3.B3dulos',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Operations&printable=yes#Types_of_Modules',
'_blank',
'width=800,height=600'
);
}
if (typeof element !== 'undefined' && element !== null) {
element.onclick = function (event) {
if(type_name_selected == 'async_data' ||
type_name_selected == 'async_proc' ||
type_name_selected == 'async_string' ||
type_name_selected == 'generic_proc'||
type_name_selected == 'generic_data' ||
type_name_selected == 'generic_data_inc' ||
type_name_selected == 'generic_data_inc_abs'||
type_name_selected == 'generic_data_string' ||
type_name_selected == 'keep_alive'
){
if (language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Operacion&printable=yes#Tipos_de_m.C3.B3dulos',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Operations&printable=yes#Types_of_Modules',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_icmp' ||
type_name_selected == 'remote_icmp_proc'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_ICMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#ICMP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_snmp_string' ||
type_name_selected == 'remote_snmp_proc' ||
type_name_selected == 'remote_snmp_inc' ||
type_name_selected == 'remote_snmp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizando_con_m.C3.B3dulos_de_red_tipo_SNMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#Monitoring_by_Network_Modules_with_SNMP',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_tcp_string' ||
type_name_selected == 'remote_tcp_proc' ||
type_name_selected == 'remote_tcp_inc' ||
type_name_selected == 'remote_tcp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_TCP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#TCP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'web_data' ||
type_name_selected == 'web_proc' ||
type_name_selected == 'web_content_data' ||
type_name_selected == 'web_content_string'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_web&printable=yes#Creaci.C3.B3n_de_m.C3.B3dulos_web',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Web_Monitoring&printable=yes#Creating_Web_Modules',
'_blank',
'width=800,height=600'
);
}
}
}
}
if(type_name_selected == 'remote_icmp' ||
type_name_selected == 'remote_icmp_proc'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_ICMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#ICMP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_snmp_string' ||
type_name_selected == 'remote_snmp_proc' ||
type_name_selected == 'remote_snmp_inc' ||
type_name_selected == 'remote_snmp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizando_con_m.C3.B3dulos_de_red_tipo_SNMP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#Monitoring_by_Network_Modules_with_SNMP',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'remote_tcp_string' ||
type_name_selected == 'remote_tcp_proc' ||
type_name_selected == 'remote_tcp_inc' ||
type_name_selected == 'remote_tcp'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_remota&printable=yes#Monitorizaci.C3.B3n_TCP',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Remote_Monitoring&printable=yes#TCP_Monitoring',
'_blank',
'width=800,height=600'
);
}
}
if(type_name_selected == 'web_data' ||
type_name_selected == 'web_proc' ||
type_name_selected == 'web_content_data' ||
type_name_selected == 'web_content_string'
){
if(language == 'es'){
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Monitorizacion_web&printable=yes#Creaci.C3.B3n_de_m.C3.B3dulos_web',
'_blank',
'width=800,height=600'
);
}
else{
window.open(
'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Web_Monitoring&printable=yes#Creating_Web_Modules',
'_blank',
'width=800,height=600'
);
}
}
}
if (type_name_selected.match(/_string$/) == null) {
// Numeric types

View File

@ -278,7 +278,7 @@ if ($ag_group > 0) {
$ag_groups = [];
$ag_groups = (array) $ag_group;
if ($recursion) {
$ag_groups = groups_get_id_recursive($ag_group, true);
$ag_groups = groups_get_children_ids($ag_group, true);
}
}

View File

@ -156,6 +156,14 @@ $agent_max_value = true;
$agent_min_value = true;
$uncompressed_module = true;
// Users.
$id_users = [];
$users_groups = [];
$select_by_group = false;
$nothing = __('Local metaconsole');
$nothing_value = 0;
$graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type_mode_graph'];
switch ($action) {
@ -223,8 +231,9 @@ switch ($action) {
$server_name = $item['server_name'];
// Metaconsole db connection.
if ($meta && !empty($server_name)) {
if ($meta && empty($server_name) === false) {
$connection = metaconsole_get_connection($server_name);
$server_id = $connection['id'];
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
}
@ -725,6 +734,8 @@ switch ($action) {
case 'group_configuration':
$group = $item['id_group'];
$recursion = $item['recursion'];
$nothing = '';
$nothing_value = 0;
break;
case 'netflow_area':
@ -746,6 +757,22 @@ switch ($action) {
$top_n_value = $item['top_n_value'];
break;
case 'permissions_report':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$id_users = array_combine(
array_values($es['id_users']),
array_values($es['id_users'])
);
if (isset($id_users[0]) && $id_users[0] == 0) {
$id_users[0] = __('None');
}
$users_groups = $es['users_groups'];
$select_by_group = $es['select_by_group'];
break;
default:
// It's not possible.
break;
@ -933,8 +960,8 @@ $class = 'databox filters';
'combo_server',
$server_name,
'',
__('Local metaconsole'),
0
$nothing,
$nothing_value
);
?>
</td>
@ -1040,23 +1067,6 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_resolution" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Resolution');
?>
</td>
<td style="">
<?php
html_print_select(
netflow_resolution_select_params(),
'resolution',
$resolution
);
?>
</td>
</tr>
<tr id="row_period1" style="" class="datos">
<td style="font-weight:bold;">
<?php
@ -1383,8 +1393,7 @@ $class = 'databox filters';
html_print_input_hidden('id_agent', $idAgent);
html_print_input_hidden('server_name', $server_name);
html_print_input_hidden('server_id', $server_name);
html_print_input_hidden('id_server', '');
html_print_input_hidden('server_id', $server_id);
$params = [];
$params['show_helptip'] = false;
@ -1896,7 +1905,14 @@ $class = 'databox filters';
</tr>
<tr id="row_query" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('SQL query'); ?></td>
<td style="font-weight:bold;">
<?php
echo __('SQL query').ui_print_help_tip(
__('The entities of the fields that contain them must be included.'),
true
);
?>
</td>
<td style="" id="sql_entry">
<?php
html_print_textarea('sql', 5, 25, $sql_query_report);
@ -2846,7 +2862,102 @@ $class = 'databox filters';
?>
</td>
</tr>
<tr id="row_profiles_group" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Group');
?>
</td>
<td>
<?php
$user_groups = users_get_groups();
// Add a selector for users without assigned group.
$user_groups[''] = __('Unassigned group');
html_print_select(
$user_groups,
'users_groups[]',
$users_groups,
'',
false,
'',
false,
true,
false,
'',
false,
'min-width: 180px'
);
?>
</td>
</tr>
<tr id="row_users" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('User');
?>
</td>
<td style="">
<?php
$tmp_users = db_get_all_rows_filter('tusuario', [], 'id_user');
foreach ($tmp_users as $key => $user) {
$select_users[$user['id_user']] = $user['id_user'];
}
$input_data = [
'type' => 'select_multiple_filtered',
'class' => 'w80p mw600px',
'name' => 'id_users',
'return' => 0,
'available' => array_diff(
$select_users,
$id_users
),
'selected' => $id_users,
'group_filter' => [
'page' => 'godmode/users/user_list',
'method' => 'get_users_by_group',
'nothing' => __('Unnasigned group'),
'nothing_value' => -1,
'id' => $id_users,
],
'texts' => [
'title-left' => 'Available users',
'title-right' => 'Selected users',
'filter-item' => 'Filter user name',
],
'sections' => [
'filters' => 1,
'item-selected-filters' => 0,
],
];
html_print_input($input_data, 'div', true);
?>
</td>
</tr>
<tr id="row_select_by_group" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Select by group');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'select_by_group',
1,
$select_by_group,
false
);
?>
</td>
</tr>
<tr id="row_landscape" style="" class="datos">
<td style="font-weight:bold;">
<?php
@ -3707,6 +3818,14 @@ echo "<div id='message_no_interval_option' title='".__('Item Editor Information
echo "<p style='text-align: center;font-weight: bold;'>".__('Please checked a custom interval option.').'</p>';
echo '</div>';
echo "<div id='message_no_user' title='".__('Item Editor Information')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Please select a user.').'</p>';
echo '</div>';
echo "<div id='message_no_group' title='".__('Item Editor Information')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Please select a group.').'</p>';
echo '</div>';
ui_require_javascript_file(
'pandora_inventory',
ENTERPRISE_DIR.'/include/javascript/'
@ -3744,7 +3863,16 @@ $(document).ready (function () {
$("#combo_group").change (
function () {
$("#id_agents").html('');
// Alert report group must show all matches when selecting All group
// ignoring 'recursion' option. #6497.
if ($("#combo_group").val() == 0) {
$('#checkbox-recursion').attr('disabled',true)
$('#checkbox-recursion').attr('checked','checked')
} else {
$('#checkbox-recursion').removeAttr('disabled')
}
$("#id_agents2").html('');
$("#module").html('');
$("#inventory_modules").html('');
@ -3772,6 +3900,7 @@ $(document).ready (function () {
);
}
);
$("#combo_group").change();
$("#checkbox-recursion").change (
function () {
@ -3921,6 +4050,20 @@ $(document).ready (function () {
});
});
$("#checkbox-select_by_group").change(function () {
var select_by_group = $('#checkbox-select_by_group').prop('checked');
if(select_by_group == true) {
$("#row_users").hide();
$("#row_profiles_group").show();
} else {
$("#row_users").show();
$("#row_profiles_group").hide();
}
});
$("#checkbox-fullscale").change(function(e){
if(e.target.checked === true) {
$("#graph_render").prop('disabled', 'disabled');
@ -3984,6 +4127,16 @@ $(document).ready (function () {
return false;
}
break;
case 'permissions_report':
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
dialog_message('#message_no_group');
return false;
}
if ($("#checkbox-select_by_group").prop("checked") == false && $("select#selected-select-id_users>option:selected").val() == 0) {
dialog_message('#message_no_user');
return false;
}
break;
default:
break;
}
@ -4105,6 +4258,18 @@ $(document).ready (function () {
return false;
}
break;
case 'permissions_report':
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
dialog_message('#message_no_group');
return false;
}
if ($("#checkbox-select_by_group").prop("checked") == false && $("select#selected-select-id_users>option:selected").val() == 0) {
dialog_message('#message_no_user');
return false;
}
break;
default:
break;
}
@ -4991,6 +5156,10 @@ function chooseType() {
$("#row_select_fields2").hide();
$("#row_select_fields3").hide();
$("#row_uncompressed_module").hide();
$("#row_users").hide();
$("#row_profiles_group").hide();
$("#row_select_by_group").hide();
// SLA list default state.
$("#sla_list").hide();
@ -5637,6 +5806,7 @@ function chooseType() {
$("#row_group").show();
$("#row_servers").show();
$("#row_historical_db_check").hide();
$("#combo_server option[value='0']").remove();
break;
case 'netflow_area':
@ -5674,7 +5844,21 @@ function chooseType() {
$("#row_period").show();
$("#row_quantity").show();
break;
case 'permissions_report':
$("#row_description").show();
$("#row_users").show();
$("#row_profiles_group").show();
$("#row_select_by_group").show();
if($("#checkbox-select_by_group").prop("checked")) {
$("#row_users").hide();
} else {
$("#row_profiles_group").hide();
}
}
switch (type) {
case 'event_report_agent':
case 'simple_graph':
@ -5763,4 +5947,5 @@ function dialog_message(message_id) {
}
});
}
</script>

View File

@ -1380,11 +1380,12 @@ switch ($action) {
switch ($action) {
case 'update':
$values = [];
$server_name = get_parameter('server_id');
if (is_metaconsole() && $server_name != '') {
$id_meta = metaconsole_get_id_server($server_name);
$server_id = get_parameter('server_id', 0);
if (is_metaconsole() === true
&& empty($server_id) === false
) {
$connection = metaconsole_get_connection_by_id(
$id_meta
$server_id
);
metaconsole_connect($connection);
$values['server_name'] = $connection['server_name'];
@ -1431,10 +1432,7 @@ switch ($action) {
'module_description' => $module_description,
];
$values['name'] = reporting_label_macro(
$items_label,
$name_it
);
$values['name'] = $name_it;
$values['landscape'] = get_parameter('landscape');
$values['pagebreak'] = get_parameter('pagebreak');
@ -1811,13 +1809,10 @@ switch ($action) {
'combo_modulegroup'
);
$values['id_group'] = get_parameter('combo_group');
$values['server_name'] = get_parameter('server_name');
if ($values['server_name'] == '') {
$values['server_name'] = get_parameter(
'combo_server'
);
}
$values['server_name'] = get_parameter(
'combo_server'
);
if ((($values['type'] == 'custom_graph')
|| ($values['type'] == 'automatic_custom_graph'))
@ -1867,9 +1862,7 @@ switch ($action) {
);
// If metaconsole is activated.
if ($config['metaconsole'] == 1
&& defined('METACONSOLE')
) {
if (is_metaconsole() === true) {
if (($values['type'] == 'custom_graph')
|| ($values['type'] == 'automatic_custom_graph')
) {
@ -2058,6 +2051,14 @@ switch ($action) {
}
break;
case 'permissions_report':
$es['id_users'] = get_parameter('selected-select-id_users', 0);
$es['users_groups'] = get_parameter('users_groups', 0);
$es['select_by_group'] = get_parameter('select_by_group', 0);
$description = get_parameter('description');
$values['external_source'] = json_encode($es);
break;
default:
// Default.
break;
@ -2138,10 +2139,7 @@ switch ($action) {
'module_description' => $module_description,
];
$values['name'] = reporting_label_macro(
$items_label,
$name_it
);
$values['name'] = $name_it;
$values['landscape'] = get_parameter('landscape');
$values['pagebreak'] = get_parameter('pagebreak');
@ -2673,6 +2671,14 @@ switch ($action) {
}
break;
case 'permissions_report':
$es['id_users'] = get_parameter('selected-select-id_users');
$es['users_groups'] = get_parameter('users_groups', 0);
$es['select_by_group'] = get_parameter('select_by_group', 0);
$description = get_parameter('description');
$values['external_source'] = json_encode($es);
break;
default:
// Default.
break;

View File

@ -115,7 +115,7 @@ if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) {
$return_all_group,
'ag_group',
$ag_group,
'this.form.submit();',
'',
'',
0,
false,
@ -126,7 +126,7 @@ if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) {
);
echo "</li></ul></li><li class='second_elements'><ul><li>";
echo __('Group Recursion');
html_print_checkbox('recursion', 1, $recursion, false, false, 'this.form.submit()');
html_print_checkbox('recursion', 1, $recursion, false, false, '');
echo '</li><li>';
echo "<input name='search_visual_console' type='submit' class='sub search' value='".__('Search')."'>";
echo '</li></ul></li></ul>';
@ -143,7 +143,7 @@ if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) {
$ag_groups = [];
$ag_groups = (array) $ag_group;
if ($recursion) {
$ag_groups = groups_get_id_recursive($ag_group, true);
$ag_groups = groups_get_children_ids($ag_group, true);
}
} else if ($own_info['is_admin']) {
$returnAllGroups = 1;

View File

@ -140,7 +140,7 @@ if (isset($_GET['server'])) {
ui_print_error_message(__('There was a problem deleting the server'));
}
} else if (isset($_GET['update'])) {
$address = trim(get_parameter_post('address'), '&#x20;');
$address = trim(io_safe_output(get_parameter_post('address')), ' ');
$description = trim(get_parameter_post('description'), '&#x20;');
$id_server = get_parameter_post('server');
$exec_proxy = get_parameter_post('exec_proxy');

View File

@ -91,8 +91,20 @@ foreach ($servers as $server) {
// Status
$data[1] = ui_print_status_image(STATUS_SERVER_OK, '', true);
if (($server['status'] == 0) || (($date - time_w_fixed_tz($server['keepalive'])) > ($server['server_keepalive']) * 2)) {
$data[1] = ui_print_status_image(STATUS_SERVER_DOWN, '', true);
if ($server['status'] == -1) {
$data[1] = ui_print_status_image(
STATUS_SERVER_CRASH,
__('Server has crashed.'),
true
);
} else if (($server['status'] == 0)
|| (($date - time_w_fixed_tz($server['keepalive'])) > ($server['server_keepalive']) * 2)
) {
$data[1] = ui_print_status_image(
STATUS_SERVER_DOWN,
__('Server is stopped.'),
true
);
}
// Type

View File

@ -55,7 +55,11 @@ if (isset($_POST['create'])) {
'expire_timestamp' => $expire_timestamp,
];
$id_link = db_process_sql_insert('tnews', $values);
if ($subject === '') {
$id_link = false;
} else {
$id_link = db_process_sql_insert('tnews', $values);
}
ui_print_result_message(
$id_link,
@ -92,7 +96,11 @@ if (isset($_POST['update'])) {
'expire_timestamp' => $expire_timestamp,
];
$result = db_process_sql_update('tnews', $values, ['id_news' => $id_news]);
if ($subject === '') {
$result = false;
} else {
$result = db_process_sql_update('tnews', $values, ['id_news' => $id_news]);
}
ui_print_result_message(
$result,
@ -173,7 +181,7 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) {
$data = [];
$data[0] = __('Subject').'<br>';
$data[0] .= '<input type="text" name="subject" size="35" value="'.$subject.'">';
$data[0] .= '<input type="text" name="subject" size="35" value="'.$subject.'" >';
$data[1] = __('Group').'<br>';
$data[1] .= '<div class="w250px">';

View File

@ -189,6 +189,10 @@ if (is_ajax()) {
100,
true
);
$row['control'] .= ui_print_reveal_password(
'ldap_admin_pass',
true
);
$table->data['ldap_admin_pass'] = $row;
break;
@ -217,10 +221,33 @@ if (is_ajax()) {
'double_auth_enabled',
1,
$config['double_auth_enabled'],
true
true,
false,
'showAndHide()'
);
$table->data['double_auth_enabled'] = $row;
// Enable 2FA for all users.
// Set default value.
set_unless_defined($config['2FA_all_users'], false);
$row = [];
$row['name'] = __('Force 2FA for all users is enabled');
$row['control'] .= html_print_checkbox_switch(
'2FA_all_users',
1,
$config['2FA_all_users'],
true
);
if (!$config['double_auth_enabled']) {
$table->rowclass['2FA_all_users'] = 'invisible';
} else {
$table->rowclass['2FA_all_users'] = '';
}
$table->data['2FA_all_users'] = $row;
// Session timeout.
// Default session timeout.
set_when_empty($config['session_timeout'], 90);
@ -313,6 +340,22 @@ echo '</form>';
?>
<script type="text/javascript">
function showAndHide() {
if ($('input[type=checkbox][name=double_auth_enabled]:checked').val() == 1) {
$('#table1-2FA_all_users').removeClass('invisible');
$('#table1-2FA_all_users-name').removeClass('invisible');
$('#table1-2FA_all_users-control').removeClass('invisible');
$('#table1-2FA_all_users').show();
} else {
$('#table1-2FA_all_users').hide();
}
}
$( document ).ready(function() {
});
//For change autocreate remote users
$('#auth').on('change', function(){
type_auth = $('#auth').val();
$.ajax({

View File

@ -82,6 +82,7 @@ $table_remote->data['ehorus_user'] = $row;
$row = [];
$row['name'] = __('Password');
$row['control'] = html_print_input_password('ehorus_pass', io_output_password($config['ehorus_pass']), '', 30, 100, true);
$row['control'] .= ui_print_reveal_password('ehorus_pass', true);
$table_remote->data['ehorus_pass'] = $row;
// Directory hostname.

View File

@ -116,7 +116,8 @@ $table->data[$i][0] = __('Phantomjs bin directory');
$table->data[$i++][1] = html_print_input_text('phantomjs_bin', io_safe_output($config['phantomjs_bin']), '', 30, 100, true);
$table->data[$i][0] = __('Auto login (hash) password');
$table->data[$i++][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true);
$table->data[$i][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true);
$table->data[$i++][1] .= ui_print_reveal_password('loginhash_pwd', true);
$table->data[$i][0] = __('Time source');
$sources['system'] = __('System');
@ -154,7 +155,8 @@ if (isset($_POST['list_ACL_IPs_for_API'])) {
$table->data[$i++][1] = html_print_textarea('list_ACL_IPs_for_API', 2, 25, $list_ACL_IPs_for_API, 'style="height: 50px; width: 300px"', true);
$table->data[$i][0] = __('API password');
$table->data[$i++][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true);
$table->data[$i][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true);
$table->data[$i++][1] .= ui_print_reveal_password('api_password', true);
$table->data[$i][0] = __('Enable GIS features');
$table->data[$i++][1] = html_print_checkbox_switch('activate_gis', 1, $config['activate_gis'], true);
@ -379,6 +381,7 @@ $table_mail_conf->data[5][1] = html_print_input_text('email_username', $config['
$table_mail_conf->data[6][0] = __('Email password');
$table_mail_conf->data[6][1] = html_print_input_password('email_password', io_output_password($config['email_password']), '', 30, 100, true);
$table_mail_conf->data[6][1] .= ui_print_reveal_password('email_password', true);
$uniqid = uniqid();

View File

@ -221,6 +221,7 @@ $table_remote->data['integria_user'] = $row;
$row = [];
$row['name'] = __('Password');
$row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true);
$row['control'] .= ui_print_reveal_password('integria_pass', true);
$table_remote->data['integria_pass'] = $row;
// Integria hostname.
@ -233,6 +234,7 @@ $table_remote->data['integria_hostname'] = $row;
$row = [];
$row['name'] = __('API Password');
$row['control'] = html_print_input_password('integria_api_pass', io_output_password($config['integria_api_pass']), '', 30, 100, true);
$row['control'] .= ui_print_reveal_password('integria_api_pass', true);
$table_remote->data['integria_api_pass'] = $row;
// Request timeout.

View File

@ -1482,7 +1482,7 @@ $row++;
'.' => '.',
',' => ',',
];
$table_other->data[$row][0] = __('CSV decimal separator').ui_print_help_tip(__('Only for csv reports'), true);
$table_other->data[$row][0] = __('CSV decimal separator');
$table_other->data[$row][1] = html_print_select($decimal_separator, 'csv_decimal_separator', $config['csv_decimal_separator'], '', '', '', true, false, false);
$row++;

View File

@ -1,16 +1,17 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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.
/**
* Pandora FMS - http://pandorafms.com
* ==================================================
* Copyright (c) 2005-2020 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.
*/
// Load global vars
if (! check_acl($config['id_user'], 0, 'LW')) {
db_pandora_audit(
@ -61,6 +62,11 @@ if ($add_action) {
$values[db_escape_key_identifier('al_field13')] = get_parameter('field13_value');
$values[db_escape_key_identifier('al_field14')] = get_parameter('field14_value');
$values[db_escape_key_identifier('al_field15')] = get_parameter('field15_value');
$values[db_escape_key_identifier('al_field16')] = get_parameter('field16_value');
$values[db_escape_key_identifier('al_field17')] = get_parameter('field17_value');
$values[db_escape_key_identifier('al_field18')] = get_parameter('field18_value');
$values[db_escape_key_identifier('al_field19')] = get_parameter('field19_value');
$values[db_escape_key_identifier('al_field20')] = get_parameter('field20_value');
$result = db_process_sql_insert('talert_snmp_action', $values);
}
@ -123,6 +129,11 @@ if ($save_alert || $modify_alert) {
$al_field13 = (string) get_parameter_post('field13_value');
$al_field14 = (string) get_parameter_post('field14_value');
$al_field15 = (string) get_parameter_post('field15_value');
$al_field16 = (string) get_parameter_post('field16_value');
$al_field17 = (string) get_parameter_post('field17_value');
$al_field18 = (string) get_parameter_post('field18_value');
$al_field19 = (string) get_parameter_post('field19_value');
$al_field20 = (string) get_parameter_post('field20_value');
$max_alerts = (int) get_parameter_post('max_alerts', 1);
$min_alerts = (int) get_parameter_post('min_alerts', 0);
$priority = (int) get_parameter_post('priority', 0);
@ -195,6 +206,11 @@ if ($save_alert || $modify_alert) {
'al_field13' => $al_field13,
'al_field14' => $al_field14,
'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
'description' => $description,
'agent' => $source_ip,
'custom_oid' => $custom_value,
@ -267,7 +283,9 @@ if ($save_alert || $modify_alert) {
al_field5 = '%s', al_field6 = '%s',al_field7 = '%s',
al_field8 = '%s', al_field9 = '%s',al_field10 = '%s',
al_field11 = '%s', al_field12 = '%s', al_field13 = '%s',
al_field14 = '%s', al_field15 = '%s',
al_field14 = '%s', al_field15 = '%s', al_field16 = '%s',
al_field17 = '%s', al_field18 = '%s', al_field19 = '%s',
al_field20 = '%s',
description = '%s',
agent = '%s', custom_oid = '%s', oid = '%s',
time_threshold = %d, max_alerts = %d, min_alerts = %d,
@ -318,6 +336,11 @@ if ($save_alert || $modify_alert) {
$al_field13,
$al_field14,
$al_field15,
$al_field16,
$al_field17,
$al_field18,
$al_field19,
$al_field20,
$description,
$source_ip,
$custom_value,
@ -417,6 +440,11 @@ if ($update_alert || $duplicate_alert) {
$al_field13 = $alert['al_field13'];
$al_field14 = $alert['al_field14'];
$al_field15 = $alert['al_field15'];
$al_field16 = $alert['al_field16'];
$al_field17 = $alert['al_field17'];
$al_field18 = $alert['al_field18'];
$al_field19 = $alert['al_field19'];
$al_field20 = $alert['al_field20'];
$max_alerts = $alert['max_alerts'];
$min_alerts = $alert['min_alerts'];
$priority = $alert['priority'];
@ -490,6 +518,11 @@ if ($update_alert || $duplicate_alert) {
$al_field13 = '';
$al_field14 = '';
$al_field15 = '';
$al_field16 = '';
$al_field17 = '';
$al_field18 = '';
$al_field19 = '';
$al_field20 = '';
$max_alerts = 1;
$min_alerts = 0;
$priority = 0;
@ -547,10 +580,11 @@ if ($duplicate_alert) {
id_alert, al_field1, al_field2, al_field3,
al_field4, al_field5, al_field6, al_field7,
al_field8, al_field9, al_field10, al_field11,
al_field12, al_field13, al_field14, al_field15,
description, alert_type, agent, custom_oid, oid, time_threshold,
times_fired, last_fired, max_alerts, min_alerts,
internal_counter, priority,
al_field12, al_field13, al_field14, al_field15,
al_field16, al_field17, al_field18, al_field19,
al_field20, description, alert_type, agent, custom_oid,
oid, time_threshold, times_fired, last_fired,
max_alerts, min_alerts, internal_counter, priority,
'.db_escape_key_identifier('_snmp_f1_').',
'.db_escape_key_identifier('_snmp_f2_').',
'.db_escape_key_identifier('_snmp_f3_').',
@ -597,6 +631,11 @@ if ($duplicate_alert) {
$al_field13,
$al_field14,
$al_field15,
$al_field16,
$al_field17,
$al_field18,
$al_field19,
$al_field20,
$description,
$alert_type,
$source_ip,
@ -998,6 +1037,11 @@ if ($create_alert || $update_alert) {
'al_field13' => $al_field13,
'al_field14' => $al_field14,
'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
];
// Hidden div with help hint to fill with javascript
@ -1421,6 +1465,11 @@ if ($create_alert || $update_alert) {
'al_field13' => $al_field13,
'al_field14' => $al_field14,
'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
];
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {

View File

@ -44,6 +44,16 @@ if (! check_acl($config['id_user'], 0, 'PM')
return;
}
require_once $config['homedir'].'/include/functions_update_manager.php';
if (update_manager_verify_license_expired()) {
ui_print_error_message(
__('The license has expired. Please contact Artica at info@artica.es')
);
return;
}
$baseurl = ui_get_full_url(false, false, false, false);
$current_package = db_get_value(

View File

@ -94,6 +94,13 @@ if ($upload_max_filesize < $PHPupload_max_filesize_min) {
$php_settings_fine++;
}
if (update_manager_verify_license_expired()) {
ui_print_error_message(
__('The license has expired. Please contact Artica at info@artica.es')
);
return;
}
// Verify registry.
if (update_manager_verify_registration() === false) {
ui_require_css_file('register');

View File

@ -196,6 +196,8 @@ if (is_ajax()) {
}
}
$tab = get_parameter('tab', 'user');
if ($id) {
@ -1128,6 +1130,28 @@ if ($config['ehorus_user_level_conf']) {
$ehorus .= '</div>';
}
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id);
if ($config['double_auth_enabled'] && check_acl($config['id_user'], 0, 'PM')) {
$double_authentication = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Double authentication').'</p>';
if (($config['2FA_all_users'] == '' && !$double_auth_enabled)
|| ($config['double_auth_enabled'] == '' && $double_auth_enabled)
|| check_acl($config['id_user'], 0, 'PM')
) {
$double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true);
}
// Dialog.
$double_authentication .= '<div id="dialog-double_auth" style="display:none"><div id="dialog-double_auth-container"></div></div>';
}
if ($double_auth_enabled && $config['double_auth_enabled'] && $config['2FA_all_users'] != '') {
$double_authentication .= html_print_button(__('Show information'), 'show_info', false, 'javascript:show_double_auth_info();', '', true);
}
if (isset($double_authentication)) {
$double_authentication .= '</div>';
}
if ($meta) {
enterprise_include_once('include/functions_metaconsole.php');
@ -1179,7 +1203,7 @@ echo '<div id="user_form">
<div class="edit_user_autorefresh white_box"><p style="font-weight:bold;">Extra info</p>'.$email.$phone.$not_login.$session_time.'</div>
</div>
<div class="user_edit_second_row white_box">
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$newsletter.'</div>
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$newsletter.$double_authentication.'</div>
<div class="edit_user_timezone">'.$timezone;
if (!is_metaconsole()) {
@ -1278,6 +1302,15 @@ if (!is_metaconsole()) {
var json_profile = $('#hidden-json_profile');
/* <![CDATA[ */
$(document).ready (function () {
$("input#checkbox-double_auth").change(function (e) {
e.preventDefault();
if (this.checked) {
show_double_auth_activation();
} else {
show_double_auth_deactivation();
}
});
$('input:radio[name="is_admin"]').change(function() {
if($('#radiobtn0002').prop('checked')) {
$('#metaconsole_agents_manager_div').show();
@ -1313,6 +1346,7 @@ $(document).ready (function () {
var img_delete = '<?php echo $delete_image; ?>';
var id_user = '<?php echo io_safe_output($id); ?>';
var is_metaconsole = '<?php echo $meta; ?>';
var data = [];
$('input:image[name="add"]').click(function (e) {
@ -1357,7 +1391,7 @@ $(document).ready (function () {
$('input:image[name="del"]').click(function (e) {
e.preventDefault();
var rows = $("#table_profiles tr").length;
if (rows <= 3) {
if ((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) {
if (!confirm('<?php echo __('Deleting last profile will delete this user'); ?>' + '. ' + '<?php echo __('Are you sure?'); ?>')) {
return;
}
@ -1379,21 +1413,39 @@ $(document).ready (function () {
success: function (data) {
row.remove();
var rows = $("#table_profiles tr").length;
if (rows <= 2) {
if ((is_metaconsole === '1' && rows <= 3) || (is_metaconsole === '' && rows <= 2)) {
window.location.replace("<?php echo ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0', false, false, false); ?>");
}
}
});
});
$('#submit-crtbutton').click(function (e) {
function checkProfiles(e) {
e.preventDefault();
var rows = $("#table_profiles tr").length;
if (rows <= 2) {
alert('<?php echo __('please add a profile'); ?>');
if ($('input[name="is_admin"]:checked').val() == 1) {
// Admin does not require profiles.
$('#user_profile_form').submit();
} else {
this.form.submit();
if ($('#table_profiles tbody').children().length == 1) {
confirmDialog({
title: "<?php echo __('Warning'); ?>",
message: "<?php echo __('User will be created without profiles assigned and won\'t be able to log in, are you sure?'); ?>",
onAccept: function() {
$('#user_profile_form').submit();
}
});
} else {
$('#user_profile_form').submit();
}
}
}
$('#submit-crtbutton').click(function (e) {
checkProfiles(e);
});
$('#submit-uptbutton').click(function (e) {
checkProfiles(e);
});
});
@ -1476,5 +1528,216 @@ function switch_ehorus_conf()
}
function show_double_auth_info () {
var userID = '<?php echo io_safe_output($id); ?>';
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container");
$dialogContainer.html($loadingSpinner);
console.log(userID);
// Load the info page
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'html',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
get_double_auth_data_page: 1,
FA_forced: 1,
containerID: $dialogContainer.prop('id')
},
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
// isNaN = is not a number
if (isNaN(data)) {
$dialogContainer.html(data);
}
// data is a number, convert it to integer to do the compare
else if (Number(data) === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
}
},
error: function(xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error loading the data').'</div></b>'; ?>");
}
});
$("div#dialog-double_auth")
.css('display','block')
.append($dialogContainer)
.dialog({
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication information'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 400,
height: 375,
close: function(event, ui) {
// Abort the ajax request
if (typeof request != 'undefined')
request.abort();
// Remove the contained html
$dialogContainer.empty();
}
})
.show();
}
function show_double_auth_activation () {
var userID = '<?php echo io_safe_output($id); ?>';
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container");
$dialogContainer.html($loadingSpinner);
// Load the info page
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'html',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
FA_forced: 1,
get_double_auth_info_page: 1,
containerID: $dialogContainer.prop('id')
},
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
// isNaN = is not a number
if (isNaN(data)) {
$dialogContainer.html(data);
}
// data is a number, convert it to integer to do the compare
else if (Number(data) === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
}
},
error: function(xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error loading the data').'</div></b>'; ?>");
}
});
$("div#dialog-double_auth").dialog({
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 500,
height: 400,
close: function(event, ui) {
// Abort the ajax request
if (typeof request != 'undefined')
request.abort();
// Remove the contained html
$dialogContainer.empty();
document.location.reload();
}
})
.show();
}
function show_double_auth_deactivation () {
var userID = '<?php echo io_safe_output($id); ?>';
console.log(userID);
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container");
var message = "<p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p>";
var $button = $("<input type=\"button\" value=\"<?php echo __('Deactivate'); ?>\" />");
$dialogContainer
.empty()
.append(message)
.append($button);
var request;
$button.click(function(e) {
e.preventDefault();
$dialogContainer.html($loadingSpinner);
// Deactivate the double auth
request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'json',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
FA_forced: 1,
deactivate_double_auth: 1
},
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
console.log(data);
if (data === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else if (data) {
$dialogContainer.html("<?php echo '<b><div class=\"green\">'.__('The double autentication was deactivated successfully').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
}
},
error: function(xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
}
});
});
$("div#dialog-double_auth").dialog({
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 300,
height: 150,
close: function(event, ui) {
// Abort the ajax request
if (typeof request != 'undefined')
request.abort();
// Remove the contained html
$dialogContainer.empty();
document.location.reload();
}
})
.show();
}
/* ]]> */
</script>

View File

@ -33,6 +33,53 @@ if (! check_acl($config['id_user'], 0, 'UM')) {
exit;
}
if (is_ajax()) {
$method = get_parameter('method');
$group_id = get_parameter('group_id');
$group_recursion = (bool) get_parameter('group_recursion', 0);
$return_all = false;
if ($group_id == -1) {
$sql = 'SELECT tusuario.id_user FROM tusuario
LEFT OUTER JOIN tusuario_perfil
ON tusuario.id_user = tusuario_perfil.id_usuario
WHERE tusuario_perfil.id_usuario IS NULL';
$users = io_safe_output(db_get_all_rows_sql($sql));
foreach ($users as $key => $user) {
$ret_user[$user['id_user']] = $user['id_user'];
}
echo json_encode($ret_user);
return;
}
if ($group_id == 0) {
$users = io_safe_output(db_get_all_rows_filter('tusuario', [], 'id_user'));
foreach ($users as $key => $user) {
$ret_user[$user['id_user']] = $user['id_user'];
}
echo json_encode($ret_user);
return;
}
if ($method === 'get_users_by_group') {
if ($group_recursion === true) {
$group_id = groups_get_children_ids($group_id);
}
$users_id = io_safe_output(users_get_user_users(false, 'AR', false, null, $group_id));
foreach ($users_id as $key => $user_id) {
$ret_id[$user_id] = $user_id;
}
echo json_encode($ret_id);
return;
}
}
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$tab = get_parameter('tab', 'user');

View File

@ -176,7 +176,7 @@ class DiscoveryTaskList extends HTML
'type' => 'button',
'attributes' => 'class="sub upd"',
'return' => true,
'script' => 'location.reload();',
'script' => 'location.href = \''.$this->url.'\';',
],
],
],
@ -402,8 +402,10 @@ class DiscoveryTaskList extends HTML
$table->headstyle[$i] = 'text-align: left;';
}
// Task name.
$table->headstyle[1] .= 'min-width: 150px; width: 300px;';
// Name.
$table->headstyle[4] .= 'min-width: 100px; width: 600px;';
$table->headstyle[4] .= 'min-width: 100px; width: 400px;';
// Status.
$table->headstyle[5] .= 'min-width: 50px; width: 100px;';
// Task type.

View File

@ -336,6 +336,12 @@ class HostDevices extends Wizard
)
)
);
// Forbidden chars cleaning.
foreach ($network as $key => $singleNetwork) {
$network[$key] = preg_replace('/[-()\']/', '', $singleNetwork);
}
unlink($_FILES['network_csv']['tmp_name']);
if (empty($network) || is_array($network) === false) {
$this->msg = __(
@ -1170,6 +1176,380 @@ class HostDevices extends Wizard
];
}
// Input: SNMP enabled.
$form['inputs'][] = [
'label' => __('SNMP enabled'),
'arguments' => [
'name' => 'snmp_enabled',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1,
'onclick' => 'extraSNMP();',
],
];
// SNMP CONFIGURATION.
$form['inputs'][] = [
'hidden' => 1,
'block_id' => 'snmp_extra',
'class' => 'indented',
'block_content' => [
[
'label' => __('SNMP version'),
'arguments' => [
'name' => 'snmp_version',
'fields' => [
'1' => 'v. 1',
'2c' => 'v. 2c',
'3' => 'v. 3',
],
'type' => 'select',
'script' => 'SNMPExtraShow(this.value)',
'selected' => $this->task['snmp_version'],
'return' => true,
],
],
],
];
// SNMP Options pack v1.
$form['inputs'][] = [
'hidden' => 1,
'block_id' => 'snmp_options_basic',
'class' => 'indented',
'block_content' => [
[
'label' => __('SNMP communities to try with').ui_print_help_tip(
__(
'You can specify several values, separated by commas, for example: public,mysecret,1234'
),
true
),
'arguments' => [
'name' => 'community',
'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 25,
'return' => true,
],
],
],
];
// SNMP Options pack v3.
$form['inputs'][] = [
'hidden' => 1,
'block_id' => 'snmp_options_v3',
'class' => 'indented',
'block_content' => [
[
'label' => '<b>'.__('Context').'</b>',
'arguments' => [
'name' => 'snmp_context',
'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Auth user').'</b>',
'arguments' => [
'name' => 'snmp_auth_user',
'type' => 'text',
'value' => $this->task['snmp_auth_user'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Auth password').'</b>'.ui_print_help_tip(
__(
'The pass length must be eight character minimum.'
),
true
),
'arguments' => [
'name' => 'snmp_auth_pass',
'type' => 'password',
'value' => $this->task['snmp_auth_pass'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Privacy method').'</b>',
'arguments' => [
'name' => 'snmp_privacy_method',
'type' => 'select',
'fields' => [
'DES' => __('DES'),
'AES' => __('AES'),
],
'selected' => $this->task['snmp_privacy_method'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Privacy pass').'</b>'.ui_print_help_tip(
__(
'The pass length must be eight character minimum.'
),
true
),
'arguments' => [
'name' => 'snmp_privacy_pass',
'type' => 'password',
'value' => $this->task['snmp_privacy_pass'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Auth method').'</b>',
'arguments' => [
'name' => 'snmp_auth_method',
'type' => 'select',
'fields' => [
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'selected' => $this->task['snmp_auth_method'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Security level').'</b>',
'arguments' => [
'name' => 'snmp_security_level',
'type' => 'select',
'fields' => [
'noAuthNoPriv' => __('Not auth and not privacy method'),
'authNoPriv' => __('Auth and not privacy method'),
'authPriv' => __('Auth and privacy method'),
],
'selected' => $this->task['snmp_security_level'],
'size' => 15,
'return' => true,
],
],
],
];
// Input: Enforce os detection.
$form['inputs'][] = [
'label' => __('OS detection'),
'arguments' => [
'name' => 'os_detect',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['os_detect'])) ? $this->task['os_detect'] : 1,
],
];
// Input: Name resolution.
$form['inputs'][] = [
'label' => __('Name resolution'),
'arguments' => [
'name' => 'resolve_names',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 1,
],
];
// Input: Parent detection.
$form['inputs'][] = [
'label' => __('Parent detection'),
'arguments' => [
'name' => 'parent_detection',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['parent_detection'])) ? $this->task['parent_detection'] : 1,
],
];
// Input: Parent recursion.
$form['inputs'][] = [
'label' => __('Parent recursion'),
'arguments' => [
'name' => 'parent_recursion',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['parent_recursion'])) ? $this->task['parent_recursion'] : 1,
],
];
// Input: VLAN enabled.
$form['inputs'][] = [
'label' => __('VLAN enabled'),
'arguments' => [
'name' => 'vlan_enabled',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['vlan_enabled'])) ? $this->task['vlan_enabled'] : 1,
],
];
// Input: WMI enabled.
$form['inputs'][] = [
'label' => __('WMI enabled'),
'arguments' => [
'name' => 'wmi_enabled',
'type' => 'switch',
'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0,
'return' => true,
'onclick' => 'toggleAuth();',
],
];
// AUTH CONFIGURATION.
$show_auth = false;
if ((isset($this->task['wmi_enabled']) && $this->task['wmi_enabled'] > 0)
|| (isset($this->task['rcmd_enabled']) && $this->task['rcmd_enabled'] > 0)
) {
$show_auth = true;
}
include_once $config['homedir'].'/include/class/CredentialStore.class.php';
$available_keys = CredentialStore::getKeys('CUSTOM');
if (check_acl($config['id_user'], 0, 'PM')) {
$link_to_cs = '<a class="ext_link" href="'.ui_get_full_url(
'index.php?sec=gagente&sec2=godmode/groups/group_list&tab=credbox'
).'" >';
$link_to_cs .= __('No credentials available').', ';
$link_to_cs .= strtolower(__('Manage credentials')).'</a>';
} else {
$link_to_cs = __('No credentials available');
}
if (count($available_keys) > 0) {
$form['inputs'][] = [
'block_id' => 'auth_block',
'class' => 'indented',
'hidden' => !$show_auth,
'block_content' => [
[
'label' => __('Credentials to try with'),
'arguments' => [
'type' => 'select',
'name' => 'auth_strings[]',
'fields' => CredentialStore::getKeys('CUSTOM'),
'selected' => explode(
',',
$this->task['auth_strings']
),
'multiple' => true,
'class' => 'select_multiple',
],
],
],
];
} else {
$form['inputs'][] = [
'block_id' => 'auth_block',
'class' => 'indented',
'hidden' => !$show_auth,
'block_content' => [
[
'label' => __('Credentials'),
'extra' => $link_to_cs,
],
],
];
}
ui_require_jquery_file('tag-editor.min');
ui_require_jquery_file('caret.min');
ui_require_css_file('jquery.tag-editor');
$form['js'] = '
$(\'#text-community\').tagEditor({
forceLowercase: false
});
function SNMPExtraShow(target) {
$("#snmp_options_basic").hide();
$("#snmp_options_v3").hide();
if (document.getElementsByName("snmp_enabled")[0].checked) {
$("#snmp_extra").show();
if (target == 3) {
$("#snmp_options_v3").show();
} else {
$("#snmp_options_basic").show();
}
}
}
function extraSNMP() {
if (document.getElementsByName("snmp_enabled")[0].checked) {
SNMPExtraShow($("#snmp_version").val());
$("#snmp_extra").show();
// Enable snmp dependant checks
if (!document.getElementsByName("parent_recursion")[0].checked)
$("input[name=parent_recursion]").click();
if (!document.getElementsByName("parent_detection")[0].checked)
$("input[name=parent_detection]").click();
if (!document.getElementsByName("resolve_names")[0].checked)
$("input[name=resolve_names]").click();
if (!document.getElementsByName("vlan_enabled")[0].checked)
$("input[name=vlan_enabled]").click();
} else {
// Hide unusable sections
$("#snmp_extra").hide();
$("#snmp_options_basic").hide();
$("#snmp_options_v3").hide();
// Disable snmp dependant checks
if (document.getElementsByName("parent_recursion")[0].checked)
$("input[name=parent_recursion]").click();
if (document.getElementsByName("parent_detection")[0].checked)
$("input[name=parent_detection]").click();
if (document.getElementsByName("resolve_names")[0].checked)
$("input[name=resolve_names]").click();
if (document.getElementsByName("vlan_enabled")[0].checked)
$("input[name=vlan_enabled]").click();
}
}
function toggleAuth() {
if (document.getElementsByName("wmi_enabled")[0].checked
|| (typeof document.getElementsByName("rcmd_enabled")[0] != "undefined"
&& document.getElementsByName("rcmd_enabled")[0].checked)
) {
$("#auth_block").show();
} else {
$("#auth_block").hide();
}
}
$(function() {
SNMPExtraShow($("#snmp_version").val());
});
';
if (enterprise_installed()) {
// Feature configuration.
$extra = enterprise_hook('hd_showextrainputs', [$this]);
@ -1178,7 +1558,7 @@ class HostDevices extends Wizard
$form['inputs'],
$extra['inputs']
);
$form['js'] = $extra['js'];
$form['js'] .= $extra['js'];
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -216,7 +216,7 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
} else if ($search_agents && is_metaconsole()) {
$id_agent = (int) get_parameter('id_agent');
$string = (string) get_parameter('q');
// q is what autocomplete plugin gives
// Q is what autocomplete plugin gives.
$id_group = (int) get_parameter('id_group', -1);
$addedItems = html_entity_decode((string) get_parameter('add'));
$addedItems = json_decode($addedItems);
@ -236,6 +236,7 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
'alias',
'direccion',
'id_tmetaconsole_setup AS id_server',
'server_name',
];
$filter = [];
@ -254,36 +255,33 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
case 'enabled':
$filter['disabled'] = 0;
break;
default:
// Not possible.
break;
}
if (!empty($id_agent)) {
if (empty($id_agent) === false) {
$filter['id_agente'] = $id_agent;
}
if (!empty($string)) {
if (empty($string) === false) {
// Get agents for only the alias.
$filter_alias = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_alias[] = '(alias COLLATE utf8_general_ci LIKE "%'.$string.'%")';
break;
$filter_alias[] = '(alias COLLATE utf8_general_ci LIKE "%'.$string.'%")';
case 'postgresql':
$filter_alias[] = '(alias LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_alias,
$fields
);
case 'oracle':
$filter_alias[] = '(UPPER(alias) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_alias, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'alias',
@ -293,27 +291,20 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
// Get agents for only the name.
$filter_agents = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_agents[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")';
break;
$filter_agents[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")';
case 'postgresql':
$filter_agents[] = '(alias NOT LIKE \'%'.$string.'%\' AND nombre LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_agents,
$fields
);
case 'oracle':
$filter_agents[] = '(UPPER(alias) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(nombre) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_agents, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'agent',
@ -321,29 +312,22 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
}
}
// Get agents for only the address
// Get agents for only the address.
$filter_address = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_address[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion LIKE "%'.$string.'%")';
break;
$filter_address[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion LIKE "%'.$string.'%")';
case 'postgresql':
$filter_address[] = '(alias NOT LIKE \'%'.$string.'%\' AND nombre NOT LIKE \'%'.$string.'%\' AND direccion LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_address,
$fields
);
case 'oracle':
$filter_address[] = '(UPPER(alias) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_address, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'address',
@ -351,29 +335,22 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
}
}
// Get agents for only the description
// Get agents for only the description.
$filter_description = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_description[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")';
break;
$filter_description[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")';
case 'postgresql':
$filter_description[] = '(alias NOT LIKE \'%'.$string.'%\' AND nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_description,
$fields
);
case 'oracle':
$filter_description[] = '(UPPER(alias) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_description, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'description',

View File

@ -17,7 +17,9 @@ check_login();
// Security check
$id_user = (string) get_parameter('id_user');
if ($id_user !== $config['id_user']) {
$FA_forced = (int) get_parameter('FA_forced');
if ($id_user !== $config['id_user'] && $FA_forced != 1) {
db_pandora_audit(
'ACL Violation',
'Trying to access Double Authentication'

View File

@ -114,7 +114,9 @@ if ($get_comments) {
sprintf(
' HAVING max_id_evento = %d',
$event['id_evento']
)
),
// True for show comments of validated events.
true
);
if ($events !== false) {
$event = $events[0];
@ -331,17 +333,52 @@ if ($get_filter_values) {
if ($event_filter === false) {
$event_filter = [
'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'tag_with' => [],
'tag_without' => [],
'history' => false,
'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'tag_with' => [],
'tag_without' => [],
'history' => false,
'module_search' => '',
'filter_only_alert' => '-1',
'user_comment' => '',
'id_extra' => '',
'id_user_ack' => '',
'date_from' => '',
'date_to' => '',
'severity' => '',
'event_type' => '',
'group_rep' => 0,
'id_group' => 0,
'id_group_filter' => 0,
'group_name' => 'All',
'text_agent' => '',
'id_agent' => 0,
'id_name' => 'None',
'filter_id' => 0,
];
} else {
$event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']]));
$a = array_keys(users_get_groups(false));
$event_filter['group_name'] = '';
foreach ($a as $key => $value) {
if ($value == $event_filter['id_group']) {
$event_filter['group_name'] = db_get_value('nombre', 'tgrupo', 'id_grupo', $event_filter['id_group_filter']);
if ($event_filter['group_name'] === false) {
$event_filter['group_name'] = __('All');
}
}
}
$event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']]));
}
$event_filter['search'] = io_safe_output($event_filter['search']);
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
$event_filter['text_agent'] = io_safe_output($event_filter['text_agent']);
$event_filter['source'] = io_safe_output($event_filter['source']);
$event_filter['tag_with'] = base64_encode(
io_safe_output($event_filter['tag_with'])
);
@ -353,7 +390,7 @@ if ($get_filter_values) {
}
if ($load_filter_modal) {
$current = get_parameter('current_filter', '');
$current = db_get_value_filter('default_event_filter', 'tusuario', ['id_user' => $config['id_user']]);
$filters = events_get_event_filter_select();
$user_groups_array = users_get_groups_for_select(
$config['id_user'],
@ -433,10 +470,12 @@ function load_form_filter() {
},
function (data) {
jQuery.each (data, function (i, val) {
console.log(val);
if (i == 'id_name')
$("#hidden-id_name").val(val);
if (i == 'id_group')
$("#id_group").val(val);
if (i == 'id_group'){
$('#id_group').val(val);
}
if (i == 'event_type')
$("#event_type").val(val);
if (i == 'severity') {
@ -446,9 +485,9 @@ function load_form_filter() {
if (i == 'status')
$("#status").val(val);
if (i == 'search')
$("#text-search").val(val);
$('#text-search').val(val);
if (i == 'text_agent')
$("#text_id_agent").val(val);
$('input[name=text_agent]').val(val);
if (i == 'id_agent')
$('input:hidden[name=id_agent]').val(val);
if (i == 'id_agent_module')
@ -477,6 +516,15 @@ function load_form_filter() {
$("#text-user_comment").val(val);
if (i == 'id_source_event')
$("#text-id_source_event").val(val);
if(i == 'date_from')
$("#text-date_from").val(val);
if(i == 'date_to')
$("#text-date_to").val(val);
if(i == 'module_search')
$('input[name=module_search]').val(val);
if(i == 'group_name')
$("#select2-id_group_filter-container").text(val);
});
reorder_tags_inputs();
// Update the info with the loaded filter
@ -1145,12 +1193,37 @@ if ($change_status) {
$event_ids = get_parameter('event_ids');
$new_status = get_parameter('new_status');
$return = events_change_status(explode(',', $event_ids), $new_status, $meta, $history);
$return = events_change_status(
explode(',', $event_ids),
$new_status,
$meta,
$history
);
if ($return) {
echo 'status_ok';
if ($return !== false) {
echo json_encode(
[
'status' => 'status_ok',
'user' => db_get_value(
'fullname',
'tusuario',
'id_user',
$config['id_user']
),
]
);
} else {
echo 'status_error';
echo json_encode(
[
'status' => 'status_error',
'user' => db_get_value(
'fullname',
'tusuario',
'id_user',
$config['id_user']
),
]
);
}
return;

View File

@ -239,8 +239,7 @@ function process_user_login_remote($login, $pass, $api=false)
// Unknown authentication method
default:
$config['auth_error'] = 'User not found in database
or incorrect password';
$config['auth_error'] = 'User not found in database or incorrect password';
return false;
break;
}
@ -263,11 +262,6 @@ function process_user_login_remote($login, $pass, $api=false)
if ($config['autocreate_remote_users'] == 1) {
if ($config['ad_save_password']) {
$update_credentials = change_local_user_pass_ldap($login, $pass);
if ($update_credentials) {
$config['auth_error'] = __('Your permissions have changed. Please, login again.');
return false;
}
} else {
delete_user_pass_ldap($login);
}
@ -288,11 +282,6 @@ function process_user_login_remote($login, $pass, $api=false)
if ($return === 'error_permissions') {
$config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator');
return false;
} else {
if ($return === 'permissions_changed') {
$config['auth_error'] = __('Your permissions have changed. Please, login again.');
return false;
}
}
}
} else if ($config['auth'] === 'ldap') {
@ -300,11 +289,6 @@ function process_user_login_remote($login, $pass, $api=false)
if ($config['autocreate_remote_users'] == 1) {
if ($config['ldap_save_password']) {
$update_credentials = change_local_user_pass_ldap($login, $pass);
if ($update_credentials) {
$config['auth_error'] = __('Your permissions have changed. Please, login again.');
return false;
}
} else {
delete_user_pass_ldap($login);
}
@ -326,11 +310,6 @@ function process_user_login_remote($login, $pass, $api=false)
if ($return === 'error_permissions') {
$config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator');
return false;
} else {
if ($return === 'permissions_changed') {
$config['auth_error'] = __('Your permissions have changed. Please, login again.');
return false;
}
}
}
}

View File

@ -273,7 +273,7 @@ class AgentWizard extends HTML
// Check access.
check_login();
if (! check_acl($config['id_user'], 0, 'AR')) {
if (!check_acl($config['id_user'], 0, 'AR')) {
db_pandora_audit(
'ACL Violation',
'Trying to access event viewer'
@ -293,6 +293,29 @@ class AgentWizard extends HTML
$this->idAgent = get_parameter('id_agente', '');
$this->idPolicy = get_parameter('id', '');
$this->targetIp = get_parameter('targetIp', '');
if (!empty($this->idAgent)) {
$array_aux = db_get_all_rows_sql(
sprintf(
'SELECT ip FROM taddress ta
INNER JOIN taddress_agent taa ON taa.id_a = ta.id_a
WHERE taa.id_agent = %d',
$this->idAgent
)
);
if (!empty($array_aux)) {
$this->datalist = [];
foreach ($array_aux as $key => $value) {
$this->datalist[] = $value['ip'];
}
}
if (count($this->datalist) === 1 && $this->targetIp === '') {
$this->targetIp = $this->datalist[0];
}
}
$this->server = (int) get_parameter('server', '1');
if ($this->server !== 0) {
$this->serverType = (int) db_get_value(
@ -563,6 +586,18 @@ class AgentWizard extends HTML
],
];
if (!empty($this->datalist)) {
$inputs[] = [
'id' => 'li_address_list',
'arguments' => [
'name' => 'address_list',
'type' => 'datalist',
'value' => $this->datalist,
'return' => true,
],
];
}
$inputs[] = [
'label' => __('Target IP'),
'id' => 'txt-targetIp',
@ -573,6 +608,7 @@ class AgentWizard extends HTML
'class' => '',
'value' => $this->targetIp,
'return' => true,
'list' => 'address_list',
],
];
@ -865,7 +901,6 @@ class AgentWizard extends HTML
],
true
);
}
@ -992,10 +1027,51 @@ class AgentWizard extends HTML
}
if ($this->wizardSection === 'snmp_interfaces_explorer') {
// First, try x64 interfaces.
$this->interfacesx64 = true;
// Check if thereis x64 counters.
$snmp_tmp = '.1.3.6.1.2.1.31.1.1.1.6';
$check_x64 = get_snmpwalk(
$this->targetIp,
$this->version,
$this->community,
$this->authUserV3,
$this->securityLevelV3,
$this->authMethodV3,
$this->authPassV3,
$this->privacyMethodV3,
$this->privacyPassV3,
0,
$snmp_tmp,
$this->targetPort,
$this->server,
$this->extraArguments
);
if ($check_x64) {
$this->interfacesx64 = true;
$oidExplore = '.1.3.6.1.2.1.31.1.1.1.1';
} else {
$this->interfacesx64 = false;
$oidExplore = '1.3.6.1.2.1.2.2.1.2';
}
// Explore interface names.
$oidExplore = '.1.3.6.1.2.1.31.1.1.1.1';
$receivedOid = get_snmpwalk(
$this->targetIp,
$this->version,
$this->community,
$this->authUserV3,
$this->securityLevelV3,
$this->authMethodV3,
$this->authPassV3,
$this->privacyMethodV3,
$this->privacyPassV3,
0,
$oidExplore,
$this->targetPort,
$this->server,
$this->extraArguments
);
} else {
// Get the device PEN.
$oidExplore = '.1.3.6.1.2.1.1.2.0';
@ -1310,7 +1386,7 @@ class AgentWizard extends HTML
*
* @return array
*/
public function candidateModuleToCreate(array $data):array
public function candidateModuleToCreate(array $data): array
{
$modulesActivated = [];
$generalInterface = false;
@ -1391,10 +1467,16 @@ class AgentWizard extends HTML
$result[$value]['name'] = $data['module-default_name-'.$key];
} else if (empty(preg_match('/module-description-set/', $k)) === false) {
$result[$value]['description'] = $data['module-default_description-'.$key];
} else if (empty(preg_match('/module-value/', $k)) === false) {
$result[$value]['value'] = $data['module-value-'.$key];
}
preg_match('/^(.*)-.*?_(\d-\d)$/', $k, $matches);
preg_match('/^(.*)-.*?_(\d+-\d+)$/', $k, $matches);
$k = $matches[1].'-0_'.$matches[2];
} else {
if (empty(preg_match('/module-value/', $k)) === false) {
$result[$value]['value'] = $data[$k];
}
}
}
@ -1418,7 +1500,7 @@ class AgentWizard extends HTML
$result[$value]['scan_type'] = (int) $data[$k];
} else if (empty(preg_match('/module-execution_type/', $k)) === false) {
$result[$value]['execution_type'] = (int) $data[$k];
} else if (empty(preg_match('/module-value/', $k)) === false) {
} else if (($data['wizard_section'] !== 'snmp_interfaces_explorer') && (empty(preg_match('/module-value/', $k)) === false)) {
$result[$value]['value'] = $data[$k];
} else if (empty(preg_match('/module-macros/', $k)) === false) {
$result[$value]['macros'] = $data[$k];
@ -1560,8 +1642,8 @@ class AgentWizard extends HTML
if ($this->securityLevelV3 === 'authNoPriv'
|| $this->securityLevelV3 === 'authPriv'
) {
$values['plugin_parameter'] = $this->authMethodV3;
$values['plugin_pass'] = $this->authPassV3;
$values['plugin_parameter'] = $this->authMethodV3;
$values['plugin_pass'] = $this->authPassV3;
if ($this->securityLevelV3 === 'authPriv') {
$values['custom_string_1'] = $this->privacyMethodV3;
$values['custom_string_2'] = $this->privacyPassV3;
@ -2261,7 +2343,7 @@ class AgentWizard extends HTML
private function replacementMacrosPlugin(
string $text,
array $macros
):string {
): string {
// Only agents.
if (empty($this->idPolicy) === true) {
// Common.
@ -2308,7 +2390,7 @@ class AgentWizard extends HTML
?string $value,
?string $unit='',
?int $moduleType=0
):string {
): string {
if ($moduleType !== MODULE_TYPE_REMOTE_SNMP_INC
&& $moduleType !== MODULE_TYPE_GENERIC_DATA_INC
&& $moduleType !== MODULE_TYPE_REMOTE_TCP_INC
@ -2562,7 +2644,7 @@ class AgentWizard extends HTML
// Unpack the extra fields
// and include with key field in a field set.
$macros = json_decode($module['macros'], true);
$fieldSet = [ '0' => $module['query_key_field'] ];
$fieldSet = ['0' => $module['query_key_field']];
foreach ($macros as $fieldKey => $fieldMacro) {
if (preg_match('/extra_field_/', $fieldKey) !== 0) {
$tmpKey = explode('_', $fieldKey);
@ -3002,7 +3084,7 @@ class AgentWizard extends HTML
$newModule = $module;
// Split the values got to obtain the name.
$tmpFirst = explode('.', $value);
$tmpSecond = explode(' ', $tmpFirst[1]);
$tmpSecond = explode(' ', $tmpFirst[(count($tmpFirst) - 1)]);
// Position 0 is the index, Position 3 is the MIB name.
$snmpwalkNames[$tmpSecond[0]] = $tmpSecond[3];
// Perform the operations for get the values.
@ -3011,6 +3093,11 @@ class AgentWizard extends HTML
$currentOid = $oid.'.'.$tmpSecond[0];
$macros['macros'][$oidName] = $currentOid;
$currentOidValue = $this->snmpgetValue($currentOid);
// If for any reason the value comes empty, add 1.
if ($currentOidValue == '') {
$currentOidValue = 1;
}
$thisOperation = preg_replace(
'/'.$oidName.'/',
$currentOidValue,
@ -3095,7 +3182,6 @@ class AgentWizard extends HTML
// Add Create Modules form.
$this->createModulesForm();
}
}
@ -3204,7 +3290,6 @@ class AgentWizard extends HTML
}
return false;
}
@ -3301,7 +3386,7 @@ class AgentWizard extends HTML
*
* @return array Inputs for common data.
*/
private function getCommonDataInputs():array
private function getCommonDataInputs(): array
{
$inputs[] = [
'id' => 'create-modules-action',
@ -4111,13 +4196,13 @@ class AgentWizard extends HTML
}
/**
* This function return the definition of modules for SNMP Interfaces
*
* @param array $data Data.
*
* @return array Return modules for defect.
*/
/**
* This function return the definition of modules for SNMP Interfaces
*
* @param array $data Data.
*
* @return array Return modules for defect.
*/
private function getInterfacesModules(array $data=[])
{
$moduleDescription = '';
@ -4202,6 +4287,34 @@ class AgentWizard extends HTML
],
];
// Get x86 or x64 modules.
if ($this->interfacesx64 === true) {
$definition_temp = $this->getInterfacesModulesx64($data);
} else {
$definition_temp = $this->getInterfacesModulesx86($data);
}
// General monitoring names.
$general_module_names = [
'ifInOctets / ifHCInOctets',
'ifOutOctets / ifHCOutOctets',
'ifInUcastPkts / ifHCInUcastPkts',
'ifOutUcastPkts / ifHCOutUcastPkts',
'ifInNUcastPkts / ifHCInNUcastPkts',
'ifOutNUcastPkts / ifHCOutNUcastPkts',
];
if ($name == '') {
foreach ($definition_temp as $module => $module_def) {
$definition_temp[$module]['module_name'] = array_shift($general_module_names);
}
}
if (empty($definition_temp) === false) {
$definition = array_merge($definition, $definition_temp);
}
// Continue with common x86 and x84 modules.
// IfAdminStatus.
$moduleName = $name.'ifAdminStatus';
$definition['ifAdminStatus'] = [
@ -4328,19 +4441,6 @@ class AgentWizard extends HTML
],
];
// Get x86 or x64 modules.
if ($this->interfacesx64 === true) {
$definitionx64 = $this->getInterfacesModulesx64($data);
if (empty($definitionx64) === false) {
$definition = array_merge($definition, $definitionx64);
}
} else {
$definitionx86 = $this->getInterfacesModulesx86($data);
if (empty($definitionx86) === false) {
$definition = array_merge($definition, $definitionx86);
}
}
return $definition;
}
@ -4566,7 +4666,7 @@ class AgentWizard extends HTML
// Definition object.
$definition = [];
// ifHCInOctets.
// IfHCInOctets.
$moduleName = $name.'ifHCInOctets';
$definition['ifHCInOctets'] = [
'module_name' => $moduleName,
@ -4592,7 +4692,7 @@ class AgentWizard extends HTML
],
];
// ifHCOutOctets.
// IfHCOutOctets.
$moduleName = $name.'ifHCOutOctets';
$definition['ifHCOutOctets'] = [
'module_name' => $moduleName,
@ -4618,7 +4718,7 @@ class AgentWizard extends HTML
],
];
// ifHCInUcastPkts.
// IfHCInUcastPkts.
$moduleName = $name.'ifHCInUcastPkts';
$definition['ifHCInUcastPkts'] = [
'module_name' => $moduleName,
@ -4644,7 +4744,7 @@ class AgentWizard extends HTML
],
];
// ifHCOutUcastPkts.
// IfHCOutUcastPkts.
$moduleName = $name.'ifHCOutUcastPkts';
$definition['ifHCOutUcastPkts'] = [
'module_name' => $moduleName,
@ -4669,7 +4769,7 @@ class AgentWizard extends HTML
'inv_critical' => false,
],
];
// ifHCInNUcastPkts.
// IfHCInNUcastPkts.
$moduleName = $name.'ifHCInNUcastPkts';
$definition['ifHCInNUcastPkts'] = [
'module_name' => $moduleName,
@ -4733,17 +4833,18 @@ class AgentWizard extends HTML
* @param integer|null $type Module type.
*
* @return string
* @throws Exception Handle of unwanted operations.
*/
private function evalOperation(
string $operation,
string $unit='',
?int $type=0
) {
// Avoid non-numeric or arithmetic chars for security reasons.
if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) {
$output = 'ERROR';
} else {
try {
try {
// Avoid non-numeric or arithmetic chars for security reasons.
if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) {
throw new Exception(sprintf(__("The operation '%s' is not permitted. Review for remote components."), $operation));
} else {
// Get the result of the operation and set it.
$output = '';
eval('$output = '.$operation.';');
@ -4753,9 +4854,11 @@ class AgentWizard extends HTML
$unit,
$type
);
} catch (Exception $e) {
$output = 'ERROR';
}
} catch (Exception $e) {
$this->message['type'][] = 'error';
$this->message['message'][] = $e->getMessage();
$this->showMessage();
}
return $output;
@ -4807,7 +4910,7 @@ class AgentWizard extends HTML
try {
exec($execution, $output);
} catch (Exception $ex) {
$output = [ '0' => 'ERROR: Failed execution: '.(string) $ex];
$output = ['0' => 'ERROR: Failed execution: '.(string) $ex];
}
return $output;
@ -4905,7 +5008,7 @@ class AgentWizard extends HTML
// Meta.
var meta = "<?php echo is_metaconsole(); ?>";
var hack_meta = '';
if(meta){
if (meta) {
hack_meta = '../../';
}
@ -4913,15 +5016,15 @@ class AgentWizard extends HTML
showV3Form();
// Filter search interfaces snmp.
$('#text-filter-search').keyup(function () {
$('#text-filter-search').keyup(function() {
var string = $('#text-filter-search').val();
var regex = new RegExp(string);
var interfaces = $('.interfaces_search');
interfaces.each(function(){
if(string == ''){
interfaces.each(function() {
if (string == '') {
$(this).removeClass('hidden');
} else {
if(this.id.match(regex)) {
if (this.id.match(regex)) {
$(this).removeClass('hidden');
} else {
$(this).addClass('hidden');
@ -4931,12 +5034,12 @@ class AgentWizard extends HTML
});
// Loading.
$('#submit-sub-protocol').click(function () {
$('#submit-sub-protocol').click(function() {
$('.wizard-result').remove();
$('#form-create-modules').remove();
$('.textodialogo').remove();
$('.loading-wizard')
.html('<center><span style="font-size:25px;">Loading...</span><img style="width:25px;heigth:25px;" src="'+hack_meta+'images/spinner.gif"></center>');
.html('<center><span style="font-size:25px;">Loading...</span><img style="width:25px;heigth:25px;" src="' + hack_meta + 'images/spinner.gif"></center>');
});
});
@ -4954,17 +5057,17 @@ class AgentWizard extends HTML
function showSecurityLevelForm() {
var selector = $('#securityLevelV3').val();
if(selector === 'authNoPriv' || selector === 'authPriv'){
if (selector === 'authNoPriv' || selector === 'authPriv') {
$('#txt-authMethodV3').removeClass('invisible');
$('#txt-authPassV3').removeClass('invisible');
if(selector === 'authPriv'){
if (selector === 'authPriv') {
$('#txt-privacyMethodV3').removeClass('invisible');
$('#txt-privacyPassV3').removeClass('invisible');
} else {
$('#txt-privacyMethodV3').addClass('invisible');
$('#txt-privacyPassV3').addClass('invisible');
}
} else {
} else {
$('#txt-authMethodV3').addClass('invisible');
$('#txt-authPassV3').addClass('invisible');
$('#txt-privacyMethodV3').addClass('invisible');
@ -4978,45 +5081,42 @@ class AgentWizard extends HTML
var text = "";
var failed = 0;
try {
data = JSON.parse(data);
text = data["result"];
data = JSON.parse(data);
text = data["result"];
} catch (err) {
title = "<?php echo __('Failed'); ?>";
text = err.message;
failed = 1;
title = "<?php echo __('Failed'); ?>";
text = err.message;
failed = 1;
}
if (!failed && data["error"] != undefined) {
title = "<?php echo __('Failed'); ?>";
text = data["error"];
failed = 1;
title = "<?php echo __('Failed'); ?>";
text = data["error"];
failed = 1;
}
if (data["report"] != undefined) {
data["report"].forEach(function(item) {
text += "<br>" + item;
});
data["report"].forEach(function(item) {
text += "<br>" + item;
});
}
$("#msg").empty();
$("#msg").html(text);
$("#msg").dialog({
width: 450,
position: {
my: "center",
at: "center",
of: window,
collision: "fit"
},
title: title,
buttons: [
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
width: 450,
position: {
my: "center",
at: "center",
of: window,
collision: "fit"
},
title: title,
buttons: [{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: "OK",
click: function(e) {
$("#msg").close();
}
}
]
}]
});
}
@ -5034,41 +5134,39 @@ class AgentWizard extends HTML
var imageInfoModules = $("#image-info-modules-" + blockNumber);
var totalCount = 0;
var markedCount = 0;
var hidden_input = document.getElementById("hidden-module-active-"+switchName[2]+"_"+switchName[3]);
var id_input = hidden_input.id.split("_");
if (type == 'block') {
selectedBlock
.parent()
.removeClass("alpha50");
.parent()
.removeClass("alpha50");
if (selectedBlock.prop("checked")) {
// Set to active the values of fields.
$("[id*='"+id_input[0]+"']")
$("[id*=hidden-module-active-"+blockNumber+"]")
.each(function(){
$(this).val('1');
});
// Set checked.
$("[id*=checkbox-sel_module_" + blockNumber + "]")
.each(function(){
$(this).prop("checked", true);
});
.each(function() {
$(this).prop("checked", true);
});
imageInfoModules.removeClass('hidden');
} else {
// Set to inactive the values of fields.
$("[id*='"+id_input[0]+"']")
$("[id*=hidden-module-active-"+blockNumber+"]")
.each(function(){
$(this).val('0');
});
// Set unchecked.
$("[id*=checkbox-sel_module_" + blockNumber + "]")
.each(function(){
$(this).prop("checked", false);
});
.each(function() {
$(this).prop("checked", false);
});
imageInfoModules.addClass('hidden');
}
} else if (type == 'module') {
// Getting the element.
var thisModuleHidden = document.getElementById("hidden-module-active-"+switchName[2]+"_"+moduleNumber);
var thisModule = $("#checkbox-sel_module_"+blockNumber+"_"+moduleNumber);
var thisModuleHidden = document.getElementById("hidden-module-active-" + switchName[2] + "_" + moduleNumber);
var thisModule = $("#checkbox-sel_module_" + blockNumber + "_" + moduleNumber);
// Setting the individual field
if (thisModule.prop('checked')) {
thisModuleHidden.value = '1';
@ -5078,12 +5176,12 @@ class AgentWizard extends HTML
// Get the list of selected modules.
$("[id*=checkbox-sel_module_" + blockNumber + "]")
.each(function() {
if ($(this).prop("checked")) {
markedCount++;
}
totalCount++;
});
.each(function() {
if ($(this).prop("checked")) {
markedCount++;
}
totalCount++;
});
if (totalCount == markedCount) {
selectedBlock.prop("checked", true);
@ -5112,7 +5210,7 @@ class AgentWizard extends HTML
*/
function switchBlockControlInterfaces(e) {
var string = $('#text-filter-search').val();
if(string == ''){
if (string == '') {
if (e.checked) {
$(".interfaz_select").prop("checked", true);
} else {
@ -5121,15 +5219,15 @@ class AgentWizard extends HTML
} else {
var regex = new RegExp(string);
var interfaces = $('.interfaces_search');
interfaces.each(function(){
if(this.id.match(regex)) {
interfaces.each(function() {
if (this.id.match(regex)) {
$(this).removeClass('hidden');
if (e.checked) {
$("input[name='interfaz_select_"+this.id+"']")
$("input[name='interfaz_select_" + this.id + "']")
.prop("checked", true);
} else {
$("input[name='interfaz_select_"+this.id+"']")
.prop("checked", false);
$("input[name='interfaz_select_" + this.id + "']")
.prop("checked", false);
}
}
});
@ -5137,13 +5235,13 @@ class AgentWizard extends HTML
}
/**
* Show the modal with modules for create.
*/
* Show the modal with modules for create.
*/
function processListModules() {
confirmDialog({
title: "<?php echo __('Modules about to be created'); ?>",
message: function() {
var id = "div-"+uniqId();
var id = "div-" + uniqId();
var loading = "<?php echo __('Loading'); ?>" + "...";
$.ajax({
method: "post",
@ -5159,22 +5257,22 @@ class AgentWizard extends HTML
},
datatype: "html",
success: function(data) {
$('#'+id).empty().append(data);
$('#' + id).empty().append(data);
},
error: function(e) {
showMsg(e);
}
});
return "<div id ='"+id+"'>"+loading+"</div>";
return "<div id ='" + id + "'>" + loading + "</div>";
},
ok: "<?php echo __('OK'); ?>",
cancel: "<?php echo __('Cancel'); ?>",
onAccept: function() {
$('#reviewed-modules').submit();
$('#reviewed-modules').submit();
},
size:750,
maxHeight:500
size: 750,
maxHeight: 500
});
}

File diff suppressed because it is too large Load Diff

View File

@ -86,17 +86,17 @@ class ConsoleSupervisor
*
* @var boolean
*/
public $verbose;
public $interactive;
/**
* Constructor.
*
* @param boolean $verbose Show output while executing or not.
* @param boolean $interactive Show output while executing or not.
*
* @return class This object
*/
public function __construct(bool $verbose=true)
public function __construct(bool $interactive=true)
{
$source = db_get_row(
'tnotification_source',
@ -104,16 +104,16 @@ class ConsoleSupervisor
io_safe_input('System status')
);
$this->verbose = $verbose;
$this->interactive = $interactive;
if ($source === false) {
$this->notificationsEnabled = false;
$this->enabled = false;
$this->sourceId = null;
$this->targetGroups = null;
$this->targetUsers = null;
} else {
$this->notificationsEnabled = (bool) $source['enabled'];
$this->enabled = (bool) $source['enabled'];
$this->sourceId = $source['id'];
// Assign targets.
@ -153,42 +153,42 @@ class ConsoleSupervisor
/*
* PHP configuration warnings:
* NOTIF.PHP.SAFE_MODE
* NOTIF.PHP.INPUT_TIME
* NOTIF.PHP.EXECUTION_TIME
* NOTIF.PHP.UPLOAD_MAX_FILESIZE
* NOTIF.PHP.MEMORY_LIMIT
* NOTIF.PHP.DISABLE_FUNCTIONS
* NOTIF.PHP.PHANTOMJS
* NOTIF.PHP.VERSION
* NOTIF.PHP.SAFE_MODE
* NOTIF.PHP.INPUT_TIME
* NOTIF.PHP.EXECUTION_TIME
* NOTIF.PHP.UPLOAD_MAX_FILESIZE
* NOTIF.PHP.MEMORY_LIMIT
* NOTIF.PHP.DISABLE_FUNCTIONS
* NOTIF.PHP.PHANTOMJS
* NOTIF.PHP.VERSION
*/
$this->checkPHPSettings();
/*
* Check license.
* NOTIF.LICENSE.EXPIRATION
* NOTIF.LICENSE.EXPIRATION
*/
$this->checkLicense();
/*
* Check component statuses (servers down - frozen).
* NOTIF.SERVER.STATUS.ID_SERVER
* NOTIF.SERVER.STATUS.ID_SERVER
*/
$this->checkPandoraServers();
/*
* Check at least 1 server running in master mode.
* NOTIF.SERVER.MASTER
* NOTIF.SERVER.MASTER
*/
$this->checkPandoraServerMasterAvailable();
/*
* Check if CRON is running.
* NOTIF.CRON.CONFIGURED
* NOTIF.CRON.CONFIGURED
*/
if (enterprise_installed()) {
@ -197,14 +197,14 @@ class ConsoleSupervisor
/*
* Check if instance is registered.
* NOTIF.UPDATEMANAGER.REGISTRATION
* NOTIF.UPDATEMANAGER.REGISTRATION
*/
$this->checkUpdateManagerRegistration();
/*
* Check if there're new messages in UM.
* NOTIF.UPDATEMANAGER.MESSAGES
* NOTIF.UPDATEMANAGER.MESSAGES
*/
$this->getUMMessages();
@ -212,31 +212,32 @@ class ConsoleSupervisor
/*
* Check if the Server and Console has
* the same versions.
* NOTIF.SERVER.MISALIGNED
*/
$this->checkConsoleServerVersions();
/*
* Check if AllowOverride is None or All.
* NOTIF.ALLOWOVERIDE.MESSAGE
*/
$this->checkAllowOverrideEnabled();
/*
* Check if AllowOverride is None or All.
* NOTIF.HAMASTER.MESSAGE
*/
$this->checkHaStatus();
$this->checkAllowOverrideEnabled();
/*
* Check if the Pandora Console log
* file remains in old location.
* NOTIF.PANDORACONSOLE.LOG.OLD
*/
$this->checkPandoraConsoleLogOldLocation();
/*
* Check if the audit log file
* remains in old location.
* NOTIF.AUDIT.LOG.OLD
*/
$this->checkAuditLogOldLocation();
}
@ -253,7 +254,7 @@ class ConsoleSupervisor
$this->maintenanceOperations();
if ($this->notificationsEnabled === false) {
if ($this->enabled === false) {
// Notifications not enabled.
return;
}
@ -280,65 +281,65 @@ class ConsoleSupervisor
/*
* Check license.
* NOTIF.LICENSE.EXPIRATION
* NOTIF.LICENSE.LIMITED
* NOTIF.LICENSE.EXPIRATION
* NOTIF.LICENSE.LIMITED
*/
$this->checkLicense();
/*
* Check number of files in attachment:
* NOTIF.FILES.ATTACHMENT
* NOTIF.FILES.ATTACHMENT
*/
$this->checkAttachment();
/*
* Files in data_in:
* NOTIF.FILES.DATAIN (>1000)
* NOTIF.FILES.DATAIN.BADXML (>150)
* NOTIF.FILES.DATAIN (>1000)
* NOTIF.FILES.DATAIN.BADXML (>150)
*/
$this->checkDataIn();
/*
* Check module queues not growing:
* NOTIF.SERVER.QUEUE.ID_SERVER
* NOTIF.SERVER.QUEUE.ID_SERVER
*/
$this->checkServers();
/*
* Check component statuses (servers down - frozen).
* NOTIF.SERVER.STATUS.ID_SERVER
* NOTIF.SERVER.STATUS.ID_SERVER
*/
$this->checkPandoraServers();
/*
* Check at least 1 server running in master mode.
* NOTIF.SERVER.MASTER
* NOTIF.SERVER.MASTER
*/
$this->checkPandoraServerMasterAvailable();
/*
* PHP configuration warnings:
* NOTIF.PHP.SAFE_MODE
* NOTIF.PHP.INPUT_TIME
* NOTIF.PHP.EXECUTION_TIME
* NOTIF.PHP.UPLOAD_MAX_FILESIZE
* NOTIF.PHP.MEMORY_LIMIT
* NOTIF.PHP.DISABLE_FUNCTIONS
* NOTIF.PHP.PHANTOMJS
* NOTIF.PHP.VERSION
* NOTIF.PHP.SAFE_MODE
* NOTIF.PHP.INPUT_TIME
* NOTIF.PHP.EXECUTION_TIME
* NOTIF.PHP.UPLOAD_MAX_FILESIZE
* NOTIF.PHP.MEMORY_LIMIT
* NOTIF.PHP.DISABLE_FUNCTIONS
* NOTIF.PHP.PHANTOMJS
* NOTIF.PHP.VERSION
*/
$this->checkPHPSettings();
/*
* Check connection with historical DB (if enabled).
* NOTIF.HISTORYDB
* NOTIF.HISTORYDB
*/
$this->checkPandoraHistoryDB();
@ -346,23 +347,23 @@ class ConsoleSupervisor
/*
* Check pandoradb running in main DB.
* Check pandoradb running in historical DB.
* NOTIF.PANDORADB
* NOTIF.PANDORADB.HISTORICAL
* NOTIF.PANDORADB
* NOTIF.PANDORADB.HISTORICAL
*/
$this->checkPandoraDBMaintenance();
/*
* Check historical DB MR version.
* NOTIF.HISTORYDB.MR
* NOTIF.HISTORYDB.MR
*/
$this->checkPandoraHistoryDBMR();
/*
* Check external components.
* NOTIF.EXT.ELASTICSEARCH
* NOTIF.EXT.LOGSTASH
* NOTIF.EXT.ELASTICSEARCH
* NOTIF.EXT.LOGSTASH
*
*/
@ -370,76 +371,76 @@ class ConsoleSupervisor
/*
* Check Metaconsole synchronization issues.
* NOTIF.METACONSOLE.DB_CONNECTION
* NOTIF.METACONSOLE.DB_CONNECTION
*/
$this->checkMetaconsole();
/*
* Check incoming scheduled downtimes (< 15d).
* NOTIF.DOWNTIME
* NOTIF.DOWNTIME
*/
$this->checkDowntimes();
/*
* Check if instance is registered.
* NOTIF.UPDATEMANAGER.REGISTRATION
* NOTIF.UPDATEMANAGER.REGISTRATION
*/
$this->checkUpdateManagerRegistration();
/*
* Check if event storm protection is activated.
* NOTIF.MISC.EVENTSTORMPROTECTION
* NOTIF.MISC.EVENTSTORMPROTECTION
*/
$this->checkEventStormProtection();
/*
* Check if develop_bypass is enabled.
* NOTIF.MISC.DEVELOPBYPASS
* NOTIF.MISC.DEVELOPBYPASS
*/
$this->checkDevelopBypass();
/*
* Check if fontpath exists.
* NOTIF.MISC.FONTPATH
* NOTIF.MISC.FONTPATH
*/
$this->checkFont();
/*
* Check if default user and password exists.
* NOTIF.SECURITY.DEFAULT_PASSWORD
* NOTIF.SECURITY.DEFAULT_PASSWORD
*/
$this->checkDefaultPassword();
/*
* Check if there're new updates.
* NOTIF.UPDATEMANAGER.OPENSETUP
* NOTIF.UPDATEMANAGER.UPDATE
* NOTIF.UPDATEMANAGER.OPENSETUP
* NOTIF.UPDATEMANAGER.UPDATE
*/
$this->checkUpdates();
/*
* Check if there're new minor updates available.
* NOTIF.UPDATEMANAGER.MINOR
* NOTIF.UPDATEMANAGER.MINOR
*/
$this->checkMinorRelease();
if (enterprise_installed()) {
if ((bool) enterprise_installed() === true) {
// Release the lock.
enterprise_hook('cron_supervisor_release_lock');
}
/*
* Check if CRON is running.
* NOTIF.CRON.CONFIGURED
* NOTIF.CRON.CONFIGURED
*/
if (enterprise_installed()) {
@ -448,14 +449,14 @@ class ConsoleSupervisor
/*
* Check if instance is registered.
* NOTIF.UPDATEMANAGER.REGISTRATION
* NOTIF.UPDATEMANAGER.REGISTRATION
*/
$this->checkUpdateManagerRegistration();
/*
* Check if there're new messages in UM.
* NOTIF.UPDATEMANAGER.MESSAGES
* NOTIF.UPDATEMANAGER.MESSAGES
*/
$this->getUMMessages();
@ -463,18 +464,23 @@ class ConsoleSupervisor
/*
* Check if the Server and Console has
* the same versions.
* NOTIF.SERVER.MISALIGNED
*/
$this->checkConsoleServerVersions();
/*
* Check if AllowOverride is None or All.
* NOTIF.ALLOWOVERRIDE.MESSAGE
*/
$this->checkAllowOverrideEnabled();
/*
* Check if HA status.
*/
if (enterprise_installed()) {
/*
* Check if HA status.
*/
if ((bool) enterprise_installed() === true) {
$this->checkHaStatus();
}
@ -482,13 +488,8 @@ class ConsoleSupervisor
* Check if the audit log file
* remains in old location.
*/
$this->checkAuditLogOldLocation();
/*
Check if AllowOverride is None or All.
*/
$this->checkAllowOverrideEnabled();
}
@ -511,13 +512,13 @@ class ConsoleSupervisor
* Update targets for given notification using object targets.
*
* @param array $notification Current notification.
* @param boolean $update Only update db targets, no email.
* @param boolean $send_mails Only update db targets, no email.
*
* @return void
*/
public function updateTargets(
array $notification,
bool $update=false
bool $send_mails=true
) {
$notification_id = $notification['id_mensaje'];
$blacklist = [];
@ -536,7 +537,7 @@ class ConsoleSupervisor
);
$insertion_string .= ',';
if ($update === false) {
if ($send_mails === true) {
// Send mail.
if (isset($user['also_mail']) && $user['also_mail'] == 1) {
enterprise_hook(
@ -570,7 +571,7 @@ class ConsoleSupervisor
);
$insertion_string .= ',';
if ($update === false) {
if ($send_mails === true) {
// Send mail.
if (isset($group['also_mail']) && $group['also_mail'] == 1) {
enterprise_hook(
@ -611,7 +612,7 @@ class ConsoleSupervisor
public function notify(
array $data,
int $source_id=0,
int $max_age=86400
int $max_age=SECONDS_1DAY
) {
// Uses 'check failed' logic.
if (is_array($data) === false) {
@ -680,8 +681,8 @@ class ConsoleSupervisor
// NOTIF.SERVER.MASTER.
// NOTIF.SERVER.STATUS.ID_SERVER.
if (preg_match('/^NOTIF.SERVER/', $data['type']) === true) {
// Component notifications require be inmediate.
$max_age = 0;
// Send notification once a day.
$max_age = SECONDS_1DAY;
}
// Else ignored.
@ -692,7 +693,9 @@ class ConsoleSupervisor
$prev = db_get_row(
'tmensajes',
'subtype',
$data['type']
$data['type'],
false,
false
);
if ($prev !== false
@ -711,7 +714,7 @@ class ConsoleSupervisor
],
['id_mensaje' => $prev['id_mensaje']]
);
$this->updateTargets($prev, true);
$this->updateTargets($prev, false);
return;
}
@ -960,7 +963,7 @@ class ConsoleSupervisor
{
global $config;
$remote_config_dir = io_safe_output($config['remote_config']);
$remote_config_dir = (string) io_safe_output($config['remote_config']);
if (enterprise_installed()
&& isset($config['license_nms'])
@ -1200,6 +1203,8 @@ class ConsoleSupervisor
*/
public function checkPandoraServers()
{
global $config;
$servers = db_get_all_rows_sql(
'SELECT
id_server,
@ -1239,8 +1244,29 @@ class ConsoleSupervisor
$this->cleanNotifications('NOTIF.SERVER.STATUS%');
return;
} else {
// Clean notifications. Only show notif for down servers.
$this->cleanNotifications('NOTIF.SERVER.STATUS%');
// Clean notifications. Only show notif for down servers
// ONLY FOR RECOVERED ONES.
$servers_working = db_get_all_rows_sql(
'SELECT
id_server,
name,
server_type,
server_keepalive,
status,
unix_timestamp() - unix_timestamp(keepalive) as downtime
FROM tserver
WHERE
unix_timestamp() - unix_timestamp(keepalive) <= server_keepalive
OR status != 0'
);
if (is_array($servers_working) === true) {
foreach ($servers_working as $server) {
$this->cleanNotifications(
'NOTIF.SERVER.STATUS'.$server['id_server']
);
}
}
}
foreach ($servers as $server) {
@ -1297,6 +1323,8 @@ class ConsoleSupervisor
*/
public function checkPandoraServerMasterAvailable()
{
global $config;
$n_masters = db_get_value_sql(
'SELECT
count(*) as n
@ -2541,7 +2569,7 @@ class ConsoleSupervisor
}
/*
/**
* Check if Pandora console log file remains in old location.
*
* @return void

View File

@ -248,7 +248,7 @@ class CredentialStore extends Wizard
);
} else {
$groups = [ $filter['filter_id_group'] ];
$childrens = groups_get_childrens($id_group, null, true);
$childrens = groups_get_children($id_group, null, true);
if (!empty($childrens)) {
foreach ($childrens as $child) {
$groups[] = (int) $child['id_grupo'];

View File

@ -547,7 +547,13 @@ class HTML
} else {
if ($input['arguments']['type'] != 'hidden'
&& $input['arguments']['type'] != 'hidden_extended'
&& $input['arguments']['type'] != 'datalist'
) {
// Raw content for attach at the start of the input.
if (isset($input['surround_start']) === true) {
$output .= $input['surround_start'];
}
if (!$direct) {
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';
}
@ -562,6 +568,11 @@ class HTML
if (!$direct) {
$output .= '</li>';
}
// Raw content for attach at the end of the input.
if (isset($input['surround_end']) === true) {
$output .= $input['surround_end'];
}
} else {
$output .= self::printInput($input['arguments']);
// Allow dynamic content.

View File

@ -409,6 +409,8 @@ class ModuleTemplates extends HTML
case 'export':
global $config;
enterprise_include_once('include/functions_reporting_csv.php');
$id_network_profile = safe_int($this->id_np);
if (empty($id_network_profile)) {
return false;
@ -500,7 +502,7 @@ class ModuleTemplates extends HTML
}
// Then print the first line (row names)
echo '"'.implode('","', $row_names).'"';
echo '"'.implode('"'.$config['csv_divider'].'"', $row_names).'"';
echo "\n";
// Then print the rest of the data. Encapsulate in quotes in case we have comma's in any of the descriptions
@ -509,7 +511,19 @@ class ModuleTemplates extends HTML
unset($row[$bad_key]);
}
echo '"'.implode('","', $row).'"';
if ($config['csv_decimal_separator'] !== '.') {
foreach ($row as $name => $data) {
if (is_numeric($data)) {
// Get the number of decimals, if > 0, format dec comma.
$decimals = strlen(substr(strrchr($data, '.'), 1));
if ($decimals !== 0) {
$row[$name] = csv_format_numeric((float) $data, $decimals, true);
}
}
}
}
echo '"'.implode('"'.$config['csv_divider'].'"', $row).'"';
echo "\n";
}
@ -845,7 +859,7 @@ class ModuleTemplates extends HTML
$row['id_np'],
'',
true,
['title' => 'Export to CSV']
['title' => 'Export tdaso CSV']
);
$data[3] = '<a href="'.$this->baseUrl.'&action=delete&id_np='.$row['id_np'].'" onclick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
$data[3] .= '<a href="'.$this->baseUrl.'&action=export&id_np='.$row['id_np'].'">'.html_print_image('images/csv.png', true, ['title' => __('Export to CSV')]).'</a>';

View File

@ -810,7 +810,7 @@ class NetworkMap
$filter['id_grupo'] = $this->idGroup;
} else {
// Show current group and children.
$childrens = groups_get_childrens($this->idGroup, null, true);
$childrens = groups_get_children($this->idGroup, null, true);
if (!empty($childrens)) {
$childrens = array_keys($childrens);

View File

@ -565,7 +565,6 @@ class Tree
$module['id_module_type'] = (int) $module['id_tipo_modulo'];
$module['server_type'] = (int) $module['id_modulo'];
$module['status'] = $module['estado'];
$module['value'] = modules_get_agentmodule_data_for_humans($module);
if (is_metaconsole()) {
$module['serverID'] = $this->serverID;
@ -575,6 +574,8 @@ class Tree
$module['serverID'] = false;
}
$module['value'] = modules_get_agentmodule_data_for_humans($module);
if (!isset($module['value'])) {
$module['value'] = modules_get_last_value($module['id']);
}

View File

@ -264,6 +264,7 @@ class TreeService extends Tree
ts.id_agent_module,
ts.name,
ts.name as `alias`,
ts.description as `description`,
ts.id as `rootID`,
"services" as `rootType`,
"services" as `type`,
@ -311,6 +312,7 @@ class TreeService extends Tree
];
$services[$service['id']]['name'] = $service['name'];
$services[$service['id']]['id'] = $service['id'];
$services[$service['id']]['description'] = $service['description'];
$services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id'];
}
@ -512,6 +514,8 @@ class TreeService extends Tree
$tmp['id'] = (int) $item->service()->id();
$tmp['name'] = $item->service()->name();
$tmp['alias'] = $item->service()->name();
$tmp['description'] = $item->service()->description();
$tmp['elementDescription'] = $item->description();
if ($this->connectedToNode === false
&& is_metaconsole() === true
@ -643,6 +647,8 @@ class TreeService extends Tree
ts.id_agent_module,
ts.name,
ts.name as `alias`,
ts.description as `description`,
tse.description as `elementDescription`,
tse.id_service as `rootID`,
"services" as `rootType`,
"services" as `type`,

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC201015';
$build_version = 'PC201202';
$pandora_version = 'v7.0NG.750';
// Do not overwrite default timezone set if defined.

View File

@ -309,7 +309,7 @@ define('STATUS_ALERT_DISABLED', 'alert_disabled.png');
// For servers.
define('STATUS_SERVER_OK', 'server_ok.png');
define('STATUS_SERVER_DOWN', 'server_down.png');
define('STATUS_SERVER_CRASH', 'server_crash.png');
// Status images (ball).
@ -335,6 +335,7 @@ define('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png');
// For servers.
define('STATUS_SERVER_OK_BALL', 'server_ok_ball.png');
define('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png');
define('STATUS_SERVER_CRASH_BALL', 'server_crash_ball.png');
@ -456,6 +457,9 @@ define('REPORT_OLD_TYPE_SUMATORY', 10);
define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0);
define('REPORT_GENERAL_GROUP_BY_AGENT', 1);
define('REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP', 0);
define('REPORT_PERMISSIONS_GROUP_BY_GROUP', 1);
define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15);
// POLICIES.

View File

@ -1342,6 +1342,73 @@ function get_priority_name($priority)
}
/**
* Translates status into string.
*
* @param integer $status Agent status.
*
* @return string Translation.
*/
function get_agent_status_string($status)
{
switch ($status) {
case AGENT_STATUS_CRITICAL:
return __('CRITICAL');
case AGENT_STATUS_WARNING:
return __('WARNING');
case AGENT_STATUS_ALERT_FIRED:
return __('ALERT FIRED');
case AGENT_STATUS_NOT_INIT:
return __('NO DATA');
case AGENT_STATUS_NORMAL:
return __('NORMAL');
case AGENT_STATUS_UNKNOWN:
default:
return __('UNKNOWN');
}
}
/**
* Translates status into string.
*
* @param integer $status Module status.
*
* @return string Translation.
*/
function get_module_status_string($status)
{
switch ($status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
return __('CRITICAL');
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
return __('ALERT FIRED');
case AGENT_MODULE_STATUS_WARNING:
return __('WARNING');
case AGENT_MODULE_STATUS_UNKNOWN:
return __('UNKNOWN');
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
return __('NO DATA');
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_NORMAL:
default:
return __('NORMAL');
}
}
/**
* Get priority class (CSS class) from priority value.
*
@ -2222,13 +2289,19 @@ function check_login($output=true)
* @param integer $id_group Agents group id to check from
* @param string $access Access privilege
* @param boolean $onlyOneGroup Flag to check acl for specified group only (not to roots up, or check acl for 'All' group when $id_group is 0).
* @param boolean $cache Use cache.
*
* @return boolean 1 if the user has privileges, 0 if not.
*/
function check_acl($id_user, $id_group, $access, $onlyOneGroup=false)
{
function check_acl(
$id_user,
$id_group,
$access,
$onlyOneGroup=false,
$cache=true
) {
if (empty($id_user)) {
// User ID needs to be specified
// User ID needs to be specified.
trigger_error('Security error: check_acl got an empty string for user id', E_USER_WARNING);
return 0;
} else if (is_user_admin($id_user)) {
@ -2238,7 +2311,15 @@ function check_acl($id_user, $id_group, $access, $onlyOneGroup=false)
}
if ($id_group != 0 || $onlyOneGroup === true) {
$groups_list_acl = users_get_groups($id_user, $access, false, true, null);
$groups_list_acl = users_get_groups(
$id_user,
$access,
false,
true,
null,
'id_grupo',
$cache
);
} else {
$groups_list_acl = get_users_acl($id_user);
}
@ -2263,16 +2344,17 @@ function check_acl($id_user, $id_group, $access, $onlyOneGroup=false)
/**
* Check the ACL of a list of groups.
*
* @param string $id_user to check the ACL
* @param array $groups. All groups to check
* @param string $access. Profile to check
* @param string $id_user to check the ACL
* @param array $groups. All groups to check
* @param string $access. Profile to check
* @param boolean $cache Use cached group information.
*
* @return boolean True if at least one of this groups check the ACL
*/
function check_acl_one_of_groups($id_user, $groups, $access)
function check_acl_one_of_groups($id_user, $groups, $access, $cache=true)
{
foreach ($groups as $group) {
if (check_acl($id_user, $group, $access)) {
if (check_acl($id_user, $group, $access, false, $cache)) {
return true;
}
}
@ -3753,7 +3835,16 @@ function series_type_graph_array($data, $show_elements_graph)
$name_legend .= __('Unit ').' ';
$name_legend .= $show_elements_graph['unit'].': ';
} else {
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
if (isset($show_elements_graph['from_interface']) === true
&& (bool) $show_elements_graph['from_interface'] === true
) {
$label_interfaces = array_flip($show_elements_graph['modules_series']);
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']][$label_interfaces[$value['agent_module_id']]].': ';
} else if (is_array($show_elements_graph['labels'][$value['agent_module_id']]) === true) {
$name_legend = 'Avg: ';
} else {
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
}
}
} else {
if (strpos($key, 'baseline') !== false) {
@ -3813,17 +3904,23 @@ function series_type_graph_array($data, $show_elements_graph)
$data_return['legend'][$key] .= __('Min:').remove_right_zeros(
number_format(
$value['min'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator'],
$config['csv_decimal_separator'] == ',' ? '.' : ','
)
).' '.__('Max:').remove_right_zeros(
number_format(
$value['max'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator'],
$config['csv_decimal_separator'] == ',' ? '.' : ','
)
).' '._('Avg:').remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator'],
$config['csv_decimal_separator'] == ',' ? '.' : ','
)
).' '.$str;
@ -3887,7 +3984,8 @@ function series_type_graph_array($data, $show_elements_graph)
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator']
)
).' '.$str;
}
@ -5820,4 +5918,5 @@ function send_test_email(
}
return $result;
}

Some files were not shown because too many files have changed in this diff Show More