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_+3])
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 }
00024 CPUStat::~CPUStat()
00025 {
00026 delete poster_;
00027 delete mstat_;
00028 }
00029
00030 void CPUStat::sendStat(unsigned int lsid)
00031 {
00032 chart_.flip(lsid,float(entries_-mstat_[2])/float(entries_));
00033 poster_->postBinary((unsigned char *)mstat_,(nstates_+4)*sizeof(int),lsid,"/postChoke");
00034 }
00035
00036 void CPUStat::sendLegenda(const std::vector<std::string> &mapmod)
00037 {
00038 std::string message;
00039 unsigned int i = 0;
00040 while(i<mapmod.size()){
00041 message+=mapmod[i];
00042 if(++i!=mapmod.size()) message+=",";
00043 }
00044 poster_->postString(message.c_str(),message.length(),0,CurlPoster::leg,"/postChoke");
00045 }
00046
00047 }