うちのDebian系環境だとsystemctlじゃなくてserviceだけど

if (system("service apache2 status > /dev/null") != 0) {
// 動いてない
}