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