Following on from an attempt to generate XML reports via direct URL Emilio advised I take a look at the API. Attached is a rough and ready version of this that emails report output to clients and Pandora FMS admin users. This version is specifically for total data usage (OctetsIn and OctetsOut) but can be easily modified. // A set of API related functions that generates emails summarising total data used by an agent: // Daily - send email at 6:30AM with data used in last 24 hours for each agent Monthly - send email at 6:30AM on the first of the month with data used in last 30 days for each agent Hourly - check a data limit (e.g. 200MB) has not been breached. Send email if it has. //Prerequisites: A network agent monitoring SNMP inbound and outbound data You must create at least one custom report for the network agent Each report can only have two line items (OctetsIn and OctetsOut) The period the report covers is not important as we change this below The report must be assigned to a group with at least one email contact sendmail() must be correctly configured on your server Name the file "functions_mailreports.php", store it in the "include" directory of the pandora_console, "chown" the file to a suitable user (e.g. apache) and add the following lines to "/include/functions_api.php" : include_once($config['homedir'] . "/include/functions_mailreports.php"); include_once($config['homedir'] . "/include/functions_reporting.php"); You will need to set the From email address in "api_get_mailreport" and "api_get_adminmail" You will need to set the To address in "api_get_adminmail" //Usage: Create crontab entries for a suitable user as follows - 00 * * * * curl -o temp.txt "http://127.0.0.1/pandora\_console/include/api.php?apipass=&user=&pass=&op=get&op2=mailreport&id2=hourly" 30 06 * * * curl -o temp.txt "http://127.0.0.1/pandora\_console/include/api.php?apipass=&user=&pass=&op=get&op2=mailreport&id2=daily" 30 06 1 * * curl -o temp.txt "http://127.0.0.1/pandora\_console/include/api.php?apipass=&user=&pass=&op=get&op2=mailreport&id2=monthly" 00 * * * * curl -o temp.txt "http://127.0.0.1/pandora\_console/include/api.php?apipass=&user=&pass=&op=get&op2=adminmail&id2=hourly" 30 06 * * * curl -o temp.txt "http://127.0.0.1/pandora\_console/include/api.php?apipass=&user=&pass=&op=get&op2=adminmail&id2=daily" 30 06 1 * * curl -o temp.txt "http://127.0.0.1/pandora\_console/include/api.php?apipass=&user=&pass=&op=get&op2=adminmail&id2=monthly" // Reports for anything other than total data usage are not supported in this version. These functions are provided as is and without warranty. They work for me as of version 6.0 and do only as much as I need. YMMV. If you improve upon this code (which won't be difficult) then share the love back to the community. :)
Inicio del debate
