Skip to content
Snippets Groups Projects
Commit 267283ed authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add help: remove IML specific check for auto updates; add idletime; add markdown help page

parent 43f6d6c3
No related branches found
No related tags found
1 merge request!299add help: remove IML specific check for auto updates; add idletime; add markdown help page
......@@ -18,36 +18,68 @@
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2020-03-10 v1.2 <axel.hahn@iml.unibe.ch> add performance data
# 2020-07-02 v1.3 <axel.hahn@iml.unibe.ch> use sec for performance data
# 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2022-10-21 v1.4 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2025-02-19 v1.5 <axel.hahn@unibe.ch> add help: remove IML specific check for auto updates; add idletime
# ======================================================================
. `dirname $0`/inc_pluginfunctions
cronfile=/etc/cron.d/system-updater
. "$( dirname "$0" )/inc_pluginfunctions"
self_APPVERSION=1.5
# ----------------------------------------------------------------------
# MAIN
# functions
# ----------------------------------------------------------------------
iSecUp=`cat /proc/uptime | awk '{print $1}'`
echo "Uptime: `uptime | awk '{ print $3 " days " $5 " h"}' | tr -d ","` ... $iSecUp sec"
# --- status of auto update (IML specific)
ls ${cronfile} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo Autoupdate ON
grep -- " -r" ${cronfile} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo Autoreboot ON
else
echo Autoreboot OFF
fi
else
echo Autoupdate OFF
# show help text
function showHelp(){
local _self; _self=$(basename $0)
cat <<EOF
$( ph.showImlHelpHeader )
Show uptime and idle time.
The script sends performance data withvalues in seconds.
SYNTAX:
$_self [-h]
OPTIONS:
-h or --help show this help.
PARAMETERS:
None.
EOF
}
# ----------------------------------------------------------------------
# check params
# ----------------------------------------------------------------------
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
showHelp
exit 0;
fi
if [ -n "$*" ]; then
echo "ERROR: no parameter expected."
exit 1
fi
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
iSecUp=$( cat /proc/uptime | awk '{print $1}' )
iSecIdle=$( cat /proc/uptime | awk '{print $2}' )
echo "Uptime: $( uptime ) ... up: $iSecUp sec ... idle: $iSecIdle sec"
# --- add performance data
ph.perfadd uptime $iSecUp
ph.perfadd idletime $iSecIdle
ph.exit
......
......@@ -52,5 +52,5 @@
* check_systemdservices
* [check_systemdunit](check_systemdunit.md)
* [check_timesync](check_timesync.md)
* check_uptime
* [check_uptime](check_uptime.md)
* hello
## Check uptime
Script: `check_uptime`
**check_uptime** is a plugin to show uptime and idle time of a system.
It reads the counters from `/proc/uptime` and show the output of `upime` command.
## Requirements
Nothing special.
## Standalone installation
From this repository ypu need next to this script:
* `inc_pluginfunctions` shared function for all IML checks written in bash
## Syntax
Start the script with `-h` or `--help` to get the help.
```txt
______________________________________________________________________
CHECK_UPTIME
v1.5
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_uptime.html
______________________________________________________________________
Show uptime and idle time.
The script sends performance data withvalues in seconds.
SYNTAX:
check_uptime [-h]
OPTIONS:
-h or --help show this help.
PARAMETERS:
None.
```
## Examples
No parameter is needed.
`./check_uptime`
returns
```txt
Uptime: 17:03:41 up 8:23, 1 user, load average: 2.40, 1.92, 1.61 ... up: 30203.20 sec ... idle: 447821.43 sec
|uptime=30203.20;; idletime=447821.43;;
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment