Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8832111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:27:28+00:00 2026-06-14T08:27:28+00:00

unable to make modifications to fit into my enviroment, this is the check_disc function,

  • 0

unable to make modifications to fit into my enviroment, this is the check_disc function, but not working correctly in my enviroment where disc is attached through /dev/mapper/ so i have
for exmaple /dev/mapper/debian-var instead of /var.

Function from BASH script:

function check_disks {

    THOLD=$1;
    DISK_ERROR="";

    # df -kl is the most portable options for df 

    MOUNTS=`df -lk | grep -v devfs | grep -v none | grep -v Filesystem | awk '{print $6}'`;
    for MOUNT in $MOUNTS; do
        PERCENT=`df -kl $MOUNT | grep -v Filesystem | awk '{print $5}' | sed 's/\%//'`;
        if [ $PERCENT -gt $THOLD ]; then
            DISK_ERROR="$DISK_ERROR    Volume '$MOUNT' is at $PERCENT% usage.\n";
        fi
    done
    if [ -n "$DISK_ERROR" ]; then
        echo -en "ERROR: The following volumes have exceeded the allowable threshold of $THOLD% usage.\n$DISK_ERROR";
        return 1;
    else
        return 0;
    fi

}

Output of df -kl cmd:

df -kl
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/debian-root
                       1919048    493616   1327948  28% /
tmpfs                 18717148        12  18717136   1% /lib/init/rw
udev                     10240       784      9456   8% /dev
tmpfs                 18717148         0  18717148   0% /dev/shm
/dev/cciss/c0d0p1       241116     23679    204989  11% /boot
/dev/mapper/debian-home
                       3842104   2681264    965668  74% /home
/dev/mapper/debian-tmp
                       4805760    366228   4195412   9% /tmp
/dev/mapper/debian-usr
                       3842104   1816200   1830732  50% /usr
/dev/mapper/debian-var
                     377857560 183429768 175233732  52% /var

This line should be changed i guess:

MOUNTS=`df -lk | grep -v devfs | grep -v none | grep -v Filesystem | awk '{print $6}'`;

But not sure how. Anyone can give me a hand?
Thx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:27:29+00:00Added an answer on June 14, 2026 at 8:27 am

    There is a portability option on df that keeps the output in one line per volume :

       -P, --portability
              use the POSIX output format
    

    I think changing

    MOUNTS=`df -lk | grep -v devfs | grep -v none | grep -v Filesystem | awk '{print $6}'`
    

    to

    MOUNTS=`df -lkP | grep -v devfs | grep -v none | grep -v Filesystem | awk '{print $6}'`
    

    would help.

    FYI, here is an example of the output difference :

    $ df -lk | grep -B1 /var
    /dev/mapper/rootvg-var
                       4062912   1900724   1952476  50% /var
    $ df -lkP | grep /var
    /dev/mapper/rootvg-var   4062912   1900748   1952452      50% /var
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has probably been asked before, but I'm unable to make my way through
I'm trying to make a floating joystick for my android game but am unable
I'm struggling to make Glassfish 3.1.1 to log to syslog, but I'm unable to.
I often have to go into other people's work to make modifications for short-term
I've been unable to make this work because of what I believe is a
Hi I am trying to experiment with gcm but unable to make it work.
I am trying to use robocopy but am unable to make it work because
I browsed all SO questions and answers about this topic but I'm still unable
I'm unable to execute the following prepared statement , PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
Im unable to start new project in a virtualenv. This is what i did

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.