| 
									
										
										
										
											2016-07-29 13:23:20 +02:00
										 |  |  | #!/usr/bin/env bash | 
					
						
							| 
									
										
										
										
											2016-07-21 22:28:41 -05:00
										 |  |  | ############################################################# | 
					
						
							|  |  |  | # - put this file on the nfs server somewhere like /opt/    # | 
					
						
							|  |  |  | # - edit your snmpd.conf and add line                       # | 
					
						
							|  |  |  | #  extend nfsstat /opt/nfsstats.sh                          # | 
					
						
							|  |  |  | # - restart snmpd                                           # | 
					
						
							|  |  |  | # - make sure that you have all the binaries required below # | 
					
						
							|  |  |  | ############################################################# | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CFG_NFSVER='3' | 
					
						
							|  |  |  | BIN_NFSSTAT='/usr/sbin/nfsstat' | 
					
						
							|  |  |  | BIN_TR='/usr/bin/tr' | 
					
						
							|  |  |  | BIN_CUT='/usr/bin/cut' | 
					
						
							|  |  |  | BIN_GREP='/usr/bin/grep' | 
					
						
							|  |  |  | BIN_PASTE='/usr/bin/paste' | 
					
						
							|  |  |  | BIN_RM='/usr/bin/rm' | 
					
						
							|  |  |  | BIN_MV='/usr/bin/mv' | 
					
						
							| 
									
										
										
										
											2019-08-08 21:18:06 -05:00
										 |  |  | LOG_OLD='/var/cache/librenms/nfsstats_old' | 
					
						
							|  |  |  | LOG_NEW='/var/cache/librenms/nfsstats_new' | 
					
						
							| 
									
										
										
										
											2016-07-21 22:28:41 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | $BIN_NFSSTAT -$CFG_NFSVER -n -l | $BIN_TR -s " " | $BIN_CUT -d ' ' -f 5 | $BIN_GREP -v '^$' > $LOG_NEW 2>&1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $BIN_PASTE $LOG_NEW $LOG_OLD | while read a b ; do | 
					
						
							|  |  |  |   echo $(($a - $b))   | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $BIN_RM $LOG_OLD 2>&1 | 
					
						
							|  |  |  | $BIN_MV $LOG_NEW $LOG_OLD 2>&1 |