Coleta de Informações de crescimento de utilização de file system

Publicado por Hertz Raya Zocolan Silva (última atualização em 06/07/2018)

[ Hits: 2.364 ]

Download coleta_disco.sh




Coleta de informações utilizando comando df para dados de crescimento de file system.

Informações coletadas:

File System (cria um arquivo para cada file system existente)
Data
Hora
Tamanho
Utilizado (MB)
Disponivel (MB)
Porcentagem Utilizado

Formato do arquivo de saída: CSV com (;) separando os campos

  



Esconder código-fonte

#!/bin/bash
#
# Script : /usr/local/scripts/coleta_disco.sh
# Feito  : Hertz S. ( 11/04/2016 )
# Obs    : Script para coleta de informacoes de utilizacao
#          de espaco em disco
#

#exec 1>/dev/null
#exec 2>&1

# 
# Rotina de Inclusao de Variaveis Globais -------------------------------------
#

     PROCESS="COLETA_DSK"
PROCESS_NAME="Coleta de Informacoes de Utilizacao de Espaco em Disco"

export PATH=$PATH:/usr/bin
SERVER="`hostname`"
IP_LOCAL="`/sbin/ifconfig | grep \"cast\" | head -1 | awk '{print $2}' | cut -d\: -f2,2`"
DT_FULL="`date +%d/%m/%Y`"
  DT_DT="`date +%d%m%Y`"
DT_HORA="`date +%H:%M:%S`"
  DT_HR="`date +%H%M%S`"
 DT_MES="`date +%m_%Y`"
 DT_ano="`date +%Y`"
 DT_mes="`date +%m`"
 DT_DIA="`date +%a`"

if [ "${DT_DIA}" = "Sun" ] ; then DT_DIA="Domingo" ; fi
if [ "${DT_DIA}" = "Mon" ] ; then DT_DIA="Segunda" ; fi
if [ "${DT_DIA}" = "Tue" ] ; then DT_DIA="Terca"   ; fi
if [ "${DT_DIA}" = "Wed" ] ; then DT_DIA="Quarta"  ; fi
if [ "${DT_DIA}" = "Thu" ] ; then DT_DIA="Quinta"  ; fi
if [ "${DT_DIA}" = "Fri" ] ; then DT_DIA="Sexta"   ; fi
if [ "${DT_DIA}" = "Sat" ] ; then DT_DIA="Sabado"  ; fi

if [ "${DT_mes}" = "01" ] ; then DT_MES_NAME="Janeiro"   ; fi
if [ "${DT_mes}" = "02" ] ; then DT_MES_NAME="Fevereiro" ; fi
if [ "${DT_mes}" = "03" ] ; then DT_MES_NAME="Marco"     ; fi
if [ "${DT_mes}" = "04" ] ; then DT_MES_NAME="Abril"     ; fi
if [ "${DT_mes}" = "05" ] ; then DT_MES_NAME="Maio"      ; fi
if [ "${DT_mes}" = "06" ] ; then DT_MES_NAME="Junho"     ; fi
if [ "${DT_mes}" = "07" ] ; then DT_MES_NAME="Julho"     ; fi
if [ "${DT_mes}" = "08" ] ; then DT_MES_NAME="Agosto"    ; fi
if [ "${DT_mes}" = "09" ] ; then DT_MES_NAME="Setembro"  ; fi
if [ "${DT_mes}" = "10" ] ; then DT_MES_NAME="Outubro"   ; fi
if [ "${DT_mes}" = "11" ] ; then DT_MES_NAME="Novembro"  ; fi
if [ "${DT_mes}" = "12" ] ; then DT_MES_NAME="Dezembro"  ; fi

# Declaracao de Variaveis -----------------------------------------------------

DIRCOL="/usr/local/coleta_`hostname`/disco/${DT_MES}"
mkdir -p ${DIRCOL}

#
# Inicio do Script ------------------------------------------------------------
#

df -m  | grep -v Mounted | grep -v shm | grep -v media | grep -v Uso | awk '{print $6}' | \
while read fs
do

df -m "$fs" | grep -v Mounted | grep -v Uso > /tmp/tmp.$$

  DEV="`cat /tmp/tmp.$$ | awk '{print $1}'`"
 SIZE="`cat /tmp/tmp.$$ | awk '{print $2}'`"
   FS="`cat /tmp/tmp.$$ | awk '{print $6}'`"
 USED="`cat /tmp/tmp.$$ | awk '{print $3}'`"
 AVAI="`cat /tmp/tmp.$$ | awk '{print $4}'`"
 PUSE="`cat /tmp/tmp.$$ | awk '{print $5}'`"
FStxt="`echo \"$FS\" | sed 's:\/:_:g'`"
FSTXT="${DIRCOL}/${FStxt}.txt"

if [ -f "${FSTXT}" ]
then
   echo $FSTXT existe > /dev/null
   echo "${DT_FULL};${DT_HORA};${SIZE};${USED};${AVAI};${PUSE}" >> ${FSTXT}
else
   echo $FSTXT nao > /dev/null
   echo "[ ${SERVER} ${IP_LOCAL} ] - ${DT_MES_NAME} de ${DT_ano}" > ${FSTXT}
   echo "File System : ${FS} - ${DEV}" >> ${FSTXT}
   echo "" >> ${FSTXT}
   echo "Data;Hora;Tamanho;Utilizado (MB);Disponivel (MB);Porcentagem Utilizado" >> ${FSTXT}
   echo "${DT_FULL};${DT_HORA};${SIZE};${USED};${AVAI};${PUSE}" >> ${FSTXT}
fi

unset FSTXT
unset FStxt

rm /tmp/tmp.$$

done

#
# Final  do Script ------------------------------------------------------------
#

Scripts recomendados

e17 Uptade

Script simples de backup de arquivos em máquina remota

Uebevert - All in One [version 3]

Speedy

Convertendo rmvb para avi


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts