EDIT: Advanced Ping Template Version 1.3 for Cacti 0.8.6g

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

You need to enable the socket extension in php.ini.

TheWitness
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?
Phobos182
Cacti User
Posts: 65
Joined: Tue Sep 21, 2004 2:22 pm
Location: Madison, WI

Post by Phobos182 »

I get this error when trying to import the template.

Error: XML: Cacti version does not exist.

I've verified that I'm running the current version

mysql> select * from version\G
*************************** 1. row ***************************
cacti: 0.8.6g
1 row in set (0.00 sec)

How do I solve this?
[size=84][color=red] Electronic Frontier Foundation[/color]
[url]http://eff.org[/url][/size]
henryd31
Posts: 30
Joined: Wed Apr 13, 2005 3:11 pm

Post by henryd31 »

TheWitness wrote:If you are running UNIX, the script_server has to have rights to create a RAW socket (aka root or asroot). Otherwise use something like "TCP 80" or something similar. Windows does not care.

TheWitness
I have the same issue, running by hand seems to work, results are properly returned, but the script is not able to generate anything other than loss:100.00

[root@cacti log]# php /data/www/cacti/scripts/ss_fping.php lab1-ewr2 20 ICMP
min:1.3700 avg:1.4370 max:1.5400 dev:0.0524 loss:0.0000

or

[root@cacti log]# php /data/www/cacti/script_server.php
PHP Script Server has Started - Parent is cmd
/data/www/cacti/scripts/ss_fping.php ss_fping lab1-ewr2 20 ICMP
min:1.3300 avg:1.4637 max:2.3200 dev:0.2102 loss:5.0000
quit
PHP Script Server Shutdown request received, exiting

So how do you give the server_script the needed rights ?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

What does your poller_cache look like for those items? Have you logged in as the poller account and tried this?

TheWitness
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?
henryd31
Posts: 30
Joined: Wed Apr 13, 2005 3:11 pm

Post by henryd31 »

TheWitness wrote:What does your poller_cache look like for those items? Have you logged in as the poller account and tried this?

TheWitness
I saw your other post on making the poller run as "root" to be one of the
options here to allow the sockets to be created by the process and once
I did that it started working :-)

Thanks.
linebacker
Posts: 18
Joined: Sun May 15, 2005 6:12 pm

Advanced Ping - PHP socket support

Post by linebacker »

How do I enable socket support without recompiling php? Is that possible? I am trying to get the Advanced Pink v1.3 working and have seen that enabling the socket support needs to be done. I am running Fedora Core 4 and Cacti 0.86g.

Thanks in advance!
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

This is from my /etc/php.ini

Code: Select all

; Default timeout for socket based streams (seconds)
default_socket_timeout = 60
; Default socket name for local MySQL connects.  If empty, uses the built-in
mysql.default_socket =
[Sockets]
sockets.use_system_read = On
Reinhard
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

I would think it would be something like:

extension=php_socket.so

TheWitness

btb: I only run in Windows right now.
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?
havoc1942
Posts: 11
Joined: Tue Oct 26, 2004 11:35 am

Post by havoc1942 »

How do I do this as I am having the Loss 100% issue from the script_server?
TheWitness wrote:If you are running UNIX, the script_server has to have rights to create a RAW socket (aka root or asroot). Otherwise use something like "TCP 80" or something similar. Windows does not care.

TheWitness
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Hello,

I have made some additional speedups as well as support for IPv6 in ping.php. Please keep in mind that you must have PHP 5.x or better.

Also, please note, that I have moved to the dark side (Linux) as of yesterday and saw some nasty things relative to DNS caching. Therefore, I made some additional changes to speed that stuff up.

I think you will like these enhancements.

Regards,

TheWitness
Attachments
ping.zip
(3.18 KiB) Downloaded 2350 times
ss_fping.zip
(1.11 KiB) Downloaded 1890 times
Last edited by TheWitness on Tue Nov 15, 2005 7:07 am, edited 3 times in total.
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?
soundombj
Posts: 5
Joined: Tue Aug 23, 2005 9:40 pm

