/[projects]/smsdaemon/plugins/HostStatusPlugin.cpp
ViewVC logotype

Diff of /smsdaemon/plugins/HostStatusPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 184 by torben, Mon Dec 8 21:49:49 2008 UTC revision 185 by torben, Mon Dec 15 09:10:05 2008 UTC
# Line 3  Line 3 
3  #include "Sms.h"  #include "Sms.h"
4  #include "Util.h"  #include "Util.h"
5    
6    #include <vector>
7    #include <sstream>
8    #include <iostream>
9    
10  using namespace std;  using namespace std;
11    
# Line 11  HostStatusPlugin::HostStatusPlugin() Line 14  HostStatusPlugin::HostStatusPlugin()
14  {  {
15  }  }
16    
17    string ParseMemory(string mem)
18    {
19            stringstream out;
20    
21            vector<string> lines = Util::str_split(mem,"\n");
22            vector<string> line2 = Util::str_split( lines[1] );
23            vector<string> line3 = Util::str_split( lines[2] );
24    
25            out << "Mem." << endl;
26            out << "Applications: " << line3[2] << "mb\n" ;
27            out << "Buffers: " << line2[5] << "mb\n" ;
28            out << "Cache: " << line2[6] << "mb\n";
29            out << "Free: " << line2[3] << "mb\n\n";
30    
31            return out.str();
32    }
33    
34  void HostStatusPlugin::Execute(ISmsTransceiver& modem, SMS& sms)  void HostStatusPlugin::Execute(ISmsTransceiver& modem, SMS& sms)
35  {  {
36          string message;          string message;
# Line 22  void HostStatusPlugin::Execute(ISmsTrans Line 42  void HostStatusPlugin::Execute(ISmsTrans
42          Util::my_system("uptime", &out);          Util::my_system("uptime", &out);
43          message += out;          message += out;
44    
45            Util::my_system("free -m",&out);
46            message += ParseMemory(out);
47    
48          Util::my_system("df -h  | grep dev | awk '{ print $6 \" \" $5}'", &out);          Util::my_system("df -h  | grep dev | awk '{ print $6 \" \" $5}'", &out);
49          message += out;          message += out;
50    

Legend:
Removed from v.184  
changed lines
  Added in v.185

  ViewVC Help
Powered by ViewVC 1.1.20