This shows you the differences between two versions of the page.
Last revision | |||
— | sdk:scripts:ping-supervision [2015/05/05 15:04] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SDK Script ping-supervision.are ====== | ||
+ | <code c ping-supervision.are> | ||
+ | /* DESC: This script will supervise a specified host. | ||
+ | * Copyright (C) 2013 NetModule AG, Switzerland | ||
+ | */ | ||
+ | |||
+ | void usage() | ||
+ | { | ||
+ | printf(" | ||
+ | exit(1); | ||
+ | } | ||
+ | |||
+ | if (argc < 2) { | ||
+ | usage(); | ||
+ | } | ||
+ | |||
+ | HOST = argv[1]; | ||
+ | INTERVAL = 5; | ||
+ | MAX_FAILURES = 3; | ||
+ | |||
+ | failures = 0; | ||
+ | while (1) { | ||
+ | ret = nb_ping(HOST); | ||
+ | if (ret != 1) { | ||
+ | failures++; | ||
+ | nb_syslog(" | ||
+ | if (failures >= MAX_FAILURES) { | ||
+ | nb_syslog(" | ||
+ | nb_reboot(); | ||
+ | break; | ||
+ | } | ||
+ | } else { | ||
+ | nb_syslog(" | ||
+ | failures = 0; | ||
+ | } | ||
+ | sleep(INTERVAL); | ||
+ | } | ||
+ | |||
+ | exit(0); | ||
+ | |||
+ | </ | ||