Cloudmonitor is an excellent server monitoring service in China. It supports HTTP, ping, DNS, FTP, SMTP, Pop, IMAP, TCP, etc, the SNMP protocol is also used to monitor server performance and capacity. It supports various servers, including Linux, windows, BSD, Mac, Solaris, And Aix. It also supports service layer monitoring, including Apache, Lighttpd, nginx, and MySQL. Wpmind naturally uses this service to monitor the service status of the website at all times, so as to better serve the readers.
On the fifth mobiledev day in May 22, I showed you a monitoring client based on Windows Phone 7. You can use it on your Windows Phone 7 mobile phone (of course... Please wait for at least half a year, and now you can only use simulators) to monitor the running status of your server. TheProgramThe API provided by monitoring Bao is used to obtain the server status information.
To use this API, we only need to pay attention to two key points.
1. That is, the server data is obtained. We will use the WebClient object for asynchronous data acquisition. For a trial of WebClient objects, we can only use asynchronous loading on Windows Phone 7. Similarly, WebService can only be asynchronously loaded on Windows Phone 7. We also need to pay attention to the fact that basic authentication is also required for accessing the monitoring treasure API. RelatedCodeThe snippets are as follows:
Basic Identity Authentication:
Code snippet
-
- WC =New WebClient();
- StringUsername = GetUserName ();
-
- StringPassword = GetPassword ();
-
- StringUsernamepassword = username +":"+ Password;
-
- WC. Credentials =New Networkcredential(Username, password );
-
- WC. headers ["Authorization"] ="Basic"+Convert. Tobase64string (system. Text.Encoding. Utf8.getbytes (usernamepassword ));
For the data obtained by asynchronous loading, we bind the data directly to the interface list through XML to LINQ:
Code snippet
-
- VoidWcrefreshall_downloadstringcompleted (ObjectSender,DownloadstringcompletedeventargsE)
-
- {
-
- If(E. Error! =Null)
-
- {
-
- MessageBox. Show (E. Error. Message,"Error",Messageboxbutton. OK );
-
- Return;
-
- }
-
- XelementXmlallstatus =Xelement. Parse (E. Result );
-
- Console. Write (xmlallstatus. value );
-
-
- Statuslist. itemssource =FromTaskInXmlallstatus. Elements ("Task")
-
- Select New Taskstatus
-
- {
-
- Id = task. element ("Task_id"). Value,
- Name = task. element ("Task_name"). Value,
-
- Summary = task. element ("Task_summary"). Value,
-
- Type = task. element ("Task_type"). Value,
-
- Createtime = task. element ("Task_create_time"). Value,
-
- Frequency = task. element ("Frequency"). Value,
-
- Lastresponsetime = task. element ("Last_resp_time"). Value,
-
- Lastresponseresult = task. element ("Last_resp_result"). Value,
- Lastresponsestatus = task. element ("Last_resp_status"). Value,
-
- Checktime = task. element ("Last_check_time"). Value,
-
- Tag = task. element ("Task_id"). Value +","+ Task. element ("Task_name"). Value
-
- };
-
-
- }
2. Of course, in addition to viewing the current system status, it can also view the status curve so that you can understand the server's response changes. Currently, there is no line chart control in the SDK for Windows Phone 7. Here I use a control transplanted by someone else based on the Silverlight toolkit. Of course, if you want to have other controls, you can use:
PairSource codeInterested friends, please go to the Forum to download: http://bbs.wpmind.com/thread-267-1-1.html