2008/07/28
サーバモニタ
by
菊地時夫
—
posted at
2008-07-28 17:03
last modified
2008-07-28 17:03
XServe のサーバモニタのデータは、https://xserve.example.com:311/ から読み出すことができるようだ。
管理権限を持った username/password が必要なので、不用意に外からアクセスできるようになってたりするとアウトだな。
こんな感じ
import httplib import base64 cmd = '/commands/servermgr_xserve?input=<%3Fxml+version%3D"1.0"' \ '+encoding%3D"UTF-8"%3F>%0D%0A<plist+version%3D"0.9">%0D%0A' \ '<dict>%0D%0A%09<key>command<%2Fkey>%0D%0A%09<string>status' \ '<%2Fstring>%0D%0A<%2Fdict>%0D%0A<%2Fplist>%0D%0A' \ '&send=Send+Command' c = httplib.HTTPSConnection('xserve.example.com', 311) user = 'administrator' pswd = 'topsecretpassword' cred = base64.encodestring('%s:%s' % (user, pswd)) headers = {'Authorization': 'Basic %s' % cred} c.request('GET', cmd, headers=headers) r = c.getresponse() print r.status, r.reason for k,v in r.getheaders(): print '%s: %s' % (k,v) print d = r.read() print d c.close()
- Category(s)
- なんでも
- The URL to Trackback this entry is:
- http://sango.lab.tkikuchi.net/Members/tkikuchi/30e130e2/30b530fc30e230cb30bf/tbping