$shard_info .= $shard['_id'] . ' = ' . $shard['host'] . ' || '; } write_to_data_file("{$zabbix_name} shard_info " . $shard_info); $collection = $mongo_connection->selectDB('config')->selectCollection('databases'); $cursor = $collection->find(); $db_array = iterator_to_array($cursor); $db_info = ''; foreach ($db_array as $db) { if ($db['partitioned']) { $partitioned = 'yes'; } else { $partitioned = 'no'; } $db_info .= $db['_id'] . ' : ' . 'partitioned = ' . $partitioned . ', primary = ' . $db['primary'] . ' || '; } write_to_data_file("{$zabbix_name} db_info " . $db_info); } //-------------------------------------------------------------------------// // Get data collection end time (we will use this to compute the total data collection time) $end_time = time(); $data_collection_time = $end_time - $start_time; write_to_data_file("{$zabbix_name} mongoDB_plugin_data_collection_time {$data_collection_time}"); write_to_data_file("{$zabbix_name} mongoDB_plugin_version {$command_version}"); write_to_data_file("{$zabbix_name} mongoDB_plugin_checksum {$md5_checksum_string}"); fclose($data_file_handle); exec("zabbix_sender -vv -z 127.0.0.1 -i {$data_file_name} 2>&1", $log_file_data); foreach ($log_file_data as $log_line) { write_to_log_file("{$log_line}\n"); } fclose($log_file_handle); exit;
$shard_info .= $shard['_id'] . ' = ' . $shard['host'] . ' || '; } write_to_data_file($zabbix_name, "shard_info", $shard_info); $collection = $mongo_connection->selectDB('config')->selectCollection('databases'); $cursor = $collection->find(); $db_array = iterator_to_array($cursor); $db_info = ''; foreach ($db_array as $db) { if ($db['partitioned']) { $partitioned = 'yes'; } else { $partitioned = 'no'; } $db_info .= $db['_id'] . ' : ' . 'partitioned = ' . $partitioned . ', primary = ' . $db['primary'] . ' || '; } write_to_data_file($zabbix_name, "db_info", $db_info); } //-------------------------------------------------------------------------// // Get data collection end time (we will use this to compute the total data collection time) $end_time = time(); $data_collection_time = $end_time - $start_time; write_to_data_file($zabbix_name, "mongoDB_plugin_data_collection_time", $data_collection_time); write_to_data_file($zabbix_name, "mongoDB_plugin_version", $command_version); write_to_data_file($zabbix_name, "mongoDB_plugin_checksum", $md5_checksum_string); fclose($data_file_handle); exec("zabbix_sender -vv -z {$zabbix_server} -p {$zabbix_server_port} -i {$data_file_name} 2>&1", $log_file_data); foreach ($log_file_data as $log_line) { write_to_log_file("{$log_line}\n"); } fclose($log_file_handle); exit;
function EC2_DescribeVolumes($creds) { $zabbix_name = $creds['zabbix_name']; $xml_object = exec_ec2_query($creds, 'DescribeVolumes'); debug_output(__FILE__ . ':' . __FUNCTION__ . ':' . __LINE__ . ':' . "HTTP result received from EC2 for DescribeVolumes = " . var_export($xml_object, true)); // Initialize counters $volume_status_array = array("creating" => array("Volumes_Status_creating" => 0, "Volumes_Status_creating_Total_Size_GB" => 0), "available" => array("Volumes_Status_available" => 0, "Volumes_Status_available_Total_Size_GB" => 0), "other" => array("Volumes_Status_other" => 0, "Volumes_Status_other_Total_Size_GB" => 0)); $volume_attachment_status_array = array("attaching" => array("Volumes_attaching" => 0, "Volumes_attaching_Total_Size_GB" => 0), "attached" => array("Volumes_attached" => 0, "Volumes_attached_Total_Size_GB" => 0), "detaching" => array("Volumes_detaching" => 0, "Volumes_detaching_Total_Size_GB" => 0), "detached" => array("Volumes_detached" => 0, "Volumes_detached_Total_Size_GB" => 0)); // A successful query to the EC2 API will have one or more // volumeSets - so iterate through that. // Each volumeSet in turn will have zero, one or more // items containing a volume with volumeId. foreach ($xml_object->volumeSet as $volumeSet) { if (empty($volumeSet)) { break; } foreach ($volumeSet->item as $volumeId) { $volume_status = $volumeId->status; $volume_size = $volumeId->size; switch ($volume_status) { case "creating": break; case "available": break; default: $volume_status = "other"; break; } $volume_status_array["{$volume_status}"]["Volumes_Status_{$volume_status}"]++; $volume_status_array["{$volume_status}"]["Volumes_Status_{$volume_status}_Total_Size_GB"] += $volume_size; foreach ($volumeId->attachmentSet as $attachmentSet) { if (empty($volumeSet)) { break; } $attachment_status = $attachmentSet->item->status; $volume_attachment_status_array["{$attachment_status}"]["Volumes_{$attachment_status}"]++; $volume_attachment_status_array["{$attachment_status}"]["total_{$attachment_status}_Total_Size_GB"] += $volume_size; } } } // Print all the data so that it can be sent to Zabbix foreach ($volume_status_array as $volume_status => $volume_status_data_array) { foreach ($volume_status_data_array as $key => $value) { write_to_data_file("{$zabbix_name} {$key} {$value}"); } } foreach ($volume_attachment_status_array as $volume_attachment_status => $volume_attachment_status_data_array) { foreach ($volume_attachment_status_data_array as $key => $value) { write_to_data_file("{$zabbix_name} {$key} {$value}"); } } }