Skip to content

Instantly share code, notes, and snippets.

@syphernl
syphernl / discover_vhosts.php
Created December 1, 2014 09:24
Low Level Discovery Userscript for Zabbix Agent
#!/usr/bin/env php -n
<?php
function apache_vhosts($binary='/usr/sbin/apache2ctl')
{
$command = " -S 2>&1 | grep 'port ' | awk {'print $2,$4'} | sort -u -t' ' -k2,2 | grep -v 'localhost'";
$vhosts = shell_exec(sprintf("%s %s", $binary, $command));
$vhosts = explode("\n", trim($vhosts));
$results = array();
foreach($vhosts as $vhost)