⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linuxmon.cpp

📁 电驴的MAC源代码
💻 CPP
字号:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Name:         LinuxMon Class////// Purpose:      Monitor Linux system by reading /proc file system////// Author:       ThePolish <thepolish@vipmail.ru>////// Copyright (C) 2004 by ThePolish////// Derived from CAS by Pedro de Oliveira <falso@rdk.homeip.net>////// Pixmats from aMule http://www.amule.org////// This program is free software; you can redistribute it and/or modify///  it under the terms of the GNU General Public License as published by/// the Free Software Foundation; either version 2 of the License, or/// (at your option) any later version.////// This program is distributed in the hope that it will be useful,/// but WITHOUT ANY WARRANTY; without even the implied warranty of/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the/// GNU General Public License for more details.////// You should have received a copy of the GNU General Public License/// along with this program; if not, write to the/// Free Software Foundation, Inc.,/// 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#ifdef __BORLANDC__ #pragma hdrstop#endif// For all others, include the necessary headers#ifndef WX_PRECOMP #include "wx/wx.h"#endif#include "linuxmon.h"#include <wx/txtstrm.h>#include <wx/wfstream.h>// Constantsconst wxFileNameLinuxMon::UPTIME_FILE ( wxT( "/proc/uptime" ) );const wxFileNameLinuxMon::LOADAVG_FILE ( wxT( "/proc/loadavg" ) );// ConstructorsLinuxMon::LinuxMon (){	Refresh ();}// DestructorLinuxMon::~LinuxMon (){}// RefreshvoidLinuxMon::Refresh (){	wxFileInputStream upInput ( UPTIME_FILE.GetFullPath () );	wxFileInputStream loadInput ( LOADAVG_FILE.GetFullPath () );	wxTextInputStream upText ( upInput );	wxTextInputStream loadText ( loadInput );	loadText >> m_sysLoad_1;	loadText >> m_sysLoad_5;	loadText >> m_sysLoad_15;	double uptime;	upText >> uptime;	wxInt32 day, hour, min, sec;	day = ( wxInt32 ) ( uptime / 86400 );	hour = ( wxInt32 ) ( ( uptime - day * 86400 ) / 3600 );	min = ( wxInt32 ) ( ( uptime - day * 86400 - hour * 3600 ) / 60 );	sec = ( wxInt32 ) ( uptime - day * 86400 - hour * 3600 - min * 60 );	m_uptime =	    m_uptime.Format ( _( "%i day(s) %i hour(s) %i min %i s" ), day, hour, min,	                      sec );}// AccessorswxStringLinuxMon::GetUptime () const{	return m_uptime;}wxStringLinuxMon::GetSysLoad_1 () const{	return m_sysLoad_1;}wxStringLinuxMon::GetSysLoad_5 () const{	return m_sysLoad_5;}wxStringLinuxMon::GetSysLoad_15 () const{	return m_sysLoad_15;}// File_checked_for_headers

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -