问题
Is it possible to send a push notification to my Mac and my Android devices if, for example, my WebServer(s) go down, or if a particular script is running?
回答1:
I'd recommend to employ CURL utility for such task: http://curl.haxx.se
Script it for periodical access to the index of your site (schedulers like CRON, Quartz etc), then parse the response.
If web-site is alive, CURL will receive something like "HTTP 1.1 200 OK" header, otherwise you can start your custom logic (script to send SMS, email, puch notification - whatever suits you) and report then what CURL actually receives (404, 500, timeout etc).
回答2:
While I don't know about push notifications or android, if you're on 10.8 this answer should give you some help for using the built-in notification center; I'm not on 10.6.8 so I haven't tested.
If you want to use the older, free version of growl you can use the add-on growlnotify
utility:
growlnotify -t Terminal -m "The System... Is Down." && tput bel
I hear rumors that in 10.7 that's more fun.
来源:https://stackoverflow.com/questions/17664478/push-notification-if-web-server-goes-down