Show status of a server in my personal message - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Show status of a server in my personal message (/showthread.php?tid=77508)
Show status of a server in my personal message by elliotmoso on 09-15-2007 at 04:35 PM
Hello, I want to show the status of my website server in my personal message. If you can tell me how I can develop it, i can program in php, javascript and other languajes but I don't know how do this.
Thanks, elliotmoso
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 04:46 PM
I would normally get the code for you, but what you need to essentially do is either:
1) Use XMLHTTP and check the response code (if it's an error, you're site is probabny down)
or
2) If you can access external stats about the server, use the same method to check the status there.
As you say you can program javascript, it should be fairly simple for you to work out how to do this and the MP!L scripting docs can show you how to interact with messenger
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 04:50 PM
but my javascript programing is too simple now, I'm studing it to learn more but in this moments I don't know very much.
XMLHTTP is Ajax I know. In google I search it and it only shows how to do it in php.
Thanks, elliotmoso
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 04:59 PM
code: function OnEvent_Initialize(){
http_request = new ActiveXObject("Microsoft.XMLHTTP");
http_request.open('GET', "http://website.com", true);
http_request.onreadystatechange = event;
http_request.send();
}
function event(){
if (http_request.readyState == 4) {
if (http_request.status != 12007) {
Messenger.MyPersonalMessage="My Server is working";
}else{
Messenger.MyPersonalMessage="My Server is down";
}
}
}
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 05:09 PM
it don't work, it says: The script may be defective or you may not have the proper privileges to run scripts
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 05:10 PM
Try it now, I missed a brace (Just re-copy and paste )
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 05:14 PM
I don't know why it don't work. it says de same.
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 05:22 PM
I don't know why it's not working as I just tested it and it does... Maybe somebody else will be able to offer some information
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 05:24 PM
I think it don't work becouse I don't have the ActiveX becouse I don't use IE. I think but I don't know why it don't work
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 05:26 PM
It shouldn't matter if you use IE or not, the files are still there anyway
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 05:27 PM
what version of IE do you use??
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 05:29 PM
I use IE7, but a lot of people with older browsers, or different browsers, can use scripts with this code in it... The error you described usually happens when something is either wrong with the code (which there shouldn't be), or the user doesn't have admin rights...
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 05:32 PM
I see the error, the activeX is not the same as that I use.
code: function OnEvent_Initialize(){
http_request = new ActiveXObject("Msxml2.XMLHTTP");
http_request.open('GET', "http://elliotmoso.com", true);
http_request.onreadystatechange = event;
http_request.send();
}
function event(){
if (http_request.readyState == '4') {
if (http_request.status != '404') {
Messenger.MyPersonalMessage="[c=9] ● [/c]www.elliotmoso.com funciona correctamente";
}else{
Messenger.MyPersonalMessage="[c=4] ● [/c]www.elliotmoso.com está caido el servidor";
}
}
}
RE: Show status of a server in my personal message by Spunky on 09-15-2007 at 05:33 PM
change the line code: if (http_request.status != '404') {
to:
code: if (http_request.status != '12007) {
Updated previous post earlier
RE: Show status of a server in my personal message by elliotmoso on 09-15-2007 at 07:13 PM
I edited it to add new functions.
code: web = "http://www.elliotmoso.com";
function OnEvent_Initialize(){
http_request = new ActiveXObject("Msxml2.XMLHTTP");
http_request.open('GET', web, true);
http_request.onreadystatechange = event;
http_request.send();
}
function OnEvent_Timer(sTimerId){
if(sTimerId == "RefreshPSM"){
http_request = new ActiveXObject("Msxml2.XMLHTTP");
http_request.open('GET', web, true);
http_request.onreadystatechange = event;
http_request.send();
MsgPlus.AddTimer("RefreshPSM",60000);
}
}
function event(){
if (http_request.readyState != '4') {
Messenger.MyName = "Cargando datos desde el server";
}else{
if (http_request.status == '404') {
Messenger.MyName = "[c=9] ● [/c]Estado de la web[c=9] "+ web +" funciona correctamente[/c]";
}else{
Messenger.MyName = "[c=4] ● [/c]Estado de la web[c=4] "+ web +" el servidor está caido[/c]";
}
MsgPlus.AddTimer("RefreshPSM",60000);
}
}
This can change the url fastly, it Refreshes it every minute and it shows it in the nickname (becouse the colors).
RE: Show status of a server in my personal message by elliotmoso on 09-17-2007 at 04:06 PM
Hi guys I edited some the script but the state of charging don't work.
here I put my code:
code: //En la variable web solo poner el dominio sin http:// ni www. //
web = "elliotmoso.com";
metodo = true; //GET=true POST=false
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
bar = 0;
barra = 0;
if(metodo==true){
tipo = "GET";
}else{
tipo = "POST";
}
function OnEvent_Initialize(){
http_request = new ActiveXObject("Msxml2.XMLHTTP");
http_request.open(tipo, "http://www."+web+"/", true);
http_request.onreadystatechange = event;
http_request.send();
}
function OnEvent_Timer(sTimerId){
if(sTimerId == "Recargar"){
http_request = new ActiveXObject("Msxml2.XMLHTTP");
http_request.open(tipo, "http://www."+web+"/", true);
http_request.onreadystatechange = event;
http_request.send();
MsgPlus.AddTimer("Recargar",120000);
}
if(sTimerId == "Cargando"){
if(barra <= 3){
barra = ++bar;
}else{
barra = 0;
bar = 0;
}
MsgPlus.AddTimer("Cargando", 500);
}
}
function event(){
if (http_request.readyState <= 3) {
if (barra==0){
Messenger.MyPersonalMessage = "Cargando [c=3][/c][c=4]████████[/c]";
}else if (barra==1){
Messenger.MyPersonalMessage = "Cargando [c=3]██[/c][c=4]██████[/c]";
}else if (barra==2){
Messenger.MyPersonalMessage = "Cargando [c=3]████[/c][c=4]████[/c]";
}else if (barra==3){
Messenger.MyPersonalMessage = "Cargando [c=3]██████[/c][c=4]██[/c]";
}else if (barra==4){
Messenger.MyPersonalMessage = "Cargando [c=3]████████[/c][c=4][/c]";
}
MsgPlus.AddTimer("Cargando",500);
}else if (http_request.readyState == 4) {
if (http_request.status == 200) {
Messenger.MyPersonalMessage = "[c=3] ● [/c]Estado del Servidor: [c=3] "+ web +": ·> OnLinE[/c]";
}else if (http_request.status == 404 || 503){
Messenger.MyPersonalMessage = "[c=4] ● [/c]Estado del Servidor: [c=4] "+ web +": ·> OfLiNe[/c]";
}else{
Messenger.MyPersonalMessage = "[c=14] ● [/c]Estado del Servidor:[c=14] "+ web +": ·> Estado no Disponible[/c]";
}
MsgPlus.AddTimer("Recargar",120000);
}
}
Thanks, Elliotmoso
RE: Show status of a server in my personal message by toddy on 09-17-2007 at 04:25 PM
barra is undefined, under "bar = 0;" add "barra = 0;"
RE: Show status of a server in my personal message by elliotmoso on 09-17-2007 at 04:34 PM
I edited it but the status of charging (if (http_request.readyState <= 3) {) don't appears
|