#!/usr/bin/php $cnt) { echo $country . '.label ' . $country . "\n"; } exit(0); } foreach (get_sshd_invalid_countries() as $country => $cnt) { echo $country . '.value ' . $cnt . "\n"; } function get_sshd_invalid_countries() { $countries = array(); exec(AWK_CMD, $wholeips, $ret); if ($ret != 0) return $countries; $uniqueips = array_count_values($wholeips); $GeoIP = Net_GeoIP::getInstance(GEOIP_DB); foreach ($uniqueips as $ip => $cnt) { try { $country = $GeoIP->lookupCountryName($ip); $countries[$country] = isset($countries[$country]) ? $countries[$country] + $cnt : $cnt; } catch (Exception $e) { $countries['Unknown'] = isset($countries['Unknown']) ? $countries['Unknown'] + $cnt : $cnt; } } ksort($countries); return $countries; }