mirror of
				https://github.com/DerTyp7/.dotfiles.git
				synced 2025-10-30 13:37:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			508 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			508 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| mount="/"
 | |
| warning=20
 | |
| critical=10
 | |
| 
 | |
| df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical '
 | |
| /\/.*/ {
 | |
|   text=$4
 | |
|   tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6
 | |
|   use=$5
 | |
|   exit 0
 | |
| }
 | |
| END {
 | |
|   class=""
 | |
|   gsub(/%$/,"",use)
 | |
|   if ((100 - use) < critical) {
 | |
|     class="critical"
 | |
|   } else if ((100 - use) < warning) {
 | |
|     class="warning"
 | |
|   }
 | |
|   print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}"
 | |
| }
 | |
| '
 |