Availreport

Announcements concerning Plugins for Cacti

Moderators: Developers, Moderators

victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Availreport

Post by victorantunes »

Hello there,

I've just finished creating a small plugin for Cacti that focuses on device availability history.

Basically, the user chooses one of the device's .rrd files and checks a certain time range for the existence of data. If data exists, the device was up, and vice-versa.

However, the script prioritizes uptime data source-related .rrd files, simply because if you choose a data source related to something that doesn't always produce data, you'd get false positives.

Also, I've inserted a side-tab option called "Cluster Management", so you can add logical clusters that mimic your real clusters, in order to obtain the availability for that as well, based on calculations that take in consideration wether the devices are in series or in parallel.

It's quite simple, really, but I hope it can prove useful to you guys.

Also: the code is quite rudimentary. I'm just a beginner. Feel free to add your own changes to it, as I'd love to see what you experienced devs out there would do to make it better.

Plugin page: http://docs.cacti.net/userplugin:availreport

I'd love to get some feedback on this.

Screenshots:
Attachments
availreport_3.png
availreport_3.png (42.37 KiB) Viewed 11056 times
availreport_2.png
availreport_2.png (15.54 KiB) Viewed 11056 times
availreport_1.png
availreport_1.png (11.5 KiB) Viewed 11056 times
GhostOrchid
Posts: 23
Joined: Tue Feb 14, 2012 1:24 am

Re: Availreport

Post by GhostOrchid »

Installed it right away
Looks great
GhostOrchid
Posts: 23
Joined: Tue Feb 14, 2012 1:24 am

Re: Availreport

Post by GhostOrchid »

Some error in setup.php routine
I corrected it like this
//Cluster management tables
if(!in_array('hostgroup', $tables)){
$sql[] = 'CREATE TABLE hostgroup(
`id` mediumint(8) unsigned NOT NULL auto_increment,
`description` varchar(255) NOT NULL default "",
`type` enum("S", "P", "M") NOT NULL default "M",
PRIMARY KEY (`id`)) ENGINE=MyISAM;
';
}

if(!in_array('hostgroup_host', $tables)){
$sql[] = 'CREATE TABLE hostgroup_host(
`hostgroup_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`host_id` mediumint(8) unsigned NOT NULL default 0,
PRIMARY KEY (`hostgroup_id`, `host_id`)

) ENGINE=MyISAM;
';
}

Is it correct?
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: Availreport

Post by victorantunes »

GhostOrchid wrote:Some error in setup.php routine
I corrected it like this
//Cluster management tables
if(!in_array('hostgroup', $tables)){
$sql[] = 'CREATE TABLE hostgroup(
`id` mediumint(8) unsigned NOT NULL auto_increment,
`description` varchar(255) NOT NULL default "",
`type` enum("S", "P", "M") NOT NULL default "M",
PRIMARY KEY (`id`)) ENGINE=MyISAM;
';
}

if(!in_array('hostgroup_host', $tables)){
$sql[] = 'CREATE TABLE hostgroup_host(
`hostgroup_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`host_id` mediumint(8) unsigned NOT NULL default 0,
PRIMARY KEY (`hostgroup_id`, `host_id`)

) ENGINE=MyISAM;
';
}

Is it correct?
Ah, good catch. Turns out both those cases were mistakes of mine.

The second part you did just right, but the "M" isn't used anywhere important anymore. I'll take it off the setup and the code that uses it.

I'll post a corrected version when I have some proper time. Thanks a ton.
mharisoo7
Posts: 5
Joined: Fri May 17, 2013 4:50 am

Re: Availreport

Post by mharisoo7 »

Hi Guys,

I installed this plugin but unfortunatly its not working for me. I am using cacti 8.7.i, spaine 8.8a and structured rra config. its showing below errors is web server's log file.

[Fri May 17 14:27:38 2013] [error] [client 172.31.6.102] File does not exist: /var/www/html/plugins/availreport/css/images/ui-icons_5fa5e3_256x240.png, referer: http://172.31.0.142/plugins/availreport ... F1%2F8.rrd
[Fri May 17 14:27:40 2013] [error] [client 172.31.6.102] File does not exist: /var/www/html/plugins/availreport/css/images/ui-bg_diagonals-thick_20_e69700_40x40.png, referer: http://172.31.0.142/plugins/availreport ... F1%2F8.rrd
[Fri May 17 14:28:47 2013] [error] [client 172.31.6.102] PHP Fatal error: Call to undefined function rrd_fetch() in /var/www/html/plugins/availreport/availreport_lib.php on line 159, referer: http://172.31.0.142/plugins/availreport ... F1%2F8.rrd
[Fri May 17 14:29:35 2013] [error] [client 172.31.6.102] PHP Notice: Undefined index: cluster_setup.php:save in /var/www/html/lib/functions.php on line 1821, referer: http://172.31.0.142/plugins/availreport ... action=add
[Fri May 17 14:29:35 2013] [error] [client 172.31.6.102] PHP Notice: Undefined index: cluster_setup.php:save in /var/www/html/lib/functions.php on line 1821, referer: http://172.31.0.142/plugins/availreport ... action=add
availreport-SHM.jpg
availreport-SHM.jpg (235.61 KiB) Viewed 10972 times
availreport-CM.jpg
availreport-CM.jpg (219.03 KiB) Viewed 10972 times
Please help me to resolve this issue.

Thanks & Regards
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: Availreport

Post by victorantunes »

Apply those changes suggested by GhostOrchid above and your "save failed" error should disappeear. Let me know if that doesn't work for you;

I should've updated the plugin page with a newer version by now, but I've been quite busy with other things.

Sorry for the delay, I'll apply those changes later today.

