天天看点

Nagios和ndo2db系统脚本---for gentoo

Gentoo下Nagios系统启动脚本

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

<code>#!/sbin/runscript</code>

<code># Copyright 1999-2013 Gentoo Foundation</code>

<code># Distributed under the terms of the GNU General Public License v2</code>

<code># $Header: $</code>

<code>depend() {</code>

<code>need net</code>

<code>}</code>

<code>if</code> <code>[ -f </code><code>/etc/rc</code><code>.d</code><code>/init</code><code>.d</code><code>/functions</code> <code>]; </code><code>then</code>

<code>. </code><code>/etc/rc</code><code>.d</code><code>/init</code><code>.d</code><code>/functions</code>

<code>elif</code> <code>[ -f </code><code>/etc/init</code><code>.d</code><code>/functions</code> <code>]; </code><code>then</code>

<code>. </code><code>/etc/init</code><code>.d</code><code>/functions</code>

<code>fi</code>

<code>checkconfig() {</code>

<code>nagios_bin_file=</code><code>/var/www/localhost/htdocs/nagios/bin/nagios</code>

<code>nagios_cfg_file=</code><code>/var/www/localhost/htdocs/nagios/etc/nagios</code><code>.cfg</code>

<code>if</code> <code>[ ! -f </code><code>"$nagios_bin_file"</code> <code>]; </code><code>then</code>

<code>echo</code> <code>"$nagios_bin_file is not exist."</code>

<code>exit</code> <code>1</code>

<code>if</code> <code>[ ! -f </code><code>"$nagios_cfg_file"</code> <code>]; </code><code>then</code>

<code>echo</code> <code>"$nagios_cfg_file is not exist."</code>

<code>$nagios_bin_file -</code><code>v</code> <code>$nagios_cfg_file &gt; </code><code>/dev/null</code> <code>2&gt;&amp;1</code>

<code>if</code> <code>[ $? -</code><code>ne</code> <code>0 ]; </code><code>then</code>

<code>echo</code> <code>"please check your nagios configuration file."</code>

<code>start() {</code>

<code>nagios_script_file=</code><code>/var/www/localhost/htdocs/nagios/sbin/nagios</code>

<code>checkconfig</code>

<code>ebegin </code><code>"starting nagios"</code>

<code>start-stop-daemon --start --</code><code>exec</code> <code>$nagios_script_file</code>

<code>eend $?</code>

<code>stop() {</code>

<code>nagios_pid_file=</code><code>/var/www/localhost/htdocs/nagios/var/nagios</code><code>.lock</code>

<code>ebegin </code><code>"Stopping nagios"</code>

<code>start-stop-daemon --stop --retry 30 --pidfile $nagios_pid_file</code>

<code>status() {</code>

<code>nagios_run_path=</code><code>/var/www/localhost/htdocs/nagios/var</code>

<code>if</code> <code>[ ! -f $nagios_run_path</code><code>/nagios</code><code>.lock ]; </code><code>then</code>

<code>echo</code> <code>"nagios is not running."</code>

<code>else</code>

<code>nagios_pid_NO=`</code><code>head</code> <code>-n 1 $nagios_run_path</code><code>/nagios</code><code>.lock`</code>

<code>echo</code> <code>"nagios( pid:$nagios_pid_NO ) is running."</code>

Gentoo下ndo2db系统启动脚本

<code>ndo2db_bin_file=</code><code>/var/www/localhost/htdocs/nagios/bin/ndo2db-3x</code>

<code>ndo2db_cfg_file=</code><code>/var/www/localhost/htdocs/nagios/etc/ndo2db</code><code>.cfg</code>

<code>if</code> <code>[ ! -f </code><code>"$ndo2db_bin_file"</code> <code>]; </code><code>then</code>

<code>echo</code> <code>"$ndo2db_bin_file is not exist."</code>

<code>if</code> <code>[ ! -f </code><code>"$ndo2db_cfg_file"</code> <code>]; </code><code>then</code>

<code>echo</code> <code>"$ndo2db_cfg_file is not exist."</code>

<code>ndo2db_script_file=</code><code>/var/www/localhost/htdocs/nagios/sbin/ndo2db</code>

<code>ebegin </code><code>"starting ndo2db"</code>

<code>start-stop-daemon --start --</code><code>exec</code> <code>$ndo2db_script_file</code>

<code>ndo2db_pid_file=</code><code>/var/www/localhost/htdocs/nagios/var/ndo2db</code><code>.lock</code>

<code>ebegin </code><code>"Stopping ndo2db"</code>

<code>start-stop-daemon --stop --retry 30 --pidfile $ndo2db_pid_file</code>

<code>ndo2db_run_path=</code><code>/var/www/localhost/htdocs/nagios/var</code>

<code>if</code> <code>[ ! -f $ndo2db_run_path</code><code>/ndo2db</code><code>.lock ]; </code><code>then</code>

<code>echo</code> <code>"ndo2db service is not running."</code>

<code>ndo2db_pid_NO=`</code><code>head</code> <code>-n 1 $ndo2db_run_path</code><code>/ndo2db</code><code>.lock`</code>

<code>echo</code> <code>"ndo2db( pid:$ndo2db_pid_NO ) is running."</code>

本文转自 chengchow 51CTO博客,原文链接:http://blog.51cto.com/chengchow/1397259,如需转载请自行联系原作者

继续阅读