Home » SQL & PL/SQL » SQL & PL/SQL » Check for status of a computer in the network (Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production)
Check for status of a computer in the network [message #673266] Wed, 14 November 2018 01:00 Go to next message
chat2raj.s
Messages: 135
Registered: October 2010
Location: Chennai, India
Senior Member
How can i find if a computer in the network is ON or OFF.
Re: Check for status of a computer in the network [message #673270 is a reply to message #673266] Wed, 14 November 2018 01:14 Go to previous messageGo to next message
Michel Cadot
Messages: 67290
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

ping

Re: Check for status of a computer in the network [message #673274 is a reply to message #673270] Wed, 14 November 2018 02:58 Go to previous messageGo to next message
gazzag
Messages: 1082
Registered: November 2010
Location: Bristol, UK
Senior Member
What has this got to do with Oracle? Or even SQL & PL/SQL?

[Updated on: Wed, 14 November 2018 02:58]

Report message to a moderator

Re: Check for status of a computer in the network [message #673289 is a reply to message #673274] Wed, 14 November 2018 06:00 Go to previous messageGo to next message
chat2raj.s
Messages: 135
Registered: October 2010
Location: Chennai, India
Senior Member
Some raw data is being auto generated from a network computer and if by chance it is down then i need an automatic alert so i can fix it
Re: Check for status of a computer in the network [message #673290 is a reply to message #673289] Wed, 14 November 2018 06:01 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
Again - why is this anything to do with oracle?
Re: Check for status of a computer in the network [message #673291 is a reply to message #673290] Wed, 14 November 2018 06:10 Go to previous messageGo to next message
chat2raj.s
Messages: 135
Registered: October 2010
Location: Chennai, India
Senior Member
Am into programming and not sure if there is any other way to check and raise alert. Probably there should be some option from windows, but am not into it.
Re: Check for status of a computer in the network [message #673292 is a reply to message #673291] Wed, 14 November 2018 06:16 Go to previous messageGo to next message
Michel Cadot
Messages: 67290
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Did you try what I posted?

Re: Check for status of a computer in the network [message #673293 is a reply to message #673274] Wed, 14 November 2018 06:17 Go to previous messageGo to next message
gazzag
Messages: 1082
Registered: November 2010
Location: Bristol, UK
Senior Member
gazzag wrote on Wed, 14 November 2018 08:58
What has this got to do with Oracle? Or even SQL & PL/SQL?
Re: Check for status of a computer in the network [message #673295 is a reply to message #673293] Wed, 14 November 2018 07:10 Go to previous messageGo to next message
chat2raj.s
Messages: 135
Registered: October 2010
Location: Chennai, India
Senior Member
Yes Michael, it worked and i used as below. Thanks a lot.

CREATE OR REPLACE FUNCTION PING(P_HOST_NAME VARCHAR2,
                                P_PORT      NUMBER DEFAULT 1000)
  RETURN VARCHAR2 IS
  TCPCONNECTION UTL_TCP.CONNECTION;   

C_PING_OK           CONSTANT VARCHAR2(10)  := 'OK';
C_PING_ERROR        CONSTANT VARCHAR2(10)  := 'ERROR';
C_PING_LISTNER      CONSTANT VARCHAR2(20)  := 'LISTNER NOT FOUND';

BEGIN
  TCPCONNECTION := UTL_TCP.OPEN_CONNECTION(REMOTE_HOST => P_HOST_NAME,
                                           REMOTE_PORT => P_PORT);
  UTL_TCP.CLOSE_CONNECTION(TCPCONNECTION);
  RETURN C_PING_OK;
EXCEPTION
  WHEN UTL_TCP.NETWORK_ERROR THEN
    IF (UPPER(SQLERRM) LIKE '%HOST%') THEN 
      RETURN C_PING_ERROR;
    ELSIF (UPPER(SQLERRM) LIKE '%LISTENER%') THEN 
      RETURN C_PING_LISTNER;
    ELSE
      RAISE;
    END IF;
END PING;
Re: Check for status of a computer in the network [message #673303 is a reply to message #673270] Wed, 14 November 2018 08:21 Go to previous messageGo to next message
JPBoileau
Messages: 88
Registered: September 2017
Member
Michel Cadot wrote on Wed, 14 November 2018 01:14

ping

FYI - The above only works in versions 10 or below. ACL's were added in Oracle 11g and above, which will generate the ACL error: "ORA-24247: network access denied by access control list (ACL)".

JP
Re: Check for status of a computer in the network [message #673305 is a reply to message #673303] Wed, 14 November 2018 08:28 Go to previous messageGo to next message
Michel Cadot
Messages: 67290
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Indeed, you have to execute something like:
BEGIN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl         => 'ping.xml',
                                    description => 'Access to a network address',
                                    principal   => USER,
                                    is_grant    => true,
                                    privilege   => 'connect');
 
  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl       => 'ping.xml',
                                       principal => USER,
                                       is_grant  => true,
                                       privilege => 'resolve');
 
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl  => 'ping.xml',
                                    host => '*');
  COMMIT;
END;
/

[Updated on: Wed, 14 November 2018 08:29]

Report message to a moderator

Re: Check for status of a computer in the network [message #673627 is a reply to message #673305] Tue, 27 November 2018 23:58 Go to previous messageGo to next message
chat2raj.s
Messages: 135
Registered: October 2010
Location: Chennai, India
Senior Member
This particular server is Oracle 9i and PING helped me to solve the problem. I didn't try the ACL feature. Thanks a lot.
Re: Check for status of a computer in the network [message #673630 is a reply to message #673627] Wed, 28 November 2018 00:56 Go to previous messageGo to next message
Michel Cadot
Messages: 67290
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
This particular server is Oracle 9i

So where does come?

Quote:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
Re: Check for status of a computer in the network [message #673636 is a reply to message #673630] Wed, 28 November 2018 01:45 Go to previous messageGo to next message
chat2raj.s
Messages: 135
Registered: October 2010
Location: Chennai, India
Senior Member
My production server is 11.2 and i tried this option from another server which was 9i.
Re: Check for status of a computer in the network [message #673655 is a reply to message #673636] Wed, 28 November 2018 07:58 Go to previous message
joy_division
Messages: 4949
Registered: February 2005
Location: East Coast USA
Senior Member
And when that server get upgraded, your code will fail. Very shortsighted thinking on your part.
Previous Topic: Materialised Views - FAST Refresh
Next Topic: Display Time
Goto Forum:
  


Current Time: Fri Aug 07 23:18:40 CDT 2020