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>
33 # define SIZE_MAX ((size_t) -1)
36 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
39 ssize_t getline (
char **lineptr,
size_t *
n, FILE *fp)
50 if (*lineptr ==
NULL || *n == 0)
53 *lineptr = (
char *) malloc (*n);
73 if (cur_len + 1 >= *n)
77 size_t needed = 2 * *n + 1;
80 if (needed_max < needed)
82 if (cur_len + 1 >= needed)
88 new_lineptr = (
char *) realloc (*lineptr, needed);
89 if (new_lineptr ==
NULL)
95 *lineptr = new_lineptr;
99 (*lineptr)[cur_len] =
i;
105 (*lineptr)[cur_len] =
'\0';
106 result = cur_len ? (ssize_t) cur_len : result;
134 , handicapped_(
false)
137 std::ifstream vulture(
"/tmp/vulture.cmd");
140 FILE *outf = fopen(
"/tmp/vulture.cmd",
"w");
141 fprintf(outf,
"where\n");
156 pid_t retval = fork();
163 std::cout <<
"Vulture::could not set process undumpable" << std::endl;
167 success = prctl( PR_SET_PDEATHSIG, SIGKILL );
170 std::cout <<
"Vulture::could not set process death signal" << std::endl;
173 tmp_ = opendir(
FS.c_str());
175 success = prctl ( PR_SET_NAME ,
"vulture");
178 std::cout <<
"Vulture::could not set process name" << std::endl;
183 pt::PeerTransport * ptr =
184 pt::getPeerTransportAgent()->getPeerTransport(
"http",
"soap",pt::Receiver);
187 catch (pt::exception::PeerTransportNotFound &
e ){
195 toolbox::task::getWorkLoopFactory()->getWorkLoop(
"Ctrll",
204 std::cout <<
"Vulture:constructor - could not start workloop 'Ctrl' for process " << retval << std::endl;
245 strcpy(stamsg.
url_,url.c_str());
267 pid_t killedOrNot = waitpid(
vulturePid_,&sl,WNOHANG);
275 gettimeofday(&now,0);
280 toolbox::task::getWorkLoopFactory()->getWorkLoop(
"Prowl",
301 std::cout <<
"Vulture::exception on msgrcv for control, bailing out of control workloop - good bye" << std::endl;
319 std::cout <<
"Vulture::start - exception in starting prowling workloop " << e.what() << std::endl;
323 std::cout <<
"Vulture::start - could not contact iDie - chech Url - will not start prowling loop" << std::endl;
348 sprintf(messageDie,
"Dead");
350 std::cout <<
"Vulture: asked to stop prowling but no poster "
360 std::cout <<
"Received STOP message, going to delete poster " << std::endl;
369 struct stat filestat;
372 gettimeofday(&now,0);
376 while((dirp = readdir(
tmp_))!=0){
377 if(strncmp(dirp->d_name,
"core",4)==0){
378 stat(dirp->d_name,&filestat);
391 std::cout <<
"Vulture cannot send to iDie server, bail out " << std::endl;
405 std::string command =
"gdb /opt/xdaq/bin/xdaq.exe -batch -x /tmp/vulture.cmd -c /tmp/";
414 FILE *ps = popen(command.c_str(),
"r");
418 while(getline(&p,&s,ps) != -1){
419 if(strncmp(
"Core",p,4)==0) filter =
true;
420 if(filter)cmdout +=
p;
425 int rch = chmod(filePathAndName.c_str(),0777);
428 std::cout <<
"ERROR: couldn't change corefile access privileges -"
429 << strerror(errsv)<< std::endl;
431 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_
#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 *)
unsigned long rcvNonBlocking(MsgBuf &ptr)
#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