1+ /***
2+ * The goal of this file is to know about the Operating System functions;
3+ *
4+ * We need to use require('os') Build-In NPM to get access to dew basic
5+ * operating system related utility functions.
6+ *
7+ * How to run this example:
8+ * 1. node os.js
9+ * 2. See the message get displayed on prompt.
10+ */
11+
12+ /***
13+ * Note: Use require('os') to get access to os based utility functions.
14+ */
15+ var os = require ( 'os' ) ;
16+
17+ /***
18+ * Returns the hostname of the operating system.
19+ */
20+ console . info ( "Hostname is: %s" , os . hostname ( ) ) ;
21+
22+ /***
23+ * Returns the name of the operating system.
24+ */
25+ console . log ( "Type is %s" , os . type ( ) ) ;
26+
27+ /***
28+ * Returns the platform of the operating system.
29+ */
30+ console . log ( "Platform is %s" , os . platform ( ) ) ;
31+
32+ /***
33+ * Returns the operating system CPU architecture.
34+ */
35+ console . log ( "CPU Architecture is %s" , os . arch ( ) ) ;
36+
37+ /***
38+ * Returns the operating system release.
39+ */
40+ console . log ( "Release is %s" , os . release ( ) ) ;
41+
42+ /***
43+ * Returns the operating system uptime in seconds.
44+ */
45+ console . log ( "Uptime is %d Seconds" , os . uptime ( ) ) ;
46+
47+ /***
48+ * Returns the operating system total amount of system memory in bytes.
49+ */
50+ console . log ( "Total amount of system memory is %d in bytes" , os . totalmem ( ) ) ;
51+
52+ /***
53+ * Returns the operating system the amount of free system memory in bytes.
54+ */
55+ console . log ( "Total amount of free system memory is %d in bytes" , os . freemem ( ) ) ;
56+
57+ /***
58+ * Returns the operating system's default directory for temp files.
59+ */
60+ console . log ( "Temp directory is" , os . tmpDir ( ) ) ;
61+
62+ /***
63+ * Returns an array of objects containing information about each CPU/core installed:
64+ * model, speed (in MHz), and times
65+ */
66+ console . log ( "Information about CPU/Core Installed:\n" ) ;
67+ console . log ( os . cpus ( ) ) ;
68+
69+ /***
70+ * Returns get a list of network interfaces:
71+ */
72+ console . log ( "List of network interfaces:\n" ) ;
73+ console . log ( os . networkInterfaces ( ) ) ;
0 commit comments