Hi Phil,
I think you need one more thing to do: You need to create a user
interface plugin or command-line interface to scheduler jobs for your
new agent. I create an simple example for you, you need add this
plugin under /usr/share/fossology/www/plugins/, and run fossjobs –a, I
think you can see your agent list.
<?php
global $GlobalReady;
if (!isset($GlobalReady)) { exit; }
class Hfoss_trigger extends FO_Plugin
{
public $Name = " Hfoss_trigger ";
public $Title = " Hfoss_trigger agent";
public $Version = "1.0";
public $Dependency = array("db");
public $DBaccess = PLUGIN_DB_ANALYZE;
/***********************************************************
RegisterMenus(): Register additional menus.
***********************************************************/
function RegisterMenus()
{
if ($this->State != PLUGIN_STATE_READY) { return(0); } // don't run
menu_insert("Agents::" . $this->Title,0,$this->Name);
}
/*********************************************
AgentCheck(): Check if the job is already in the
queue. Returns:
0 = not scheduled
1 = scheduled but not completed
2 = scheduled and completed
*********************************************/
function AgentCheck($uploadpk)
{
global $DB;
$SQL = "SELECT jq_pk,jq_starttime,jq_endtime FROM jobqueue INNER
JOIN job ON job_upload_fk = '$uploadpk' AND job_pk = jq_job_fk AND
jq_type = ' Hfoss_trigger ';";
$Results = $DB->Action($SQL);
if (empty($Results[0]['jq_pk'])) { return(0); }
if (empty($Results[0]['jq_endtime'])) { return(1); }
return(2);
} // AgentCheck()
/*********************************************
AgentAdd(): Given an uploadpk, add a job.
$Depends is for specifying other dependencies.
$Depends can be a jq_pk, or an array of jq_pks, or NULL.
Returns NULL on success, string on failure.
*********************************************/
function AgentAdd ($uploadpk,$Depends=NULL,$Priority=0)
{
global $DB;
/* Prepare the job: job " Hfoss_trigger Agent" */
$jobpk = JobAddJob($uploadpk," Hfoss_trigger Agent ",$Priority=0);
if (empty($jobpk) || ($jobpk < 0)) { return("Failed to insert job
record"); }
/* Add job: job " Hfoss_trigger " has jobqueue item "
Hfoss_trigger " */
$jobqueuepk = JobQueueAdd($jobpk," Hfoss_trigger
","","no",NULL,$Depends,TRUE);
if (empty($jobqueuepk)) { return("Failed to insert testagent into
job queue"); }
return(NULL);
} // AgentAdd()
};
$NewPlugin = new Hfoss_trigger;
?>
Hope can help you.
Vincent
*From:* Gobeille, Robert
*Sent:* Thursday, April 29, 2010 7:10 AM
*To:* Ma, Dong (vinc...@bas-becom-bj)
*Cc:* Laser, Mary; Donohoe, Mark
*Subject:* Fwd: [FOSSology] Fossology Agent
Vincent,
Is there any chance you can respond to this on [email protected]
<mailto:[email protected]>?
Bob
Begin forwarded message:
*From: *Philippe PM Martin <[email protected]
<mailto:[email protected]>>
*Date: *April 26, 2010 9:39:44 AM MDT
*To: *"[email protected] <mailto:[email protected]>"
<[email protected] <mailto:[email protected]>>
*Subject: [FOSSology] Fossology Agent*
*Reply-To: *"[email protected]
<mailto:[email protected]>"
<[email protected]
<mailto:[email protected]>>
Hello,
I have not yet found an answer to this pb ... but to use a modified
version of fo_notify.
Any help would be welcome
Cheers,
Re: [FOSSology] Fossology Agent
Philippe PM Martin
Wed, 10 Mar 2010 05:46:24 -0800
Mark Donohoe wrote:
MARTIN, PHILIPPE PM (PHILIPPE) wrote:
Hello,
I want to write an agent which would trigger the update of a portal on job
completion. I launch the job analysis in batch mode, using cp2foss or fossjobs
(no UI).
For a start, I took the quick and dirty approach using engine-shell as
explained in http://www.fossology.com/how_to_create_an_agent
- I wrote a bash script implementing the trigger in
/usr/lib/fossology/agents/Hfoss_trigger_agent - I modified
/etc/fossology/Scheduler.conf to include my agent
agent=Hfoss_trigger host=localhost | /usr/lib/fossology/agents/engine-shell
Hfoss_trigger '/usr/lib/fossology/agents/Hfoss_trigger_agent %{*}'
But I must be missing smth because if I try to:
cp2foss -q 'agent_unpack,agent_license,Hfoss_trigger'
/path/to/upload
Or fossjobs -A "agent_unpack,agent_license,Hfoss_trigger" -U 20
the agent is not called by the scheduler.
If I look at fossology.log, I see that the scheduler is aware of my
agent:
"scheduler[28741] : Child[15] 'agent=Hfoss_trigger host=localhost '
state=FREE(1)"
Can somebody tell me what is wrong?
Thanks
-- Phil
Phil,
I'm looking into this now. No updates at this point. I am going to
try to reproduce your situation. One question. Do you see your
agent if you do a fossjobs -a ? More after I investigate.
Bonjour,
my config is :
CentOS release 5.4
Fossology RPM fossology-1.1.0-1.el5
[r...@santos ~]# fossjobs -a
The available agents are:
agent_license
agent_mimetype
agent_pkgmetagetta
agent_specagent
agent_unpack
My agent Hfoss_trigger is not listed.
-- Phil