Created
June 15, 2011 09:10
-
-
Save deanet/1026765 to your computer and use it in GitHub Desktop.
sms notifikasi twitter+nagios dg tweepy
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
!/usr/bin/env python | |
import tweepy | |
CONSUMER_KEY = 'Cud4jdfAAwf9hKnAERjjvg' | |
CONSUMER_SECRET = 'lzRScymdaUanhVq5k7PrTQKM77EtH8yFN6kvhkRn0QA' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth_url = auth.get_authorization_url() | |
print 'Please authorize: ' + auth_url | |
verifier = raw_input('PIN: ').strip() | |
auth.get_access_token(verifier) | |
print "ACCESS_KEY = '%s'" % auth.access_token.key | |
print "ACCESS_SECRET = '%s'" % auth.access_token.secret |
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
1181 yum install python-setuptools-0.6c5-2.el5.noarch | |
1195 yum install -y python26-simplejson.x86_64 | |
1200 yum install -y python-simplejson.x86_64 | |
1201 yum install -y python-cjson.x86_64 | |
[root@master sms]# easy_install tweepy | |
Searching for tweepy | |
Reading http://cheeseshop.python.org/pypi/tweepy/ | |
Reading http://cheeseshop.python.org/pypi/tweepy/1.6 | |
Reading http://github.com/joshthecoder/tweepy | |
Reading http://cheeseshop.python.org/pypi/tweepy/1.7.1 | |
Best match: tweepy 1.7.1 | |
Downloading http://pypi.python.org/packages/2.4/t/tweepy/tweepy-1.7.1-py2.4.egg#md5=9532717b5938abd3536d67cbd8f1e8f0 | |
Processing tweepy-1.7.1-py2.4.egg | |
Moving tweepy-1.7.1-py2.4.egg to /usr/lib/python2.4/site-packages | |
Adding tweepy 1.7.1 to easy-install.pth file | |
Installed /usr/lib/python2.4/site-packages/tweepy-1.7.1-py2.4.egg | |
Processing dependencies for tweepy | |
[root@master sms]# python coderiver.py | |
Please authorize: http://twitter.com/oauth/authorize?oauth_token=wAAZYcMh454UGdjB5Qo3NNwmF0XMxnG0TgYKb57bGFk | |
PIN: 6355846 | |
ACCESS_KEY = '97888754-tEz8cPpNT920kjAJ4UzHqMKpHhB22F6V2JvP4rAaX' | |
ACCESS_SECRET = 'SRaHdcr4MA2A2Fx4e4ftF8WmCQZywbwaOio3ghPw' | |
[root@master sms]# vim sms.py | |
[root@master sms]# ./sms.py 'admin e sopo iki ?? server e down' | |
[root@master sms]# cat sms.py | |
#!/usr/bin/env python | |
import sys | |
import tweepy | |
#untuk developer ;p | |
CONSUMER_KEY = 'Cud4jdfAAwf9hKnAERjjvg' | |
CONSUMER_SECRET = 'lzRScymdaUanhVq5k7PrTQKM77EtH8yFN6kvhkRn0QA' | |
ACCESS_KEY = '97888754-tEz8cPpNT920kjAJ4UzHqMKpHhB22F6V2JvP4rAaX' | |
ACCESS_SECRET = 'SRaHdcr4MA2A2Fx4e4ftF8WmCQZywbwaOio3ghPw' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) | |
api = tweepy.API(auth) | |
api.update_status(sys.argv[1]) | |
[root@master src]# cat /root/coderiver.py | |
!/usr/bin/env python | |
import tweepy | |
CONSUMER_KEY = 'Cud4jdfAAwf9hKnAERjjvg' | |
CONSUMER_SECRET = 'lzRScymdaUanhVq5k7PrTQKM77EtH8yFN6kvhkRn0QA' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth_url = auth.get_authorization_url() | |
print 'Please authorize: ' + auth_url | |
verifier = raw_input('PIN: ').strip() | |
auth.get_access_token(verifier) | |
print "ACCESS_KEY = '%s'" % auth.access_token.key | |
print "ACCESS_SECRET = '%s'" % auth.access_token.secret | |
tambahkan command di nagios / groundwork nagios (saya pake yg ini) | |
Command name: service-notify-by-sms | |
Type: notify | |
Command line: /usr/local/groundwork/nagios/scripts/sms.py '$NOTIFICATIONTYPE$ $HOSTALIAS$ $SERVICESTATE$ $LONGDATETIME$' | |
Command name: host-notify-by-sms | |
Type: notify | |
Command line: ? /usr/local/groundwork/nagios/scripts/sms.py '$NOTIFICATIONTYPE$ , $HOSTNAME$ , $HOSTSTATE$ $LONGDATETIME$' | |
ref: | |
http://talkfast.org/2010/05/31/twitter-from-the-command-line-in-python-using-oauth |
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
Command name: service-notify-by-sms | |
Type: notify | |
Command line: /usr/local/groundwork/nagios/scripts/sms.py '$NOTIFICATIONTYPE$ $HOSTALIAS$ $SERVICESTATE$ $LONGDATETIME$' | |
Command name: host-notify-by-sms | |
Type: notify | |
Command line: ? /usr/local/groundwork/nagios/scripts/sms.py '$NOTIFICATIONTYPE$ , $HOSTNAME$ , $HOSTSTATE$ $LONGDATETIME$' |
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
#!/usr/bin/env python | |
import sys | |
import tweepy | |
#untuk developer ;p | |
CONSUMER_KEY = 'Cud4jdfAAwf9hKnAERjjvg' | |
CONSUMER_SECRET = 'lzRScymdaUanhVq5k7PrTQKM77EtH8yFN6kvhkRn0QA' | |
ACCESS_KEY = '97888754-tEz8cPpNT920kjAJ4UzHqMKpHhB22F6V2JvP4rAaX' | |
ACCESS_SECRET = 'SRaHdcr4MA2A2Fx4e4ftF8WmCQZywbwaOio3ghPw' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) | |
api = tweepy.API(auth) | |
api.update_status(sys.argv[1]) |
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
[root@master sms]# easy_install tweepy | |
Searching for tweepy | |
Reading http://cheeseshop.python.org/pypi/tweepy/ | |
Reading http://cheeseshop.python.org/pypi/tweepy/1.6 | |
Reading http://github.com/joshthecoder/tweepy | |
Reading http://cheeseshop.python.org/pypi/tweepy/1.7.1 | |
Best match: tweepy 1.7.1 | |
Downloading http://pypi.python.org/packages/2.4/t/tweepy/tweepy-1.7.1-py2.4.egg#md5=9532717b5938abd3536d67cbd8f1e8f0 | |
Processing tweepy-1.7.1-py2.4.egg | |
Moving tweepy-1.7.1-py2.4.egg to /usr/lib/python2.4/site-packages | |
Adding tweepy 1.7.1 to easy-install.pth file | |
Installed /usr/lib/python2.4/site-packages/tweepy-1.7.1-py2.4.egg | |
Processing dependencies for tweepy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment