HW monitor
 
About
 
Install
 
Download
 
FAQ
 
 

1. INSTALL

Run "make" at first, you can find the "hwmonitor" and "hwclient" bin files. Copy the floowing file to your prefix path:

  hwmonitor
  hwclient
  hwmonitor.conf
  hwclient.conf

For example, I copy these into "/server/hwmonitor".


2. MAKE A HWMONITOR DAEMON
(How can I run a predefine command remotely)

  • Modify <config-file-install-path>/hwmonitor.conf, change "listen_ip" and "listen_port" in [global] group, append/modify some predefine command in [command] group if you need.
      (FORMAT: <predefine-command> = <real command line>)
      hw_date = date
    

  • Run "<install-path>/hwmonitor <config-file-install-path>/hwmonitor.conf", for example:
      /server/hwmonitor/hwmonitor /server/hwmonitor/hwmonitor.conf
    
  • hwmonitor daemon listened on listen_ip/listen_port, and you can telnet to this ip/port, input your predefine command to get the real command output message remotely.

    For example, run predefine command "hw_date" (real command is 'date') and get the date info from remote server:

      root@game:~# telnet 172.16.1.210 1000
      Trying 172.16.1.210...
      Connected to 172.16.1.210.
      Escape character is '^]'.
      hw_date
      Thu Feb 23 11:10:57 HKT 2012
      Connection closed by foreign host.
      root@game:~# 
    
    Line "Thu Feb 23 11:10:57 HKT 2012" is the output. I use this function to confirm each server time is sync (Write a shell or PHP/ruby/perl/etc. command to connect to each hwmonitor listen_ip/port, get the info and show me at once. read FAQ document for the detail.)

  • NOTE: use iptables/ipchains to protect hwmonitor listen port by yourself, or only listen on internal IP.


    3. MAKE A HWCLIENT DAEMON
    (How can I get the server load average and IO idle value into a text file. How can I use "hwclient" )

    I just wont to know each server information at first, and, "Can I use hwmonitor to know each remote-server worked fine? I'm not 24 hours online, let it do something, use a simple client to get server load average' each 60 seconds and write the info into a text file ...", so "hwclient" to appear.

    "hwclient" is a extend function, get remote-server load average (from "top" command output) and IO idle (from "iostat" command output) each 60 seconds. It connect to multi remote-server(define servers into the hwclient.conf [monitor_server] group) and write the information to different file.

    -- * hwclient depend on 'sed' and 'iostat' command, confirm these commands exist. * --

  • Telnet to hwmonitor listen_ip/port, input "hw_average" predefine command:
      root@game:~# telnet 172.16.1.210 1000
      Trying 172.16.1.210...
      Connected to 172.16.1.210.
      Escape character is '^]'.
      hw_average
      0.00,0.10,0.07,1,94.31,2012-02-23,11:54:43
      Connection closed by foreign host.
      root@game:~# 
    
    Output info like:
      "0.00,0.10,0.07,1,94.31,2012-02-23,11:54:43"
    
    if the string like:
      "0.00,0.10,0.07,1,,2012-02-23,11:54:43" (The five value empty)
    
    check the "iostat" command exist (include in 'sysstat' package).

  • Modify <config-file-install-path>/hwclient.conf, change "save_path" in [global] group, add/modify "server" line in [monitor_server] group, line format is : "<display name>, <ip>, <port>, <send command>", for example:
      server = web1, 172.16.1.210, 1000, hw_average
    
    • <display name>: hwclient write remote-server info into the save_path and the filename is "<display-name>_<ip>_<date>.log", (like: web1_172.16.1.210_2012-02-23.log), split-character is "_" so don't use it in <display_name> (hwclient drop the "_" char automatic).
    • <ip>: remote-server ip.
    • <port>: remote-server hwmonitor listen port.
    • <send command>: default set is "hw_average", you can find in hwmonitor.conf, the real-comand is a PIPE bash shell-group.

    o. Run "/hwclient /hwclient.conf", for example:

      /server/hwclient/hwclient /server/hwmonitor/hwclient.conf
    
    Check the "save_path", you can find remote-server info text file exist, hwclient append a "hw_average" info line each 60 seconds, That's ok.


    4. MAKE A LOAD-AVERAGE/IO IDLE CHART
    (hwclient only have some output-data, I need a chart -- use hwgraphic PHP extend module)

    hwgraphic is hwmonitor [http://hwmonitor.sf.net] extend module and use to show the server load-average/IO idle chart, it writen in PHP.

    o. Copy hwgraphic_PHP/* into you webroot. modify the config.php:

      $P_dataPath = "/data/webroot/www/hwmonitor_data";
    
      Replace it same to hwclient.conf -> [global] -> save_path.

    o. Visit http://hwgraphic-install-url/list.php

    -- Cheng Dong [ ccdong[-at-]gmail[dot]com ] [ http://hwmonitor.sf.net]
     

  •  
     
    -- Go Top --