Access Monit on PHP

Posted by xian on Server Fault See other posts from Server Fault or by xian
Published on 2012-06-22T09:07:24Z Indexed on 2012/06/22 9:17 UTC
Read the original article Hit count: 367

Filed under:
|
|

i have a remote server (Centos 5.8) and i have installed monit on it as my monitoring tool.

monit installation

yum install monit

now, on my local machine (still Centos5.8), i want to get the system status (shown below) of the said server provided by monit

---------------------------------------------------
| Parameter           | Value                     |
---------------------------------------------------
| Name                | serverHostname            |
| Status              | Running                   |
| Monitoring mode     | active                    |
| Monitoring status   | Monitored                 |
| Data collected      | Fri, 22 Jun 2012 16:47:01 |
| Load average        | [0.32] [0.37] [0.43]      |
| CPU usage           | 3.3%us 0.2%sy 0.0%wa      |
| Memory usage        | 2005212 kB [53.9%]        |
| Swap usage          | 893256 kB  [21.8%]        |
---------------------------------------------------

This information is shown when you clicked on the system name link found on the your monit's home page http://localhost:2812

How can I do that in php? How can I retrieve those information?

i was thinking of executing this linux command in php:

/usr/bin/monit status

Output of this is

The Monit daemon 5.4 uptime: 2h 55m 

System 'system_asi454'
status                            Running
monitoring status                 Monitored
load average                      [0.22] [0.34] [0.42]
cpu                               3.3%us 0.2%sy 0.0%wa
memory usage                      2005212 kB [53.9%]
swap usage                        892928 kB [21.8%]
data collected                    Fri, 22 Jun 2012 16:47:01

which is similar to the table content show above.

© Server Fault or respective owner

Related posts about php

Related posts about centos5