forked from facebookarchive/scribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscribe_ctrl
executable file
·54 lines (46 loc) · 1.77 KB
/
scribe_ctrl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
## Copyright (c) 2007-2008 Facebook
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## See accompanying file LICENSE or visit the Scribe site at:
## http://developers.facebook.com/scribe/
'''scribe_ctrl: A simple script for running and monitoring scribe.'''
import sys
#make this work for facebook environment too
isFacebook = 0
if (isFacebook == 1):
# put your own path here!
sys.path.insert(0, '/mytrunk/fbcode-test/common/fb303/scripts')
import fb303_simple_mgmt
else:
from fb303_scripts import *
# thrift python packages need to be installed
import thrift
from thrift import protocol, transport
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
if (len(sys.argv) > 2):
port = int(sys.argv[2])
else:
port = 1463
if (len(sys.argv) > 1):
retval = fb303_simple_mgmt.service_ctrl(sys.argv[1],
port,
trans_factory = TTransport.TFramedTransportFactory(),
prot_factory = TBinaryProtocol.TBinaryProtocolFactory())
sys.exit(retval)
else:
print 'Usage: scribe_ctrl command [port]'
print ' commands: stop counters status version name alive'
sys.exit(2)