Simplify checks for empty or non-empty strings

This commit is contained in:
Lars Kruse 2020-02-08 04:44:39 +01:00
parent 5190244c92
commit 94a695860d
3 changed files with 32 additions and 32 deletions

View file

@ -45,7 +45,7 @@ config_cpu() {
echo "idle.max 5000" echo "idle.max 5000"
echo "idle.type DERIVE" echo "idle.type DERIVE"
echo "idle.info Idle CPU time" echo "idle.info Idle CPU time"
if [ ! -z "$extinfo" ]; then if [ -n "$extinfo" ]; then
echo "iowait.label iowait" echo "iowait.label iowait"
echo "iowait.draw STACK" echo "iowait.draw STACK"
echo "iowait.min 0" echo "iowait.min 0"

View file

@ -9,7 +9,7 @@ graph_category system"
do do
IDL=$(echo "$IINFO" | grep "^$ID:") IDL=$(echo "$IINFO" | grep "^$ID:")
INFO=$(eval "echo \"$IDL\" | cut -d ' ' -f '$((3 + CPUS))-'") INFO=$(eval "echo \"$IDL\" | cut -d ' ' -f '$((3 + CPUS))-'")
if [ "$INFO" = "" ]; then if [ -z "$INFO" ]; then
echo "i$ID.label $ID" echo "i$ID.label $ID"
else else
echo "i$ID.label $INFO" echo "i$ID.label $INFO"

View file

@ -18,10 +18,10 @@ config_memory() {
INACTCLEAN=$(echo "$MINFO" | grep "^Inact_clean:" | cut -d\ -f2) INACTCLEAN=$(echo "$MINFO" | grep "^Inact_clean:" | cut -d\ -f2)
GRAPH_ORDER="apps"; GRAPH_ORDER="apps";
test "$PAGETABLES" != "" && GRAPH_ORDER="$GRAPH_ORDER page_tables" [ -n "$PAGETABLES" ] && GRAPH_ORDER="$GRAPH_ORDER page_tables"
test "$SWAPCACHED" != "" && GRAPH_ORDER="$GRAPH_ORDER swap_cache" [ -n "$SWAPCACHED" ] && GRAPH_ORDER="$GRAPH_ORDER swap_cache"
test "$VMALLOCUSED" != "" && GRAPH_ORDER="$GRAPH_ORDER vmalloc_used" [ -n "$VMALLOCUSED" ] && GRAPH_ORDER="$GRAPH_ORDER vmalloc_used"
test "$SLAB" != "" && GRAPH_ORDER="$GRAPH_ORDER slab" [ -n "$SLAB" ] && GRAPH_ORDER="$GRAPH_ORDER slab"
GRAPH_ORDER="$GRAPH_ORDER cached buffers free swap" GRAPH_ORDER="$GRAPH_ORDER cached buffers free swap"
echo "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit $MEMTOTAL" echo "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit $MEMTOTAL"
@ -44,65 +44,65 @@ config_memory() {
echo "free.label unused" echo "free.label unused"
echo "free.draw STACK" echo "free.draw STACK"
echo "free.info Wasted memory. Memory that is not used for anything at all." echo "free.info Wasted memory. Memory that is not used for anything at all."
if [ "$SLAB" != "" ]; then if [ -n "$SLAB" ]; then
echo "slab.label slab_cache" echo "slab.label slab_cache"
echo "slab.draw STACK" echo "slab.draw STACK"
echo "slab.info Memory used by the kernel (major users are caches like inode, dentry, etc)." echo "slab.info Memory used by the kernel (major users are caches like inode, dentry, etc)."
fi fi
if [ "$SWAPCACHED" != "" ]; then if [ -n "$SWAPCACHED" ]; then
echo "swap_cache.label swap_cache" echo "swap_cache.label swap_cache"
echo "swap_cache.draw STACK" echo "swap_cache.draw STACK"
echo "swap_cache.info A piece of memory that keeps track of pages that have been fetched from swap but not yet been modified." echo "swap_cache.info A piece of memory that keeps track of pages that have been fetched from swap but not yet been modified."
fi fi
if [ "$PAGETABLES" != "" ]; then if [ -n "$PAGETABLES" ]; then
echo "page_tables.label page_tables" echo "page_tables.label page_tables"
echo "page_tables.draw STACK" echo "page_tables.draw STACK"
echo "page_tables.info Memory used to map between virtual and physical memory addresses.\n" echo "page_tables.info Memory used to map between virtual and physical memory addresses.\n"
fi fi
if [ "$VMALLOCUSED" != "" ]; then if [ -n "$VMALLOCUSED" ]; then
echo "vmalloc_used.label vmalloc_used" echo "vmalloc_used.label vmalloc_used"
echo "vmalloc_used.draw STACK" echo "vmalloc_used.draw STACK"
echo "vmalloc_used.info Virtual memory used by the kernel (used when the memory does not have to be physically contiguous)." echo "vmalloc_used.info Virtual memory used by the kernel (used when the memory does not have to be physically contiguous)."
fi fi
if [ "$COMMITTEDAS" != "" ]; then if [ -n "$COMMITTEDAS" ]; then
echo "committed.label committed" echo "committed.label committed"
echo "committed.draw LINE2" echo "committed.draw LINE2"
echo "committed.warn" $((SWAPTOTAL + MEMTOTAL)) echo "committed.warn" $((SWAPTOTAL + MEMTOTAL))
echo "committed.info The amount of memory that would be used if all the memory that's been allocated were to be used." echo "committed.info The amount of memory that would be used if all the memory that's been allocated were to be used."
fi fi
if [ "$MAPPED" != "" ]; then if [ -n "$MAPPED" ]; then
echo "mapped.label mapped" echo "mapped.label mapped"
echo "mapped.draw LINE2" echo "mapped.draw LINE2"
echo "mapped.info All mmap()ed pages." echo "mapped.info All mmap()ed pages."
fi fi
if [ "$ACTIVE" != "" ]; then if [ -n "$ACTIVE" ]; then
echo "active.label active" echo "active.label active"
echo "active.draw LINE2" echo "active.draw LINE2"
echo "active.info Memory recently used. Not reclaimed unless absolutely necessary." echo "active.info Memory recently used. Not reclaimed unless absolutely necessary."
fi fi
if [ "$ACTIVEANON" != "" ]; then if [ -n "$ACTIVEANON" ]; then
echo "active_anon.label active_anon" echo "active_anon.label active_anon"
echo "active_anon.draw LINE1" echo "active_anon.draw LINE1"
fi fi
if [ "$ACTIVECACHE" != "" ]; then if [ -n "$ACTIVECACHE" ]; then
echo "active_cache.label active_cache" echo "active_cache.label active_cache"
echo "active_cache.draw LINE1" echo "active_cache.draw LINE1"
fi fi
if [ "$INACTIVE" != "" ]; then if [ -n "$INACTIVE" ]; then
echo "inactive.label inactive" echo "inactive.label inactive"
echo "inactive.draw LINE2" echo "inactive.draw LINE2"
echo "inactive.info Memory not currently used." echo "inactive.info Memory not currently used."
fi fi
if [ "$INACTDIRTY" != "" ]; then if [ -n "$INACTDIRTY" ]; then
echo "inact_dirty.label inactive_dirty" echo "inact_dirty.label inactive_dirty"
echo "inact_dirty.draw LINE1" echo "inact_dirty.draw LINE1"
echo "inact_dirty.info Memory not currently used, but in need of being written to disk." echo "inact_dirty.info Memory not currently used, but in need of being written to disk."
fi fi
if [ "$INACTLAUNDRY" != "" ]; then if [ -n "$INACTLAUNDRY" ]; then
echo "inact_laundry.label inactive_laundry" echo "inact_laundry.label inactive_laundry"
echo "inact_laundry.draw LINE1" echo "inact_laundry.draw LINE1"
fi fi
if [ "$INACTCLEAN" != "" ]; then if [ -n "$INACTCLEAN" ]; then
echo "inact_clean.label inactive_clean" echo "inact_clean.label inactive_clean"
echo "inact_clean.draw LINE1" echo "inact_clean.draw LINE1"
echo "inact_clean.info Memory not currently used." echo "inact_clean.info Memory not currently used."
@ -137,47 +137,47 @@ fetch_memory() {
echo "swap.value" $((SWAP * 1024)) echo "swap.value" $((SWAP * 1024))
echo "cached.value" $((CACHED * 1024)) echo "cached.value" $((CACHED * 1024))
echo "free.value" $((MEMFREE * 1024)) echo "free.value" $((MEMFREE * 1024))
if [ "$SLAB" != "" ]; then if [ -n "$SLAB" ]; then
echo "slab.value" $((SLAB * 1024)) echo "slab.value" $((SLAB * 1024))
APPS=$((APPS - SLAB)) APPS=$((APPS - SLAB))
fi fi
if [ "$SWAPCACHED" != "" ]; then if [ -n "$SWAPCACHED" ]; then
echo "swap_cache.value" $((SWAPCACHED * 1024)) echo "swap_cache.value" $((SWAPCACHED * 1024))
APPS=$((APPS - SWAPCACHED)) APPS=$((APPS - SWAPCACHED))
fi fi
if [ "$PAGETABLES" != "" ]; then if [ -n "$PAGETABLES" ]; then
echo "page_tables.value" $((PAGETABLES * 1024)) echo "page_tables.value" $((PAGETABLES * 1024))
APPS=$((APPS - PAGETABLES)) APPS=$((APPS - PAGETABLES))
fi fi
if [ "$VMALLOCUSED" != "" ]; then if [ -n "$VMALLOCUSED" ]; then
echo "vmalloc_used.value" $((VMALLOCUSED * 1024)) echo "vmalloc_used.value" $((VMALLOCUSED * 1024))
APPS=$((APPS - VMALLOCUSED)) APPS=$((APPS - VMALLOCUSED))
fi fi
if [ "$COMMITTEDAS" != "" ]; then if [ -n "$COMMITTEDAS" ]; then
echo "committed.value" $((COMMITTEDAS * 1024)) echo "committed.value" $((COMMITTEDAS * 1024))
fi fi
if [ "$MAPPED" != "" ]; then if [ -n "$MAPPED" ]; then
echo "mapped.value" $((MAPPED * 1024)) echo "mapped.value" $((MAPPED * 1024))
fi fi
if [ "$ACTIVE" != "" ]; then if [ -n "$ACTIVE" ]; then
echo "active.value" $((ACTIVE * 1024)) echo "active.value" $((ACTIVE * 1024))
fi fi
if [ "$ACTIVEANON" != "" ]; then if [ -n "$ACTIVEANON" ]; then
echo "active_anon.value" $((ACTIVEANON * 1024)) echo "active_anon.value" $((ACTIVEANON * 1024))
fi fi
if [ "$ACTIVECACHE" != "" ]; then if [ -n "$ACTIVECACHE" ]; then
echo "active_cache.value" $((ACTIVECACHE * 1024)) echo "active_cache.value" $((ACTIVECACHE * 1024))
fi fi
if [ "$INACTIVE" != "" ]; then if [ -n "$INACTIVE" ]; then
echo "inactive.value" $((INACTIVE * 1024)) echo "inactive.value" $((INACTIVE * 1024))
fi fi
if [ "$INACTDIRTY" != "" ]; then if [ -n "$INACTDIRTY" ]; then
echo "inact_dirty.value" $((INACTDIRTY * 1024)) echo "inact_dirty.value" $((INACTDIRTY * 1024))
fi fi
if [ "$INACTLAUNDRY" != "" ]; then if [ -n "$INACTLAUNDRY" ]; then
echo "inact_laundry.value" $((INACTLAUNDRY * 1024)) echo "inact_laundry.value" $((INACTLAUNDRY * 1024))
fi fi
if [ "$INACTCLEAN" != "" ]; then if [ -n "$INACTCLEAN" ]; then
echo "inact_clean.value" $((INACTCLEAN * 1024)) echo "inact_clean.value" $((INACTCLEAN * 1024))
fi fi