Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Jun 29, 2017 5:39 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Availreport
PostPosted: Tue Apr 23, 2013 4:02 pm 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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 7164 times ]
availreport_2.png
availreport_2.png [ 15.54 KiB | Viewed 7164 times ]
availreport_1.png
availreport_1.png [ 11.5 KiB | Viewed 7164 times ]
Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Sun May 12, 2013 8:09 am 
Offline

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


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Sun May 12, 2013 8:27 am 
Offline

Joined: Tue Feb 14, 2012 1:24 am
Posts: 23
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?


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Sun May 12, 2013 11:52 pm 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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.


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 5:16 am 
Offline

Joined: Fri May 17, 2013 4:50 am
Posts: 5
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/availreport.php?hosts_radio=1&host_id=1&data_source_path=%2F1%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/availreport.php?hosts_radio=1&host_id=1&data_source_path=%2F1%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/availreport.php?hosts_radio=1&host_id=1&data_source_path=%2F1%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/cluster_setup.php?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/cluster_setup.php?action=add
Attachment:
availreport-SHM.jpg
availreport-SHM.jpg [ 235.61 KiB | Viewed 7080 times ]

Attachment:
availreport-CM.jpg
availreport-CM.jpg [ 219.03 KiB | Viewed 7080 times ]


Please help me to resolve this issue.

Thanks & Regards


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 12:01 pm 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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.


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 12:22 pm 
Offline

Joined: Fri May 17, 2013 4:50 am
Posts: 5
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;


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 12:50 pm 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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.


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 3:38 pm 
Offline

Joined: Fri May 17, 2013 4:50 am
Posts: 5
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.
Attachment:
cacti-db.jpg
cacti-db.jpg [ 30.06 KiB | Viewed 7064 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/availreport.php?hosts_radio=1&host_id=1&data_source_path=%2F1%2F8.rrd


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 3:46 pm 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 4:19 pm 
Offline

Joined: Fri May 17, 2013 4:50 am
Posts: 5
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.

[[email protected] include]# php -m | grep rrdtool
rrdtool
[[email protected] include]# rpm -q rrdtool
rrdtool-1.4.7-1.el5.rf
[[email protected] include]# rpm -q php-rrdtool
php-rrdtool-1.4.4-1.el5.rf


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 5:11 pm 
Offline

Joined: Fri May 17, 2013 4:50 am
Posts: 5
After restarting httpd service its start working :D
Attachment:
SHM-1.jpg
SHM-1.jpg [ 49.44 KiB | Viewed 7060 times ]

but still showing Error
"Error: Host '127.0.0.1 (NMS)' has no associated Uptime data sources. It is not recommended to proceed."
Attachment:
SHM.jpg
SHM.jpg [ 65.95 KiB | Viewed 7060 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


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Fri May 17, 2013 6:00 pm 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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.


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Sat Aug 31, 2013 1:24 am 
Offline

Joined: Tue Feb 15, 2011 4:51 am
Posts: 35
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


Top
 Profile  
 
 Post subject: Re: Availreport
PostPosted: Mon Sep 02, 2013 9:39 am 
Offline
Cacti User

Joined: Fri Sep 28, 2012 6:52 pm
Posts: 111
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group