is it a bug in ping.php

Post by soundombj »

function ping($avail_method = AVAIL_SNMP_AND_PING, $ping_type = ICMP_PING, $timeout=500, $retries=3)

$ping_type = ICMP_PING
should be $ping_type = PING_ICMP


TheWitness wrote:Hello,

I have made some additional speedups as well as support for IPv6 in ping.php. Please keep in mind that you must have PHP 5.x or better.

Also, please note, that I have moved to the dark side (Linux) as of yesterday and saw some nasty things relative to DNS caching. Therefore, I made some additional changes to speed that stuff up.

I think you will like these enhancements.

Regards,

TheWitness
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

:oops:

TheWitness
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?
sll
Posts: 3
Joined: Tue Nov 15, 2005 9:33 am

Post by sll »

Get the following error when I try to import your template:

Notice: Only variable references should be returned by reference in /usr/share/cacti/lib/import.php on line 44

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/cacti/lib/import.php:44) in /usr/share/cacti/templates_import.php on line 67

Ideas?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

What version of php are you running? (4.4 or 5.0.5) What version of Cacti are you running. Best to upgrade to 0.8.6g and apply the patches.

Larry
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?
giulioharding
Posts: 1
Joined: Tue Nov 15, 2005 9:57 pm

Post by giulioharding »

TheWitness wrote:If you are running UNIX, the script_server has to have rights to create a RAW socket (aka root or asroot). Otherwise use something like "TCP 80" or something similar. Windows does not care.

TheWitness

I noticed that a lot of people have had this 'Operation not permitted' problem using ICMP pings on Linux - I've had the same problem, and despite a lot of research, couldn't find any suggestions on how to fix it.

The issue, in my case, is that the gateway I wish to ping, to monitor our internet link, only responds to ICMP pings - there are no TCP/UDP ports open for me to use, so that rules out using those protocols as a work-around. I need ICMP, therefore, cacti needs elevated priveleges somehow.

I don't want to run cacti in it's entirety as root, so in the absence of any other ideas, or knowledge of the cacti script mechanism, or PHP, I hacked up a little modification to the ss_fping.php script, using sudo to give it elevated privileges :)

It's ugly, but it works - in case anyone else might find this handy, here's the summary of the changes I made: (Cacti 0.8.6g, up-to-date Fedora Core 4 install)

1.) Install sudo if you haven't got it already, and add the following lines to /etc/sudoers: (you may need to change 'cacti' to whatever user is running the poller)

# Allow cacti user to run ping script with elevated privileges (so it can send ICMP pings)
cacti ALL=NOPASSWD: /usr/bin/php /var/www/cacti/scripts/ss_fping_exec.php [0-9a-zA-Z]*

2.) Rename ss_fping.php to ss_fping_exec.php

3.) Create a new ss_fping.php with the following code snippet (ripped from ss_fping.php) - change the ''/var/www/cacti/" reference to match the path to your cacti installation.

<?php
#!/usr/bin/php -q

//STANDARD SCRIPT SERVER HEADER!!!
$no_http_headers = true;

/* display No errors */
error_reporting(E_ERROR);

if (!isset($called_by_script_server)) {
array_shift($_SERVER["argv"]);
print call_user_func_array("ss_fping", $_SERVER["argv"]);
}
//End header.

function ss_fping($hostname, $ping_sweeps=6, $ping_type="ICMP", $port=80) {
return exec('sudo /usr/bin/php /var/www/cacti/scripts/ss_fping_exec.php '.$hostname.' '.$ping_sweeps.' '.$ping_type.' '.$port);
}
?>

4.) That's it! (I think :) The ss_fping.php wrapper script should now invoke the real ss_fping script using sudo, without requiring a password, allowing ICMP pings to be sent without running anything else as root.

This isn't ideal, from a security point of view (I haven't looked over the ss_fping script to see if the root privileges could be exploited somehow by passing bogus parameter values), but it works, so I'm happy enough :)

If anyone wants to make any suggestions, or point out some horrid mistake I've made, please do so!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest