]> arthur.barton.de Git - nagcollect.git/blob - client/lib/tests/Uptime.tst
58ed1464729becbb18eb89c0b0a4facd3432dc48
[nagcollect.git] / client / lib / tests / Uptime.tst
1 # NagCollect -- Nagios Data Collector for Passive Checks
2 # Copyright (c)2009-2010 Alexander Barton, alex@barton.de
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 # Please read the file COPYING, README and AUTHORS for more information.
9 #
10
11 SERVICE="Uptime_p"
12 STATUS=0
13
14 uptime=`LC_ALL=C uptime`
15 uptime=${uptime%,*user*}
16 uptime=${uptime##* up }
17
18 os="`uname -s` `uname -r`"
19
20 if [ `uname` = "Darwin" ]; then
21         os="`sw_vers -productName` `sw_vers -productVersion`"
22         case "$os" in
23                 *Server*)
24                         case "$uptime" in
25                                 *" days, "*)
26                                         STATUS=0
27                                         ;;
28                                 "1 day, "*)
29                                         STATUS=1
30                                         ;;
31                                 *:*|"1 hr"|*" hrs"|*" mins")
32                                         STATUS=2
33                                         ;;
34                                 *)
35                                         STATUS=3
36                                         ;;
37                         esac
38                         ;;
39         esac
40 fi
41
42 TEXT="Uptime: $uptime - $os"