Monitoring a shell script (external job) running on CentOS with Jenkins

So I wanted to setup Jenkins external monitoring on a web server I have on a Centos VM, and I found a combination of these three blog posts worked!

Firstly, run the following commands :

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
yum -y install jenkins

… or download the RPM at http://pkg.jenkins-ci.org/redhat/ and run “rpm -Uhv jenkinx*.rpm”

  • run the following:
cd /usr/lib/jenkins
unzip /usr/lib/jenkins/jenkins.war
  • Install OpenJDK while you’re at it.
  • Go to Jenkins and create a “Monitor an external job” called “New Job”
* Create an environment variable by 
$export JENKINS_HOME=http://jenkins_host:8080 , replacing "jenkins_host" with the server running Jenkins
  • To have Jenkins monitor a script, run a command like the following…
java -jar /usr/lib/jenkins/WEB-INF/lib/jenkins-core-*.jar “New Job” /path_to/myreport.sh 2>&1 > /dev/null

And you can put that command in a cron job too!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s