Push notification if web server goes down

岁酱吖の 提交于 2019-12-11 18:59:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!