7 #include "pt/PeerTransportReceiver.h"
8 #include "pt/PeerTransportAgent.h"
10 #include "toolbox/task/Action.h"
11 #include "toolbox/task/WorkLoop.h"
12 #include "toolbox/task/WorkLoopFactory.h"
16 #include <sys/prctl.h>
32 # define SIZE_MAX ((size_t) -1)
35 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
38 ssize_t getline (
char **lineptr,
size_t *
n, FILE *fp)
49 if (*lineptr ==
NULL || *n == 0)
52 *lineptr = (
char *) malloc (*n);
72 if (cur_len + 1 >= *n)
75 SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
76 size_t needed = 2 * *n + 1;
79 if (needed_max < needed)
81 if (cur_len + 1 >= needed)
87 new_lineptr = (
char *) realloc (*lineptr, needed);
88 if (new_lineptr ==
NULL)
94 *lineptr = new_lineptr;
98 (*lineptr)[cur_len] =
i;
104 (*lineptr)[cur_len] =
'\0';
105 result = cur_len ? (ssize_t) cur_len : result;
133 , handicapped_(
false)
136 FILE *outf = fopen(
"/tmp/vulture.cmd",
"w");
137 fprintf(outf,
"where\n");
150 pid_t retval = fork();
154 success = prctl( PR_SET_DUMPABLE, 0 );
157 std::cout <<
"Vulture::could not set process undumpable" << std::endl;
161 success = prctl( PR_SET_PDEATHSIG, SIGKILL );
164 std::cout <<
"Vulture::could not set process death signal" << std::endl;
167 tmp_ = opendir(
FS.c_str());
169 success = prctl ( PR_SET_NAME ,
"vulture");
172 std::cout <<
"Vulture::could not set process name" << std::endl;
177 pt::PeerTransport * ptr =
178 pt::getPeerTransportAgent()->getPeerTransport(
"http",
"soap",pt::Receiver);
181 catch (pt::exception::PeerTransportNotFound &
e ){
189 toolbox::task::getWorkLoopFactory()->getWorkLoop(
"Ctrll",
198 std::cout <<
"Vulture:constructor - could not start workloop 'Ctrl' for process " << retval << std::endl;
239 strcpy(stamsg.
url_,url.c_str());
261 pid_t killedOrNot = waitpid(
vulturePid_,&sl,WNOHANG);
269 gettimeofday(&now,0);
274 toolbox::task::getWorkLoopFactory()->getWorkLoop(
"Prowl",
283 std::string
msg =
"Failed to start workloop 'Prowl'.";
295 std::cout <<
"Vulture::exception on msgrcv for control, bailing out of control workloop - good bye" << std::endl;
313 std::cout <<
"Vulture::start - exception in starting prowling workloop " << e.what() << std::endl;
317 std::cout <<
"Vulture::start - could not contact iDie - chech Url - will not start prowling loop" << std::endl;
342 sprintf(messageDie,
"Dead");
358 struct stat filestat;
361 gettimeofday(&now,0);
365 while((dirp = readdir(
tmp_))!=0){
366 if(strncmp(dirp->d_name,
"core",4)==0){
367 stat(dirp->d_name,&filestat);
380 std::cout <<
"Vulture cannot send to iDie server, bail out " << std::endl;
394 std::string
command =
"gdb /opt/xdaq/bin/xdaq.exe -batch -x /tmp/vulture.cmd -c /tmp/";
397 std::string filePathAndName =
FS +
"/";
403 FILE *ps = popen(command.c_str(),
"r");
407 while(getline(&p,&s,ps) != -1){
408 if(strncmp(
"Core",p,4)==0) filter =
true;
409 if(filter)cmdout +=
p;
414 int rch = chmod(filePathAndName.c_str(),0777);
417 std::cout <<
"ERROR: couldn't change corefile access privileges -"
418 << strerror(errsv)<< std::endl;
420 unsigned int ipid = (
unsigned int)atoi(pid.c_str());
char url_[VULTURE_START_MESSAGE_URL_SIZE]
toolbox::task::WorkLoop * wlProwl_
#define MSQS_VULTURE_TYPE_ACK
static const std::string FS
bool prowling(toolbox::task::WorkLoop *)
void postString(const char *, size_t, unsigned int, mode, const std::string &=standard_post_method_)
std::vector< std::string > currentCoreList_
unsigned long rcvNonBlocking(MsgBuf &ptr)
#define MSQM_MESSAGE_TYPE_NOP
toolbox::task::ActionSignature * asCtrl_
int start(std::string, int=0)
toolbox::task::ActionSignature * asProwl_
toolbox::task::WorkLoop * wlCtrl_
bool control(toolbox::task::WorkLoop *)
#define NUMERIC_MESSAGE_SIZE
#define MSQM_VULTURE_TYPE_STP
unsigned long rcv(MsgBuf &ptr)
static const int vulture_queue_offset
#define MSQM_VULTURE_TYPE_STA