module openconfig-procmon {
  yang-version 1;
  namespace "http://openconfig.net/yang/system/procmon";
  prefix oc-proc;

  import openconfig-extensions {
    prefix oc-ext;
  }
  import openconfig-types {
    prefix oc-types;
  }
  import openconfig-yang-types {
    prefix oc-yang;
  }

  organization
    "OpenConfig working group";
  contact
    "OpenConfig working group
     www.openconfig.net";
  description
    "This module provides data definitions for process health
     monitoring of one or more processes running on the system.";

  revision 2019-03-15 {
    description
      "Update process start time to be an absolute timestamp,
       ensure that the units for CPU time are expressed correctly.
       Update cpu-usage leaves to commonly use counter64 for consumed
       CPU time.";
    reference
      "0.4.0";
  }
  revision 2018-11-21 {
    description
      "Add OpenConfig module metadata extensions.";
    reference
      "0.3.1";
  }
  revision 2017-09-18 {
    description
      "Updated to use OpenConfig types modules";
    reference
      "0.3.0";
  }
  revision 2017-07-06 {
    description
      "Move to oc-inet types, add IETF attribution, add RADIUS
       counters, changed password leaf names to indicate hashed";
    reference
      "0.2.0";
  }
  revision 2017-01-29 {
    description
      "Initial public release";
    reference
      "0.1.0";
  }

  oc-ext:openconfig-version "0.4.0";
  oc-ext:regexp-posix;
  oc-ext:catalog-organization "openconfig";
  oc-ext:origin "openconfig";

  grouping procmon-processes-top {
    description
      "Top level grouping for attributes for processes.";
    container processes {
      description
        "Parameters related to all monitored processes";
      list process {
        key "pid";
        config false;
        description
          "List of monitored processes";
        leaf pid {
          type leafref {
            path "../state/pid";
          }
          description
            "Reference to the process pid key";
        }
        container state {
          config false;
          description
            "State parameters related to monitored processes";
          uses procmon-process-attributes-state;
        }
      }
    }
  }

  grouping procmon-process-attributes-state {
    description
      "Attributes state definitions for a process";
    leaf pid {
      type uint64;
      description
        "The process pid";
    }
    leaf name {
      type string;
      description
        "The process name";
    }
    leaf-list args {
      type string;
      description
        "Current process command line arguments.  Arguments with
         a parameter (e.g., --option 10  or -option=10) should be
         represented as a single element of the list with the
         argument name and parameter together.  Flag arguments, i.e.,
         those without a parameter should also be in their own list
         element.";
    }
    leaf start-time {
      type oc-types:timeticks64;
      description
        "The time at which this process started,
         relative to the UNIX epoch.  The system must be
         synchronized such that the start-time can be
         reported accurately, otherwise it should not be reported.";
    }
    leaf cpu-usage-user {
      type oc-yang:counter64;
      units "nanoseconds";
      description
        "CPU time consumed by this process in user mode in
         nanoseconds.";
    }
    leaf cpu-usage-system {
      type oc-yang:counter64;
      units "nanoseconds";
      description
        "CPU time consumed by this process in kernel mode.";
    }
    leaf cpu-utilization {
      type oc-types:percentage;
      description
        "The percentage of CPU that is being used by the process.";
    }
    leaf memory-usage {
      type uint64;
      units "bytes";
      description
        "Bytes allocated and still in use by the process";
    }
    leaf memory-utilization {
      type oc-types:percentage;
      description
        "The percentage of RAM that is being used by the process.";
    }
  }
}