Skip to main content
Code Review

Return to Answer

fix typing mistake "Youa re" → "You are", update Markdown syntax for headings [preview wants a space character after hash], fix typos
Source Link

There are a number of concerns I have here, some of them style related, but mostly about the actual functionality.... ...

##mounts

mounts

/var and /home may not necessarily be actual mount points. You should first check to see whether it is a mount point before testing it. This is because it may inaccurately reflect the / space if it is not actually a mount.

Additionally, it is (remotely) possible that, even if it is normally a mount point, that the partition may be unmounted too, but that's a remote problem.

The program /bin/mountpoint is a useful one for identifying whether a folder is in fact a mountpoint. It returns a useful exit code (0 if it is).

/bin/mountpoint -q / && echo YES

I would also possibly recommend that you just check all mounted filesystems. Something like this will do you well:

# Get mounts that come from non-kernel "magic" places.
grep -e '^/' /proc/mounts | cut -d' ' -f2

##/boot

/boot

Additionally, I highly recommend that you test the /boot folder. More than any other folder, this one has been a problem for me personally.

/boot is used for your kernel images, and it is relatively common to apply system updates, and then forget to remove old images. The /boot folder is quite small, and often can have less than 10 kernel images.... ... This has resulted in a few problems for me. Add /boot to your 'default' list of partitions to check. It will remind you to remove old and unused kernel versions, and prevent failed updates.

##Why shell? Got Perl?

Why shell? Got Perl?

df -h | perl -ne 'chomp; $line = $_; $_ =~ s/.*?\s+(\S+)\%.*/1ドル/; next unless $_ eq "Use" or $_ > 80; print "$line\n";'

For me that outputs:

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/mediavg-medialv 1.8T 1.7T 17G 100% /multimedia
/dev/mapper/snapvg-snaplv 2.7T 2.4T 349G 88% /snapshotng

(Filesystems with > 80% usage).

Youa reYou are aware that the df command will go a long way to solving the whole thing for youryou, right?

##grep/awk/sed

grep/awk/sed

df ${MOUNT} | grep / | awk '{ print 5ドル}' | sed 's/%//g'

This is a complicated line. I'mI’m pretty sure you can get awk to do the whole thing for you... ...

There are a number of concerns I have here, some of them style related, but mostly about the actual functionality....

##mounts

/var and /home may not necessarily be actual mount points. You should first check to see whether it is a mount point before testing it. This is because it may inaccurately reflect the / space if it is not actually a mount.

Additionally, it is (remotely) possible that, even if it is normally a mount point, that the partition may be unmounted too, but that's a remote problem.

The program /bin/mountpoint is a useful one for identifying whether a folder is in fact a mountpoint. It returns a useful exit code (0 if it is).

/bin/mountpoint -q / && echo YES

I would also possibly recommend that you just check all mounted filesystems. Something like this will do you well:

# Get mounts that come from non-kernel "magic" places.
grep -e '^/' /proc/mounts | cut -d' ' -f2

##/boot

Additionally, I highly recommend that you test the /boot folder. More than any other folder, this one has been a problem for me personally.

/boot is used for your kernel images, and it is relatively common to apply system updates, and then forget to remove old images. The /boot folder is quite small, and often can have less than 10 kernel images.... This has resulted in a few problems for me. Add /boot to your 'default' list of partitions to check. It will remind you to remove old and unused kernel versions, and prevent failed updates.

##Why shell? Got Perl?

df -h | perl -ne 'chomp; $line = $_; $_ =~ s/.*?\s+(\S+)\%.*/1ドル/; next unless $_ eq "Use" or $_ > 80; print "$line\n";'

For me that outputs:

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/mediavg-medialv 1.8T 1.7T 17G 100% /multimedia
/dev/mapper/snapvg-snaplv 2.7T 2.4T 349G 88% /snapshotng

(Filesystems with > 80% usage).

Youa re aware that the df command will go a long way to solving the whole thing for your, right?

##grep/awk/sed

df ${MOUNT} | grep / | awk '{ print 5ドル}' | sed 's/%//g'

