Simple implementation of the cluster CPU usage monitoring system (1) Implementation of the monitored end

Source: Internet
Author: User

 

The CPU. Sh script on the monitored end collects the CPU usage of the Local Machine, sends an HTTP request to the monitoring end recvinfo servlet, and submits data.

 

Content:

#! /Bin/sh

# Endless loop. Note the space after while

While:

Do

# Interval: one second

Sleep 1

CPU = $ (SAR-u 1 1 | awk 'nr = 4 {print $8 }')

# Use curl to send data to the specified Servlet

Curl-d "CPU = $ CPU" http: // localhost: 8080/monitor/recvinfo

Done

 

1 SAR: Ubuntu is not installed by default. Use apt-Get install sysstat to install it.

2 curl usage:

When submitting a form over HTTP, the post mode and get mode are commonly used. You only need to write the variable in the URL.
For example:
Curl http://www.yahoo.com/login.cgi? User = nickwolfe & Password = 12345 while option in post mode is-d For example, curl-d "user = nickwolfe & Password = 12345" http://www.yahoo.com/login.cgi
This is equivalent to sending a login application to this site ~~~~~ Whether to use the get mode or post mode depends on the program settings of the opposite server. Note that, in post mode, files are uploaded, such
<Form method = "Post" enctype = "multipar/form-Data" Action = "http://cgi2.tky.3web.ne.jp /~ Zzh/up_file.cgi ">
<Input type = file name = upload>
<Input type = submit name = Nick value = "go">
</Form>
To simulate such an HTTP form with curl, the syntax is as follows:
Curl-F upload = @ localfile-F Nick = go http://cgi2.tky.3web.ne.jp /~ Zzh/up_file.cgi

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.