2013-11-03 22:16:01 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Daily  Task  Checks 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  ( c )  2013  LibreNMS  Contributors 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								require  'includes/defaults.inc.php' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require  'config.php' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once  'includes/definitions.inc.php' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require  'includes/functions.php' ;  
						 
					
						
							
								
									
										
										
										
											2013-11-03 22:16:01 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$options  =  getopt ( 'f:' );  
						 
					
						
							
								
									
										
										
										
											2013-11-03 22:16:01 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-25 08:40:42 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'update' )  {  
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $pool_size  =  dbFetchCell ( 'SELECT @@innodb_buffer_pool_size' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // The following query is from the excellent mysqltuner.pl by Major Hayden https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $pool_used  =  dbFetchCell ( 'SELECT SUM(DATA_LENGTH+INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ("information_schema", "performance_schema", "mysql") AND ENGINE = "InnoDB" GROUP BY ENGINE ORDER BY ENGINE ASC' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( $pool_used  >  $pool_size )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! empty ( $config [ 'alert' ][ 'default_mail' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $subject  =  $config [ 'project_name' ]  .  ' auto-update action required' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $message  =  ' 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Hi ,  
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								We  have  just  tried  to  update  your  installation  but  it  looks  like  the  InnoDB  buffer  size  is  too  low .  
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Because  of  this  we  have  stopped  the  auto - update  running  to  ensure  your  system  is  ok .  
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								You  currently  have  a  configured  innodb_buffer_pool_size  of  ' . $pool_size / 1024 / 1024 . '  MiB  but  is  currently  using  ' . $pool_used / 1024 / 1024 . '  MiB  
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Take  a  look  at  https :// dev . mysql . com / doc / refman / 5.6 / en / innodb - buffer - pool . html  for  further  details .  
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The  ' . $config[' project_name '] . '  team . ' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            send_mail ( $config [ 'alert' ][ 'default_mail' ], $subject , $message , $html = false ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'InnoDB Buffersize too small.' . PHP_EOL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'Current size: ' . ( $pool_size  /  1024  /  1024 ) . ' MiB' . PHP_EOL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'Minimum Required: ' . ( $pool_used  /  1024  /  1024 ) . ' MiB' . PHP_EOL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'To ensure integrity, we\'re not going to pull any updates until the buffersize has been adjusted.' . PHP_EOL ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-06 17:48:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            echo  'Config proposal: "innodb_buffer_pool_size = ' . pow ( 2 , ceil ( log (( $pool_used  /  1024  /  1024 ), 2 ))) . 'M"' . PHP_EOL ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        exit ( 2 ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-03 17:13:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        exit (( int )  $config [ 'update' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-29 22:03:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-25 08:40:42 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2013-11-03 22:16:01 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-25 08:40:42 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'syslog' )  {  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( is_numeric ( $config [ 'syslog_purge' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $rows  =  dbFetchRow ( 'SELECT MIN(seq) FROM syslog' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $limit  =  dbFetchRow ( 'SELECT seq FROM syslog WHERE seq >= ? ORDER BY seq LIMIT 1000,1' ,  array ( $rows )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( empty ( $limit ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( dbDelete ( 'syslog' ,  'seq >= ? AND seq < ? AND timestamp < DATE_SUB(NOW(), INTERVAL ? DAY)' ,  array ( $rows ,  $limit ,  $config [ 'syslog_purge' ]))  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $rows  =  $limit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                echo  'Syslog cleared for entries over ' . $config [ 'syslog_purge' ] . "  days 1000 limit \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        dbDelete ( 'syslog' ,  'seq >= ? AND timestamp < DATE_SUB(NOW(), INTERVAL ? DAY)' ,  array ( $rows ,  $config [ 'syslog_purge' ])); 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-18 14:13:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-25 08:40:42 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'eventlog' )  {  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( is_numeric ( $config [ 'eventlog_purge' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( dbDelete ( 'eventlog' ,  'datetime < DATE_SUB(NOW(), INTERVAL ? DAY)' ,  array ( $config [ 'eventlog_purge' ])))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'Eventlog cleared for entries over ' . $config [ 'eventlog_purge' ] . "  days \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-18 14:13:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-25 08:40:42 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'authlog' )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_numeric ( $config [ 'authlog_purge' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( dbDelete ( 'authlog' ,  'datetime < DATE_SUB(NOW(), INTERVAL ? DAY)' ,  array ( $config [ 'authlog_purge' ])))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'Authlog cleared for entries over ' . $config [ 'authlog_purge' ] . "  days \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 01:37:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-11-03 18:25:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'perf_times' )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_numeric ( $config [ 'perf_times_purge' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( dbDelete ( 'perf_times' ,  'start < UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL ? DAY))' ,  array ( $config [ 'perf_times_purge' ])))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'Performance poller times cleared for entries over ' . $config [ 'perf_times_purge' ] . "  days \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-03 18:25:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-06 20:47:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'callback' )  {  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    include_once  'callback.php' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-06 20:47:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-22 21:55:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $options [ 'f' ]  ===  'device_perf' )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_numeric ( $config [ 'device_perf_purge' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( dbDelete ( 'device_perf' ,  'timestamp < UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL ? DAY))' ,  array ( $config [ 'device_perf_purge' ])))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  'Device performance times cleared for entries over ' . $config [ 'device_perf_purge' ] . "  days \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-22 21:55:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}