This is a complicated line. I'm pretty sure you can get awk to do the whole thing for you...

There are a number of concerns I have here, some of them style related, but mostly about the actual functionality ...

mounts

/var and /home may not necessarily be actual mount points. You should first check to see whether it is a mount point before testing it. This is because it may inaccurately reflect the / space if it is not actually a mount.

Additionally, it is (remotely) possible that, even if it is normally a mount point, that the partition may be unmounted too, but that's a remote problem.

The program /bin/mountpoint is a useful one for identifying whether a folder is in fact a mountpoint. It returns a useful exit code (0 if it is).

/bin/mountpoint -q / && echo YES

I would also possibly recommend that you just check all mounted filesystems. Something like this will do you well:

# Get mounts that come from non-kernel "magic" places.
grep -e '^/' /proc/mounts | cut -d' ' -f2

/boot

Additionally, I highly recommend that you test the /boot folder. More than any other folder, this one has been a problem for me personally.

/boot is used for your kernel images, and it is relatively common to apply system updates, and then forget to remove old images. The /boot folder is quite small, and often can have less than 10 kernel images ... This has resulted in a few problems for me. Add /boot to your 'default' list of partitions to check. It will remind you to remove old and unused kernel versions, and prevent failed updates.

Why shell? Got Perl?

df -h | perl -ne 'chomp; $line = $_; $_ =~ s/.*?\s+(\S+)\%.*/1ドル/; next unless $_ eq "Use" or $_ > 80; print "$line\n";'

For me that outputs:

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/mediavg-medialv 1.8T 1.7T 17G 100% /multimedia
/dev/mapper/snapvg-snaplv 2.7T 2.4T 349G 88% /snapshotng

(Filesystems with > 80% usage).

You are aware that the df command will go a long way to solving the whole thing for you, right?

grep/awk/sed

df ${MOUNT} | grep / | awk '{ print 5ドル}' | sed 's/%//g'

This is a complicated line. I’m pretty sure you can get awk to do the whole thing for you ...

Source Link
rolfl
  • 98.1k
  • 17
  • 219
  • 419

There are a number of concerns I have here, some of them style related, but mostly about the actual functionality....

##mounts

/var and /home may not necessarily be actual mount points. You should first check to see whether it is a mount point before testing it. This is because it may inaccurately reflect the / space if it is not actually a mount.

Additionally, it is (remotely) possible that, even if it is normally a mount point, that the partition may be unmounted too, but that's a remote problem.

The program /bin/mountpoint is a useful one for identifying whether a folder is in fact a mountpoint. It returns a useful exit code (0 if it is).

/bin/mountpoint -q / && echo YES

I would also possibly recommend that you just check all mounted filesystems. Something like this will do you well:

# Get mounts that come from non-kernel "magic" places.
grep -e '^/' /proc/mounts | cut -d' ' -f2

##/boot

Additionally, I highly recommend that you test the /boot folder. More than any other folder, this one has been a problem for me personally.

/boot is used for your kernel images, and it is relatively common to apply system updates, and then forget to remove old images. The /boot folder is quite small, and often can have less than 10 kernel images.... This has resulted in a few problems for me. Add /boot to your 'default' list of partitions to check. It will remind you to remove old and unused kernel versions, and prevent failed updates.

##Why shell? Got Perl?

df -h | perl -ne 'chomp; $line = $_; $_ =~ s/.*?\s+(\S+)\%.*/1ドル/; next unless $_ eq "Use" or $_ > 80; print "$line\n";'

For me that outputs:

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/mediavg-medialv 1.8T 1.7T 17G 100% /multimedia
/dev/mapper/snapvg-snaplv 2.7T 2.4T 349G 88% /snapshotng

(Filesystems with > 80% usage).

Youa re aware that the df command will go a long way to solving the whole thing for your, right?

##grep/awk/sed

df ${MOUNT} | grep / | awk '{ print 5ドル}' | sed 's/%//g'

This is a complicated line. I'm pretty sure you can get awk to do the whole thing for you...

lang-bash

AltStyle によって変換されたページ (->オリジナル) /