netcarver Posted May 27, 2014 Author Posted May 27, 2014 Yes, there's no reason why other modules can't publish appropriate diagnostics via the collection hook.
apeisa Posted May 27, 2014 Posted May 27, 2014 This looks great. Steve: modules need to be named with certain convention or either be autoload to be able to extend this? 1
netcarver Posted May 27, 2014 Author Posted May 27, 2014 @soma Thanks for the catch. Actually, that was me being a bit too liberal with copy-and-paste and remember this was only a proof-of-concept 2 days ago I'll redefine the Diagnostic providers so they all 'extend Wire implement Module' rather than having them be process modules. Having said that, I'll keep Nico's module extending 'Process' as it needs the js and css loading provided by the Process::init() method that I don't want to have to duplicate. I don't think any other diagnostic provider needs this special treatment. @apeisa Yes, there is a naming convention for the diagnostic provider modules. I'll update the opening post and add it to the repo's readme file soon but it goes like this... Firstly: Have your module hook the ProcessDiagnostics::collectDiagnostics() method so it can inject its diagnoses into the results array. Then either: Make your module an autoload module and call it whatever you need to call it. Don't make your module autoload but the name must start with "Diagnose" in order for ProcessDiagnostics to load it when it is initialised. Here's the code from the new "DiagnoseExample" provider module that makes it about as simple as it can... <?php /** * Hooks into ProcessDiagnostics to add additional example information. */ class DiagnoseExample extends Wire implements Module { public static function getModuleInfo() { return array( 'title' => __('Example Diagnostics Provider', __FILE__), 'summary' => __('Demonstrates how to write a simple diagnostics provider module', __FILE__), 'version' => 1, 'permanent' => false, 'autoload' => false, 'singular' => true, 'requires' => 'ProcessDiagnostics', 'installs' => 'ProcessDiagnostics', 'author' => 'Stephen Dickinson, QBox', ); } public function init() { $this->addHookAfter('ProcessDiagnostics::collectDiagnostics', $this, 'AppendDiagnostics'); } /** * Collects Diagnostics. */ public function GetDiagnostics() { $results[] = array( 'title' => $this->_('Thing diagnosed'), 'value' => $this->_('Bad value!'), 'status' => ProcessDiagnostics::$fail, // other valid values are ::$warn and ::$ok. 'action' => $this->_('Describe how to correct the bad value.'), ); return $results; } public function AppendDiagnostics($event) { $results = $event->return; $results[$this->_('Example Diagnostics')] = $this->GetDiagnostics(); $event->return = $results; } } Obviously, it takes the 2nd route I mentioned above (doesn't autoload.) Let me know if you need any more information. 1
Manfred62 Posted May 27, 2014 Posted May 27, 2014 Help translating this suite to other languages is always welcome. for german done... see this thread. 2
horst Posted May 28, 2014 Posted May 28, 2014 @steve: with the new version 0.2.0 I get an fatal error becuase of a missing method in ProcessDiagnostic. The missing function is this (from @adrian): /** * returns if function is disabled in php * * @return boolean: true, false */ static protected function isDisabled($function) { $disabled_functions = explode(',' , str_replace(' ', '', strtolower(ini_get('disable_functions')))); return in_array(strtolower($function), $disabled_functions); } @steve & @Nico: I have a question with the modules module: I don't want it to query all versions every time I call the diagnostics page. So, yes, I can uninstall it and only install it on demand. But would it not be better if this module has a button that I can press to execute the query and an option that lets select a time period (e.g. 1 week) that let run it via lazy cron at least once in the given time period? 1
Nico Knoll Posted May 28, 2014 Posted May 28, 2014 Well I included a cache at first - but then forgot to reimplement it after using ajax. It wouldn't be that hard for my to reimplement it but would be nice to know if this module is going to be alive in the future or will be eaten by Soma's module (because Soma already use caching)
horst Posted May 28, 2014 Posted May 28, 2014 (edited) @Nico: I can't follow in full, but simply stay to what I have said before: I don't want it to query all versions every time I call the diagnostics page! So, yes, I can uninstall it and only install it on demand. But would it not be better if this module has a button that I can press to execute the query and an option that lets select a time period (e.g. 1 week) that let run it via lazy cron at least once in the given time period? PS: Well, I remember a day back (or two), you have said it would be really useful to have this, regardless of the existence of somas modules. And well, others have agreed with you. So, now we want to have a functional module. That's all. Edited May 28, 2014 by horst 1
netcarver Posted May 28, 2014 Author Posted May 28, 2014 @horst Sorry about that. Just added it to ProcessDiagnostics. Can you let me know if this version fixes it for you? Hmm, well, I messed up something on my server - looks like Apache2 is serving php files as plain text now 1
netcarver Posted May 28, 2014 Author Posted May 28, 2014 Hmm, well, I messed up something on my server - looks like Apache2 is serving php files as plain text now Note to self: Never, I said never, accidentily delete the first line ("<?php") of PW's index.php file and save it! Punishment: On next trip to post office collect, fill out and submit form id10t. In triplicate. 5
netcarver Posted May 28, 2014 Author Posted May 28, 2014 Just pushed up some improvements to the DiagnoseDatabase module. It now takes more time poking around with character sets, collations and table information. Here's a couple of screenshots... Hope these might eventually help someone out. 5
Nico Knoll Posted May 28, 2014 Posted May 28, 2014 I added caching to DiagnoseModules. (see Pull-Request) 2
horst Posted May 28, 2014 Posted May 28, 2014 (edited) Uups, have copied the latest version over my previous installed one, where a file of Diagnose Modules exists but is not installed! After login, when trying to go to the Modules-Tab of the Backend, I get this: Fatal error: Can't use method return value in write context in DOC_ROOT\site\modules\ProcessDiagnostics\DiagnoseModules.module on line 102 Makes my Modules Backend unusable (PW 2.4.2) - Haven't investigated further. @Nico: Do you need more infos? ----------- DiagnoseDatabase module works fine! I have some of these Warnings: 'Repair table to reclaim space.' What's about a Button that lets the user directly execute an optimize / repair? $query = 'OPTIMIZE NO_WRITE_TO_BINLOG TABLE ' . implode(', ', $tableNames); Edited May 28, 2014 by horst 1
netcarver Posted May 28, 2014 Author Posted May 28, 2014 @horst You read my mind. I'm out until tomorrow evening but that happens to be next on my to-do-list for DiagnoseDatabase. @Martijn Thank you! It's really nice to have input from Nico, horst and Manfred62. Hope it is useful to folks! 2
netcarver Posted June 5, 2014 Author Posted June 5, 2014 @horst Just pushed a new version of ProcessDiagnostics and DiagnoseDatabase that should now allow you to optimize any table that has overhead. The new code allows any Diagnose module to provide custom actions via a hook. Here's how I've done it for optimizing tables but there might be a better way. Please let me know if this works for you. 6
horst Posted June 5, 2014 Posted June 5, 2014 @Steve: works perfect! Have optimized 10 tables successfully. - Maybe one optionally can have one button invoking optimize for all tables at once, instead of doing it repeatedly one by one? - And I have encountered a table that was created as InnoDB and not MyISAM. It shows Overhead 23MB, is this correct? This one get not optimized by clicking the link.
netcarver Posted June 5, 2014 Author Posted June 5, 2014 @horst, What version of MySQL is that on? I was under the impression that optimizing an InnoDB table reclaimed space and re-built the index.
netcarver Posted June 5, 2014 Author Posted June 5, 2014 If you use phpmyadmin and do an optimize on the table, does it reduce the overhead to zero?
horst Posted June 5, 2014 Posted June 5, 2014 I have no phpmyadmin installed, I used another tool and it first said: Table does not support optimize, doing recreate + analyze instead. than it said: status ok. But when I come back to the DiagnoseModule it is unchanged. Does phpmyadmin display info for overhead? Should I install it?
netcarver Posted June 5, 2014 Author Posted June 5, 2014 @horst, It (phpmyadmin) does display overhead but I wouldn't bother installing it if you don't have it. The message you got from the tool is the correct one for InnoDB tables so that's OK. 1
Manfred62 Posted June 8, 2014 Posted June 8, 2014 tested latest version: the optimizing is nice and function well. for better translation use new line for the second string and better place the blank after the closing a (see code) 136: $warnings[] = '<a href="?owner='.__CLASS__.'&action=optimize&table='.$t_Name.'">'.$this->_('Optimize').'</a> ' . 137: $this->_('table to reclaim space and reorganize indexes.'); 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now