Adaltas

Node binding to SIGAR (System Information Gatherer And Reporter)

 _   _           _       _____ _                  
| \ | |         | |     / ____(_)                 
|  \| | ___   __| | ___| (___  _  __ _  __ _ _ __ 
| . ` |/ _ \ / _` |/ _ \\___ \| |/ _` |/ _` | '__|
| |\  | (_) | (_| |  __/____) | | (_| | (_| | |   
|_| \_|\___/ \__,_|\___|_____/|_|\__, |\__,_|_|    New BSD License
                                  __/ |           
                                 |___/     

The project is Node binding to the SIGAR library. Source code is available on Github.

SIGAR includes support for Linux, FreeBSD, Windows, Solaris, AIX, HP-UX and Mac OSX across a variety of versions and architectures. Users of the SIGAR API are given portable access to inventory and monitoring data including:

  • System memory, swap, cpu, load average, uptime, logins
  • Per-process memory, cpu, credential info, state, arguments, environment, open files
  • File system detection and metrics
  • Network interface detection, configuration information and metrics
  • Network route and connection tables

Installation

Node SIGAR is open source and licensed under the new BSD license.

1
npm install sigar

In case of trouble, refer to the “requirements” section below.

Quick example

1
2
3
4
5
6
var sigar = require('sigar');

var cpus = sigar().cpuList()
for(var i = 0; i < cpus.length; i++){
  console.log(cpus[i]);
}

API - System

  • mem
    Return an object with ‘ram’, ‘total’, ‘used’, ‘free’, ‘actual_used’, ‘actual_free’, ‘used_percent’, ‘free_percent’ information.
  • swap
    Return an object with ‘total’, ‘used’, ‘free’,’page_in’,’page_out’ information.
  • uptime
    Show how long system has been running in seconds.
  • loadavg
    Show average load in pourcent for the last minute, last 5 minutes and the last 15 minutes.
    Return an array with 3 float values.
  • resourceLimit
    Return an object with ‘cpu_cur’, ‘cpu_max’, ‘file_size_cur’, ‘file_size_max’, ‘pipe_size_cur’, ‘pipe_size_max’, ‘data_cur’, ‘data_max’, ‘stack_cur’, ‘stack_max’, ‘core_cur’, ‘core_max’, ‘memory_cur’, ‘memory_max’, ‘processes_cur’, ‘processes_max’, ‘open_files_cur’, ‘open_files_max’, ‘virtual_memory_cur’, ‘virtual_memory_max’ informations.
  • whoList
  • version
    Return an object with ‘build_date’, ‘scm_revision’, ‘version’, ‘archname’, ‘archlib’, ‘binname’, ‘description’, ‘major’, ‘minor’, ‘maint’, ‘build’ informations.
  • sysInfo
  • fqdn
    Return the hostname or the IP address (hostname on OSX, IP address on Unbuntu)

API - CPU

  • cpu
  • cpuList
  • cpuInfoList

API - Process

  • procList
  • procStat
  • procMem
  • procCred
  • procTime
  • procCpu
  • procState
  • procArgs
  • procEnv
  • procFd
  • procExe
  • procModules
  • procPort
  • threadCpu

API - Disk

  • fileSystemList
  • fileSystemUsage
  • fileSystemPing

API - Network

  • netInfo
  • netRouteList
  • netInterfaceList
  • netInterfaceConfig
  • netInterfaceConfigPrimary
  • netInterfaceStat
  • netConnectionList
  • netListenAddress
  • netStat
  • netStatPort
  • tcp
  • nfsClientV2
  • nfsServerV2
  • arpList

API - Misc

  • rpcPing
  • password
  • formatSize

Testing

Run the tests with expresso:

1
2
npm install -g expresso
expresso -s

Requirements

Ubuntu

1
apt-get install libtool pkg-config

OSX (using homebrew)

1
2
3
brew install cmake pkg-config
eval `brew --config | grep HOMEBREW_PREFIX | sed 's/: /=/'`
sudo bash -c 'echo '$HOMEBREW_PREFIX/share/aclocal' >> `aclocal --print-ac-dir`/dirlist'

Resources

Contributors

Fork me on GitHub