[HOWTO] Availability Reporting

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Re: [HOWTO] Availability Reporting

Post by TFC »

U right. i forgot the " .
Now ok
Thnx
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Re: [HOWTO] Availability Reporting

Post by TFC »

MajorWoody wrote:First off, thanks for this script it works great!

A few enhancements I would love to see:

1. A static html page of the report on the Cacti website.
2. The duration and times of failed polls. So you could see that it was down twice on Tuesday, one time it was down for an hour the other time is was down for 30 minutes.
3. A link to that nodes graph in the e-mail.

I don't know if these are impossible requests or not (I am not much of a programmer) but I think these would greatly enhance there ability.


Thanks again for this awesome script,
Major
another idea is:
Maybe create report group by group. For example my cacti server is for 4 diff. company. And if i can define those company's devices and create report and send mail .. it will be perfect :)
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Re: [HOWTO] Availability Reporting

Post by TFC »

MajorWoody wrote:First off, thanks for this script it works great!

A few enhancements I would love to see:

1. A static html page of the report on the Cacti website.
2. The duration and times of failed polls. So you could see that it was down twice on Tuesday, one time it was down for an hour the other time is was down for 30 minutes.
3. A link to that nodes graph in the e-mail.

I don't know if these are impossible requests or not (I am not much of a programmer) but I think these would greatly enhance there ability.


Thanks again for this awesome script,
Major
another idea is:
Maybe create report group by group. For example my cacti server is for 4 diff. company. And if i can define those company's devices and create report and send mail .. it will be perfect :)
surajitpal2007
Posts: 35
Joined: Tue Feb 15, 2011 4:51 am

Re: [HOWTO] Availability Reporting

Post by surajitpal2007 »

Yes.........I have reached in my target....... Oshm..... :P
Attachments
Cacti_Availability_Screenshot.jpg
Cacti_Availability_Screenshot.jpg (149.82 KiB) Viewed 8478 times
Last edited by surajitpal2007 on Mon Aug 12, 2013 5:03 am, edited 3 times in total.
User avatar
TheWitness
Developer
Posts: 16897
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: [HOWTO] Availability Reporting

Post by TheWitness »

surajitpal2007 wrote:Can any one please say me, how I can add this .php / any .php into my cacti as I am running cacti in windows 2003
Personally, I would use Linux. Trust me, for web hosting, there's nothing better on the planet. So, that would be the first thing that I would have you do. Don't mess with Windows unless you use BSOD's Installer.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Re: [HOWTO] Availability Reporting

Post by TFC »

If u wanna have PAM (php,Apache,Mysql) platform ,Uniz and Linuz are the best.
asecure
Posts: 4
Joined: Mon Nov 09, 2009 4:22 am

Re: [HOWTO] Availability Reporting

Post by asecure »

Hi All,

Appreciate some help on the matter. Have no php whatsoever. The email comes in fine but only shows the headers without hosts
When running the script form cli, i get back the below-mentioned error message.

Code: Select all

