TrotskyIcepick Posted February 8, 2010 Share Posted February 8, 2010 Hi, I'm not a php programmer so forgive me if this is an easy one. I am using an addon called pnp4nagios to create performance graphs for the Nagios monitoring software. I have downloaded a custom template which will affect the graphs produced for a monitored service and when it is loaded it gives: templates/check_network_load.php [20]: Undefined offset: 1 The php code being loaded is attached. Any advice will be greatly appreciated. Thanks In Advance Andrew [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
alexjb Posted February 8, 2010 Share Posted February 8, 2010 Try changing lines 20 and 22 respectively with: $def[$graphcount] .= "DEF:in_bytes=$rrdfile:" . (($key != null && array_key_exists($key, $DS)) ? $DS[$key] : null) . ":AVERAGE " ; and: $def[$graphcount] .= "DEF:out_bytes=$rrdfile:" . (($nextkey != null && array_key_exists($nextkey, $DS)) ? $DS[$nextkey] : null) . ":AVERAGE " ; Quote Link to comment Share on other sites More sharing options...
TrotskyIcepick Posted February 8, 2010 Author Share Posted February 8, 2010 Thanks Alex for the quick response. Unfortunately I still get the same error. I can't pretend to understand why but it seems to be the code: $def[$graphcount] that is causing the error. Regards Andrew Quote Link to comment Share on other sites More sharing options...
alexjb Posted February 8, 2010 Share Posted February 8, 2010 Oh right, I see the issue. Script seems quite messy, even for a template file. Under: $graphcount=1; Just paste: $def[$graphcount] = ''; Should fix it right up. Quote Link to comment Share on other sites More sharing options...
TrotskyIcepick Posted February 8, 2010 Author Share Posted February 8, 2010 Sorry about this, like I said I'm not a programmer and this is somebody elses code. I tried your last suggestion and now get: Undefined offset: 2. So it would appear to have run through 1 iteration of the script OK and fails on the next increment of graphcount. Thanks Andrew Quote Link to comment Share on other sites More sharing options...
alexjb Posted February 8, 2010 Share Posted February 8, 2010 Before this line, $def[$graphcount] .= "DEF:in_bytes=$rrdfile: Add: if(array_key_exists($graphcount, $def) == false) $def[$graphcount] = null; Sorry, late and tired Quote Link to comment Share on other sites More sharing options...
TrotskyIcepick Posted February 8, 2010 Author Share Posted February 8, 2010 Thanks Alex, that worked a treat (now I'll try reading up on some PHP basics so I know why it works ) Thanks Very Much Andrew Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.