| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-05 09:33:32 +10:00
										 |  |  | // FIXME: This really does produce valuable data for the project team.  We
 | 
					
						
							|  |  |  | // need to get some infrastructure going and make it available on an opt-in
 | 
					
						
							|  |  |  | // basis (i.e. disabled by default).  We should schedule it from cron rather
 | 
					
						
							|  |  |  | // than putting it into the discovery process.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // See https://github.com/librenms/librenms/issues/25 for some thoughts on where to go with this code under git.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:24:34 +00:00
										 |  |  | // Generate some statistics to send along with the version request.
 | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-12 14:15:20 +00:00
										 |  |  | $stats['ports']        = dbFetchCell("SELECT count(*) FROM ports"); | 
					
						
							|  |  |  | $stats['devices']      = dbFetchCell("SELECT count(*) FROM devices"); | 
					
						
							|  |  |  | $stats['sensors']      = dbFetchCell("SELECT count(*) FROM sensors"); | 
					
						
							|  |  |  | $stats['services']     = dbFetchCell("SELECT count(*) FROM services"); | 
					
						
							|  |  |  | $stats['applications'] = dbFetchCell("SELECT count(*) FROM applications"); | 
					
						
							|  |  |  | $stats['bgp']          = dbFetchCell("SELECT count(*) FROM bgpPeers"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 20:04:35 +00:00
										 |  |  | foreach (dbFetch("SELECT COUNT(*) AS count,os from devices group by `os`") as $dt_data) | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-30 17:28:09 +00:00
										 |  |  |   $stats['devicetypes'][$dt_data['os']] = $dt_data['count']; | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-30 17:28:09 +00:00
										 |  |  | $stat_serial = base64_encode(serialize($stats)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-29 21:06:32 +10:00
										 |  |  | #$url = "http://www.observium.org/latest.php?i=".$stats['ports']."&d=".$stats['devices']."&stats=".$stat_serial."&v=".$config['version'];
 | 
					
						
							| 
									
										
										
										
											2013-10-28 22:01:43 -07:00
										 |  |  | #$dataHandle = fopen($url, r);
 | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 20:04:35 +00:00
										 |  |  | if ($dataHandle) | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-29 20:04:35 +00:00
										 |  |  |   while (!feof($dataHandle)) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     $data.= fread($dataHandle, 4096); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if ($data) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     list($omnipotence, $year, $month, $revision) = explode(".", $data); | 
					
						
							|  |  |  |     list($cur, $tag) = explode("-", $config['version']); | 
					
						
							|  |  |  |     list($cur_omnipotence, $cur_year, $cur_month, $cur_revision) = explode(".", $cur); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ($argv[1] == "--cron" || isset($options['q'])) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       $fd = fopen($config['log_file'],'a'); | 
					
						
							|  |  |  |       fputs($fd,$string . "\n"); | 
					
						
							|  |  |  |       fclose($fd); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       shell_exec("echo $omnipotence.$year.$month.$month > ".$config['rrd_dir']."/version.txt "); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       if ($cur != $data) | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2012-05-02 15:04:31 +00:00
										 |  |  |         echo("Current Revision : $cur_revision\n"); | 
					
						
							| 
									
										
										
										
											2012-04-29 20:04:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-02 22:02:30 +00:00
										 |  |  |         if ($omnipotence > $cur_revision) | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2012-05-02 15:04:31 +00:00
										 |  |  |           echo("New Revision   : $omnipotence\n"); | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-05-02 15:04:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #        if ($omnipotence > $cur_omnipotence)
 | 
					
						
							|  |  |  | #        {
 | 
					
						
							|  |  |  | #          echo("New version     : $omnipotence.$year.$month.$revision\n");
 | 
					
						
							|  |  |  | #        } elseif ($year > $cur_year) {
 | 
					
						
							|  |  |  | #          echo("New version     : $omnipotence.$year.$month.$revision\n");
 | 
					
						
							|  |  |  | #        } elseif ($month > $cur_month) {
 | 
					
						
							|  |  |  | #          echo("New version     : $omnipotence.$year.$month.$revision\n");
 | 
					
						
							|  |  |  | #        } elseif ($revision > $cur_revision) {
 | 
					
						
							|  |  |  | #          echo("New release     : $omnipotence.$year.$month.$revision\n");
 | 
					
						
							|  |  |  | #        }
 | 
					
						
							| 
									
										
										
										
											2012-04-29 20:04:35 +00:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fclose($dataHandle); | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2013-11-05 09:33:32 +10:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2011-05-05 14:59:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ?>
 |