Warning: Invalid argument supplied for foreach() in /var/www/cacti/scripts/availabilityReport.php on line 323
The line in question is.
foreach ($today as $device => $todayStat) {
Searching on the web tell me that this has something to do with php expecting an array but the variables being passed isn't seen as one.

The whole function is as per below.

Code: Select all

function yesterdaysAvailability() 
{
	global $tmpDir, $dailyRecipients, $daily, $yesterdayFile, $weeklyStats;
	
	$today = getReportDetails();
	readStats($yesterdayFile,$yesterday);
	foreach ($today as $device => $todayStat) {
		if (isset($yesterday[$device])) {
			// Make sure yesterday's counters are lower than todays before subtracting one from the other
			if ($yesterday[$device]['total_polls'] < $today[$device]['total_polls']) {
				$avail[$device]['total_polls'] = $today[$device]['total_polls'] - $yesterday[$device]['total_polls'];
				$avail[$device]['failed_polls'] = $today[$device]['failed_polls'] - $yesterday[$device]['failed_polls'];
			} else {
				// Perhaps this device was deleted and added back to Cacti with the same name.  In any case, just use the total polls read today
				$avail[$device]['total_polls'] = $today[$device]['total_polls'];
				$avail[$device]['failed_polls'] = $today[$device]['failed_polls'];
			}
			$avail[$device]['availability'] = number_format(($avail[$device]['total_polls'] - $avail[$device]['failed_polls']) / $avail[$device]['total_polls'] * 100,5,'.','');
		} else {
			$avail[$device] = $today[$device];
		}
	}
	
	$weeklyStats[(date("N")-1)] = $avail;

	// Only write out data if this is the first time running today
	
	natsort2d($avail,'availability');
	
	$extTitle = '';
	
	if ($daily['topX'] > 0) {
		$extTitle .= "Daily Top {$daily['topX']} Worst Availability<br>";
		$count = 0;
		foreach ($avail as $device => $stat) {
			$count++;
			$tmp[$device] = $stat;
			if ($count == $daily['topX']) {
				break;
			}
		}
		if (isset($tmp)) {
			$avail = $tmp;
		} else {
			$avail = array();
		}
	}
	
	if ($daily['availPercent'] > 0) {
		$extTitle .= "Devices with Availability Less Than {$daily['availPercent']}%<br>";
		foreach ($avail as $device => $stat) {
			if ($stat['availability'] > $daily['availPercent']) {
				break;
			}
			$tmp[$device] = $stat;
		}
		if (isset($tmp)) {
			$avail = $tmp;
		} else {
			$avail = array();
		}
	}
	
	if (file_exists($tmpDir . $yesterdayFile)) {
		$extTitle .= "Report Duration: " .  date("F j, Y, g:i a",filemtime($tmpDir . $yesterdayFile)) . 
	    	        " - " . date("F j, Y, g:i a") . "<br>";
	}

	if (!(file_exists($tmpDir . $yesterdayFile)) or (date("d", filemtime($tmpDir . $yesterdayFile)) != date("d"))) {
		writeData($yesterdayFile,$today);
	}
	
	emailReport($avail,$dailyRecipients,"Daily Availability Report",$extTitle);
	
}
Cacti Version - 0.8.7e
Plugin Architecture - 2.5
Poller Type - Cactid v
Server Info - Linux 2.6.28-19-server
Web Server - Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.6 with Suhosin-Patch
PHP - 5.2.6-3ubuntu4.6
PHP Extensions - zip, xmlwriter, libxml, xml, wddx, tokenizer, sysvshm, sysvsem, sysvmsg, session, SimpleXML, sockets, soap, SPL, shmop, standard, Reflection, posix, mime_magic, mbstring, json, iconv, hash, gettext, ftp, filter, exif, dom, dba, date, ctype, calendar, bz2, bcmath, zlib, pcre, openssl, xmlreader, apache2handler, ldap, mysql, mysqli, PDO, pdo_mysql
MySQL - 5.0.75-0ubuntu10.5
RRDTool - 1.3.1
SNMP - 5.4.1
Plugins
  • Host Info (hostinfo - v0.2)
    Global Plugin Settings (settings - v0.5)
    Send Graphs via EMail (nectar - v0.26)
    Thresholds (thold - v0.4.1)
    QuickTree (quicktree - v0.2)
    Device Monitoring (monitor - v0.8.2)
sergiop11
Posts: 3
Joined: Wed Sep 12, 2012 1:22 pm

Re: [HOWTO] Availability Reporting

Post by sergiop11 »

english
as I do to install reports help please,
now if I generate the graphs, what I want is to generate reports'm somewhat new to this I would ask you to please explain so I understand thanks good afternoon


español

como le hago para instalar reportes ayuda por favor,
actualmente si me generar la gráficas, lo quiero es que genere reportes soy un tanto nuevo en esto les pediría de favor que me expliquen de manera que entienda gracias buenas tardes
sergiop11
Posts: 3
Joined: Wed Sep 12, 2012 1:22 pm

Re: [HOWTO] Availability Reporting

Post by sergiop11 »

como hago para instalar informes ayudan por favor,
ahora si puedo generar los gráficos, lo que quiero es generar reports'm algo nuevo en esto me gustaría pedirle que explique lo que entiendo gracias buenas tardes español Como Le Hago párr Instalar Reportes Ayuda please, actualmente si me Generar la Gráficas, lo quiero de es Que genere Reportes soy un Tanto en Nuevo ESTO les pediría de favor Que me expliquen de Manera Que entienda gracias buenas tardes
panvin
Posts: 3
Joined: Tue Aug 13, 2013 11:59 pm

Re: [HOWTO] Availability Reporting

Post by panvin »

hi, thanks a lot for this feature!!!

is it possible to insert in email "Notes" row from host table?
monkeydedragon
Posts: 9
Joined: Fri Mar 06, 2015 10:36 am

Re: [HOWTO] Availability Reporting

Post by monkeydedragon »

try use this script for my cacti but not working is there any log or something i can trace.
cacti 0.8.8c
suse linux

need advice.
mrossTTX
Cacti User
Posts: 114
Joined: Wed Dec 07, 2022 12:49 pm

Re: [HOWTO] Availability Reporting

Post by mrossTTX »

I just took at look at this one and updated it. it works via a command line now.. i fixed it so it will run on windows and uses updated mysql commands.. i dont know , or if, i can include this directly in cacti's interface to call it or schedule it.. but it works.
Attachments
availabilityReport.zip
(9.25 KiB) Downloaded 28 times
ziiisqo
Posts: 1
Joined: Wed Jun 21, 2023 3:46 am

Re: [HOWTO] Availability Reporting

Post by ziiisqo »

what should i do with smtp_class.php?
keep getting error S 530 5.7.0 Must issue a STARTTLS command first.

really need help here :(
User avatar
TheWitness
Developer
Posts: 16897
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: [HOWTO] Availability Reporting

Post by TheWitness »

The author should have used the php_mailer class in Cacti. The error message is indicating that you mail provider is using SSL connections. So, the mail client must be SSL compatible.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests