- Custom Ansible roles can be stored in the `roles/custom` directory - The list `custom_roles` determines which roles are included
		
			
				
	
	
		
			33 lines
		
	
	
	
		
			906 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			906 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/usr/bin/bash
 | 
						|
#
 | 
						|
# Send stdout of some commands to monitoring server.
 | 
						|
# Collect the reports with 'nc -u -k -l 1234' on 'sendto'.
 | 
						|
# Use /bin/nc.openbsd, /bin/nc.traditional seems not to work.
 | 
						|
#
 | 
						|
set -eu
 | 
						|
 | 
						|
sendto="collector.steinbeis.schule 1234"
 | 
						|
n=0
 | 
						|
 | 
						|
cmds=(
 | 
						|
    'uname -a'
 | 
						|
    'tail -1 /var/local/ansible-stamps'
 | 
						|
    'ip route list default'
 | 
						|
    'ip link show | \
 | 
						|
       sed -nE -e "s/^[2-9]: (\S+): .+/\1/p" -e "s/.+ether ([0-9a-f:]+) .+/\1/p" | \
 | 
						|
       paste - -'
 | 
						|
)
 | 
						|
#    'w'
 | 
						|
#    'uptime'
 | 
						|
#    'ls -d --full-time /home/ansible/.ansible/tmp/'
 | 
						|
#    'ip addr show'
 | 
						|
#    'apt list --upgradeable -o Apt::Cmd::Disable-Script-Warning=true'
 | 
						|
 | 
						|
r="$HOSTNAME ------- $(date --rfc-3339=seconds) -------
 | 
						|
$(for c in "${cmds[@]}" ; do
 | 
						|
      n=$(( n + 1 ))
 | 
						|
      echo -n "$n"
 | 
						|
      eval "$c" | sed 's/^/\t/'
 | 
						|
done | sed "s/^/$HOSTNAME /")
 | 
						|
## -------------------------------------------------"
 | 
						|
echo "$r" | nc -w 1 -u $sendto
 |