linuxx 发表于 2019-1-17 11:50:25

Smokeping初始配置

  3.1修改smokeping相关文件名
  在smokeping的子目录中会发现很多“*.dist”命名的文件,这些文件使用的时候请将其改名为“*”并进行配置,可以通过如下命令批量操作:  ls | while read name; do mv ${name} ${name%%.*};done;

  3.2建立相关目录
  接着建立三个目录用于保存smokeping的数据等,如下所示:  mkdir /usr/local/smokeping/data
  mkdir /usr/local/smokeping/var
  mkdir /usr/local/smokeping/cache
  chown –R apache.apache /usr/local/smokeping

  3.3修改配置文件
  (1)/usr/local/smokeping/etc/config (somkeping配置基本都在这个文件上)  *** General ***
  owner =
  contact =
  mailhost = my.mail.host
  sendmail = /usr/lib/sendmail
  imgcache = /usr/local/smokeping/htdocs/cache
  imgurl = cache
  datadir = /data/smokeping/data
  piddir = /usr/local/smokeping/var
  cgiurl = http://IP/smokeping/smokeping.cgi
  smokemail = /usr/local/smokeping/etc/smokemail
  tmail = /usr/local/smokeping/etc/tmail.dist
  *** Presentation ***
  template = /usr/local/smokeping/etc/basepage.html
  charset = UTF-8

  (2)把#*** Slaves ***下的所有东西注释掉,这里暂时不采用master/slave模式。
  (3)在Targets下添加监控节点,其中Multi也就是在一张图里画多个监测点的数值:  + Telecom
  menu= TeleCom
  title = 21ViaNet(China)Telecom
  ++ HeiLJ
  menu = HeiLJ
  title = HeiLJ_219.147.130.76
  host = 219.147.130.76
  ++ JiLin menu = JiLin
  title = JiLin_219.149.194.1
  host = 219.149.194.1
  ++ TeleComMulti
  menu = TeleMulti
  title = 21ViaNet(China) Telecom Network
  host = /Telecom/HeiLJ /Telecom/JiLin

  (4) /usr/local/smokeping/htdocs/smokeping.cgi 注意修改如下内容即可  #!/usr/bin/speedy –w use lib qw(/usr/local/rrdtool/lib/perl);
  use lib qw(/usr/local/smokeping/lib); Smokeping::cgi("/usr/local/smokeping/etc/config ");

  (5)/usr/local/smokeping/bin/smokeping 注意修改如下内容即可:  #!/usr/bin/perl –w
  use lib qw(/usr/local/rrdtool/lib/perl);
  use lib qw(/usr/local/smokeping/lib); Smokeping::main("/usr/local/smokeping/etc/config");

  3.4启动smokeping
  (1)编写smokeping启动脚本,赋予可执行权限,并放在/etc/init.d目录下  #!/bin/sh
  PIDFILE=/usr/local/smokeping/var/smokeping.pid
  SMOKEPING=/usr/local/smokeping/bin/smokeping
  ERROR=0
  RUNNING=0
  ARGV="$@"
  if [ "x$ARGV" = "x" ] ; then
  ARGS=help
  fi
  for ARG in $@ $ARGS
  do
  if [ -f $PIDFILE ] ; then
  PID=`cat $PIDFILE`
  if kill -0 $PID 2>/dev/null ; then
  # smokeping is running
  RUNNING=1
  else
  # smokeping not running but PID file exists => delete PID file
  rm -f $PIDFILE
  RUNNING=0
  fi
  else
  # smokeping (no pid file) not running
  RUNNING=0
  fi
  case $ARG in
  start)
  if [ $RUNNING -eq 0 ] ; then
  if $SMOKEPING > /dev/null; then
  echo "$0 $ARG: smokeping started"
  else
  echo "$0 $ARG: smokeping could not be started"
  ERROR=1
  fi
  else
  echo "$0 $ARG: smokeping is running with PID $PID"
  ERROR=2
  fi
  ;;
  stop)
  if [ $RUNNING -eq 1 ] ; then
  if kill $PID ; then
  echo "$0 $ARG: smokeping ($PID) stopped"
  rm $PIDFILE
  else
  echo "$0 $ARG: smokeping could not be stopped"
  ERROR=3
  fi
  else
  echo "$0 $ARG: smokeping not running"
  ERROR=4
  fi
  ;;
  restart)
  if [ $RUNNING -eq 1 ] ; then
  if $SMOKEPING --restart > /dev/null; then
  echo "$0 $ARG: smokeping restarted"
  else
  echo "$0 $ARG: smokeping could not be started"
  ERROR=5
  fi
  else
  $0 start
  fi
  ;;
  strace_debug)
  rm -f /tmp/strace_smokeping
  if [ $RUNNING -eq 1 ] ; then
  if strace -o/tmp/strace_smokeping $SMOKEPING --restart >/dev/null; then
  echo "$0 $ARG: smokeping restarted with strace debug in /tmp/strace_smokeping"
  else
  echo "$0 $ARG: smokeping strace debug could not be started"
  ERROR=6
  fi
  else
  if strace -o/tmp/strace_smokeping $SMOKEPING >/dev/null; then
  echo "$0 $ARG: smokeping started with strace debug in /tmp/strace_smokeping"
  else
  echo "$0 $ARG: smokeping strace debug could not be started"
  ERROR=7
  fi
  fi
  ;;
  status)
  if [ $RUNNING -eq 1 ] ; then
  echo "$0 $ARG: smokeping is running with PID ($PID)"
  else
  echo "$0 $ARG: smokeping is not running"
  fi
  ;;
  *)
  echo "usage: $0 (start|stop|restart|status|strace_debug|help)"
  cat
  Options FollowSymLinks ExecCGI
  AllowOverride None
  AddHandler cgi-script cgi
  Order allow,deny
  Allow from all
  

  (4)修改完后重启apache,在浏览器输入 http://IP/smokeping/smokeping.cgi



页: [1]
查看完整版本: Smokeping初始配置