The Brilliant Gears
  Home   Products
  • HTML Decompose
  • KSM
  • Multiple RBLCheck
  • WebRefer
  • KINS
  • KINS FTP
  •   Download
  • HTML Decompose
  • KSM
  • Multiple RBLCheck
  • WebRefer
  • KINS Manual
  •   Blog/Essay
  • Software development
  • Hardware related
  • System administration
  • Collections/bookmarks
  • Funny and amusing
  • Non-English
  • Scratchbook
  • Miscellaneous
  • * Complete list
  •   About
  • Saintus
  • Privacy policy
  • The author
  • Contact us
  •   Site map
     
      About Saintus
    Saintus.com is an innovative pioneer devoted to provide quality software components. The gears cover from high-level script to low-level engines. (more)
     
      Latest Blog/Essay
     
      Recommendations
  • Diet for a new America
  • Virtual Museum (Big5)
  • Shumei Motel (Big5)
  • Monkia Info. (Big5)
  • NOPAM (Big5)
  •  
      Subscribe
    Stay tuned with Saintus to receive:
  • latest news
  • product update
  • new download
  •  
    Home > Product > KSM > Examples

    Basic examples

    Advanced example

    * You are welcome to share your examples/scenarios.


    Detect local web server failure
    This is a simple example to show how to use KSM to detect a local web server failure. In this example, the web server is Apache and installed in "/usr/local/apache". It listens port 80 and has a keyword "Welcome to ABC" in '/index.html'. KSM fetches '/index.html' and check the keyword 'Welcome to ABC' every 30 seconds. If failure instances are counted up to 4, a failure event occurs. When server failure detected, KSM will try to start apache and send Apache error log in email to webmaster.

    Detect process status
    Suppose that you install a UNIX daemon named "ghost", and use it to provide authentication service. However, it sometimes disappears (terminated) for some unknown reason, and the service is stoppped. You can use KSM to monitor the process, and restart it when necessary. Since the task of "authentication" is important, we restart "ghost" as soon as find that it disappears by set MAX_RETRY to 1. The program ghost write its messages in '/var/log/ghost.log'. We will "tail" the log file for the latest segment and send it to root.

    Detect network connection failure for backup routing
    On a gateway host, the server connects to Internet through a high speed DSL. The host also has a slow speed ADSL for backup routing, if the high speed DSL is down. The high speed DSL is binded by network interface "eth0", while the low speed ADSL is binded by interface "eth1". We can use KSM to detect outgoing connection failure on "eth0", and switch default route to "eth1" automatically. We detect network failure by pinging ISP's router IP (ex. 187.42.0.254). Since it's normal to have network failures because of temporary "traffic jam", we should not conclude a "failure" event when a single 'ping' fails. In this example, if failure instances (ping fails) are counted up to 4, then a failure event occurs.
    Note: the KAAS_START_CMD in this example uses "route" to switch default route from "eth0" to "eth1", however, the syntax may be different to different OS.

    Detect core dump and mail the core file
    You develop a program named "ultraman". The program is designed for providing network service, but it sometimes "core dumps" due to unknown reason. The "core dump" will happen when the program runs several days. By using KSM, you can restart "ultraman" when it core dumps as soon as possible, and save dumpped core file for debugging. In this example, we use MPACK, the utility for encoding binary files in MIME format mail messages to send the core file as mail attatchment. Because the "ultraman" is not a daemon program, KSM fork a child progcess to start it, so KSM can back to the monitoring loop again.

    Detect abnormal memory usage
    Very often, a buggy program has the symptom of memory leak. It uses little memory but consumes huge amount of memory gradually, and finally it gets core dumped. Sometimes, the symptom may surface after runing several days or several weeks. In this example, the program is named "monster" and installed in /usr/local/monster. The program can flush run-time data into disk and stoped by sending SIGHUP signal. You can use KSM to detect the situation and take necessary actions before it gets core dumped. We use "top" (1) to detect program's memory usage, and stop the program gracefully before too late.


    Saintus (C)Copyright 2004-2008 with all rights reserved
    Be Veg Go Green Save the Planet
  • 歐盟 牲畜 肉食 暖化 甲烷 畜牧業 甲烷 環保 補助金
  • 歐盟支持減產肉品 EU氣候委員會承認牲畜造成全球暖化, 建議減少畜牧補助金,以降低溫室氣體
  • 沙漠化 飼料 牛肉 畜牧 漢堡 牛奶 耗水
  • 生產1公斤牛肉,需要消耗耗水資源 2 ~ 4萬公升