Hilfe mit shell script für lxc Hilfe

luiluiboy014

Renowned Member
Aug 19, 2015
35
0
71
hallo leute kann mir einer helfen mit shell script haben ein kleines Problem ist lxc hdd abfrage

hier mein problem

Code:
    if [ "$1" = "LXC" ]; then
   Status_VS "$1" "$2" "$3"
   STATUS="$return_status"

       if [ "$return_status" = "RUNNING" ]; then
  
           if [[ "$3" = "uptime" || "$3" = "all" ]]; then
           UPT0=$"`pct exec $2 uptime`"
           UPT1=$( echo "$UPT0" | awk -F"up " '{print $2}' | awk -F"load" '{print $1}' )
           UPT2=$( echo "$UPT1" | sed -e 's/,//g' )
           UPT3=$( echo "$UPT2" | awk -F"  " '{print $1}' )
           UPT4=$( echo "$UPT3" | cut -d" " -f2 )

               if [ "$UPT4" = "min" ]; then
               UPT5=$( echo "$UPT3" | cut -d" " -f1 )
              
                   if [ "$3" != "all" ]; then
                       return_info="0,0,$UPT5,0"
                   else
                       UPTIME="0,0,$UPT5,0"
                   fi
               fi
              
               if [[ "$UPT4" = "day" || "$UPT4" = "days" ]]; then
               UPT5=$( echo "$UPT3" | cut -d" " -f1 )
               UPT6=$( echo "$UPT3" | cut -d" " -f3 )
               UPT7=$( echo "$UPT6" | cut -d":" -f1 )
               UPT8=$( echo "$UPT6" | cut -d":" -f2 )

                   if [ "$3" != "all" ]; then
                       return_info="$UPT5,$UPT7,$UPT8,0"
                   else
                       UPTIME="$UPT5,$UPT7,$UPT8,0"
                   fi

               fi
              
               if [[ "$UPT4" != "min" && "$UPT4" != "day" && "$UPT4" != "days" ]] ; then
               UPT5=$( echo "$UPT3" | cut -d":" -f1 )
               UPT6=$( echo "$UPT3" | cut -d":" -f2 )

                   if [ "$3" != "all" ]; then
                       return_info="0,$UPT5,$UPT6,0"
                   else
                       UPTIME="0,$UPT5,$UPT6,0"
                   fi
               fi
           fi
          
           if [[ "$3" = "ram" || "$3" = "all" ]]; then
           FREE="`pct exec $2 free | head -n 2 | tail -n 1`"
           SIZE=$( echo "$FREE" | awk '{print $2}' )
           USED=$( echo "$FREE" | awk '{print $3}' )
           AVAI=$( echo "$FREE" | awk '{print $4}' )

               if [ "$3" != "all" ]; then
                   return_info="$SIZE,$USED,$AVAI"
               else
                   RAM="$SIZE,$USED,$AVAI"
               fi
           fi
          
           if [[ "$3" = "cpu" || "$3" = "all" ]]; then
               if [ "$3" != "all" ]; then
                   return_info="0"
               else
                   CPU="0"
               fi
           fi
          
           if [[ "$3" = "swap" || "$3" = "all" ]]; then
           FREE="(pct exec $2 free | tail -n 1 | head -1)"
           SIZE=$( echo "$FREE" | awk '{print $2}' )
           USED=$( echo "$FREE" | awk '{print $3}' )
           AVAI=$( echo "$FREE" | awk '{print $4}' )
              
               if [ "$3" != "all" ]; then
                   return_info="$SIZE,$USED,$AVAI"
               else
                   SWAP="$SIZE,$USED,$AVAI"
               fi
           fi
      
           if [[ "$3" = "hdd" || "$3" = "all" ]]; then
           FREE="`pct exec $2 df | grep /dev/loop0`"
           SIZE=$( echo "$FREE" | awk '{print $2}' )
           USED=$( echo "$FREE" | awk '{print $3}' )
           AVAI=$( echo "$FREE" | awk '{print $4}' )
           PERC=$( echo "$FREE" | awk '{print $5}' )

               if [ "$3" != "all" ]; then
               return_info="$SIZE,$USED,$AVAI,$PERC"
               else
                   HDD="$SIZE,$USED,$AVAI,$PERC"
               fi
           fi

           if [ "$3" = "status" ]; then
               return_info="$STATUS"
           fi
          
           if [ "$3" = "all" ]; then
               return_info="$STATUS|$UPTIME|$HDD|$RAM|$SWAP|$CPU"
           fi
          
       else
       return_info="NOK"
       fi
      
   fi


In info line 215:
                        FREE="`pct exec $2 df (%) | grep /dev/loop0`"
                              ^-- SC2006: Use $(..) instead of legacy `..`.
                                        ^-- SC2086: Double quote to prevent glo bbing and word splitting.
hoffe ihr könnt mir da helfen
 
Last edited:
hallo leute kann mir einer helfen mit shell script haben ein kleines Problem ist lxc hdd abfrage

Falls das Problem noch aktuell ist: bitte angeben
- was der script in welcher Situation machen soll
- Beispiel für die darauf bezogene Konfiguration ( /etc/pve/lxc/<cid>.conf etc.)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!