leachus2002 Posted December 2, 2010 Share Posted December 2, 2010 Hi Everyone, I have seen on the web that you can purchase some server monitoring applications, which mainly run using PHP. Because I don't necesserally need something so powerful, I just want to monitor memory usage and cpu usage. Is there anyway that I can do this using PHP? I have SMNP enabled if that helps? Thanks Matt Link to comment https://forums.phpfreaks.com/topic/220449-grabbing-server-stats-using-php/ Share on other sites More sharing options...
sweeb Posted December 2, 2010 Share Posted December 2, 2010 You can use the exec php function, then run the shell command 'uptime'. Then dump these results into a text file or database at whatever intervals with cron. If you really want to get fancy you can write a log parsing file to display them nicely for you. Link to comment https://forums.phpfreaks.com/topic/220449-grabbing-server-stats-using-php/#findComment-1142158 Share on other sites More sharing options...
leachus2002 Posted December 2, 2010 Author Share Posted December 2, 2010 Sounds good. Does shell require SSH? Link to comment https://forums.phpfreaks.com/topic/220449-grabbing-server-stats-using-php/#findComment-1142165 Share on other sites More sharing options...
sweeb Posted December 2, 2010 Share Posted December 2, 2010 No, when you use exec the only thing that is needed is PHP with safe mode turned off. Link to comment https://forums.phpfreaks.com/topic/220449-grabbing-server-stats-using-php/#findComment-1142174 Share on other sites More sharing options...
leachus2002 Posted December 2, 2010 Author Share Posted December 2, 2010 Cool, I will take a look, has anyone got any code examples for grabbing this data? Thanks Matt Link to comment https://forums.phpfreaks.com/topic/220449-grabbing-server-stats-using-php/#findComment-1142183 Share on other sites More sharing options...
sweeb Posted December 2, 2010 Share Posted December 2, 2010 Also, in conjunction with load times from 'uptime' (which somewhat CPU usage) you can use system("free -m") to get mem usage Link to comment https://forums.phpfreaks.com/topic/220449-grabbing-server-stats-using-php/#findComment-1142194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.