Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1014297 // parseDiskSpacePercentage - parse output of Disk Space Bot - return % full (including inodes)

JavaX fragment (include)

static double parseDiskSpacePercentage(S s) {
  L<S> l = regexpGroups("(\\d+) MB free of (\\d+) MB\\.", s);
  if (empty(l)) ret -1;
  double ratio = 1-doubleRatio(parseInt(first(l)), parseInt(second(l)));
  l = regexpGroups("Free inodes: (\\d+)K/(\\d+)K", s);
  if (nempty(l)) { 
    double ratio2 = 1-doubleRatio(parseInt(first(l)), parseInt(second(l)));
    print("ratio=" + ratio + ", ratio2=" + ratio2);
    ratio = max(ratio, ratio2);
  }
  ret ratio*100;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014297
Snippet name: parseDiskSpacePercentage - parse output of Disk Space Bot - return % full (including inodes)
Eternal ID of this version: #1014297/8
Text MD5: 086a45f3cfa8d94e1c6ab6d7a6eedaad
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-14 18:46:36
Source code size: 473 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 531 / 537
Version history: 7 change(s)
Referenced in: [show references]