Monday, March 23, 2015

more ghettovcb status fun

so. i'd like to know what's there, what's stale and what's gone missing. and email myself.
 #!/bin/bash  
   
 datestamp=$(date +"%x %r %Z")  
   
 echo "virtual machines $datestamp" > /tmp/vm_report1  
 echo "..........................." >> /tmp/vm_report1  
   
 echo " " > /tmp/vm_report2  
 echo "new virtual machines $datestamp" >> /tmp/vm_report2  
 echo "..............................." >> /tmp/vm_report2  
   
 echo " " > /tmp/vm_report3  
 echo "stale repostitory backups $datestamp" >> /tmp/vm_report3  
 echo ".............................." >> /tmp/vm_report3  
   
 echo " " > /tmp/vm_report4  
 echo "repository backups $datestamp" >> /tmp/vm_report4  
 echo "............................." >> /tmp/vm_report4  
   
 ls /opt/vm-repo/vm_backups > /tmp/vm_header2  
 diff -c <(sort /tmp/vm_header1) <(sort /tmp/vm_header2) | sed '/^!/ d' > /tmp/vm_header3  
   
 find /opt/vm-repo/vm_backups -type d -mtime 0 | sort > /tmp/vm_backup2  
 diff -c <(sort /tmp/vm_backup1) <(sort /tmp/vm_backup2) | sed '/^!/ d' > /tmp/vm_backup3  
   
 cat /tmp/vm_report1 /tmp/vm_header2 /tmp/vm_report2 /tmp/vm_header3 /tmp/vm_report3 /tmp/vm_header3 /tmp/vm_report4 /tmp/vm_backup3 /tmp/vm_backup2 | mail -s "vm_backup status" me@there.com  
   
 mv /tmp/vm_backup2 /tmp/vm_backup1  
 mv /tmp/vm_header2 /tmp/vm_header1  
   
Post a Comment