Created
January 22, 2017 12:45
-
-
Save koma5/e9cc6617cf5eb4f1cd1f0880c1f6671d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import commands as co" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "poolIps = co.getoutput(\"dig ch.pool.ntp.org +short\").split('\\n')\n", | |
| "myMap = [{'ip' : i, 'hostname' : co.getoutput('dig -x ' + i + ' +short')} for i in poolIps]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "['81.94.123.17', '195.141.190.190', '217.147.208.1', '217.147.223.78']\n", | |
| "81.94.123.17 ntp1.as34288.net.\n", | |
| "195.141.190.190 time.sunrise.net.\n", | |
| "217.147.208.1 ns1.nexellent.net.\n", | |
| "217.147.223.78 bart.nexellent.net.\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "print poolIps\n", | |
| "\n", | |
| "for m in myMap:\n", | |
| " print m['ip'], m['hostname']" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "217.147.223.78\r\n", | |
| "81.94.123.17\r\n", | |
| "195.141.190.190\r\n", | |
| "217.147.208.1\r\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "!dig ch.pool.ntp.org +short" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.6.0" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment