Passing script errors to Cacti log
Moderators: Developers, Moderators
Passing script errors to Cacti log
I'm working on a PHP script that fetches a https status page of proxy servers (unfortunately they don't carry OIDs to get this data) and parses it to extract some data to graph.
I was wondering if the error trapping routines I built in can send encountered errors (such as custom error messages) to the Cacti log.
On that topic, is it wise to built in thight error trapping for scripts used by Cacti?
And what is best practice to avoid errors such as 'ERROR: Empty result' when a script fails to complete?
When and how is a NaN created using scripts.
Please be aware that I'm not provicient at PHP coding.
Examples and other methods of parsing https page are welcome
I was wondering if the error trapping routines I built in can send encountered errors (such as custom error messages) to the Cacti log.
On that topic, is it wise to built in thight error trapping for scripts used by Cacti?
And what is best practice to avoid errors such as 'ERROR: Empty result' when a script fails to complete?
When and how is a NaN created using scripts.
Please be aware that I'm not provicient at PHP coding.
Examples and other methods of parsing https page are welcome
Sorry I asked
Is there no one that can answer this?
This is my third post without an answer. I thought this was a lively and helpfull community?
And yes, I have tried googling for an answer, but there is way too much info to wade through. Someone should trash all posts older than 1 year. Posts by the way that often have broken links to documentation.
If it is a stupid question, just tell me, but these "WARNING: Result from CMD not valid. Partial Result: U " warnings realy drive me crazy.
I encouter these in php and perl scripts.
What do I do to pass on 'empty/null/no data/U' to rrdtool without getting those warnings?
So please assist.
This is my third post without an answer. I thought this was a lively and helpfull community?
And yes, I have tried googling for an answer, but there is way too much info to wade through. Someone should trash all posts older than 1 year. Posts by the way that often have broken links to documentation.
If it is a stupid question, just tell me, but these "WARNING: Result from CMD not valid. Partial Result: U " warnings realy drive me crazy.
I encouter these in php and perl scripts.
What do I do to pass on 'empty/null/no data/U' to rrdtool without getting those warnings?
So please assist.
Support is hit and miss, depending how much time the mods feel like devoting. For some reason, very few forum members have risen to the occasion to provide additional support for others...
As for the script, I'd either have it return the full text error message (in hopes that whatever poller in use will return all/part of it to the cacti log) or just "NaN" if it failed to work. I seem to recall only the recent versions of cacti can handle NaN text too.
Bottom line, there is no clear cut documentation how scripts should handle/return errors.
As for the script, I'd either have it return the full text error message (in hopes that whatever poller in use will return all/part of it to the cacti log) or just "NaN" if it failed to work. I seem to recall only the recent versions of cacti can handle NaN text too.
Bottom line, there is no clear cut documentation how scripts should handle/return errors.
| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
OK. Thanks for the clarification. Didn't realize that only mods responded and then of course they have a hard time keeping up with answering the load of posts.
As for the script, I tried returning 'U' as I saw that in a ping script, but that doesn't seem to prevent the error message.
Will try NaN as return.
As for the script, I tried returning 'U' as I saw that in a ping script, but that doesn't seem to prevent the error message.
Will try NaN as return.
Change the cacti logging level to debug and then watch for your script to run during a polling cycle. paste the relevant results
| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
Below data from the log set to DEBUG, once if data is returned properly (polled device is up) and once if 'NaN' should be returned (polled device -solar power convertor BTW- is not providing data).
++++++++++++++++++++ Success
++++++++++++++++++++ FAILURE
Why would would the line:
be chopped when failing, and not when succeeding?
I don't see anything suspicious in the script (attached)... I think.
++++++++++++++++++++ Success
Code: Select all
03/31/2010 06:25:05 PM - SYSTEM STATS: Time:3.2247 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:27 RRDsProcessed:11
03/31/2010 06:25:05 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /var/www/html/cacti/rra/solar_logger_day_co2_144.rrd --template total_co2:day_co2:total_energy:day_energy:pac 1270052704:240167.168:3873.664:453145.6:7308.8:130
03/31/2010 06:25:05 PM - POLLER: Poller[0] Parsed MULTI output field 'pac:130' [map pac->pac]
03/31/2010 06:25:05 PM - POLLER: Poller[0] Parsed MULTI output field 'day_energy:7308.8' [map day_energy->day_energy]
03/31/2010 06:25:05 PM - POLLER: Poller[0] Parsed MULTI output field 'total_energy:453145.6' [map total_energy->total_energy]
03/31/2010 06:25:05 PM - POLLER: Poller[0] Parsed MULTI output field 'day_co2:3873.664' [map day_co2->day_co2]
03/31/2010 06:25:05 PM - POLLER: Poller[0] Parsed MULTI output field 'total_co2:240167.168' [map total_co2->total_co2]
03/31/2010 06:25:04 PM - CMDPHP: Poller[0] Time: 2.0610 s, Theads: N/A, Hosts: 3
03/31/2010 06:25:04 PM - PHPSVR: Poller[0] DEBUG: PHP Script Server Shutdown request received, exiting
03/31/2010 06:25:04 PM - CMDPHP: Poller[0] Host[17] Description[Solar Logger] DS[144] Graphs['Fronius weblogger - Power','Fronius weblogger - Total Energy','Fronius weblogger - Total CO2'] CMD: perl /var/www/html/cacti/scripts/fronius.pl 192.168.0.120 0.9136, output: total_co2:240167.168 day_co2:3873.664 total_energy:453145.6 day_energy:7308.8 pac:130
03/31/2010 06:25:04 PM - CMDPHP: Poller[0] Host[17] Description[Solar Logger] PING: ICMP Ping Success (0.375 ms)
03/31/2010 06:25:02 PM - CMDPHP: Poller[0] PHP Script Server Started Properly
03/31/2010 06:25:02 PM - PHPSVR: Poller[0] PHP Script Server has Started - Parent is cmd
03/31/2010 06:25:02 PM - PHPSVR: Poller[0] DEBUG: FILENM: /var/www/html/cacti/script_server.php
03/31/2010 06:25:02 PM - PHPSVR: Poller[0] DEBUG: DIRNAM: /var/www/html/cacti
03/31/2010 06:25:02 PM - PHPSVR: Poller[0] DEBUG: GETCWD: /home/koen
03/31/2010 06:25:02 PM - PHPSVR: Poller[0] DEBUG: SERVER: cmd
03/31/2010 06:25:02 PM - POLLER: Poller[0] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q "/var/www/html/cacti/cmd.php" 0 17]
03/31/2010 06:25:02 PM - POLLER: Poller[0] NOTE: Poller Int: '300', Cron Int: '300', Time Since Last: '300', Max Runtime '298', Poller Runs: '1'
++++++++++++++++++++ FAILURE
Code: Select all
03/31/2010 09:50:03 PM - POLLER: Poller[0] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q /var/www/html/cacti/plugins/rrdclean/rrdmove.php]
03/31/2010 09:50:03 PM - SYSTEM THOLD STATS: Time:0.0232 Tholds:1 Hosts:0
03/31/2010 09:50:03 PM - SYSTEM STATS: Time:2.1982 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:27 RRDsProcessed:10
03/31/2010 09:50:03 PM - CMDPHP: Poller[0] Time: 1.8123 s, Theads: N/A, Hosts: 3
03/31/2010 09:50:03 PM - PHPSVR: Poller[0] DEBUG: PHP Script Server Shutdown request received, exiting
03/31/2010 09:50:03 PM - CMDPHP: Poller[0] Host[17] Description[Solar Logger] DS[144] Graphs['Fronius weblogger - Power','Fronius weblogger - Total Energy','Fronius weblogger - Total CO2'] CMD: perl /var/www/html/cacti/scripts/fronius.pl 192.168.0.120 0.9136, output: total_co2:NaN day_co2
03/31/2010 09:50:03 PM - CMDPHP: Poller[0] Host[17] Description[Solar Logger] DS[144] Graphs['Fronius weblogger - Power','Fronius weblogger - Total Energy','Fronius weblogger - Total CO2'] WARNING: Result from CMD not valid. Partial Result: total_co2:NaN day_co
03/31/2010 09:50:03 PM - CMDPHP: Poller[0] Host[17] Description[Solar Logger] PING: ICMP Ping Success (0.884 ms)
03/31/2010 09:50:02 PM - CMDPHP: Poller[0] PHP Script Server Started Properly
03/31/2010 09:50:02 PM - PHPSVR: Poller[0] PHP Script Server has Started - Parent is cmd
03/31/2010 09:50:02 PM - PHPSVR: Poller[0] DEBUG: FILENM: /var/www/html/cacti/script_server.php
03/31/2010 09:50:02 PM - PHPSVR: Poller[0] DEBUG: DIRNAM: /var/www/html/cacti
03/31/2010 09:50:02 PM - PHPSVR: Poller[0] DEBUG: GETCWD: /home/koen
03/31/2010 09:50:02 PM - PHPSVR: Poller[0] DEBUG: SERVER: cmd
03/31/2010 09:50:01 PM - POLLER: Poller[0] DEBUG: About to Spawn a Remote Process [CMD: /usr/bin/php, ARGS: -q "/var/www/html/cacti/cmd.php" 0 17]
03/31/2010 09:50:01 PM - POLLER: Poller[0] WARNING: Poller Output Table not Empty. Issues Found: 1, Data Sources: (DS[144] Graphs['Fronius weblogger - Power','Fronius weblogger - Total Energy','Fronius weblogger - Total CO2'])
03/31/2010 09:50:01 PM - POLLER: Poller[0] NOTE: Poller Int: '300', Cron Int: '300', Time Since Last: '300', Max Runtime '298', Poller Runs: '1'
Code: Select all
perl /var/www/html/cacti/scripts/fronius.pl 192.168.0.120 0.9136, output: total_co2:NaN day_co2
I don't see anything suspicious in the script (attached)... I think.
- Attachments
-
- fronius.pl
- (1005 Bytes) Downloaded 81 times
I believe this is just the way the code is written... to only output a few characters of an error message a script might be throwing.drh wrote:Why would would the line:Code: Select all
perl /var/www/html/cacti/scripts/fronius.pl 192.168.0.120 0.9136, output: total_co2:NaN day_co2
I was pretty sure the NaN thing would work, since one of my older scripts that gandalf improved upon and added NaN when there was no valid data. It was a php script server script though, so that might be the key...
| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
Who is online
Users browsing this forum: No registered users and 3 guests