Go to the documentation of this file.00001 #include "EventFilter/Utilities/interface/CPUStat.h"
00002 #include "EventFilter/Utilities/interface/CurlPoster.h"
00003
00004 namespace evf{
00005
00006 CPUStat::CPUStat(unsigned int nstates,
00007 unsigned int nproc,
00008 unsigned int instance,
00009 std::string iDieUrl) : iDieUrl_(iDieUrl)
00010 , nstates_(nstates)
00011 , nproc_(nproc)
00012 , instance_(instance)
00013 , entries_(0)
00014 , mstat_(new int[nstates_+6])
00015 , chart_("busy fraction",50)
00016 {
00017 poster_ = new CurlPoster(iDieUrl_);
00018 for(int i = 0; i < nstates_; i++)
00019 mstat_[i]=0;
00020 mstat_[nstates_]=nproc_;
00021 mstat_[nstates_+1]=instance_;
00022 mstat_[nstates_+2]=0;
00023 mstat_[nstates_+3]=0;
00024 mstat_[nstates_+4]=0;
00025 mstat_[nstates_+5]=0;
00026 }
00027 CPUStat::~CPUStat()
00028 {
00029 delete poster_;
00030 delete mstat_;
00031 }
00032
00033 void CPUStat::sendStat(unsigned int lsid)
00034 {
00035 chart_.flip(lsid,float(entries_-mstat_[2])/float(entries_));
00036 poster_->postBinary((unsigned char *)mstat_,(nstates_+6)*sizeof(int),lsid,"/postChoke");
00037 }
00038
00039 void CPUStat::sendLegenda(const std::vector<std::string> &mapmod)
00040 {
00041 std::string message;
00042 unsigned int i = 0;
00043 while(i<mapmod.size()){
00044 message+=mapmod[i];
00045 if(++i!=mapmod.size()) message+=",";
00046 }
00047 poster_->postString(message.c_str(),message.length(),0,CurlPoster::leg,"/postChoke");
00048 }
00049
00050 }