LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 02-25-2016, 08:28 PM   #1
ulto
Member
 
Registered: Apr 2004
Posts: 52

Rep: Reputation: 1
Puppet Service Status check


The init script I have for a service I am managing in puppet is all messed up so instead of using the standard 'ensure = > running' and waiting for an exit code of 0 I have to write my own status check, as follows

PHP Code:
    service 'myservice':
    
ensure    => 'running',
    
hasstatus => false,
    
status    => 'ps -ef | grep "connector-logging.jar:/opt/gsa/Connectors/Oracle/Tomcat/bin/bootstrap.jar" | grep -v grep | cut -d \' \' -f4',
    
enable    => true,
 } 
When I run the ps command on the command line it works, as in it returns the PID when the service is running and doesn't return anything if the service is stopped.
Yet, when I run puppet agent it doesn't do anything if the service is stopped.

As a side note when I change the status command from using cut to awk, like so.

PHP Code:
status    => 'ps -ef | grep "connector-logging.jar:/opt/gsa/Connectors/Oracle/Tomcat/bin/bootstrap.jar" | grep -v grep | awk {\'print \$2\'}'
Running puppet with this status check will entail that the service is never running and will also attempt to start it even though the process already exists.

Anyone with experience with this?

Last edited by ulto; 02-25-2016 at 08:29 PM.
 
Old 03-13-2016, 03:14 PM   #2
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,794

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Perhaps you need the exit status?
Try pgrep, that gives an exit status and a pid result
Code:
    status    => 'pgrep -f "connector-logging.jar:/opt/gsa/Connectors/Oracle/Tomcat/bin/bootstrap.jar"',

Last edited by MadeInGermany; 03-13-2016 at 04:04 PM.
 
Old 03-22-2016, 01:30 AM   #3
ulto
Member
 
Registered: Apr 2004
Posts: 52

Original Poster
Rep: Reputation: 1
I managed to fix this up myself. One has to be very careful with the escape brackets and the like. It may take a few goes to get it right.

For reference this is what I did.

Quote:
service { 'gsac':
ensure => 'running',
hasstatus => false,
status => '/etc/init.d/gsac status | /bin/grep -q "is running"',
enable => true,
}
Of course depends on the init.d script
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script that can check the status of service, if online then only it should run manish007raut@gmail.com Linux - Newbie 15 12-16-2015 09:35 AM
[SOLVED] How to check NSF or SMB service running status akhlaqur Linux - Security 1 12-15-2013 05:13 AM
puppet needs to stop a service, do something, then start the service edwardcode Programming 1 12-03-2012 01:58 PM
There doesn't appear to be any service status information in the status log parthipan Linux - Server 1 06-25-2012 05:53 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 08:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration