Jump to content

Recommended Posts

Posted

I'm not too sure where to stick this, so I'll put it here for the time being.

 

 

Currently we have 5 printer in the school. 1 connected via ethernet, the other 4 are wireless.

 

The ethernet one has an option to set up e-mail alerts for low/no toner, paper jams, other malfunctions, but the others don't.

 

 

Is there a way of setting them up to shoot off a message about errors?

 

Bear in mind, we have no money. So buying something like papercut isn't really an option.

Posted

Ah, I should have mentioned... We don't host/control/provide/own the e-mail server.

 

The LEA provide it. I'm still trying to actually get the settings for it so I can set up the ethernet printer.

 

 

This may even be moot depending on the LEA's reply.

 

 

One day... ONE DAY... I'll actually be allowed to do my job...

Posted

Another vote for Nagios.

For 5 printers any old PC should do you, and you can get Nagios to alert you however you want. Ours alerts via e-Mail, SMS (via Twitter) and a display screen in the office.

  • Thanks 1
Posted

You will need (at least) two Twitter accounts, one to post alerts to, and one (per person to be alerted) to follow the alert account. I keep the alert account's timeline private as I don't want to announce system issues to the world. You will also need to install Tweepy [ tweepy - Twitter API library for Python - Google Project Hosting ] and it's dependencies, Python 2.5+, Simplejson, Python-OAuth, python-memcached.

 

Excuse me if I miss anything out, it's been years since I set this up.

If memory serves, you will need to register a new application with Twitter. Register it online [ OAuth FAQ | dev.twitter.com ] then enter consumer secret and key in the variables below and run the first script.

 

/usr/local/nagios/twitnag-authorize.py

#!/usr/bin/env python                                                                                                                                  

import tweepy

CONSUMER_KEY = ''
CONSUMER_SECRET = ''

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

 

Take the access secret and key produced by this script and add them, along with the consumer secret and key, into the second script, and update the proxy details as needed.

 

/usr/local/nagios/twitnag.py

#!/usr/bin/env python                                                                                                                                  

import sys
import tweepy

CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_KEY = ''
ACCESS_SECRET = ''

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth, proxy_host="proxy.county.org.uk", proxy_port="8080")
api.update_status(sys.argv[1])

 

Then create two new definitions in your Nagios config.

 

/usr/local/nagios/etc/objects/commands.cfg

define command{
command_name notify-host-by-twitter
command_line /usr/bin/python /usr/local/nagios/twitnag.py "$NOTIFICATIONTYPE$ - $HOSTNAME$-$SERVICEDESC$ - $SERVICESTATE$ - $SERVICEOUTPUT$"       
}

define command{
command_name notify-service-by-twitter
command_line /usr/bin/python /usr/local/nagios/twitnag.py "$NOTIFICATIONTYPE$ - $HOSTNAME$-$SERVICEDESC$ - $SERVICESTATE$ - $SERVICEOUTPUT$"
}

 

Add the new commands to your contact definition(s).

 

/usr/local/nagios/etc/objects/contacts.cfg

service_notification_commands   notify-service-by-email notify-service-by-twitter    ; send service notifications via email and twitter
host_notification_commands      notify-host-by-email notify-host-by-twitter          ; send host notifications via email and twitter

 

Now restart Nagios and any system alerts are sent to Twitter, and you can use their SMS gateway to receive alerts without paying* :D

 

* Assuming you're on a supported mobile network.

  • Thanks 2
Posted
@Irazmus do you know of any way to get the proxy to work under Windows? I have a few things I could use this for. I got it working how I wanted at home but it doesn't seem to recognise the proxy settings under Windows as from what I can tell, they are Linux env vars.
Posted
I gave up with that in the end and managed to get a perl script called nitter2 to work under Linux at least. I would like to know if anyone has success with tweepy though.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...