| 
									
										
										
										
											2011-09-30 00:19:48 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:24:34 +00:00
										 |  |  | // Polls ntpd-server statistics from script via SNMP
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; | 
					
						
							|  |  |  | $options      = '-O qv'; | 
					
						
							|  |  |  | $oid          = 'nsExtendOutputFull.10.110.116.112.100.115.101.114.118.101.114'; | 
					
						
							| 
									
										
										
										
											2015-11-11 20:37:51 +01:00
										 |  |  | $mib          = 'NET-SNMP-EXTEND-MIB'; | 
					
						
							| 
									
										
										
										
											2011-09-30 00:19:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-11 20:37:51 +01:00
										 |  |  | $ntpdserver = snmp_get($device, $oid, $options, $mib); | 
					
						
							| 
									
										
										
										
											2011-09-30 00:19:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | echo ' ntpd-server'; | 
					
						
							| 
									
										
										
										
											2011-09-30 00:19:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | list ($stratum, $offset, $frequency, $jitter, $noise, $stability, $uptime, | 
					
						
							|  |  |  |     $buffer_recv, $buffer_free, $buffer_used, $packets_drop, $packets_ignore, | 
					
						
							|  |  |  |     $packets_recv, $packets_sent) = explode("\n", $ntpdserver); | 
					
						
							| 
									
										
										
										
											2011-09-30 00:19:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if (!is_file($rrd_filename)) { | 
					
						
							|  |  |  |     rrdtool_create( | 
					
						
							|  |  |  |         $rrd_filename, | 
					
						
							| 
									
										
										
										
											2015-09-28 08:24:57 +00:00
										 |  |  |         '--step 300  | 
					
						
							|  |  |  |         DS:stratum:GAUGE:600:-1000:1000  | 
					
						
							|  |  |  |         DS:offset:GAUGE:600:-1000:1000  | 
					
						
							|  |  |  |         DS:frequency:GAUGE:600:-1000:1000  | 
					
						
							|  |  |  |         DS:jitter:GAUGE:600:-1000:1000  | 
					
						
							|  |  |  |         DS:noise:GAUGE:600:-1000:1000  | 
					
						
							|  |  |  |         DS:stability:GAUGE:600:-1000:1000  | 
					
						
							|  |  |  |         DS:uptime:GAUGE:600:0:125000000000  | 
					
						
							|  |  |  |         DS:buffer_recv:GAUGE:600:0:100000  | 
					
						
							|  |  |  |         DS:buffer_free:GAUGE:600:0:100000  | 
					
						
							|  |  |  |         DS:buffer_used:GAUGE:600:0:100000  | 
					
						
							|  |  |  |         DS:packets_drop:DERIVE:600:0:125000000000  | 
					
						
							|  |  |  |         DS:packets_ignore:DERIVE:600:0:125000000000  | 
					
						
							|  |  |  |         DS:packets_recv:DERIVE:600:0:125000000000  | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |         DS:packets_sent:DERIVE:600:0:125000000000 '.$config['rrd_rra'] | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2011-09-30 00:19:48 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-18 16:26:55 +00:00
										 |  |  | $fields = array( | 
					
						
							|  |  |  |     'stratum'        => $stratum, | 
					
						
							|  |  |  |     'offset'         => $offset, | 
					
						
							|  |  |  |     'frequency'      => $frequency, | 
					
						
							|  |  |  |     'jitter'         => $jitter, | 
					
						
							|  |  |  |     'noise'          => $noise, | 
					
						
							|  |  |  |     'stability'      => $stability, | 
					
						
							|  |  |  |     'uptime'         => $uptime, | 
					
						
							|  |  |  |     'buffer_recv'    => $buffer_recv, | 
					
						
							|  |  |  |     'buffer_free'    => $buffer_free, | 
					
						
							|  |  |  |     'buffer_used'    => $buffer_used, | 
					
						
							|  |  |  |     'packets_drop'   => $packets_drop, | 
					
						
							|  |  |  |     'packets_ignore' => $packets_ignore, | 
					
						
							|  |  |  |     'packets_recv'   => $packets_recv, | 
					
						
							|  |  |  |     'packets_sent'   => $packets_sent, | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | rrdtool_update($rrd_filename, $fields); | 
					
						
							| 
									
										
										
										
											2015-08-19 20:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $tags = array('name' => 'ntpdserver', 'app_id' => $app['app_id']); | 
					
						
							|  |  |  | influx_update($device,'app',$tags,$fields); |