I'll have to take a look at the log errors, but I suspect what they might be already.

As for the first error message, that's correct. It's more of a warning message.
Your device doesn't have any data sources associated with either of the Uptime OID's (sysUptime or hrSystemUptime). If you choose to proceed, the output may not be reliable. My opening post kind of tries to explain that.
mharisoo7
Posts: 5
Joined: Fri May 17, 2013 4:50 am

Re: Availreport

Post by mharisoo7 »

I already applied these changes but still facing same issue. please see below FYI.

//Cluster management tables
if(!in_array('hostgroup', $tables)){
$sql[] = 'CREATE TABLE hostgroup(
`id` mediumint(8) unsigned NOT NULL auto_increment,
`description` varchar(255) NOT NULL default "",
`type` enum("S", "P") NOT NULL default "",
PRIMARY KEY (`id`)) ENGINE=MyISAM;
';
}

if(!in_array('hostgroup_host', $tables)){
$sql[] = 'CREATE TABLE hostgroup_host(
`hostgroup_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`host_id` mediumint(8) unsigned NOT NULL default 0,
PRIMARY KEY (`hostgroup_id`, `host_id`)
) ENGINE=MyISAM;
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: Availreport

Post by victorantunes »

Please run both those CREATE commands manually (just copy and paste them inside MySQL console) and let me know.

The tables appear to not have been created for some reason.

EDIT: I've uploaded a fixed version that hopefully will solve the database setup issues.
mharisoo7
Posts: 5
Joined: Fri May 17, 2013 4:50 am

Re: Availreport

Post by mharisoo7 »

I tried to run both commands into mysql console but its show below errors.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(8) unsignedNOT NULL default "",
t(8) unsignedNOT NULL default ""
GINE=MyISAM' at line 2

Also I check cacti DB structure and its showing both tables are created.
cacti-db.jpg
cacti-db.jpg (30.06 KiB) Viewed 10956 times
Also after with new version I am able to create clustor as well as can add devices into it but when I tried to run it, it show below error.

[Sat May 18 01:24:03 2013] [error] [client 172.31.6.110] PHP Fatal error: Call to undefined function rrd_fetch() in /var/www/html/plugins/availreport/availreport_lib.php on line 159, referer: http://172.31.0.142/plugins/availreport ... F1%2F8.rrd
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: Availreport

Post by victorantunes »

I see. You're missing the PHP bindings for RRDtool.

On the plugin page there are links to download and instructions to install the prerequisites, as available on the official RRDtool website: http://docs.cacti.net/userplugin:availr ... requisites
mharisoo7
Posts: 5
Joined: Fri May 17, 2013 4:50 am

Re: Availreport

Post by mharisoo7 »

I already installed "php-rrdtool-1.4.4-1.el5.rf.i386.rpm", still do I need to install "php_rrdtool.tar.gz"? also see below.

[root@localhost include]# php -m | grep rrdtool
rrdtool
[root@localhost include]# rpm -q rrdtool
rrdtool-1.4.7-1.el5.rf
[root@localhost include]# rpm -q php-rrdtool
php-rrdtool-1.4.4-1.el5.rf
mharisoo7
Posts: 5
Joined: Fri May 17, 2013 4:50 am

Re: Availreport

Post by mharisoo7 »

After restarting httpd service its start working :D
SHM-1.jpg
SHM-1.jpg (49.44 KiB) Viewed 10952 times
but still showing Error
"Error: Host '127.0.0.1 (NMS)' has no associated Uptime data sources. It is not recommended to proceed."
SHM.jpg
SHM.jpg (65.95 KiB) Viewed 10952 times
Also I think something is missing like export results in CSV OR PDF file :D PLz...

Thank you very much for very useful plugin which is missing for very long time.

Best Regards
Haris
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: Availreport

Post by victorantunes »

Ha, thanks. Glad you like it.

I'll change that message to display "Warning" instead of "Error", because that's what it is.
You see, that message appears because your haven't added to your device any graphs that contemplate its Uptime. By that, I mean the OID's referring to hrSystemUptime or sysUptime.

The reason for that warning is because this plugin revolves around reading user-specified .rrd files in search of the EXISTENCE of data. It's a pretty basic logic: if data exists, the device was up at that time. If it's a NaN or inf, the device was down.

Perhaps I should've made it clear before, but I've chosen to focus primarily on those two OID's because they're always producing values as long as the device is available. The same cannot be said for something like network traffic or disk space usage. Maybe I'm in the wrong here, but that's the way it made sense to me.

So, whenever this message appears, you should do better at choosing a data source related to something that never stops producing data whenever the device is up. Things like network traffic, dropped packets, etc, aren't very reliable in that regard.

Hope it helps.

Also, I'll be sure to keep in mind to produce reports in PDF or something in that sense in the (maybe near) future.

Thanks for the feedback.
surajitpal2007
Posts: 35
Joined: Tue Feb 15, 2011 4:51 am

Re: Availreport

Post by surajitpal2007 »

victorantunes wrote:I see. You're missing the PHP bindings for RRDtool.

On the plugin page there are links to download and instructions to install the prerequisites, as available on the official RRDtool website: http://docs.cacti.net/userplugin:availr ... requisites
Hi victorantunes,

I am also facing same problem. But I have installed same in windows. How I can overcome from this problem or how I can configure PHP binding for RRDtool in windows. Official page only suggests for linux.. :(

Pl suggest. Thanks a ton in advance.
-Jit
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: Availreport

Post by victorantunes »

I'm sorry, but I don't have a lot of experience with PHP on Windows, and only have experience with Cacti on Linux.

Wish I could help, but I wouldn't know how to solve your problem.

Perhaps someone else here might help him?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests