I used exactly the same methods as https://github.com/Normation/rudder-packages/blob/master/rudder-agent/SOURCES/check-rudder-agent#L81
I figured it was that way for a good reason