Merge remote-tracking branch 'origin/develop' into ent-5778-9834-db2-para-discovery
This commit is contained in:
commit
b4219472f2
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.746-200609
|
||||
Version: 7.0NG.746-200611
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.746-200609"
|
||||
pandora_version="7.0NG.746-200611"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -55,7 +55,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.746';
|
||||
use constant AGENT_BUILD => '200609';
|
||||
use constant AGENT_BUILD => '200611';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.746"
|
||||
PI_BUILD="200609"
|
||||
PI_BUILD="200611"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -164,7 +164,7 @@ uninstall () {
|
|||
rm -f $DESTDIR/etc/logrotate.d/pandora_agent
|
||||
|
||||
# Remove systemd service if exists
|
||||
if [ $(systemctl --v | grep systemd | wc -l) != 0 ]
|
||||
if [ `systemctl --v 2> /dev/null | grep systemd | wc -l` != 0 ]
|
||||
then
|
||||
PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service"
|
||||
rm -f $PANDORA_AGENT_SERVICE
|
||||
|
@ -480,7 +480,7 @@ install () {
|
|||
fi
|
||||
|
||||
# Create systemd service
|
||||
if [ $(systemctl --v | grep systemd | wc -l) != 0 ]
|
||||
if [ `systemctl --v 2> /dev/null | grep systemd | wc -l` != 0 ]
|
||||
then
|
||||
echo "Creating systemd service for pandora_agent_daemon"
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{200609}
|
||||
{200611}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.746(Build 200609)")
|
||||
#define PANDORA_VERSION ("7.0NG.746(Build 200611)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.746(Build 200609))"
|
||||
VALUE "ProductVersion", "(7.0NG.746(Build 200611))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.746-200609
|
||||
Version: 7.0NG.746-200611
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.746-200609"
|
||||
pandora_version="7.0NG.746-200611"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -271,7 +271,7 @@ ui_print_page_header(
|
|||
$help_header,
|
||||
true,
|
||||
$onheader,
|
||||
true,
|
||||
false,
|
||||
'massivemodal'
|
||||
);
|
||||
|
||||
|
|
|
@ -367,11 +367,11 @@ if ($search) {
|
|||
$found = false;
|
||||
|
||||
if (!empty($filter_search)) {
|
||||
if (preg_match('/.*'.$filter_search.'.*/', $user_info['fullname']) != 0) {
|
||||
if (preg_match('/.*'.strtolower($filter_search).'.*/', strtolower($user_info['fullname'])) != 0) {
|
||||
$found = true;
|
||||
}
|
||||
|
||||
if (preg_match('/.*'.$filter_search.'.*/', $user_info['id_user']) != 0) {
|
||||
if (preg_match('/.*'.strtolower($filter_search).'.*/', strtolower($user_info['id_user'])) != 0) {
|
||||
$found = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC200609';
|
||||
$build_version = 'PC200611';
|
||||
$pandora_version = 'v7.0NG.746';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -3718,6 +3718,14 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||
}
|
||||
}
|
||||
|
||||
if ((int) $value['min'] === PHP_INT_MAX) {
|
||||
$value['min'] = 0;
|
||||
}
|
||||
|
||||
if ((int) $value['max'] === (-PHP_INT_MAX)) {
|
||||
$value['max'] = 0;
|
||||
}
|
||||
|
||||
$data_return['legend'][$key] .= __('Min:').remove_right_zeros(
|
||||
number_format(
|
||||
$value['min'],
|
||||
|
|
|
@ -1506,6 +1506,12 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((int) $other['data'][3] == 0) {
|
||||
$agent_creation_error = __('The agent could not be created, for security reasons use a group another than 0');
|
||||
returnError('generic error', $agent_creation_error);
|
||||
return;
|
||||
}
|
||||
|
||||
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $other['data'][0])));
|
||||
$direccion_agente = io_safe_input($other['data'][1]);
|
||||
$nombre_agente = hash('sha256', $direccion_agente.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000)));
|
||||
|
@ -2048,31 +2054,31 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType)
|
|||
// Filter by status
|
||||
switch ($other['data'][2]) {
|
||||
case 'warning':
|
||||
if ($status == 2) {
|
||||
if ($status == AGENT_MODULE_STATUS_WARNING || $status == AGENT_MODULE_STATUS_WARNING_ALERT) {
|
||||
$result_agents[] = $agent;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'critical':
|
||||
if ($status == 1) {
|
||||
if ($status == AGENT_MODULE_STATUS_CRITICAL_BAD || $status == AGENT_MODULE_STATUS_CRITICAL_ALERT) {
|
||||
$result_agents[] = $agent;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'unknown':
|
||||
if ($status == 3) {
|
||||
if ($status == AGENT_MODULE_STATUS_UNKNOWN) {
|
||||
$result_agents[] = $agent;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'normal':
|
||||
if ($status == 0) {
|
||||
if ($status == AGENT_MODULE_STATUS_NORMAL || $status == AGENT_MODULE_STATUS_NORMAL_ALERT) {
|
||||
$result_agents[] = $agent;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'alert_fired':
|
||||
if ($status == 4) {
|
||||
if ($status == AGENT_STATUS_ALERT_FIRED || $status == AGENT_MODULE_STATUS_WARNING_ALERT || $status == AGENT_MODULE_STATUS_CRITICAL_ALERT || $status == AGENT_MODULE_STATUS_NORMAL_ALERT) {
|
||||
$result_agents[] = $agent;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -633,6 +633,14 @@ function events_update_status($id_evento, $status, $filter=null, $history=false)
|
|||
break;
|
||||
|
||||
case EVENT_STATUS_VALIDATED:
|
||||
events_change_owner(
|
||||
$id_evento,
|
||||
$config['id_user'],
|
||||
false,
|
||||
is_metaconsole() ? true : false,
|
||||
$history
|
||||
);
|
||||
|
||||
$status_string = 'Validated';
|
||||
break;
|
||||
|
||||
|
@ -1870,6 +1878,16 @@ function events_change_status(
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($new_status == EVENT_STATUS_VALIDATED) {
|
||||
events_change_owner(
|
||||
$id_event,
|
||||
$config['id_user'],
|
||||
false,
|
||||
$meta,
|
||||
$history
|
||||
);
|
||||
}
|
||||
|
||||
events_comment(
|
||||
$id_event,
|
||||
'',
|
||||
|
|
|
@ -369,11 +369,21 @@ if ($delete_file) {
|
|||
$config['filemanager']['message'] = ui_print_success_message(__('Deleted'), '', true);
|
||||
|
||||
if (is_dir($filename)) {
|
||||
rmdir($filename);
|
||||
if (rmdir($filename)) {
|
||||
$config['filemanager']['delete'] = 1;
|
||||
} else {
|
||||
unlink($filename);
|
||||
$config['filemanager']['delete'] = 0;
|
||||
}
|
||||
} else {
|
||||
if (unlink($filename)) {
|
||||
$config['filemanager']['delete'] = 1;
|
||||
} else {
|
||||
$config['filemanager']['delete'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['filemanager']['delete'] == 0) {
|
||||
$config['filemanager']['message'] = ui_print_error_message(__('Deleted'), '', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -743,7 +753,7 @@ function filemanager_file_explorer(
|
|||
|
||||
if (($editor) && (!$readOnly)) {
|
||||
if (($typefile != 'bin') && ($typefile != 'pdf') && ($typefile != 'png') && ($typefile != 'jpg')
|
||||
&& ($typefile != 'iso') && ($typefile != 'docx') && ($typefile != 'doc')
|
||||
&& ($typefile != 'iso') && ($typefile != 'docx') && ($typefile != 'doc') && ($fileinfo['mime'] != MIME_DIR)
|
||||
) {
|
||||
$hash = md5($fileinfo['realpath'].$config['dbpass']);
|
||||
$data[4] .= "<a style='vertical-align: top;' href='$url&edit_file=1&hash=".$hash.'&location_file='.$fileinfo['realpath']."' style='float: left;'>".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'</a>';
|
||||
|
|
|
@ -2123,13 +2123,6 @@ function html_print_input_number(array $settings):string
|
|||
$settings['maxlength'] = 255;
|
||||
}
|
||||
|
||||
// Check Size.
|
||||
if (isset($settings['size']) === false
|
||||
|| $settings['size'] === 0
|
||||
) {
|
||||
$settings['size'] = 255;
|
||||
}
|
||||
|
||||
foreach ($settings as $attribute => $attr_value) {
|
||||
// Check valid attribute.
|
||||
if (in_array($attribute, $valid_attrs) === false) {
|
||||
|
|
|
@ -238,8 +238,17 @@ function snmp_browser_print_tree(
|
|||
/**
|
||||
* Build the SNMP tree for the given SNMP agent.
|
||||
*
|
||||
* @param target_ip string IP of the SNMP agent.
|
||||
* @param community string SNMP community to use.
|
||||
* @param string $target_ip Target_ip.
|
||||
* @param string $community Community.
|
||||
* @param string $starting_oid Starting_oid.
|
||||
* @param string $version Version.
|
||||
* @param string $snmp3_auth_user Snmp3_auth_user.
|
||||
* @param string $snmp3_security_level Snmp3_security_level.
|
||||
* @param string $snmp3_auth_method Snmp3_auth_method.
|
||||
* @param string $snmp3_auth_pass Snmp3_auth_pass.
|
||||
* @param string $snmp3_privacy_method Snmp3_privacy_method.
|
||||
* @param string $snmp3_privacy_pass Snmp3_privacy_pass.
|
||||
* @param string|null $snmp3_context_engine_id Snmp3_context_engine_id.
|
||||
*
|
||||
* @return array The SNMP tree.
|
||||
*/
|
||||
|
@ -253,7 +262,8 @@ function snmp_browser_get_tree(
|
|||
$snmp3_auth_method='',
|
||||
$snmp3_auth_pass='',
|
||||
$snmp3_privacy_method='',
|
||||
$snmp3_privacy_pass=''
|
||||
$snmp3_privacy_pass='',
|
||||
$snmp3_context_engine_id=null
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -277,6 +287,7 @@ function snmp_browser_get_tree(
|
|||
|
||||
default:
|
||||
$snmp_version = SNMP::VERSION_2c;
|
||||
break;
|
||||
}
|
||||
|
||||
$snmp_session = new SNMP($snmp_version, $target_ip, $community);
|
||||
|
@ -284,10 +295,34 @@ function snmp_browser_get_tree(
|
|||
|
||||
// Set security if SNMP Version is 3.
|
||||
if ($snmp_version == SNMP::VERSION_3) {
|
||||
$snmp_session->setSecurity($snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, $snmp3_privacy_method, $snmp3_privacy_pass);
|
||||
$snmp_session->setSecurity(
|
||||
$snmp3_security_level,
|
||||
$snmp3_auth_method,
|
||||
$snmp3_auth_pass,
|
||||
$snmp3_privacy_method,
|
||||
$snmp3_privacy_pass,
|
||||
$community,
|
||||
$snmp3_context_engine_id
|
||||
);
|
||||
}
|
||||
|
||||
snmp_read_mib($config['homedir'].'/attachment/mibs');
|
||||
$mibs_dir = $config['homedir'].'/attachment/mibs';
|
||||
$_dir = opendir($mibs_dir);
|
||||
|
||||
// Future. Recomemended: Use a global config limit of MIBs loaded.
|
||||
while (($mib_file = readdir($_dir)) !== false) {
|
||||
if ($mib_file == '..' || $mib_file == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rs = snmp_read_mib($mibs_dir.'/'.$mib_file);
|
||||
if ($rs !== true) {
|
||||
error_log('Failed while reading MIB file: '.$mib_file);
|
||||
}
|
||||
}
|
||||
|
||||
closedir($_dir);
|
||||
|
||||
$output = $snmp_session->walk($starting_oid);
|
||||
if ($output == false) {
|
||||
$output = $snmp_session->getError();
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
export: {
|
||||
export_data: false, // or true
|
||||
labels_long: null,
|
||||
homeurl: ''
|
||||
}
|
||||
homeurl: "",
|
||||
},
|
||||
};
|
||||
|
||||
function init(plot) {
|
||||
|
@ -13,215 +13,7 @@
|
|||
//options = options || {};
|
||||
|
||||
// Options
|
||||
var type = 'csv';
|
||||
type = type.toLowerCase().trim();
|
||||
|
||||
var graphData,
|
||||
dataObject,
|
||||
dataObjects = plot.getData(),
|
||||
result = [];
|
||||
|
||||
// Throw errors
|
||||
var retrieveDataOject = function (dataObjects, custom) {
|
||||
var result;
|
||||
if (typeof dataObjects === 'undefined')
|
||||
throw new Error('Empty parameter');
|
||||
|
||||
// Try to retrieve the avg set (not 100% reliable, I know)
|
||||
if (dataObjects.length == 1) {
|
||||
result = dataObjects.shift();
|
||||
}
|
||||
if (dataObjects.length > 1) {
|
||||
dataObjects.forEach(function (element) {
|
||||
if(custom){
|
||||
if (/^Avg.:/i.test(element.label)){
|
||||
result = element;
|
||||
}
|
||||
} else {
|
||||
result = element;
|
||||
}
|
||||
});
|
||||
|
||||
// If the avg set is missing, retrieve the first set
|
||||
if (typeof result === 'undefined')
|
||||
result = dataObjects.shift();
|
||||
}
|
||||
|
||||
if (typeof result === 'undefined')
|
||||
throw new Error('Empty result');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Throw errors
|
||||
var processDataObject = function (dataObject) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObject === 'undefined')
|
||||
throw new Error('Empty parameter');
|
||||
|
||||
if (typeof dataObject.data === 'undefined'
|
||||
|| !(dataObject.data instanceof Array))
|
||||
throw new Error('Object malformed');
|
||||
|
||||
/* {
|
||||
* head: [<column>,<column>,...,<column>],
|
||||
* data: [
|
||||
* [<data>,<data>,...,<data>],
|
||||
* [<data>,<data>,...,<data>],
|
||||
* ...,
|
||||
* [<data>,<data>,...,<data>],
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
if (type === 'csv') {
|
||||
result = {
|
||||
head: ['timestap', 'date', 'value', 'label'],
|
||||
data: []
|
||||
};
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var timestap = item[0];
|
||||
|
||||
var d = new Date(item[0]);
|
||||
var monthNames = [
|
||||
"Jan", "Feb", "Mar",
|
||||
"Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep",
|
||||
"Oct", "Nov", "Dec"
|
||||
];
|
||||
|
||||
date_format = (d.getDate() <10?'0':'') + d.getDate() + " " +
|
||||
monthNames[d.getMonth()] + " " +
|
||||
d.getFullYear() + " " +
|
||||
(d.getHours()<10?'0':'') + d.getHours() + ":" +
|
||||
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
|
||||
(d.getSeconds()<10?'0':'') + d.getSeconds();
|
||||
|
||||
var date = date_format;
|
||||
|
||||
var value = item[1];
|
||||
|
||||
var clean_label = plot.getOptions().export.labels_long[dataObject.label];
|
||||
clean_label = clean_label.replace( new RegExp(" ", "g"), " ");
|
||||
result.data.push([timestap, date, value, clean_label]);
|
||||
});
|
||||
}
|
||||
/* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ],
|
||||
* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ],
|
||||
* ...,
|
||||
* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
else if (type === 'json') {
|
||||
result = [];
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = '', value = item[1];
|
||||
|
||||
// Long labels are preferred
|
||||
if (typeof labels_long[index] !== 'undefined')
|
||||
date = labels_long[index];
|
||||
else if (typeof labels[index] !== 'undefined')
|
||||
date = labels[index];
|
||||
|
||||
result.push({
|
||||
'date': date,
|
||||
'value': value,
|
||||
'label': dataObject.label
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof result === 'undefined')
|
||||
throw new Error('Empty result');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
var elements = [];
|
||||
var custom_graph = $('#hidden-custom_graph').val();
|
||||
|
||||
if (custom_graph) {
|
||||
dataObject = retrieveDataOject(dataObjects,0);
|
||||
dataObjects.forEach(function (element) {
|
||||
elements.push(processDataObject(element));
|
||||
});
|
||||
graphData = elements;
|
||||
}
|
||||
else {
|
||||
dataObject = retrieveDataOject(dataObjects,1);
|
||||
elements.push(processDataObject(dataObject));
|
||||
graphData = elements;
|
||||
}
|
||||
|
||||
// Transform the object data into a string
|
||||
// cause PHP has limitations in the number
|
||||
// of POST params received.
|
||||
var graphDataStr = JSON.stringify(graphData);
|
||||
|
||||
// Build form
|
||||
var $form = $('<form></form>'),
|
||||
$dataInput = $('<input>'),
|
||||
$typeInput = $('<input>'),
|
||||
$separatorInput = $('<input>'),
|
||||
$excelInput = $('<input>');
|
||||
|
||||
$dataInput
|
||||
.prop('name', 'data')
|
||||
.prop('type', 'text')
|
||||
.prop('value', graphDataStr);
|
||||
|
||||
$typeInput
|
||||
.prop('name', 'type')
|
||||
.prop('type', 'text')
|
||||
.prop('value', type);
|
||||
|
||||
$separatorInput
|
||||
.prop('name', 'separator')
|
||||
.prop('type', 'text')
|
||||
.prop('value', ';');
|
||||
|
||||
$excelInput
|
||||
.prop('name', 'excel_encoding')
|
||||
.prop('type', 'text')
|
||||
.prop('value', 0);
|
||||
|
||||
$form
|
||||
.prop('method', 'POST')
|
||||
.prop('action', plot.getOptions().export.homeurl + 'include/graphs/export_data.php')
|
||||
.append($dataInput, $typeInput, $separatorInput, $excelInput)
|
||||
.hide()
|
||||
// Firefox made me write into the DOM for this :(
|
||||
.appendTo('body')
|
||||
.submit();
|
||||
}
|
||||
catch (e) {
|
||||
alert('There was an error exporting the data');
|
||||
}
|
||||
}
|
||||
|
||||
plot.exportDataJSON = function (args) {
|
||||
//amount = plot.getOptions().export.type,
|
||||
//options = options || {};
|
||||
|
||||
// Options
|
||||
var type = 'json';
|
||||
var type = "csv";
|
||||
type = type.toLowerCase().trim();
|
||||
|
||||
var graphData,
|
||||
|
@ -233,8 +25,8 @@
|
|||
var retrieveDataOject = function (dataObjects) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObjects === 'undefined')
|
||||
throw new Error('Empty parameter');
|
||||
if (typeof dataObjects === "undefined")
|
||||
throw new Error("Empty parameter");
|
||||
|
||||
// Try to retrieve the avg set (not 100% reliable, I know)
|
||||
if (dataObjects.length == 1) {
|
||||
|
@ -242,31 +34,30 @@
|
|||
}
|
||||
if (dataObjects.length > 1) {
|
||||
dataObjects.forEach(function (element) {
|
||||
if (/^Avg.:/i.test(element.label))
|
||||
result = element;
|
||||
if (/^Avg.:/i.test(element.label)) result = element;
|
||||
});
|
||||
|
||||
// If the avg set is missing, retrieve the first set
|
||||
if (typeof result === 'undefined')
|
||||
result = dataObjects.shift();
|
||||
if (typeof result === "undefined") result = dataObjects.shift();
|
||||
}
|
||||
|
||||
if (typeof result === 'undefined')
|
||||
throw new Error('Empty result');
|
||||
if (typeof result === "undefined") throw new Error("Empty result");
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// Throw errors
|
||||
var processDataObject = function (dataObject) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObject === 'undefined')
|
||||
throw new Error('Empty parameter');
|
||||
if (typeof dataObject === "undefined")
|
||||
throw new Error("Empty parameter");
|
||||
|
||||
if (typeof dataObject.data === 'undefined'
|
||||
|| !(dataObject.data instanceof Array))
|
||||
throw new Error('Object malformed');
|
||||
if (
|
||||
typeof dataObject.data === "undefined" ||
|
||||
!(dataObject.data instanceof Array)
|
||||
)
|
||||
throw new Error("Object malformed");
|
||||
|
||||
/* {
|
||||
* head: [<column>,<column>,...,<column>],
|
||||
|
@ -278,25 +69,59 @@
|
|||
* ]
|
||||
* }
|
||||
*/
|
||||
if (type === 'csv') {
|
||||
|
||||
if (type === "csv") {
|
||||
result = {
|
||||
head: ['date', 'value','label'],
|
||||
data: []
|
||||
head: ["timestap", "date", "value", "label"],
|
||||
data: [],
|
||||
};
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = '', value = item[1];
|
||||
var timestap = item[0];
|
||||
|
||||
// Long labels are preferred
|
||||
if (typeof plot.getOptions().export.labels_long[index] !== 'undefined')
|
||||
date = plot.getOptions().export.labels_long[index];
|
||||
else if (typeof labels[index] !== 'undefined')
|
||||
date = labels[index];
|
||||
var d = new Date(item[0]);
|
||||
var monthNames = [
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec",
|
||||
];
|
||||
|
||||
result.data.push([date, value,dataObject.label]);
|
||||
date_format =
|
||||
(d.getDate() < 10 ? "0" : "") +
|
||||
d.getDate() +
|
||||
" " +
|
||||
monthNames[d.getMonth()] +
|
||||
" " +
|
||||
d.getFullYear() +
|
||||
" " +
|
||||
(d.getHours() < 10 ? "0" : "") +
|
||||
d.getHours() +
|
||||
":" +
|
||||
(d.getMinutes() < 10 ? "0" : "") +
|
||||
d.getMinutes() +
|
||||
":" +
|
||||
(d.getSeconds() < 10 ? "0" : "") +
|
||||
d.getSeconds();
|
||||
|
||||
var date = date_format;
|
||||
|
||||
var value = item[1];
|
||||
|
||||
var clean_label = plot.getOptions().export.labels_long[
|
||||
dataObject.label
|
||||
];
|
||||
clean_label = clean_label.replace(new RegExp(" ", "g"), " ");
|
||||
result.data.push([timestap, date, value, clean_label]);
|
||||
});
|
||||
}
|
||||
} else if (type === "json") {
|
||||
/* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
|
@ -317,35 +142,218 @@
|
|||
* }
|
||||
* ]
|
||||
*/
|
||||
else if (type === 'json') {
|
||||
result = [];
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = '', value = item[1];
|
||||
var date = "",
|
||||
value = item[1];
|
||||
|
||||
// Long labels are preferred
|
||||
if (typeof labels_long[index] !== 'undefined')
|
||||
if (typeof labels_long[index] !== "undefined")
|
||||
date = labels_long[index];
|
||||
else if (typeof labels[index] !== 'undefined')
|
||||
date = labels[index];
|
||||
else if (typeof labels[index] !== "undefined") date = labels[index];
|
||||
|
||||
result.push({
|
||||
'date': date,
|
||||
'value': value,
|
||||
'label': dataObject.label
|
||||
date: date,
|
||||
value: value,
|
||||
label: dataObject.label,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof result === 'undefined')
|
||||
throw new Error('Empty result');
|
||||
if (typeof result === "undefined") throw new Error("Empty result");
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
var elements = [];
|
||||
var custom_graph = $('input:hidden[name=custom_graph]').value;
|
||||
dataObject = retrieveDataOject(dataObjects);
|
||||
if (dataObject) {
|
||||
elements.push(processDataObject(dataObject));
|
||||
}
|
||||
dataObjects.forEach(function (element) {
|
||||
elements.push(processDataObject(element));
|
||||
});
|
||||
graphData = elements;
|
||||
|
||||
|
||||
// Transform the object data into a string
|
||||
// cause PHP has limitations in the number
|
||||
// of POST params received.
|
||||
var graphDataStr = JSON.stringify(graphData);
|
||||
|
||||
// Build form
|
||||
var $form = $("<form></form>"),
|
||||
$dataInput = $("<input>"),
|
||||
$typeInput = $("<input>"),
|
||||
$separatorInput = $("<input>"),
|
||||
$excelInput = $("<input>");
|
||||
|
||||
$dataInput
|
||||
.prop("name", "data")
|
||||
.prop("type", "text")
|
||||
.prop("value", graphDataStr);
|
||||
|
||||
$typeInput
|
||||
.prop("name", "type")
|
||||
.prop("type", "text")
|
||||
.prop("value", type);
|
||||
|
||||
$separatorInput
|
||||
.prop("name", "separator")
|
||||
.prop("type", "text")
|
||||
.prop("value", ";");
|
||||
|
||||
$excelInput
|
||||
.prop("name", "excel_encoding")
|
||||
.prop("type", "text")
|
||||
.prop("value", 0);
|
||||
|
||||
$form
|
||||
.prop("method", "POST")
|
||||
.prop(
|
||||
"action",
|
||||
plot.getOptions().export.homeurl + "include/graphs/export_data.php"
|
||||
)
|
||||
.append($dataInput, $typeInput, $separatorInput, $excelInput)
|
||||
.hide()
|
||||
// Firefox made me write into the DOM for this :(
|
||||
.appendTo("body")
|
||||
.submit();
|
||||
} catch (e) {
|
||||
alert("There was an error exporting the data");
|
||||
}
|
||||
};
|
||||
|
||||
plot.exportDataJSON = function (args) {
|
||||
//amount = plot.getOptions().export.type,
|
||||
//options = options || {};
|
||||
|
||||
// Options
|
||||
var type = "json";
|
||||
type = type.toLowerCase().trim();
|
||||
|
||||
var graphData,
|
||||
dataObject,
|
||||
dataObjects = plot.getData(),
|
||||
result = [];
|
||||
|
||||
// Throw errors
|
||||
var retrieveDataOject = function (dataObjects) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObjects === "undefined")
|
||||
throw new Error("Empty parameter");
|
||||
|
||||
// Try to retrieve the avg set (not 100% reliable, I know)
|
||||
if (dataObjects.length == 1) {
|
||||
result = dataObjects.shift();
|
||||
}
|
||||
if (dataObjects.length > 1) {
|
||||
dataObjects.forEach(function (element) {
|
||||
if (/^Avg.:/i.test(element.label)) result = element;
|
||||
});
|
||||
|
||||
// If the avg set is missing, retrieve the first set
|
||||
if (typeof result === "undefined") result = dataObjects.shift();
|
||||
}
|
||||
|
||||
if (typeof result === "undefined") throw new Error("Empty result");
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// Throw errors
|
||||
var processDataObject = function (dataObject) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObject === "undefined")
|
||||
throw new Error("Empty parameter");
|
||||
|
||||
if (
|
||||
typeof dataObject.data === "undefined" ||
|
||||
!(dataObject.data instanceof Array)
|
||||
)
|
||||
throw new Error("Object malformed");
|
||||
|
||||
/* {
|
||||
* head: [<column>,<column>,...,<column>],
|
||||
* data: [
|
||||
* [<data>,<data>,...,<data>],
|
||||
* [<data>,<data>,...,<data>],
|
||||
* ...,
|
||||
* [<data>,<data>,...,<data>],
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
if (type === "csv") {
|
||||
result = {
|
||||
head: ["date", "value", "label"],
|
||||
data: [],
|
||||
};
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = "",
|
||||
value = item[1];
|
||||
|
||||
// Long labels are preferred
|
||||
if (
|
||||
typeof plot.getOptions().export.labels_long[index] !== "undefined"
|
||||
)
|
||||
date = plot.getOptions().export.labels_long[index];
|
||||
else if (typeof labels[index] !== "undefined") date = labels[index];
|
||||
|
||||
result.data.push([date, value, dataObject.label]);
|
||||
});
|
||||
} else if (type === "json") {
|
||||
/* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ],
|
||||
* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ],
|
||||
* ...,
|
||||
* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
result = [];
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = "",
|
||||
value = item[1];
|
||||
|
||||
// Long labels are preferred
|
||||
if (typeof labels_long[index] !== "undefined")
|
||||
date = labels_long[index];
|
||||
else if (typeof labels[index] !== "undefined") date = labels[index];
|
||||
|
||||
result.push({
|
||||
date: date,
|
||||
value: value,
|
||||
label: dataObject.label,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof result === "undefined") throw new Error("Empty result");
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
try {
|
||||
var elements = [];
|
||||
var custom_graph = $("input:hidden[name=custom_graph]").value;
|
||||
|
||||
if (custom_graph) {
|
||||
dataObject = retrieveDataOject(dataObjects);
|
||||
|
@ -353,8 +361,7 @@
|
|||
elements.push(processDataObject(element));
|
||||
});
|
||||
graphData = elements;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dataObject = retrieveDataOject(dataObjects);
|
||||
elements.push(processDataObject(dataObject));
|
||||
graphData = elements;
|
||||
|
@ -366,51 +373,53 @@
|
|||
var graphDataStr = JSON.stringify(graphData);
|
||||
|
||||
// Build form
|
||||
var $form = $('<form></form>'),
|
||||
$dataInput = $('<input>'),
|
||||
$typeInput = $('<input>'),
|
||||
$separatorInput = $('<input>'),
|
||||
$excelInput = $('<input>');
|
||||
var $form = $("<form></form>"),
|
||||
$dataInput = $("<input>"),
|
||||
$typeInput = $("<input>"),
|
||||
$separatorInput = $("<input>"),
|
||||
$excelInput = $("<input>");
|
||||
|
||||
$dataInput
|
||||
.prop('name', 'data')
|
||||
.prop('type', 'text')
|
||||
.prop('value', graphDataStr);
|
||||
.prop("name", "data")
|
||||
.prop("type", "text")
|
||||
.prop("value", graphDataStr);
|
||||
|
||||
$typeInput
|
||||
.prop('name', 'type')
|
||||
.prop('type', 'text')
|
||||
.prop('value', type);
|
||||
.prop("name", "type")
|
||||
.prop("type", "text")
|
||||
.prop("value", type);
|
||||
|
||||
$separatorInput
|
||||
.prop('name', 'separator')
|
||||
.prop('type', 'text')
|
||||
.prop('value', ';');
|
||||
.prop("name", "separator")
|
||||
.prop("type", "text")
|
||||
.prop("value", ";");
|
||||
|
||||
$excelInput
|
||||
.prop('name', 'excel_encoding')
|
||||
.prop('type', 'text')
|
||||
.prop('value', 0);
|
||||
.prop("name", "excel_encoding")
|
||||
.prop("type", "text")
|
||||
.prop("value", 0);
|
||||
|
||||
$form
|
||||
.prop('method', 'POST')
|
||||
.prop('action', plot.getOptions().export.homeurl + 'include/graphs/export_data.php')
|
||||
.prop("method", "POST")
|
||||
.prop(
|
||||
"action",
|
||||
plot.getOptions().export.homeurl + "include/graphs/export_data.php"
|
||||
)
|
||||
.append($dataInput, $typeInput, $separatorInput, $excelInput)
|
||||
.hide()
|
||||
// Firefox made me write into the DOM for this :(
|
||||
.appendTo('body')
|
||||
.appendTo("body")
|
||||
.submit();
|
||||
} catch (e) {
|
||||
alert("There was an error exporting the data");
|
||||
}
|
||||
catch (e) {
|
||||
alert('There was an error exporting the data');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'exportdata',
|
||||
version: '0.1'
|
||||
name: "exportdata",
|
||||
version: "0.1",
|
||||
});
|
||||
})(jQuery);
|
|
@ -3009,7 +3009,7 @@ function number_format(number, force_integer, unit, short_data, divisor) {
|
|||
var decimals = 2;
|
||||
|
||||
if (unit == "KB") {
|
||||
return number + unit;
|
||||
return Math.round(number * decimals) + unit;
|
||||
}
|
||||
|
||||
// Set maximum decimal precision to 99 in case short_data is not set.
|
||||
|
@ -3038,6 +3038,12 @@ function number_format(number, force_integer, unit, short_data, divisor) {
|
|||
|
||||
if (divisor) {
|
||||
number = Math.round(number * decimals) / decimals;
|
||||
} else {
|
||||
number = Math.round(number * decimals);
|
||||
}
|
||||
|
||||
if (isNaN(number)) {
|
||||
number = 0;
|
||||
}
|
||||
|
||||
return number + " " + shorts[pos] + unit;
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.746';
|
||||
$build = '200609';
|
||||
$build = '200611';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.746-200609
|
||||
Version: 7.0NG.746-200611
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.746-200609"
|
||||
pandora_version="7.0NG.746-200611"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.746";
|
||||
my $pandora_build = "200609";
|
||||
my $pandora_build = "200611";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -33,7 +33,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.746";
|
||||
my $pandora_build = "200609";
|
||||
my $pandora_build = "200611";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.746
|
||||
%define release 200609
|
||||
%define release 200611
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.746"
|
||||
PI_BUILD="200609"
|
||||
PI_BUILD="200611"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.746 PS200609";
|
||||
my $version = "7.0NG.746 PS200611";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.746 PS200609";
|
||||
my $version = "7.0NG.746 PS200611";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
Loading…
Reference in New Issue