Created
June 1, 2012 12:07
-
-
Save serf/2851655 to your computer and use it in GitHub Desktop.
List all hosts in the date subdirectories of a directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<select name="hostname"> | |
<option value="">- Select Host -</option> | |
<?php | |
$collector_dir = '/var/tmp/days'; | |
$hosts = array_unique(explode("\n", shell_exec("/bin/ls $collector_dir/*"))); | |
foreach ($hosts as $host) { | |
if ( strstr($host,"/") ) { | |
# We don't want the directories | |
} elseif ( $host == "" ) { | |
# We don't want blank lines | |
} else { | |
echo "<option value='$host'>$host</option>"; | |
} | |
} | |
?> | |
</select> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given a directory with a top level sub directory for each day, and a directory (or file) for each host in each day subdirectory, list ALL hosts from all day directories.
e.g.:
/var/tmp/days/
/var/tmp/days/20120515/
/var/tmp/days/20120515/host1
/var/tmp/days/20120515/host2
/var/tmp/days/20120516/
/var/tmp/days/20120516/host1
/var/tmp/days/20120516/host3
This will generate a select list with: host1 host2 host3