Skip to content

System Administration: 4. CPU.sh. Error: integer expected #76

Description

@nikhil00shinde

Hey @ruanyf ,

I was running the CPU.sh
script, but the USE variable is getting a floating-point value instead of an integer. Because of this, the script does not enter the if block even when USE is greater than MAX.

Suggestion:

USE=$(grep 'cpu' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "" }' | awk -F. '{print $1}')

Output:

./CPU.sh
./CPU.sh: line 7: [: 11.6836: integer expected

Should I create PR for this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions